Reputation: 25745
CREATE TABLE `users` (
`ID` int(10) unsigned zerofill NOT NULL auto_increment,
`username` varchar(20) NOT NULL,
PRIMARY KEY (`ID`),
KEY `Username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
what is
a) unsigned, zerofill in ID table?
b) what do you mean by KEY Username
(username
) ?
thank you
Upvotes: 0
Views: 110
Reputation: 426
Zerofill is used to pad a number with zeros instead of spaces. In this case, the number 1337 would be padded with 6 zeros and shown as 0000001337 because of int(10). Specifying unsigned is not needed since zerofill automatically chooses unsigned, see http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html
KEY foo (bar) creates an index on the bar column. The name of the index is foo.
Upvotes: 0
Reputation: 2468
unsigned = a none positive / negative number, so you couldnt have -1 as the "-" is a sign.
zerofill = fill it with zeros by default. Not necessary as the column's already got the auto_increment / pk attributes
key = index this column i.e. make SELECTS that search on this column faster.
Ta
Upvotes: 2
Reputation: 91
here is a partial answer.
a) unsigned means that the value is positive.
b) zerofill means that it will have leftpadding with '0'
ex : without zerofill you have 55 and with you will have 00000055
Regards.
Upvotes: 0
Reputation: 47321
zerofill - left pad with 0
For example, for a column declared as INT(4) ZEROFILL, a value of 5 is retrieved as 0005.
unsigned is number not less than zero
If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column.
Unsigned type can be used to permit only nonnegative numbers in a column or when you need a larger upper numeric range for the column
details : http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html
KEY Username (username) ?
is an index name after Username
on column username
details : http://dev.mysql.com/doc/refman/5.0/en/create-table.html
Upvotes: 3