ALTER TABLE employee ADD FOREIGN KEY(branch_id) REFERENCES branch(branch_id) ON DELETE SET NULL;
gives me following error message:
near "FOREIGN": syntax error in line 12: ALTER TABLE employee ADD FOREIGN
The branch table exists with the branch_id column, also the employee table has the branch_id column, both with the same data types. Foreign Key is enabled in Pragma.
Here are the tables:
CREATE TABLE employee ( emp_id INT PRIMARY KEY, branch_id INT ); CREATE TABLE branch ( branch_id INT PRIMARY KEY, branch_name VARCHAR(40), mgr_id INT, mgr_start_date DATE, FOREIGN KEY(mgr_id) REFERENCES employee(emp_id) ON DELETE SET NULL);