我想在SQL中设置一条数据,永远不会被删除
我想在SQL中设置一条数据,永远不会被删除,比如这个系统有个帐号admin密码123456,对数据库操作时,只能对他修改密码,不能删除帐号。
------解决方案--------------------用触发器试试:
create trigger trg_delete on table
for delete
as
if exists(select 1 from deleted where ID = 'admin ')
rollback /*如果被删除的行中有指定的行则回滚,使本次删除无效*/
GO
------解决方案--------------------create trigger trg_delete on table
for delete
as
if (select 帐号 from deleted)= 'admin '
begin
rollback
end
GO