Relationship between tables-foreign key

set up:

  • Create a new table: create table table name (A int, B text, constraint rule name foreign key (field name) references table name (field name));
  • In the establishment of the built table: alter table table name add constraint rule name foreign key (field name) references table name (field name));
  • other:
    on update cascade cascade update
    on delete cascade cascade delete
    set foreign_key_checks=0 disable primary key
    set foreign_key_checks=1 enable foreign key
    alter table table name drop foreign key constraint name delete foreign key

**

Guess you like

Origin blog.csdn.net/weixin_45936162/article/details/106164417