34,838
社区成员




create table test
(
col1 varchar(50),
col2 varchar(50),
col3 varchar(50),
col4 varchar(50),
col5 varchar(50),
)
alter table test
add constraint pk_id primary key(col1)
--创建表2
select * into test2 from test
select * from test2
--对表2增加外键
alter table test2
add constraint fk_col1 foreign key(col1) references test(col1)
alter table test2
add constraint pk_id2 primary key(col1)
select * from test2
insert into test values (NEWID(),NEWID(),NEWID(),NEWID(),NEWID())
go 100000
insert into test2 select * from test
set statistics io on
delete from test where col1='E6200F7E-B53A-49EF-B3B5-96E485C390AF'
(1 行受影响)
表 'test2'。扫描计数 0,逻辑读取 3 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。
表 'test'。扫描计数 0,逻辑读取 6 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。
delete from test2 where col1='E6200F7E-B53A-49EF-B3B5-96E485C390AF'
(1 行受影响)
表 'test2'。扫描计数 0,逻辑读取 3 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。