Professional Web Applications Themes

Why display-width is needed? - MySQL

They make no difference...i.e. INT (3) CREATE TABLE `int_test` ( `id` INT( 3 ) NOT NULL ) ENGINE = innodb; INSERT INTO `int_test` ( `id` ) VALUES ( '123456789' ); SELECT * FROM `int_test` --return '123456789'...

  1. #1

    Default Why display-width is needed?

    They make no difference...i.e. INT (3)


    CREATE TABLE `int_test` (
    `id` INT( 3 ) NOT NULL
    ) ENGINE = innodb;


    INSERT INTO `int_test` ( `id` )
    VALUES (
    '123456789'
    );


    SELECT *
    FROM `int_test`

    --return '123456789'

    howachen@gmail.com Guest

  2. #2

    Default Re: Why display-width is needed?

    [email]howachen[/email] wrote:
    > They make no difference...i.e. INT (3)
    Display width is optional. It is not needed.

    You'll probably only see a difference when you use numbers that are
    shorter than the display width.

    Regards,
    Bill K.
    Bill Karwin Guest

  3. #3

    Default Re: Why display-width is needed?


    Bill Karwin wrote:
    > [email]howachen[/email] wrote:
    > > They make no difference...i.e. INT (3)
    >
    > Display width is optional. It is not needed.
    >
    > You'll probably only see a difference when you use numbers that are
    > shorter than the display width.
    >
    > Regards,
    > Bill K.
    why we need to use in real life?

    thankss...

    howachen@gmail.com Guest

  4. #4

    Default Re: Why display-width is needed?

    [email]howachen[/email] wrote:
    > Bill Karwin wrote:
    >
    >>howachen wrote:
    >>
    >>>They make no difference...i.e. INT (3)
    >>
    >>Display width is optional. It is not needed.
    >>
    >>You'll probably only see a difference when you use numbers that are
    >>shorter than the display width.
    >>
    >>Regards,
    >>Bill K.
    >
    >
    > why we need to use in real life?
    >
    > thankss...
    >
    As Bill said - it's optional. You don't need to use it.

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    [email]jstucklexattglobal.net[/email]
    ==================
    Jerry Stuckle Guest

  5. #5

    Default Re: Why display-width is needed?

    [email]howachen[/email] wrote:
    > why we need to use in real life?
    The only time I have used the display width is when I'm also using the
    ZEROFILL modifier.

    CREATE TABLE foo ( i INT(6) ZEROFILL );
    INSERT INTO foo VALUES (42);
    SELECT i FROM foo;

    Outputs: 000042

    Regards,
    Bill K.
    Bill Karwin Guest

  6. #6

    Default Re: Why display-width is needed?


    Bill Karwin wrote:
    > [email]howachen[/email] wrote:
    > > why we need to use in real life?
    >
    > The only time I have used the display width is when I'm also using the
    > ZEROFILL modifier.
    >
    > CREATE TABLE foo ( i INT(6) ZEROFILL );
    > INSERT INTO foo VALUES (42);
    > SELECT i FROM foo;
    >
    > Outputs: 000042
    >
    > Regards,
    > Bill K.
    oic, that's mean without using ZEROFILL, it is useless to set the
    display width...it was funny that many books/reference/web sites used
    display width but in fact they are useless in real life...

    howachen@gmail.com Guest

  7. #7

    Default Re: Why display-width is needed?

    [email]howachen[/email] wrote:

    : Bill Karwin wrote:
    : > [email]howachen[/email] wrote:
    : > > why we need to use in real life?
    : >
    : > The only time I have used the display width is when I'm also using the
    : > ZEROFILL modifier.
    : >
    : > CREATE TABLE foo ( i INT(6) ZEROFILL );
    : > INSERT INTO foo VALUES (42);
    : > SELECT i FROM foo;
    : >
    : > Outputs: 000042
    : >
    : > Regards,
    : > Bill K.

    : oic, that's mean without using ZEROFILL, it is useless to set the
    : display width...it was funny that many books/reference/web sites used
    : display width but in fact they are useless in real life...

    It is useless in mysql only because mysql doesn't use it. The syntax is
    most likely accepted for compatibility with the SQL language.

    In other databases the size of the column would restrict the size of data
    that is allowed. If you declared an integer of four digits and tried to
    save a number that required 5 digits then you would get an error
    indicating the number was too large.


    Malcolm Dew-Jones Guest

  8. #8

    Default Re: Why display-width is needed?


    Malcolm Dew-Jones 寫道:
    > [email]howachen[/email] wrote:
    >
    > : Bill Karwin wrote:
    > : > [email]howachen[/email] wrote:
    > : > > why we need to use in real life?
    > : >
    > : > The only time I have used the display width is when I'm also using the
    > : > ZEROFILL modifier.
    > : >
    > : > CREATE TABLE foo ( i INT(6) ZEROFILL );
    > : > INSERT INTO foo VALUES (42);
    > : > SELECT i FROM foo;
    > : >
    > : > Outputs: 000042
    > : >
    > : > Regards,
    > : > Bill K.
    >
    > : oic, that's mean without using ZEROFILL, it is useless to set the
    > : display width...it was funny that many books/reference/web sites used
    > : display width but in fact they are useless in real life...
    >
    > It is useless in mysql only because mysql doesn't use it. The syntax is
    > most likely accepted for compatibility with the SQL language.
    >
    > In other databases the size of the column would restrict the size of data
    > that is allowed. If you declared an integer of four digits and tried to
    > save a number that required 5 digits then you would get an error
    > indicating the number was too large.
    is this part of the ANSI SQL standard?

    which other database use display width as size restriction?

    howachen@gmail.com Guest

  9. #9

    Default Re: Why display-width is needed?

    [email]howachen[/email] wrote:
    > is this part of the ANSI SQL standard?
    No, it is not part of the SQL standard.

    Display-width does not constrain the range of input values for the
    column, but it can be used when formatting text output.

    It's possible that books misunderstand what the purpose of this optional
    display-width argument is. Perhaps they're confusing it with the
    precision and scale arguments to the DECIMAL type, which do affect the
    values the column can store.

    The display-width feature may not be something you need, but it is a
    generalization to say that it is useless.

    Regards,
    Bill K.
    Bill Karwin Guest

Similar Threads

  1. Flash RIA - XML Display Advice Needed
    By crpatrick in forum Macromedia Flash Data Integration
    Replies: 1
    Last Post: July 1st, 07:54 AM
  2. Chrome Lib - framerate display help needed
    By Michaelcov in forum Macromedia Director 3D
    Replies: 2
    Last Post: June 10th, 12:19 PM
  3. nav display beyond file width?
    By Wasey webforumsuser@macromedia.com in forum Macromedia Flash Sitedesign
    Replies: 1
    Last Post: August 29th, 02:53 PM
  4. Field Width In Web List Display
    By Network Interest in forum FileMaker
    Replies: 1
    Last Post: July 29th, 12:34 AM
  5. example needed: display AD info in table on web page
    By Aaron_TekRecycle.com in forum ASP
    Replies: 1
    Last Post: July 26th, 06:59 PM

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