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 470925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:56:03+00:00 2026-05-12T23:56:03+00:00

Suppose I have an AFTER ALTER trigger on my Oracle database and I rename

  • 0

Suppose I have an AFTER ALTER trigger on my Oracle database and I rename some database object (ALTER ... RENAME TO ...). Within the trigger, how do I determine the new name of the database object? It seems that the ORA_DICT_OBJ_OWNER, ORA_DICT_OBJ_NAME and ORA_DICT_OBJ_TYPE functions all return the old values of the database object.

For example:

CREATE OR REPLACE TRIGGER ADAM_BEFORE_AFTER BEFORE ALTER ON DATABASE
BEGIN
  DBMS_OUTPUT.put_line('Before alter: ' || ora_dict_obj_owner || '.' || ora_dict_obj_name || ' (' || ora_dict_obj_type || ')');
END;

CREATE OR REPLACE TRIGGER ADAM_AFTER_ALTER AFTER ALTER ON DATABASE
BEGIN
  DBMS_OUTPUT.put_line('After alter: ' || ora_dict_obj_owner || '.' || ora_dict_obj_name || ' (' || ora_dict_obj_type || ')');
END;

Suppose I rename a table:

ALTER TABLE USELESS_TABLE9 RENAME TO USELESS_TABLE10

The database outputs this:

Before alter: DEVELOPER.USELESS_TABLE9 (TABLE)
After alter: DEVELOPER.USELESS_TABLE9 (TABLE)

Update: Unfortunately, the output I presented above was incorrect. The output was actually being generated by a BEFORE DDL trigger and an AFTER DDL trigger I had created earlier, not by the BEFORE RENAME and AFTER RENAME triggers. I will continue to investigate why the BEFORE RENAME and AFTER RENAME triggers are not firing…

Update: It appears that the BEFORE RENAME and AFTER RENAME triggers refuse to fire, but the BEFORE ALTER and AFTER ALTER triggers do. I have updated the question accordingly.

  • 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-05-12T23:56:04+00:00Added an answer on May 12, 2026 at 11:56 pm

    ALTER RENAME won’t fire the trigger, RENAME x TO y will.

    As for your question about names before and after, I think you will have to parse the DDL to retrieve them, like that:

    CREATE OR REPLACE TRIGGER MK_BEFORE_RENAME BEFORE RENAME ON SCHEMA 
    DECLARE 
      sql_text ora_name_list_t;
      v_stmt VARCHAR2(2000);
      n PLS_INTEGER; 
    BEGIN  
      n := ora_sql_txt(sql_text);
      FOR i IN 1..n LOOP
       v_stmt := v_stmt || sql_text(i);
      END LOOP;
    
      Dbms_Output.Put_Line( 'Before: ' || regexp_replace( v_stmt, 'rename[[:space:]]+([a-z0-9_]+)[[:space:]]+to.*', '\1', 1, 1, 'i' ) );
      Dbms_Output.Put_Line( 'After: ' || regexp_replace( v_stmt, 'rename[[:space:]]+.*[[:space:]]+to[[:space:]]+([a-z0-9_]+)', '\1', 1, 1, 'i' ) );
    END;
    

    The regular expressions could surely be written more clearly, but it works:

    RENAME 
    mktestx
    TO                 mktesty;
    
    Before: mktestx
    After: mktesty
    

    UPDATE To accommodate your changed question:

    CREATE OR REPLACE TRIGGER MK_AFTER_ALTER AFTER ALTER ON SCHEMA 
    DECLARE 
      sql_text ora_name_list_t;
      v_stmt VARCHAR2(2000);
      n PLS_INTEGER; 
    BEGIN  
      n := ora_sql_txt(sql_text);
      FOR i IN 1..n LOOP
       v_stmt := v_stmt || sql_text(i);
      END LOOP;
    
      Dbms_Output.Put_Line( 'Before: ' || regexp_replace( v_stmt, 'alter[[:space:]]+table[[:space:]]+([a-z0-9_]+)[[:space:]]+rename[[:space:]]+to.*', '\1', 1, 1, 'i' ) );
      Dbms_Output.Put_Line( 'After: ' || regexp_replace( v_stmt, 'alter[[:space:]]+table[[:space:]]+.*to[[:space:]]+([a-z0-9_]+)', '\1', 1, 1, 'i' ) );
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have import scala.collection.immutable.TreeMap val tree = new TreeMap[String, List[String]] Now after above
I have a very basic doubt. Suppose we heve two after insert trigger TR1
I have a trigger which works after insert|update on one table(suppose table 1). The
Suppose i have a LPSTR variable. How do i free the memory after using
Suppose, I have a connected socket after writing this code.. if ((sd = accept(socket_d,
I have some scripts that are supposed to be executable. But after it is
Suppose I have string Name and Image Photo as properties of a class in
Suppose I have the following HTML: <form id=myform> <input type='checkbox' name='foo[]'/> Check 1<br/> <input
Suppose I have a list, in which no new nodes are added or deleted.
Suppose we have one sentence (several words without a dot after the last one).

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.