·021创建索引 MySQL (3) ALTER TABLE语句创建索引 MySQL中,也可以在修改数据表时创建索引。 命 ALTER TABLE表名 ADD [UNIQUE FULLTEXT SPATIAL] [INDEX KEY]] 索引名](索引列名[(长度)])[ASC|DESC MySQL数据库应用》http:/mysq!xg.hactcm.edu.cn 第16页
《MySQL数据库应用》 http://mysql.xg.hactcm.edu.cn/ 第 16 页 2.1 创建索引 (3)ALTER TABLE 语句创建索引 MySQL中,也可以在修改数据表时创建索引。 • 命令: • ALTER TABLE 表名 ADD [UNIQUE | FULLTEXT | SPATIAL] [INDEX |KEY] ] [索引名] (索引列名 [(长度)] ) [ASC | DESC]
·021创建索引 MySQL 案例:在表xskc的成绩列上创建一个普通索引; alter table xs kc add index cj(成绩) 案例:在表ⅹs的姓名列上创建一个唯一索引; alter table xs add unique index in Xs xm(姓名); MySQL数据库应用》http:/mysq!xg.hactcm.edu.cn 第17页
《MySQL数据库应用》 http://mysql.xg.hactcm.edu.cn/ 第 17 页 2.1 创建索引 • 案例:在表xs_kc的成绩列上创建一个普通索引; alter table xs_kc add index cj(成绩); • 案例:在表xs的姓名列上创建一个唯一索引; alter table xs add unique index in_xs_xm(姓名);
00022查看索引 MySQL MySQL中,可使用“SHOW| NDEX FROM表名”语 句查询表中已创建的索引。 如: SHOW INDEX FROM XS; MySQL数据库应用》http:/mysq!xg.hactcm.edu.cn 第18页
《MySQL数据库应用》 http://mysql.xg.hactcm.edu.cn/ 第 18 页 2.2 查看索引 • MySQL中,可使用“SHOW INDEX FROM 表名” 语 句查询表中已创建的索引。 • 如:SHOW INDEX FROM xs;
00023删除索引 MySQL MySQL中,可使用 DROP INDEX语句或者 ALTER TABLE语句删除索引 命令 (1) DROP INDEX索引名ON表名 (2) ALTER TABLE表名 DROP{NDEX|KEY索引名; MySQL数据库应用》http:/mysq!xg.hactcm.edu.cn 第19页
《MySQL数据库应用》 http://mysql.xg.hactcm.edu.cn/ 第 19 页 2.3 删除索引 • MySQL中,可使用DROP INDEX 语句或者ALTER TABLE 语句删除索引。 • 命令: • (1)DROP INDEX 索引名 ON 表名; • (2)ALTER TABLE 表名 DROP {INDEX | KEY} 索引名;
00023删除索引 MySQL 案例:删除表xskc的成绩索引 ALTER TABLE XS kC DROP Index in c 或者 DROP Index in cj on Xs kC, MySQL数据库应用》http:/mysq!xg.hactcm.edu.cn 第20页
《MySQL数据库应用》 http://mysql.xg.hactcm.edu.cn/ 第 20 页 2.3 删除索引 • 案例:删除表xs_kc的成绩索引; ALTER TABLE xs_kc DROP Index in_cj; DROP Index in_cj on xs_kc; 或者