工具:mysql数据库创建一个user的表里边的字段1.
普通索引 添加INDEXALTER TABLE `table_name` ADD INDEX index_name ( `column` )下面演示下给user表的name字段添加一个索引2.
主键索引 添加PRIMARY KEYALTER TABLE `table_name` ADD PRIMARY KEY ( `column` )3.唯一索引添加UNIQUEALTER TABLE `table_name` ADD UNIQUE ( `column` )4.全文索引添加FULLTEXTALTER TABLE `table_name` ADD FULLTEXT ( `column`)5.如何添加多列索引ALTER TABLE `table_name` ADD INDEX index_name ( `column1`, `column2`, `column3` )1.添加PRIMARY KEY(主键索引) mysqlALTER TABLE `table_name` ADD PRIMARY KEY ( `column` ) 2.添加UNIQUE(唯一索引) mysqlALTER TABLE `table_name` ADD UNIQUE ( `column` ) 3.添加INDEX(普通索引) mysqlALTER TABLE `table_name` ADD INDEX index_name ( `column` ) 4.添加FULLTEXT(全文索引) mysqlALTER TABLE `table_name` ADD FULLTEXT ( `column`) 5.添加多列索引 mysqlALTER TABLE `table_name` ADD INDEX index_name ( `column1`, `column2`, `column3` )1.添加PRIMARY KEY(主键索引)
mysql>ALTER TABLE `table_name` ADD PRIMARY KEY (
`column` )
2.添加UNIQUE(唯一索引)
mysql>ALTER TABLE `table_name` ADD UNIQUE
(
`column`
)
3.添加INDEX(普通索引)
mysql>ALTER TABLE `table_name`
ADD INDEX index_name ( `column` )
4.添加FULLTEXT(全文索引)
mysql>ALTER
TABLE `table_name` ADD FULLTEXT ( `column`)
5.添加多列索引
mysql>ALTER
TABLE `table_name` ADD INDEX index_name ( `column1`, `column2`, `column3` )
评论列表(0条)