面试题13 创建索引的三种方式


第一种方式:在执行create table时创建索引

 

create table user_index(

     id  int  auto_increment   primary key,

     first_name   varchar(16),

     last_name   varchar(16),

     id_card        varchar(18),

     information   text(225),

     key    name( first_name,last_name),

    fulltext   key(information),

    unique key(id_card)

);

第二种方式:使用Alter table命令去增加索引

alter table table_name add index  index_name(column_list);

第三种方式:使用create index命令来创建

create index index_name on table_name(column_list);

 

删除索引的方式有:

根据索引名来删除普通索引、唯一索引、全文索引。

alter table 表名  drop key 索引名

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM