There is such a table declaration:

DROP TABLE IF EXISTS users_online; CREATE TABLE users_online( user_id int NOT NULL, lastvisittime DATETIME NOT NULL, PRIMARY KEY(user_id), CONSTRAINT FOREIGN KEY(user_id) REFERENCES user_list(user_id) ON DELETE SET NULL ); 

But the base swears that the key is incorrectly formed. But I do not understand what is wrong? Can you help?

  • one
    And how exactly does the base swear? - Mike
  • one
    Oh, I figured it out. I also put that the field is not NULL and immediately write that when you delete SET NULL. - user3416803
  • use mysql workbench - Jean-Claude
  • @ Jean-Claude, thanks for the advice. - user3416803

0