Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8430343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:34:41+00:00 2026-06-10T05:34:41+00:00

Can a trigger be created on drop user event? if so, how do I

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:34:42+00:00Added an answer on June 10, 2026 at 5:34 am

    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:

    Causes the database to fire the trigger whenever a DROP statement
    removes a database object from the data dictionary.

    Your trigger might look something like the following:

    create or replace trigger tr_drop_user
      before drop on database
    
    begin
       if dbms_standard.dictionary_obj_type = 'USER' then
    
          insert into logs ( user, object_name )
          values ( sys_context('USERENV','OS_USER') -- OS User doing the dropping
                 , dbms_standard.dictionary_obj_name -- name of object being dropped
                  );
    
       end if;
    end;
    /
    

    This uses the not particularly well documented dbms_standard package 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 schema instead.


    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_user and create_user procedures that do everything you want in one place rather than disguising the logic in a trigger.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to protect some rows from deletion and I prefer to do it
Can a trigger for a table can be applied for tracking in same table?
I'm wondering if I can use a trigger on a table to ignore columns
I need to copy some data from one table to another in Oracle, while
I need to delete some text files when a certain database is dropped from
Lets say that I have a drop down list that I want to create
I have a table that I want : when the table has been updated,
I created some ajax paginated comments in WordPress. Unfortunately, if the user had clicked
I have a trigger that sets a datetime field in a table row when
I have tow tables concept_access and concept_access_log. I want to create a trigger that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.