sql 設定主鍵 聯合主鍵
alter table yourtable add ConstaintName primary key(columnName)
/*ConstaintName 資料型別 yourtable 表名 columnName 列名*/
or
create table yourtable(column1 int primary key,....)
--增加列
alter table [TableName] add [P_ID] bigint not null default 0
--刪除列
alter table [TableName] drop column [P_ID]
--設定主鍵
alter table [TableName] add constraint PK_TableName primary key (P_ID)
--刪除主鍵
alter table [TableName] drop constraint PK_TableName
--建立聚集索引(一個表中允許一個聚集索引)
CREATE CLUSTERED INDEX [tTopIndex] ON [TableName] ([P_ID]) ON [PRIMARY]
--建立非聚集索引
CREATE INDEX [tTopIndex] ON TableName ([P_ID]) ON [PRIMARY]
--刪除索引
drop index [TableName].[tTopIndex]
--增加欄位說明
EXECUTE sp_addextendedproperty N'MS_Description', N'照片ID', N'user', N'dbo', N'table', N'TableName', N'column', N'P_ID'
聯合主鍵
ALTER TABLE jserp.fp WITH NOCHECK ADD
CONSTRAINT [PK_jserp.fp] PRIMARY KEY NONCLUSTERED
(
fp_flid,
fp_fpid
)