我想在ORACLE中删除现有触发器。
我确实知道oracle中drop
对触发器的查询。但是想知道我如何检查Oracle DB中是否已经存在该触发器。
DROP查询:
DROP TRIGGER **TRIGGER_NAME**
a_horse_with.. 5
为此,您需要一个带有动态SQL的PL / SQL块:
-- drop the trigger if it exists declare l_count integer; begin select count(*) into l_count from user_triggers where trigger_name = 'TRIGGER_NAME'; if l_count > 0 then execute immediate 'drop trigger trigger_name'; end if; end; / -- now create the trigger create trigger trigger_name .. begin end; /
请注意,(未加引号的)标识符以大写形式存储在Oracle系统目录中。因此,请确保使用trigger_name = 'TRIGGER_NAME'
,而不是trigger_name = 'trigger_name'
在PL / SQL检查中
为此,您需要一个带有动态SQL的PL / SQL块:
-- drop the trigger if it exists declare l_count integer; begin select count(*) into l_count from user_triggers where trigger_name = 'TRIGGER_NAME'; if l_count > 0 then execute immediate 'drop trigger trigger_name'; end if; end; / -- now create the trigger create trigger trigger_name .. begin end; /
请注意,(未加引号的)标识符以大写形式存储在Oracle系统目录中。因此,请确保使用trigger_name = 'TRIGGER_NAME'
,而不是trigger_name = 'trigger_name'
在PL / SQL检查中