方式一,直接删除:
delete from T where ID=1方式二,先看有没有:
if exists(select top 1 1 from T where ID=1) delete from T where ID=1
我的问题:
1)select是不是不会产生日志?
2)delete的时候如果不存在,影响行数=0还会不会产生日志?
3)如果会,方式二是不是就不会了?
4)update是不是也一样?关键是第二个问题。希望大家帮帮忙,日志越来越大,每天删都来不及。
delete from T where ID=1方式二,先看有没有:
if exists(select top 1 1 from T where ID=1) delete from T where ID=1
我的问题:
1)select是不是不会产生日志?
2)delete的时候如果不存在,影响行数=0还会不会产生日志?
3)如果会,方式二是不是就不会了?
4)update是不是也一样?关键是第二个问题。希望大家帮帮忙,日志越来越大,每天删都来不及。
1)select是不是不会产生日志?
如果是查询不产生日志2)delete的时候如果不存在,影响行数=0还会不会产生日志?
不产生3)如果会,方式二是不是就不会了?
会4)update是不是也一样?
对.如果是truncate table tb则不产生日志.
2.不会
3.有就会 没有不会
4.同3
delete 要产生日志。 truncate table ta_name 实际上不是删除行,而是释放页,当然释放页要写入日志、
我们可以写个tran来验证他到底产生日志没:if object_id('ta') is not null drop table ta
create table ta(id int)
insert ta
select 1 union all
select 2 union all
select 3 union all
select 4 union all
select 5 union all
select 6 union all
select 7begin tran
select count(*) from ta-- 结果为7
truncate table ta
select count(*) from ta--结果为0
rollback tran
select count(*) from ta--结果为7
如果没有写入日志,rollback tran 肯定不起作用 则最后一次的结果应为0;
select查询是不产生日志的
update/delete操作是会产生日志的。
2)delete的时候如果不存在,影响行数=0还会不会产生日志?
------------------------------------
我想不会产生日志是系统没有执行后面的update语句,产生是执行了。