Mysql integer type field common property settings


1.UNSIGNED unsigned
2.auto_increment
increment (1 starts from default), the integer type and for the indexed field, such as: with the primary key (other types of indexes we later date)
3. Primary:
primary key uniquely identifies a field records a plurality of fields or
a field set the primary key
a plurality of the primary key fields composition disposed
Note points:
1) the primary key is preferably provided on a not related to the actual information field, the role of the primary key should be clear and the single
2 ) primary key is preferably disposed above the integer type field (the processing or query them more efficient)
3) primary key must be different, and can not be null
. 4) Since the primary key must be different so we fit auto_increment property
5) a table can have only one primary key, it's best to set on a field
6) when querying records based on the value of the primary key can get great speed (as set up a field primary key index has been created)!
Setting method:
When creating the table
primary key (field)
primary key (field 1, field 2)
may be written directly after the field needed to create the primary key

if you forget to set can
alter table name of the table the Add primary key (field name);
delete:
the ALTER the table table name drop primary key;
Note: If a field has auto_increment property must first remove auto_increment attributes
4. predetermined value if the field may be null not null i.e. not null, the attribute can also be used for other types of fields
5. Set Default default value for this property can also be other types of fields

Guess you like

Origin www.cnblogs.com/xiaowie/p/11889579.html