外键和簇
我有一个使用 InnoDB 表类型和外键的架构。 我计划使用 mysql Cluster,我只是想确保我可以使用“InnoDB”表类型并且外键约束仍然有效。
更新:
根据文档:
可以使用以下方式创建表 其他存储引擎(例如MyISAM 或 InnoDB)在 MySQL 服务器上 与 MySQL Cluster 一起使用,但是这些 非NDB表不参与 聚类;每个这样的表是 严格本地于单个 MySQL 它所在的服务器实例 创建。
这是否意味着如果我创建一个InnoDB表,我可以有外键约束?我知道这些表不会参与集群。
I have a schema that uses InnoDB table type and foreign keys.
I am planning to use mysql Cluster and I just want to make sure that I can use "InnoDB" table type and foreign key constraints will be still valid.
Update:
As per the documentation:
It is possible to create tables using
other storage engines (such as MyISAM
or InnoDB) on a MySQL server being
used with a MySQL Cluster, but these
non-NDB tables do not participate in
clustering; each such table is
strictly local to the individual MySQL
server instance on which it is
created.
Does it mean that if I create an InnoDB table, I can have foreign key constraint? I understand those tables will not participate in clustering.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,他们都使用
NDBCLUSTER
作为存储引擎,并且 外键约束不可用 5.6/ MySQL Cluster NDB 7.3 之前的版本。从 MySQL Cluster NDB 7.3 外键开始是可能的< /a>.不参与集群的表可以是 InnoDB(或任何其他),但仅在服务器本地(即其他服务器不知道该表),因此只能在其中一个节点上查询该表(其中有点破坏了集群的优势)。
引擎的所有功能当然都可用,所以实际上,InnoDB 表可以有外键约束,但相同的规则适用于 InnoDB<>NDB 和 InnoDB<>MyISAM:如果您提到一个,MySQL 不会抱怨位于 InnoDB 表定义中的 NDB/MyISAM 表中的列,但也不会强制完整性。
No, they all use
NDBCLUSTER
as a storage engine, and foreign key constraints are not available before 5.6/ MySQL Cluster NDB 7.3. Starting with MySQL Cluster NDB 7.3 foreign keys are possible.Tables that do not participate in clustering can be InnoDB (or any other ), but are local to the server only (i.e. the other servers are not aware of that table), so the table can only be queried on one of the nodes (which kind of defeats the advantages of clustering).
All features of the engine are then of course available, so indeed, the InnoDB table can have foreign key constraints, but the same rules apply with InnoDB<>NDB as InnoDB<>MyISAM: MySQL won't complain if you mention a column located in an NDB/MyISAM table in an InnoDB table definition, but won't enforce the integrity either.
可以以编程方式在 NDB(或任何本身不支持它们的 mysql 存储引擎)中强制执行外键:
http://dev.mysql.com/tech-resources /articles/mysql-enforcing-foreign-keys.html
或者如果您可以等待 MySQL Cluster 7.3 :
https://blogs.oracle.com/MySQL/entry/mysql_cluster_7_3_labs
It is possible to programmatically enforce foreign keys in NDB (or any mysql storage engine which does not natively support them):
http://dev.mysql.com/tech-resources/articles/mysql-enforcing-foreign-keys.html
Or if you can wait for MySQL Cluster 7.3 :
https://blogs.oracle.com/MySQL/entry/mysql_cluster_7_3_labs
MySQL集群不支持外键,因为施加外键约束可能会降低集群的性能。您可以以这样的方式设计数据库,即对数据库的操作将保留所需的检查。
MySQL cluster does not support foreign keys as imposing foreign key constraint may reduce the performance of cluster .You can design your database in such a fashion that operations on database would keep the required checks.