5

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 ?

Nimesh Vagadiya
  • 602
  • 3
  • 8
  • 18

4 Answers4

9

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

Ronak Vyas
  • 553
  • 2
  • 9
5

The parenthesised number represents the number of digits returned by the field. You can insert any number into an INT(1), but you will only get out a number between 0 and 9.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
2

INT in MySQL is always 4-byte number.

The syntax of INT type is INT(M), where M indicates the maximum display width; but not all MySQL clients supports this value.

Devart
  • 119,203
  • 23
  • 166
  • 186
0

You should use a BIGINT to get 8 bytes (See Integer Types). The number in parentesis indicates only the maximum display width (See Numeric Type Attributes)

Alepac
  • 1,833
  • 13
  • 24