Anyway, add the main key of the autodial into the existing database table

I have inherited a database application from someone else, and there are several tables that do not have any primary keys. I want to add a new column to an existing table and have its autonomy (starting from 1). How can i do this?

+3
source share
1 answer

SQL Server Syntax:

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

Source: https://habr.com/ru/post/1739734/


All Articles