mysql建立刪除索引語句

2021-10-06 16:17:45 字數 1314 閱讀 3097

1、檢視索引

show index from tb_wz_all;

2)使用alter table語句建立索引。

語法如下:

alter table table_name add index index_name (column_list) ;

create index indexname on tablename(tablecolumns(length))

alter table table_name add unique (column_list) ;

(1)建立索引:create unique index indexname on tablename(tablecolumns(length))

alter table table_name add primary key (column_list) ;

fulltext(全文索引)

alter table `table_name` add fulltext ( `col

多列索引:

alter table `table_name` add index index_name ( `column1`, `column2`, `column3` )

例如:alter table table_test add index index_test1(name) ;

3)使用create index語句對錶增加索引。

能夠增加普通索引和unique索引兩種。其格式如下:

create index index_name on table_name (column_list) ;

create unique index index_name on table_name (column_list) ;

例如:create index index_test2 on table_test(age);

4)刪除索引。

刪除索引可以使用alter table或drop index語句來實現。drop index可以在alter table內部作為一條語句處理,其格式如下:

drop index index_name on table_name ;

alter table table_name drop index index_name ;

alter table table_name drop primary key ;

例如:drop index name on table_test ;

感謝:

mysql索引語句 mysql建立索引語句格式

專案需要將某個表的某兩個字段新增唯一索引,保證這兩個欄位的值不能同時重複。alter table 表名 add unique index 索引名 欄位1,欄位2 當表中已經存在重複資料的時候,新增的時候就會報錯,這時候需要將資料去重。1 先查出來重複的資料 select from select 字段...

oracle建立索引語句

oracle 單索引create index 索引名稱 on table column 刪除索引 drop index 索引名稱 復合索引 create index wbsindex on project info wbs,is delete 查詢某張表中所有索引 select from all i...

sql語句 建立 查詢 索引語句

建立code欄位的索引 名稱叫 ix couponsinfodn code use activitydb goif exists select from sysindexes where name ix couponsinfodn code 檢測是否已經存在ix test tname索引 drop ...