简体   繁体   中英

Creating Primary Keys on the Table

We have a list of tables in our database with no primary key defined. We have decided to add a primary key on it. Most of the tables have an identity key column. But in most of the stored procedures, we used other columns for data retrieval. I am confused about in which column I need to create the primary key since it will create a clustered index also.

Thanks for help.

You can try this following example;

ALTER TABLE Db.TableName 
ADD CONSTRAINT PK_Id PRIMARY KEY NONCLUSTERED (Id);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM