How to use foreign keys in SQL Buddy?
I need to use foreign keys for update and cascade, etc.
ALTER TABLE topics
ADD FOREIGN KEY(topic_by) REFERENCES users(user_id)
ON DELETE RESTRICT开发者_StackOverflow中文版 ON UPDATE CASCADE;
but I am not able to make foreign keys in SQL Buddy.
Any way to do that?
did you try this :
ALTER TABLE topics
ADD CONSTRAINT topic_by FOREIGN KEY(user)
REFERENCES users(user_id) ON DELETE RESTRICT ON UPDATE CASCADE
Try this query:
ALTER TABLE topics
ADD CONSTRAINT topic_by
FOREIGN KEY (user_id) REFERENCES users(user_id);
精彩评论