Skip to main contentSkip to solution

Which of the following is correct syntax for adding a primary key to an already existing relation 'Customer'?

Solution

✅ Correct Option: 1

ALTER TABLE is the DDL command used to change the structure of an existing table, such as adding a column or a constraint. Adding a primary key to an existing relation is a structural change, so the syntax is ALTER TABLE CUSTOMER ADD PRIMARY KEY (ID);

The column (here ID) must already exist and must not contain NULL or duplicate values.


Option 2: CREATE TABLE makes a new table, so it cannot modify one that already exists.

Option 3: UPDATE is a DML command that changes row data, not table structure, and UPDATE TABLE is not valid SQL.

Option 4: ADD TABLE is not an SQL command.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question