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 上运行;我如何只对创建表"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.
这篇关于创建仅在创建新表时运行的触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:创建仅在创建新表时运行的触发器
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- SQL 临时表问题 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01