7 Replies Latest reply: Jul 19, 2009 11:45 AM by MichaelS RSS

    add primary key in alter command

    709779
      I have an existing table with primary key. this is created by following command..

      CREATE TABLE CUST_MSTR (
      CUST_NO VARCHAR2(10) PRIMARY KEY,
      FNAME VARCHAR2(25),
      MNAME VARCHAR2(25),
      LNAME VARCHAR2(25),
      DOB_INC DATE,
      OCCUP VARCHAR2(25),
      PHOTOGRAPH VARCHAR2(25),
      SIGNATURE VARCHAR2(25),
      PANCOPY VARCHAR2(1),
      FORM60 VARCHAR2(1)
      );


      Now I have changed the design. My primary key consists of CUST_NO and FORM60. I want to change the table by using alter command.

      How can I do this using ALTER command??

      I tried this in the following manner, but it's not working


      SQL> ALTER TABLE CUST_MSTR
      2 DROP PRIMARY KEY;

      Table altered.

      SQL> DESC CUST_MSTR
      Name Null? Type
      ----------------------------------------- -------- ----------------------------
      CUST_NO VARCHAR2(10)
      FNAME VARCHAR2(25)
      MNAME VARCHAR2(25)
      LNAME VARCHAR2(25)
      DOB_INC DATE
      OCCUP VARCHAR2(25)
      PHOTOGRAPH VARCHAR2(25)
      SIGNATURE VARCHAR2(25)
      PANCOPY VARCHAR2(1)
      FORM60 VARCHAR2(1)

      SQL> ALTER TABLE CUST_MSTR
      2 ADD PRIMARY KEY(FORM 60, CUST_NO);
      ADD PRIMARY KEY(FORM 60, CUST_NO)
      *
      ERROR at line 2:
      ORA-00907: missing right parenthesis