开发者

is there anyway to add a primary autonumber key to an already existing database table

i have inherited a database application from someone else and there are a few table开发者_运维知识库s that dont have any primary keys. I want to add a new column into an already existing table and have it autonumber (starting from 1). how would i go about doing this?


The SQL Server syntax is:

ALTER TABLE SomeTable ADD
    ID int NOT NULL IDENTITY(1, 1),
    CONSTRAINT PK_SomeTable PRIMARY KEY [NON]CLUSTERED (ID)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜