本文介绍了如何在表中使用两个主键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在sql server的一个表中,它包含一个主键,我想再使用一个列作为主键。但是我们只能使用一个主键。如何实现这个

If In a table in sql server it is containing one primary key and I want to use one more column as primary key.but we can use only one primary key for a table.How should we achieve this

推荐答案



CREATE TABLE SampleTable (
  Key1 integer,
  Key2 integer,
  SomeOtherColumn nvarchar
  primary key (key1, key2)
);





您可能还需要考虑唯一约束。


这篇关于如何在表中使用两个主键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 01:25