My 1am,1pm
Numeric type
Int (4)
Float (5,2)
Varchar (4)
Enum type
Enum (' female ', ' male ')
Set (' book ', ' Football ', ' A ' ....)
Constraint conditions
Null Default Extra
The default is allow default NULL
Not NULL default value
Key
Normal Index Index
Unique Indexes unique
PRIMARY Key PRIMARY Key
FOREIGN Key FOREIGN Key
Full-text index fulltext
View Index desc
Showindex from What is the difference between the two
CREATE index createindex xxx on table ();
UNIQUE INDEX
Delete index dropindex xxxx on table;
Build Table Specify index field
Primarykey alter TABLEXXX Modify Xcolumn ... primary key auto_increment
altertable XXX Add primary key ();
to remove the notice, first remove the auto_increment
altertable xxxx drop PRIMARY key;
Composite PRIMARY Key different when repeating, the table must be created
Foreign Key
1. the storage engine must be InnoDB
2. the field type must match the
3. the referenced field must be an indexed field
ForeignKey ( field ) References table ( field )
Onupdate Cascade on DELETE on cascade) Engine=innodb;
MySQL basic three-value type, index