Creating a trigger to run only when creating a new table

I know I can use this to create a DDL create trigger,

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

The problem is that this trigger will work on DDL, for example "Create sequence"; how can i only do this for the create table ddl files?

+7
sql database oracle triggers ddl
source share
1 answer
 CREATE OR REPLACE TRIGGER create_table_trigger AFTER CREATE ON SCHEMA BEGIN IF SYS.DICTIONARY_OBJ_TYPE = 'TABLE' THEN .... END; 

See the EVENT attribute list on this page.
http://ist.marshall.edu/ist480adbp/plsql_triggers.html (link not working)

The path to the reverse mechanism for linking to the contents of the invalid link above is: 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 for which the DDL operation occurred that triggered the trigger.
  • dictionary_obj_name Returns the name of the dictionary object for which the DDL operation occurred that triggered the trigger.
+15
source share

All Articles