Confusion Over Numeric Types

2005-10-17 Thread Shaun
Hi,

When I create a table using my ISP's web control panel and I create a column 
with a type of TINYINT it automatically creates a column with a value of 
TINYINT(4).

After looking at the documentation on the MySQL site it is not exactly clear 
what this means:

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

Is TINYINT(4) the same as an INT(4)?

Thanks for your advice. 



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Confusion Over Numeric Types

2005-10-17 Thread Dirk Kredler
Hi Shaun,

Am Montag, 17. Oktober 2005 16:56 schrieb Shaun:
 http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

 Is TINYINT(4) the same as an INT(4)?

No, they only have the same display width, see the following
quote form the manual:

Another extension is supported by MySQL for optionally specifying the display 
width of an integer value in parentheses following the base keyword for the 
type (for example, INT(4)). This optional display width specification is used 
to left-pad the display of values having a width less than the width 
specified for the column.

If you dont add a display width, MySQL uses a default display width,
that is for tinyint:
-127 ( sign + 1 byte storage )

The display width doesent change the bytes used to store a specific type,
so tinyint always uses 1 byte for storage and int always uses 4 bytes for 
storage - its independ from the display width.

Dirk



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Confusion Over Numeric Types

2005-10-17 Thread gerald_clark

Shaun wrote:


Hi,

When I create a table using my ISP's web control panel and I create a column 
with a type of TINYINT it automatically creates a column with a value of 
TINYINT(4).


After looking at the documentation on the MySQL site it is not exactly clear 
what this means:


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

Is TINYINT(4) the same as an INT(4)?

Thanks for your advice. 



 

TINYINT(4) means a type that holds a value for -128 to 127 displayed 
with max (4) character positions.
The part in parenthesis is the input/output display parameter, not the 
number of bytes of storage.



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]