vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| howachen@gmail.com 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 wrote: > howachen@gmail.com 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 wrote: > Bill Karwin wrote: > >>howachen@gmail.com 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. jstucklex@attglobal.net ================== |
| |||
| howachen@gmail.com 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 wrote: > howachen@gmail.com 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 wrote: : Bill Karwin wrote: : > howachen@gmail.com 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 寫道: > howachen@gmail.com wrote: > > : Bill Karwin wrote: > : > howachen@gmail.com 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 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. |
| Thread Tools | |
| Display Modes | |
|
|