Adding constraints in phpMyAdmin

后端 未结 3 812
暗喜
暗喜 2020-12-17 10:36

I feel like I\'m being stupid, but I can\'t find anywhere on the phpMyAdmin interface to add constraints to foreign keys e.g. CASCADE ON DELETE

I\'ve looked for simi

相关标签:
3条回答
  • 2020-12-17 10:59

    First, you should have your storage engine as InnoDB. Then select a table and go to 'Structure' tab.

    Under the table you will see 'Relation view', click it. From there you could add constraints.

    0 讨论(0)
  • 2020-12-17 11:03

    Firstly, you should choose storage engine as InnoDB.

    Follow this way: click database_name -> More -> Designer

    0 讨论(0)
  • 2020-12-17 11:05

    CASCADE

    Whenever rows in the master (referenced) table are deleted (resp. updated), the respective rows of the child (referencing) table with a matching foreign key column will get deleted (resp. updated) as well. This is called a cascade delete (resp. update[2]).

    RESTRICT

    A value cannot be updated or deleted when a row exists in a foreign key table that references the value in the referenced table. Similarly, a row cannot be deleted as long as there is a reference to it from a foreign key table.

    NO ACTION

    NO ACTION and RESTRICT are very much alike. The main difference between NO ACTION and RESTRICT is that with NO ACTION the referential integrity check is done after trying to alter the table. RESTRICT does the check before trying to execute the UPDATE or DELETE statement. Both referential actions act the same if the referential integrity check fails: the UPDATE or DELETE statement will result in an error.

    SET NULL

    The foreign key values in the referencing row are set to NULL when the referenced row is updated or deleted. This is only possible if the respective columns in the referencing table are nullable. Due to the semantics of NULL, a referencing row with NULLs in the foreign key columns does not require a referenced row.

    0 讨论(0)
提交回复
热议问题