Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Stored Procedure to rename (replace) PK name?

Stored Procedure to rename (replace) PK name?

From: <gmei_at_my-deja.com>
Date: Thu, 05 Oct 2000 02:05:29 GMT
Message-ID: <8rgnl5$30q$1@nnrp1.deja.com>

Hi:

I need to rename all PKs in a schema. I would like to write a procedure to do this globally. Before I start this, I would like to know if I am trying to re-invent the wheel here. If someone has the procedure to do this, I would certainly appreciate it if you can share with us.

Basically, I would like to have something like this:

Find existing PK name in the table
IF not found

      run dynamic sql"alter table tableName add constraint Primary key(columnName)"

else

      find all Fks that reference this old PK ,
      save all Fk's info in a cursor
      using dynamic sql to
         drop all FKs
         drop the old PK
         create new PK with new name
         re-establish all Fks

end if;

Is there any better or easiler way to do this?

TIA. Guang

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Wed Oct 04 2000 - 21:05:29 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US