On Friday 19 October 2007, Markus Gritsch wrote:
> From this page I cannot tell that TINYINT is the equivalent to
> TINYINT(1), maybe I just didn't see it.

integer_type(M) doesn't restrict the size of the storage, it only 
specifies the maximum display width. In other words M doesn't specify the 
number of bytes to use but the max expected display width.

Here is an excerpt from the mysql manual:

M indicates the maximum display width for integer types. The maximum legal 
display width is 255. Display width is unrelated to the range of values a 
type can contain, as described in Section 10.2, “Numeric Types”.

source: http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html


>
> When running the following code
>
> #---
> from sqlobject import *
>
> class Table1( SQLObject ):
>     name = BoolCol()
>
> sqlhub.threadConnection = connectionForURI(
> 'mysql://[EMAIL PROTECTED]/test?debug=True' )
>
> Table1.dropTable( ifExists = True )
> Table1.createTable( ifNotExists = True )
> #---
>
> which results in the following debug output
>
>  1/Query   :  DESCRIBE table1
>  1/Query   :  DESCRIBE table1
>  1/Query   :  CREATE TABLE table1 (
>     id INT PRIMARY KEY AUTO_INCREMENT,
>     name TINYINT
> )
>
> the table seen in the attachment is created.  It says TINYINT(4).

Again, TINYINT(1) doesn't use less space than TINYINT(4). They both use 1 
byte as per this documentation reference:

http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

The only difference is that tinyint(4) will be displayed with a maximum 
width of 4 characters to be able to accommodate a displayed value 
from -128 to +127 (4 chars considering the sign). Alas it still uses 1 
byte. tinyint(1) uses 1 byte as well but it has a max display width of 1, 
because you do not expect to have more than 1 digit there and you know 
that you will not display a sign with it. 

Even more this is just a convention and an indication of what you expect 
to have in there because is not enforced anywhere (i.e. it won't truncate 
the displayed values if they need more chars to display).

-- 
Dan

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to