What is the correct syntax for removing primary key from a table?
What is the correct syntax for removing primary key from a table?
Solution
Changing a table's structure needs the DDL command ALTER TABLE, and removing a constraint or column uses the keyword DROP. So the primary key is removed with ALTER TABLE table_name DROP PRIMARY KEY;.
Options 2 and 4: DELETE is a DML command that removes rows of data, not structural elements like constraints.
Options 3 and 4: UPDATE changes the values stored in existing rows, and UPDATE TABLE is not valid SQL syntax.
In MySQL, a table has only one primary key, so DROP PRIMARY KEY needs no name. Other databases such as SQL Server and Oracle usually drop it by constraint name with DROP CONSTRAINT.
Related questions:
2025: 20 May Shift 1
2025: 14 May Shift 1
2025: 13 May Shift 2
2026: 18 May Shift 2