-- 建立code欄位的索引 名稱叫:ix_couponsinfodn_code
use activitydb
goif exists (select * from sysindexes where name='ix_couponsinfodn_code')--檢測是否已經存在ix_test_tname索引
drop index couponsinfodn.ix_couponsinfodn_code--如果存在則刪除
--建立索引
create nonclustered index ix_couponsinfodn_code --建立乙個非聚集索引
on couponsinfodn(code) --為test表的tname欄位建立索引
with fillfactor = 30 --填充因子為30%
-- 建立cardno欄位的索引 名稱叫:ix_couponsinfodn_cardno
use activitydb
goif exists (select * from sysindexes where name='ix_couponsinfodn_cardno')--檢測是否已經存在ix_test_tname索引
drop index couponsinfodn.ix_couponsinfodn_cardno--如果存在則刪除
--建立索引
create nonclustered index ix_couponsinfodn_cardno --建立乙個非聚集索引
on couponsinfodn(cardno) --為test表的tname欄位建立索引
with fillfactor = 30 --填充因子為30%
-- 查詢couponsinfodn表中存在的索引資訊
exec sp_helpindex couponsinfodn
mysql索引語句 mysql建立索引語句格式
專案需要將某個表的某兩個字段新增唯一索引,保證這兩個欄位的值不能同時重複。alter table 表名 add unique index 索引名 欄位1,欄位2 當表中已經存在重複資料的時候,新增的時候就會報錯,這時候需要將資料去重。1 先查出來重複的資料 select from select 字段...
SQL的索引語句
create index 語句用於在表中建立索引。在不讀取整個表的情況下,索引使資料庫應用程式可以更快地查詢資料。您可以在表中建立索引,以便更加快速高效地查詢資料。使用者無法看到索引,它們只能被用來加速搜尋 查詢。注釋 更新乙個包含索引的表需要比更新乙個沒有索引的表更多的時間,這是由於索引本身也需要...
oracle建立索引語句
oracle 單索引create index 索引名稱 on table column 刪除索引 drop index 索引名稱 復合索引 create index wbsindex on project info wbs,is delete 查詢某張表中所有索引 select from all i...