Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2011
    india- new delhi

    Unanswered: What is size in tinyint(size)

    I m new in mysql, i want to know what is size in tinyint(size)
    ---> i know tiny int require one byte and can handle -128 to 127
    what happen when we write tinyint(1) or tinyint(4)

  2. #2
    Join Date
    Sep 2009
    San Sebastian, Spain
    TINYINT uses as you mention yourself a single byte of storage. In SIGNED mode this represents -128 to 127 and UNSIGNED 0 to 255. However, using TINYINT(1) does not alter the storage capacity used in the database.

    The display width (1 in TINYINT(1)) does not constrain the range of values that are stored in the column.

    Here is an extract from the MySQL manual:

    The display width does not constrain the range of values that can be stored in the column. Nor does it prevent values wider than the column display width from being displayed correctly. For example, a column specified as SMALLINT(3) has the usual SMALLINT range of -32768 to 32767, and values outside the range permitted by three digits are displayed in full using more than three digits.
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    Follow me on Twitter

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts