mysql - Constraints

can not store null null values not 

UNIQUE a column or multiple columns, each column must have a unique value, there can be more unique, the only multiple columns separated by commas 

default default field name, you can play an alias, when there is no specified default assignment values 

primary key corresponding to the unique binding and not null, a combination of a plurality of columns to ensure that only one 

foreign key table to ensure a data matching referential integrity values in another table

  Create table when writing:

create table table ( 
Field 1 Field Type primary key, 
Field 2 Field type not null, 
Field 3 Field Type, 
Field 4 Field Type default "Default", 
field 5 field type, 
Field Field Type 6, 
..... 

UNIQUE (field 3), (if difficult or more columns that uniquely named constraint custom name unique (field 2, field 3, ...)) 
Primary Key (field 1, field 2, ....) 
);

  

Add, modify, delete, not null default

In fact modify the field

alter table modify table name field name field type not null default "Default";

  

Guess you like

Origin www.cnblogs.com/ivyharding/p/11565212.html