Co tak na prawde robi INT(2)?

0

Co tak na prawde robi INT(2) - chodiz mi o ta dwojke. Zrobilem id int(2) i jest to primary key, ale moge zapisac tam liczbe 500? Tak samo z wyswietlaniem - pokazuje mi 500 a nie skraca do najwyzszej liczby dwucyfrowej. Nie rozumiem wiec po co to jest?
Jaki jest domyslny tryb dla INT?

0

Int(2) to max 512

// Dopisane

Tfu jakies zacmnienie mialem wczoraj nie 512 a 65535

0

No dobrze, ale co oznacza w takim razie to 2. Jesli jest to liczba bajtow - co mi sie nie wydajae byc prawda, ale 2^16 - 1 daje 65535, czyli maksa jak to ktos napisalm powyzej - to co oznacza np INT(6)?

0

Ja tego zupełnie nie rozumiem, zawsze byłem przekonany ze ta liczba to ilośc cyfr.. ale dobra, moze to sa bajty.. ale tworze tabele InnoDB w niej pole Int(1) wpisuje do niej 214214 i działa :| nic nie zostało obciete... wtf?!

0

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.

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.

When used in conjunction with the optional extension attribute ZEROFILL, the default padding of spaces is replaced with zeros. For example, for a column declared as INT(5) ZEROFILL, a value of 4 is retrieved as 00004. Note that if you store larger values than the display width in an integer column, you may experience problems when MySQL generates temporary tables for some complicated joins, because in these cases MySQL assumes that the data fits into the original column width.

1 użytkowników online, w tym zalogowanych: 0, gości: 1