34,874
社区成员
发帖
与我相关
我的任务
分享
只怪自己技术烂
某些情况下判断不到,造成逻辑上重复的数据,处理起来太痛苦了,
如果有主外键约束,宁愿报错也不愿意让它出现错误的数据[/quote]
程序未经充分测试就上线,根本不及格!还没达到讨论性能的层次。
这种“经验就”不要分享出来了。
只怪自己技术烂
某些情况下判断不到,造成逻辑上重复的数据,处理起来太痛苦了,
如果有主外键约束,宁愿报错也不愿意让它出现错误的数据
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 次。


队友

