zoukankan      html  css  js  c++  java
  • MYSQL CASCADE DELETE 引发的思考

    MYSQL CASCADE DELETE :级联删除。这个概念还是学习Oracle时得到的。

    就是主键记录删除时,相关的有外键的表里的记录,也删除。

    https://dev.mysql.com/doc/refman/5.7/en/delete.html

    https://stackoverflow.com/questions/2914936/mysql-foreign-key-constraints-cascade-delete

    http://www.mysqltutorial.org/mysql-on-delete-cascade/

    上面三个帖子解释的比较清楚。

    另外CASCADE模式需要MYSQL引擎支持:Engine必须是InnoDB。

    mysql> SHOW ENGINES; 
    +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
    | Engine             | Support | Comment                                                        | Transactions | XA   | Savepoints |
    +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
    | PERFORMANCE_SCHEMA | YES     | Performance Schema                                             | NO           | NO   | NO         |
    | CSV                | YES     | CSV storage engine                                             | NO           | NO   | NO         |
    | MRG_MYISAM         | YES     | Collection of identical MyISAM tables                          | NO           | NO   | NO         |
    | BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears) | NO           | NO   | NO         |
    | MyISAM             | YES     | MyISAM storage engine                                          | NO           | NO   | NO         |
    | MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables      | NO           | NO   | NO         |
    | ARCHIVE            | YES     | Archive storage engine                                         | NO           | NO   | NO         |
    | InnoDB             | DEFAULT | Supports transactions, row-level locking, and foreign keys     | YES          | YES  | YES        |
    | FEDERATED          | NO      | Federated MySQL storage engine                                 | NULL         | NULL | NULL       |
    +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
    9 rows in set
    
    mysql> 

    一篇比较常用的两个引擎MyISAM和InnoDB的文章:

    http://www.oschina.net/question/17_4248

  • 相关阅读:
    nginx+iis使用
    sqlserver中一些常用的函数总结
    HTML如何让文字居中?附两种方式
    PNG图片收集
    解决mac pro 软件损坏
    end-of-file from the keyboard
    c++while控制语句
    如何通过命令行编写调试第一个C++程序(UNIX)
    matlab直接运行fig文件时报错
    第二次结对编程作业
  • 原文地址:https://www.cnblogs.com/rgqancy/p/6933517.html
Copyright © 2011-2022 走看看