[Solved] mysql tinyint(1) vs tinyint(2) vs tinyint(3) vs tinyint(4) [duplicate]

Possible Duplicate:
MySql: Tinyint (2) vs tinyint(1) – Which difference?

What is the difference between:

  • TinyINT(1)
  • TinyINT(2)
  • TinyINT(3)
  • TinyINT(4)

Solution #1:

TinyINT(M) always has a range from -128..+127 signed or 0..255 unsigned. M is the display width.

M indicates the maximum display width for integer types. The maximum
display width is 255. Display width is unrelated to the range of
values a type can contain, as described in Section 11.2, “Numeric
Types”. For floating-point and fixed-point types, M is the total
number of digits that can be stored.

from http://dev.mysql.com/doc/refman/5.5/en/numeric-type-overview.html

Respondent: muehlbau

Solution #2:

According to Mysql manual all decimal numeric types supports syntax:

Integer Types (Exact Value)

When using DECIMAL it allows you to specify precision.

With *INT types it’s has mainly display function which also specifies how many places should be added when using ZEROFILL.

The byte size remains unaffected (1B for TINYINT).

Respondent: Vyktor

Solution #3:

TinyINT = -128…+127

(n) is for display purposes.

Respondent: Francois

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.