Which of the following is correct syntax for adding a primary key to an already existing relation 'Customer'?
Which of the following is correct syntax for adding a primary key to an already existing relation 'Customer'?
Solution
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.
Related questions:
2025: 27 May Shift 2
2025: 3 June Shift 2
2026: 29 May Shift 2