CREATEINDEX indexName ON tableName(columnName(length));ALTERtable tableName INDEX indexName(columnName);CREATETABLE mytable(
ID INTNOTNULL,
username VARCHAR(16)NOTNULL,INDEX[indexName](username(length)));
CREATE FULLTEXT indexName ON tableName(columnName);ALTERtable tableName FULLTEXT INDEX indexName(columnName);CREATETABLE article (
id INTUNSIGNEDAUTO_INCREMENTNOTNULLPRIMARYKEY,
title VARCHAR(200),
content TEXT,
FULLTEXT (title, content)--在title和content列上创建全文索引);
唯一索引
CREATEUNIQUE indexName ON tableName(columnName);ALTERtable tablename UNIQUE[indexName](columnName);CREATETABLE mytable(
ID INTNOTNULL,
username VARCHAR(16)NOTNULL,UNIQUE[indexName](username(length)));
联合索引(组合索引)
CREATEINDEX indexName ON tableName(columnName,columnName);ALTERtable tableName INDEX indexName(columnName,columnName);CREATETABLE mytable (`id`int(11),`name`VARCHAR(32),INDEX index_mytable_id_name (`id`,`name`));
MySQL常见的索引及创建方式普通索引CREATE INDEX indexName ON tableName(columnName(length)); ALTER table tableName INDEX indexName(columnName); CREATE TABLE mytable( ID INT NOT NULL, username VARCHAR(16) NOT NULL, INDEX [indexName] (username(length)) ); 主键索