if object_id('tempdb..#t1') is not null drop table #t1 create table #t1 ( ItemId int identity(0,1), a varchar(20), b varchar(30) ) insert into #t1(a,b) select 'a','b' union all select 'aa','bb' union all select 'aaa','bbb' union all select 'aaaa','bbbb' if object_id('tempdb..#t2') is not null drop table #t2 create table #t2 ( ItemId int, Id int identity(1,1), a varchar(20), b varchar(30) ) insert into #t2(ItemId,a,b) select * from #t1 select * from #t2
drop table #t1
create table #t1
(
ItemId int identity(0,1),
a varchar(20),
b varchar(30)
)
insert into #t1(a,b)
select 'a','b'
union all
select 'aa','bb'
union all
select 'aaa','bbb'
union all
select 'aaaa','bbbb'
if object_id('tempdb..#t2') is not null
drop table #t2
create table #t2
(
ItemId int,
Id int identity(1,1),
a varchar(20),
b varchar(30)
)
insert into #t2(ItemId,a,b)
select * from #t1
select * from #t2
Votes与VoteItems是一对多的,有人会么?
2、多个字段组合的值不能重复,单个字段内的数据允许重复定义主键方法:按住ctrl键,选择你想选的字段,右键设为主键即可