sql设置主键
alter table yourtable add constaints ConstaintName primarykey(columnNmae)
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'
?
http://hi.baidu.com/llbbqq99/blog/item/8216d903e891d77a3912bbd5.html