创建触发器以仅在创建新表时运行 [英] Creating a trigger to only run when a new table is being created
问题描述
我知道我可以使用这个来创建DDL创建触发器;
I know that I can use this to create DDL create trigger;
CREATE OR REPLACE TRIGGER
create_table_trigger
AFTER CREATE ON SCHEMA
DECLARE
BEGIN
END;
<如何只能为创建表DDL执行此操作?
Problem is this trigger would run on DDLs like 'Create sequence'; how can I only execute this for 'Create Table' DDLs?
推荐答案
CREATE OR REPLACE TRIGGER
create_table_trigger
AFTER CREATE ON SCHEMA
BEGIN
IF SYS.DICTIONARY_OBJ_TYPE = 'TABLE' THEN
....
END;
有关EVENT属性的列表,请参阅此页
http://ist.marshall.edu/ist480adbp/plsql_triggers.html (链接已关闭)
For a list of EVENT attributes, refer to this page
http://ist.marshall.edu/ist480adbp/plsql_triggers.html (link is down)
据我所知,dictionary_obj_type是以下之一:
TABLE | SEQUENCE | PROCEDURE | INDEX | FUNCTION | TYPE | PACKAGE
As far as I know, dictionary_obj_type is one of TABLE|SEQUENCE|PROCEDURE|INDEX|FUNCTION|TYPE|PACKAGE
而dictionary_obj_name只是表/序列/ proc / etc的名称。
And dictionary_obj_name is just the name of the table/sequence/proc/etc.
- dictionary_obj_type dictionary_obj_name 返回用于触发DDL操作的字典对象的名称。已触发触发器。
- dictionary_obj_type Returns the type of the dictionary object on which the DDL operation that fired the trigger occurred.
- dictionary_obj_name Returns the name of the dictionary object on which the DDL operation that fired the trigger occurred.
这篇关于创建触发器以仅在创建新表时运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!