当前位置: 代码迷 >> Sql Server >> sql设置主键有关问题
  详细解决方案

sql设置主键有关问题

热度:41   发布时间:2016-04-27 19:00:49.0
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))
  相关解决方案