MySQL Values of an INT

1

I'm doing some MySQL tasks and I have a question ...

I have been testing and the maximum number that can be added is 2,147,483,647 in both ...

Then my question is ... what is the point of giving it length of 2 and 6 ..

I have searched for information on the internet but I only find the bit length of each type smallint, mediumint, bigint and int ...

Thanks for your time:)

    
asked by GusZL 13.04.2018 в 06:34
source

1 answer

3

The number inside the parentheses does not indicate the size in bytes, they are still 4 bytes in both cases.

int (M)

M indicates the maximum width returned by the viewer, not all MySQL clients support this value.

for example:

create table miTabla ( unidades int(4) unsigned zerofill not null default 0 );

insert into miTabla (unidades) values (123),(456),(1234);

select * from miTabla;

Result:

0123

0456

1234

will always return an integer with the number of digits that you assign, if you do not have it, fill it with zeros.

Source: link

    
answered by 13.04.2018 / 07:44
source