Add a foreign key after table creation
SQL
Medium
4 views
Problem Description
Departments exists. Employees exists without FK. Add FK on Employees.dept_id referencing Departments.dept_id.
Output Format
DDL statement(s)
Sample Test Case
Input:
Employees, Departments
Official Solution
ALTER TABLE Employees ADD CONSTRAINT fk_emp_dept FOREIGN KEY (dept_id) REFERENCES Departments(dept_id);
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!