问题描述
我知道我可以用它来创建 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 上运行;我如何只对创建表"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)
Wayback machine 链接到上面死链接的内容:https://web.archive.org/web/20110809071133/http://ist.marshall.edu/ist480adbp/plsql_triggers.html
Wayback machine link to the contents of the dead link above: https://web.archive.org/web/20110809071133/http://ist.marshall.edu/ist480adbp/plsql_triggers.html
据我所知,dictionary_obj_type 是其中之一表|序列|过程|索引|功能|类型|包装
As far as I know, dictionary_obj_type is one of TABLE|SEQUENCE|PROCEDURE|INDEX|FUNCTION|TYPE|PACKAGE
而dictionary_obj_name 只是表/序列/过程/等的名称.
And dictionary_obj_name is just the name of the table/sequence/proc/etc.
- dictionary_obj_type 返回触发触发器的 DDL 操作发生的字典对象的类型.
- 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.
这篇关于创建仅在创建新表时运行的触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!