Mysql: adding foreign key does not give warning/error on MyISAM tables

前端 未结 2 1780
情话喂你
情话喂你 2020-12-19 18:01

Here is a table I made:

mysql> show create table notes;
+-------+----------------------------------------------------+
| Table | Create Table                      


        
相关标签:
2条回答
  • 2020-12-19 18:07

    The InnoDB engine should generally (unless you have a fulltext index for instance) be preferred, as InnoDB allows transactions, foreign keys, and row locking, for instance.

    On a test database, perform

      ALTER TABLE notes ENGINE = InnoDB;
      ALTER TABLE notetypes ENGINE = InnoDB;
    

    (and any other relevant - maybe all - tables)

    and ensure you do not have any side effects (See Mysql Alter Table).

    Check also the parameters specific to InnoDB (in my.sql), See also the Mysql InnoDB engine.

    0 讨论(0)
  • 2020-12-19 18:29

    myISAM doesn't do referential integrity. it seems it is legal to add such constraints and hence no error, though the constraints won't be enforced as long as the engine is myISAM. It does store the keys created so the user can see what was intended, though.

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