Professional Web Applications Themes

Q about column types - MySQL

For my tables I use id as unique identifier, and the column is like so: id INT(2) NOT NULL auto_increment primary key I noticed that this column will allow more than 2 digits, eg 135. I had understood that when I specify the column as INT(2), that meant that the column could only contain up to 2 digits. Apparently, this is not correct. What does the (2) represent then if not the column data length? I do know that if I have a column like: VARCHAR (25) that it will not allow any more than 25 characters, so the INT(2) ...

  1. #1

    Default Q about column types

    For my tables I use id as unique identifier, and the column is like so:

    id INT(2) NOT NULL auto_increment primary key

    I noticed that this column will allow more than 2 digits, eg 135.
    I had understood that when I specify the column as INT(2), that meant that
    the column could only contain up to 2 digits. Apparently, this is not
    correct.

    What does the (2) represent then if not the column data length?

    I do know that if I have a column like: VARCHAR (25) that it will not allow
    any more than 25 characters, so the INT(2) having more than 2 chars is
    confusing.

    Thanks for any insight you can give me!


    _Raven Guest

  2. #2

    Default Re: Q about column types

    Read:
    [url]http://dev.mysql.com/doc/refman/4.1/en/numeric-types.html[/url]

    It is more a display specification than a data restriction. If you do
    this for being compatible with other database brands, then be aware that
    some databases (MS SQL Server, for instance) use the number as the
    number of bytes to use.

    Best regards

    _Raven wrote:
    > For my tables I use id as unique identifier, and the column is like so:
    >
    > id INT(2) NOT NULL auto_increment primary key
    >
    > I noticed that this column will allow more than 2 digits, eg 135.
    > I had understood that when I specify the column as INT(2), that meant that
    > the column could only contain up to 2 digits. Apparently, this is not
    > correct.
    >
    > What does the (2) represent then if not the column data length?
    >
    > I do know that if I have a column like: VARCHAR (25) that it will not allow
    > any more than 25 characters, so the INT(2) having more than 2 chars is
    > confusing.
    >
    > Thanks for any insight you can give me!
    >
    >
    Dikkie Dik Guest

Similar Threads

  1. Disparity between XML Schema types and .Net CLS types
    By MikeL in forum ASP.NET Web Services
    Replies: 2
    Last Post: February 22nd, 06:08 AM
  2. Overriding column types
    By Robert in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: March 7th, 08:15 PM
  3. Column Types
    By Brad in forum Macromedia Dreamweaver
    Replies: 0
    Last Post: July 22nd, 04:16 PM
  4. Replies: 7
    Last Post: July 20th, 11:12 PM
  5. Help with restricting types of column entry
    By Les in forum Microsoft Access
    Replies: 0
    Last Post: July 11th, 12:56 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139