
Answer-first summary for fast verification
Answer: ALTER TABLE orders DROP PRIMARY KEY CASCADE;
The correct command is `ALTER TABLE orders DROP PRIMARY KEY CASCADE;` because: 1. `ALTER TABLE orders DROP PRIMARY KEY` removes the PRIMARY KEY constraint from the `orders` table. 2. `CASCADE` ensures that any dependent objects, like the FOREIGN KEY constraint in the `users` table referencing this PRIMARY KEY, are also dropped. Other options either lack the `CASCADE` keyword or contain syntax errors, making them incorrect.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
In a database, a column named id is the PRIMARY KEY for the orders table and also a FOREIGN KEY in the users table. Which command correctly removes the PRIMARY KEY constraint from the orders table and simultaneously drops the FOREIGN KEY reference?
A
ALTER orders DROP PRIMARY KEY CASCADE;
B
ALTER TABLE orders DROP PRIMARY_KEY;
C
ALTER TABLE orders DROP PRIMARY KEY CASCADE;
D
ALTER orders DROP PRIMARY_KEY;
E
ALTER TABLE orders DROP PRIMARY_KEY CASCADE;
No comments yet.