Category:
primary key index: can not be repeated. id can not be null
unique index: can not be repeated. null id may be
single-valued index: single, age; a plurality of tables can be single-valued index, name.
Composite Index: Index (corresponding secondary directory: z: zhao) composed of a plurality of columns (name, age) (a, b, c, d, ..., n)
to create an index:
Mode 1:
Create Index index type name on the table (field)
single-value:
Create index dept_index on TB (Dept);
unique:
Create uNIQUE index name_index on TB (name);
composite index
create index dept_name_index on tb (dept, name);
Second way: alter table table name index index type name (field)
single-value:
ALTER index dept_index the Add Table TB (Dept);
unique:
alter table tb add unique index name_index ( name);
composite index
alter table tb add index dept_name_index (dept , name);
Note: If a field is a primary key, then the change field default is the primary key index
delete indexes:
drop index index name on table name;
drop index name_index ON TB;
query index:
Show index from table name;
Show index from the table name \ G