Can a trigger be created on drop user event? if so, how do I write the the trigger –
* I want to delete some rows related to that user from a table after drop user *
“Drop User”
Can you provide an example:
If the user is drop and oracle purge the user’s schema objects is there anyway I can select what row of data I want to keep or delete?
So are you saying that a Trigger can not be created on drop user event?
Of course you can. Assuming you’re actually dropping a user and not a table:
You’re looking for a system trigger as opposed to a schema trigger or a database trigger. You can add these to a large number of ddl events including
DROP.To quote from the documentation:
Your trigger might look something like the following:
This uses the not particularly well documented
dbms_standardpackage to work out what’s happening. PSOUG has better documentation, in my opinion.If you only want to do this for a specific schema rather than for the entire database use
before drop on schemainstead.Just as a little side note I’m not convinced of the need to do this in a trigger. It would be better if you created a package with
drop_userandcreate_userprocedures that do everything you want in one place rather than disguising the logic in a trigger.