日期:2014-05-18  浏览次数:20343 次

sql设置主键问题
在直接用T-SQL语言创建表的时候,如果要创建表的主键,一般用primary   key,比如:
create   table   test_2([id]   int   primary   key,[no]   varchar(20))
insert   test_1(id,no)
select   '1 ', '1 '   union   all
select   '2 ', '2 '   union   all
select   '3 ', '3 '

那如果要两列同时作为主键,该怎么写呢?


------解决方案--------------------
create table test_2([id] int primary key (id,no),[no] varchar(20))
------解决方案--------------------
create table test_2([id] int,[no] varchar(20),primary key(id,no))