添加外鍵約束
alter table dbo.Account_UserRole add foreign key(UserID)
references dbo.Account_User(UserID)
刪除索引
drop index [User_Publish_ischeck] ON [dbo].[User_Publish]
刪除主鍵
alter table User_Publish drop constraint PK_User_Publish
建立索引
CREATE NONCLUSTERED INDEX [User_Publish_ischeck] ON [dbo].[User_Publish]
(
[IsCheck] ASC
)
--建立非叢集索引
create nonclustered index inx_entry_stock_on entry_stock_d(entry_stock_bi)
--主鍵且非聚集
alter table entry_stock_d add primary key nonclustered--主鍵且非聚集
(
entry_stock_bi,aid
}
建立唯一非叢集索引
CREATE UNIQUE INDEX AK_UnitMeasure_Name
ON Production.UnitMeasure(Name);
GO
建立分區叢集索引
create clustered index PK_User_Publish_RefTime
on User_Publish(RefTime)
on RefTimePS(RefTime);
刪除約束
alter table [User_Publish] drop constraint DF_User_Publish_IsCheck
增加約束
ALTER TABLE User_Publish
ADD CONSTRAINT DF_User_Publish_IsCheck DEFAULT (0) FOR IsCheck
修改列的類型
ALTER TABLE User_Publish ALTER column IsCheck char(1) null
刪除索引
drop index [User_Publish_ischeck] ON [dbo].[User_Publish]
刪除主鍵
alter table User_Publish drop constraint PK_User_Publish
建立索引
CREATE NONCLUSTERED INDEX [User_Publish_ischeck] ON [dbo].[User_Publish]
(
[IsCheck] ASC
)
--建立非叢集索引
create nonclustered index inx_entry_stock_on entry_stock_d(entry_stock_bi)
--主鍵且非聚集
alter table entry_stock_d add primary key nonclustered--主鍵且非聚集
(
entry_stock_bi,aid
}
建立唯一非叢集索引
CREATE UNIQUE INDEX AK_UnitMeasure_Name
ON Production.UnitMeasure(Name);
GO
建立分區叢集索引
create clustered index PK_User_Publish_RefTime
on User_Publish(RefTime)
on RefTimePS(RefTime);
刪除約束
alter table [User_Publish] drop constraint DF_User_Publish_IsCheck
增加約束
ALTER TABLE User_Publish
ADD CONSTRAINT DF_User_Publish_IsCheck DEFAULT (0) FOR IsCheck
修改列的類型
ALTER TABLE User_Publish ALTER column IsCheck char(1) null