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****
  • February 9, 2016 | 25 views