主键不是只能设置一列字段吗?为什么可以约束2条字段为主键?
------解决方案--------------------
- SQL code
--此处的pid,id就是联合主键if object_id('pt2') is not null drop table pt2gocreate table pt2(pid int not null,id int not null)goalter table pt2 add constraint [PK_pt2] primary key(pid,id) on [PRIMARY]go
------解决方案--------------------
设置两个字段叫联合主键
------解决方案--------------------
可以设置联合主键
primary key(col1,col2....)