tags:

views:

22

answers:

1

Hi ,

i have employee table and its empid length is INT 3 ,

But it accepting more then 3 character ....

How it is possible

(THIS IS TESTED IN PHPMYADMIN)

+4  A: 

To cite the documentation: 10.2. Numeric Types

Another extension is supported by MySQL for optionally specifying the display width of integer data types in parentheses following the base keyword for the type (for example, INT(4)). 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.)

and

The display width does not constrain the range of values that can be stored in the column, nor the number of digits that are displayed for values having a width exceeding that specified for the column

So you see, it is not a restriction that influences the data stored in MySQL but an additional information for applications that retrieve the data.

Felix Kling
+1 Hah, I stand corrected! I always thought this was to specify the byte range, but on second thought, that is most obviously humbug. Live and learn!
Pekka
@Pekka: Honestly, I thought the same first ;) But I recognized again that reading documentation really helps :-D
Felix Kling
@Felix oh yes, it does! :)
Pekka