IN Mysql :
INT(1) = 2147483647
and Store 4 byte,
then what about INT(2) = ?
and Store ?
byte...
I used in INT(1) more than 2147483647 it does not work ! also I used in INT(2) with same value it does not work ?? Why ?
Solution ?
In MySQL, INTEGER (INT) is a numeric value without a decimal. It defines whole numbers that can be stored in a field or column. In addition, MySQL supports the display_width attribute (for example, INT(1)) and the ZEROFILL attribute, which automatically adds zeros to the value depending on the display width.
SMALLINT − A small integer that can be signed or unsigned. If signed, the allowable range is from -32768 to 32767. If unsigned, the allowable range is from 0 to 65535.
The optional display width specifier is only applicable when using zerofill and has nothing to do with the internal size (in bytes) of the integer data type. It is always 4 bytes.
This optional display width may be used by applications to display integer values having a width less than the width specified for the column by left-padding them with spaces. (That is, this width is present in the metadata returned with result sets. Whether it is used or not is up to the application.)
Here's [a link] (http://dev.mysql.com/doc/refman/5.5/en/numeric-type-attributes.html)
Example For More
drop table if exists tablename;
create table tablename ( columnname int(4) unsigned zerofill not null default 0 );
insert into tablename (columnname) values (123),(456),(1234);
select * from tablename;
OutPut
0123
0456
1234
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With