I am trying to create two tables in phpmyadmin: Users and Keys, the schema is as follows:
Users:
id int auto_incerement primary key
name varchar(50) not null
Keys:
user_id int
keys varchar(50) not null
Now I am running the following query to make the user_id
in Keys
a foreign key referencing the id
in Users
ALTER TABLE Keys
FOREIGN KEY(user_id) REFERENCES Users(id)
ON UPDATE CASCADE
ON DELETE CASCADE
But after executing, i am getting the following error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Keys FOREIGN KEY(user_id) REFERENCES Users(id) ON UPDATE CASCADE ON DELETE CA' at line 1
Can anyone tell me what am I doing wrong?
Thanks in advance.