[英]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.我们决定在其上添加一个
primary key
。 Most of the tables have an identity
key column.大多数表都有一个
identity
键列。 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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.