If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > int(M) in mysql - What does M mean?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-05-07, 12:13
rightinpoint rightinpoint is offline
Registered User
 
Join Date: Nov 2004
Posts: 10
int(M) in mysql - What does M mean?

Just wonder, what means have number M at the field declaration like
field_name INT(M) ?

I have used to use it as length in bytes, mannual claim, that
Quote:
M indicates the maximum display width for integer types
, but simple tests doesn't show any difference between int(1), int(3), int(5), int(11).

So basically, what does that number mean?
Reply With Quote
  #2 (permalink)  
Old 11-05-07, 13:17
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
Gee it's like you found all the mysql forums today. ;-)
See this item
Reply With Quote
  #3 (permalink)  
Old 11-05-07, 15:08
ortho ortho is offline
Registered User
 
Join Date: Nov 2006
Location: Quebec
Posts: 172
I think that the M digit, is only used for the ZEROFILL parameter, so if you do not use the zerofill, you should only use INT or INT(11) wich is the default.

NB: You better validate this info, I'm not sure about it.
__________________
Less is more.
How long is now?
http://www.lesouterrain.com
Reply With Quote
  #4 (permalink)  
Old 11-05-07, 15:16
ortho ortho is offline
Registered User
 
Join Date: Nov 2006
Location: Quebec
Posts: 172
CREATE TABLE testTable (
`a` INT(11),
`b` INT(11) ZEROFILL
);
INSERT INTO testTable (`a`, `b`) VALUES (1, 1);
SELECT * FROM testTable;

With this Query you should see the difference
__________________
Less is more.
How long is now?
http://www.lesouterrain.com
Reply With Quote
  #5 (permalink)  
Old 11-05-07, 17:27
rightinpoint rightinpoint is offline
Registered User
 
Join Date: Nov 2004
Posts: 10
thank you guys for the your help, all is clear for me now
Reply With Quote
  #6 (permalink)  
Old 11-06-07, 09:42
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
INT(11) is not the default INT is. Any GUI that automatically assigns a length value to numeric data types is doing so incorrectly and really gives people the wrong idea about what values can be held in the data type.
Reply With Quote
  #7 (permalink)  
Old 11-06-07, 10:00
ortho ortho is offline
Registered User
 
Join Date: Nov 2006
Location: Quebec
Posts: 172
but if I specify INT as a datatype in mySql, and then I export the table, it will export my INT field as INT(11)...
__________________
Less is more.
How long is now?
http://www.lesouterrain.com
Reply With Quote
  #8 (permalink)  
Old 11-06-07, 10:18
aschk aschk is offline
Registered User
 
Join Date: Mar 2007
Location: 636f6d7075746572
Posts: 770
As you rightly quoted from the MySQL manual :
Quote:
M indicates the maximum display width for integer types
This means that any integer number that displays BELOW this width (as example: 4) will be padded with spaces (or if zerofill specified 0's) ,
Code:
CREATE TABLE testTable (
`a` INT(4),
`b` INT(4) ZEROFILL
);
INSERT INTO testTable (`a`, `b`) 
VALUES (1, 1)
      ,(12,12)
      ,(123,123)
      ,(1234,1234)
      ,(12345,12345);
will actually be producing :
Code:
   a  ||   b
=============
    1 || 0001
   12 || 0012
  123 || 0123
 1234 || 1234
12345 || 12345
note in column `a` you have 3,2,1,0,0 spaces in front of your number
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On