How would you add a foreign key constraint on the dept_no column in the EMP table, referring to the id column in the DEPT table?
Answer options
A
Use the ALTER TABLE command with the ADD clause on the EMP table.
B
Use the ALTER TABLE command with the MODIFY clause on the EMP table.
C
Use the CREATE TABLE command with the FOREIGN KEY clause.
D
Use the DROP TABLE command and recreate the table.
Correct answer: Use the ALTER TABLE command with the ADD clause on the EMP table.
Explanation
Quick AnswerThe correct answer is Use the ALTER TABLE command with the ADD clause on the EMP table. because it directly addresses the core logic of Database Management.
ALTER TABLE EMP ADD CONSTRAINT fk_dept FOREIGN KEY (dept_no) REFERENCES dept(dept_no);