Drop Unique Constraint and Add Primary Key : Drop Constraint « Constraints « Oracle PL / SQL






Drop Unique Constraint and Add Primary Key

  

SQL>
SQL> CREATE TABLE myTable (
  2     Name VARCHAR(50) NOT NULL,
  3     PhoneNo VARCHAR(15),
  4     CONSTRAINT unq_name UNIQUE(Name));

Table created.

SQL>
SQL> ALTER TABLE myTable DROP CONSTRAINT unq_name;

Table altered.

SQL> ALTER TABLE myTable ADD CONSTRAINT PK_myTableName PRIMARY KEY (Name);

Table altered.

SQL>
SQL>
SQL> drop table myTable;

Table dropped.

   
    
  








Related examples in the same category

1.Alter table to drop constraint with name
2.Drop a UNIQUE constraint without specifying its name by referencing the column or columns