DOYENSYS Knowledge Portal




We Welcome you to visit our DOYENSYS KNOWLEDGE PORTAL : Doyensys Knowledge Portal




Tuesday, February 9, 2016

Renaming constraints

    SQL> show user; 
    USER is "MAHE" 
     
    SQL> select dbms_metadata.get_ddl('TABLE', 'T1') from dual; 
     
    DBMS_METADATA.GET_DDL('TABLE','T1') 
    --------------------------------------------------------- 
     
      CREATE TABLE "MAHE"."T1" 
       ( "A" NUMBER 
       ) SEGMENT CREATION IMMEDIATE 
     
     
    SQL> alter table T1 add constraint t1_mypk primary key (a); 
     
    Table altered. 
     
    SQL> select dbms_metadata.get_ddl('TABLE', 'T1') from dual; 
     
    DBMS_METADATA.GET_DDL('TABLE','T1') 
    --------------------------------------------------------- 
     
      CREATE TABLE "MAHE"."T1" 
       ( "A" NUMBER, 
      CONSTRAINT "T1_MYPK" PRIMARY KEY ("A") 
     
     
    SQL> alter table T1 rename constraint T1_MYPK to T1_PK;  
     
    Table altered. 
     
    SQL> select dbms_metadata.get_ddl('TABLE', 'T1') from dual; 
     
    DBMS_METADATA.GET_DDL('TABLE','T1') 
    --------------------------------------------------------- 
     
      CREATE TABLE "MAHE"."T1" 
       ( "A" NUMBER, 
      CONSTRAINT "T1_PK" PRIMARY KEY ("A") 
     
     
      DONE****