创建简单非聚集索引
IF EXISTS(SELECT name FROM sys.indexes WHERE name=N\'IX_TAccounts_FRegisterDate\') DROP INDEX IX_TAccounts_FRegisterDate ON dbo.TAccounts GO --创建简单非聚集索引 CREATE INDEX IX_TAccounts_FRegisterDate ON dbo.TAccounts(FRegisterDate) GO --备注:TAccounts表的FRegisterDate列创建非聚集索引
创建简单非聚集组合索引
IF EXISTS(SELECT name FROM sys.indexes WHERE name=N\'IX_TAccounts_FRegisterDate_FCompanyID\') DROP INDEX IX_TAccounts_FRegisterDate ON dbo.TAccounts GO --创建简单非聚集组合索引 CREATE NONCLUSTERED INDEX IX_TAccounts_FRegisterDate_FCompanyID ON dbo.TAccounts(FRegisterDate,FCompanyID) GO --备注:TAccounts表的FRegisterDate和FCompanyID列创建非聚集组合索引
创建唯一非聚集索引
IF EXISTS(SELECT name FROM sys.indexes WHERE name=N\'IX_Unique_TAccounts_FAccount\') DROP INDEX IX_Unique_TAccounts_FAccount ON dbo.TAccounts GO --创建唯一非聚集索引 CREATE UNIQUE INDEX IX_Unique_TAccounts_FAccount ON dbo.TAccounts(FAccount) GO --备注:TAccounts表的FAccount列创建唯一非聚集索引,该索引将强制插入FAccount列中的数据具有唯一性