面試題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