创建触发器仅在创建新表时运行

发布于 2024-10-14 11:39:12 字数 203 浏览 4 评论 0原文

我知道我可以用它来创建DDL创建触发器;

CREATE OR REPLACE TRIGGER 
  create_table_trigger
  AFTER CREATE ON SCHEMA
DECLARE
BEGIN
END;

问题是此触发器将在“创建序列”等 DDL 上运行;我怎样才能只对“创建表”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;

Problem is this trigger would run on DDLs like 'Create sequence'; how can I only execute this for 'Create Table' DDLs?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜尕妞 2024-10-21 11:39:12
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(链接为向下)

回溯机链接到上面死链接的内容:
https://web.archive。 org/web/20110809071133/http://ist.marshall.edu/ist480adbp/plsql_triggers.html

据我所知,dictionary_obj_type是其中之一
TABLE|SEQUENCE|PROCEDURE|INDEX|FUNCTION|TYPE|PACKAGE

和dictionary_obj_name 只是表/序列/proc/等的名称。

  • dictionary_obj_type 返回发生触发触发器的 DDL 操作的字典对象的类型。
  • dictionary_obj_name 返回发生触发触发器的 DDL 操作的字典对象的名称。
CREATE OR REPLACE TRIGGER 
  create_table_trigger
  AFTER CREATE ON SCHEMA
BEGIN
  IF SYS.DICTIONARY_OBJ_TYPE = 'TABLE' THEN
      ....
END;

For a list of EVENT attributes, refer to this page
http://ist.marshall.edu/ist480adbp/plsql_triggers.html (link is down)

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

As far as I know, dictionary_obj_type is one of
TABLE|SEQUENCE|PROCEDURE|INDEX|FUNCTION|TYPE|PACKAGE

And dictionary_obj_name is just the name of the table/sequence/proc/etc.

  • 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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文