mysql 创建索引
程序员文章站
2022-03-07 09:05:47
...
ALTER TABLE `table_name` ADD PRIMARY KEY ( `column` )
'table_name' 表名
column 字段
将table_name表的column字段设置为主键;
ALTER TABLE `table_name` ADD UNIQUE ( `column` );
写法一:ALTER TABLE `table_name` ADD INDEX index_name ( `column` )
写法二:CREATE INDEX index_name ON `table_name`(`column1`,`column2`,`column3`);
ALTER TABLE `table_name` ADD FULLTEXT ( `column`)
写法一:ALTER TABLE `table_name` ADD INDEX index_name ( `column1`, `column2`, `column3` )
写法二:CREATE INDEX index_name ON `table_name`(`column1`,`column2`,`column3`)
SHOW INDEX FROM `table_name`;
7. 删除索引
DROP INDEX index_name ON `table_name`;
'table_name' 表名
column 字段
将table_name表的column字段设置为主键;
ALTER TABLE `table_name` ADD UNIQUE ( `column` );
写法一:ALTER TABLE `table_name` ADD INDEX index_name ( `column` )
写法二:CREATE INDEX index_name ON `table_name`(`column1`,`column2`,`column3`);
ALTER TABLE `table_name` ADD FULLTEXT ( `column`)
写法一:ALTER TABLE `table_name` ADD INDEX index_name ( `column1`, `column2`, `column3` )
写法二:CREATE INDEX index_name ON `table_name`(`column1`,`column2`,`column3`)
SHOW INDEX FROM `table_name`;
7. 删除索引
DROP INDEX index_name ON `table_name`;