Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to create a trigger that fires when a view is created on a user schema?

I want to create a meta data table which will hold all the views and a listing containing what they are supposed to do. In this system (Oracle there is only one user who has the create view privilege so that may make it easier.

The sequence of events should be something like view is created trigger fires and inserts the name of the view in the table of meta data table

I could write up some package to create views using dynamic sql but that seems a bit of overkill

share|improve this question
Isn't there a catalog/information schema on Oracle that would allow to query the views and their comments? I'm not knowing Oracle but would assume that it exposes the information somehow that is needed and prensent internally anyway. You could save yourself from the extra table then and avoid risking to get out of sync with the present views (unless a history of the DDL statements is also necessary). – Augustus Kling Aug 25 '11 at 20:38
A good idea but I wish to add a descriptive comment about what the view is for so I need a table for that anyway. – kevinsky Aug 25 '11 at 21:54
It should be possible to store the comment on the views with comment on view viewname is 'test comment'. – Augustus Kling Aug 26 '11 at 4:44
this is how you can comment on a view: comment on table aschema.myview is 'number of issues by calendar year'; (notice how even if it is a view you have to say table) SELECT * FROM all_tab_comments WHERE owner = 'aschema'; but you will need privileges to query these system data views – kevinsky Aug 26 '11 at 17:10
I'm sorry for the confusion. I did not remember Oracle calls views table when adding comments – others call them view, too. Regarding the permissions thing: You would create a view with read permissions set for your user to get the meta data. I'd say since gbn already gave a helpful answer, this discussion can be stopped here. References:… and – Augustus Kling Aug 26 '11 at 20:21
up vote 4 down vote accepted

You can use DDL triggers in Oracle.

I haven't actually done this myself, so here are some links:

share|improve this answer
That works! I can't see how to accept this as an answer. Maybe it's my browser. – kevinsky Aug 25 '11 at 17:25
Near the answer there should be a check mark sign. Change the browser if the current doesn't show it :-). – Marian Aug 25 '11 at 20:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.