- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
从 7.3 版本开始,MySQL Cluster 应该能够进行外键约束。但这是发生了什么:
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
id INT PRIMARY KEY
) ENGINE='InnoDB';
CREATE TABLE t2 (
id INT PRIMARY KEY,
t1id INT
) ENGINE='InnoDB';
ALTER TABLE t2
ADD CONSTRAINT t2t1 FOREIGN KEY (t1id) REFERENCES t1 (id)
ON DELETE CASCADE ON UPDATE CASCADE;
这是使用 InnoDB,一切正常。现在用 NDB 试试:
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
id INT PRIMARY KEY
) ENGINE='NDB';
CREATE TABLE t2 (
id INT PRIMARY KEY,
t1id INT
) ENGINE='NDB';
ALTER TABLE t2
ADD CONSTRAINT t2t1 FOREIGN KEY (t1id) REFERENCES t1 (id)
ON DELETE CASCADE ON UPDATE CASCADE;
-- ERROR 150 (HY000): Cannot add foreign key constraint
现在是奇怪的部分:
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (
id INT UNIQUE KEY
) ENGINE='NDB';
CREATE TABLE t2 (
id INT PRIMARY KEY,
t1id INT
) ENGINE='NDB';
ALTER TABLE t2
ADD CONSTRAINT t2t1 FOREIGN KEY (t1id) REFERENCES t1 (id)
ON DELETE CASCADE ON UPDATE CASCADE;
工作正常。
是否有任何规则说“使用 NDB 存储引擎,您不能在外键约束中引用主键列”或“使用 NDB,您必须在外键约束中引用 UNIQUE KEYS”?
让事情变得更奇怪:
如果将 t1 的定义替换为
CREATE TABLE t1 (
id INT UNIQUE KEY NOT NULL
) ENGINE='NDB';
你得到同样的错误。
我认为 PRIMARY KEY
意味着 NOT NULL
并且问题不在于前者而在于后者。
最佳答案
根据我从 MySQL 站点和开发者博客收集的内容:
An important difference to note with the Foreign Key implementation in InnoDB is that MySQL Cluster does not support the updating of Primary Keys from within the Data Nodes themselves - instead the UPDATE is emulated with a DELETE followed by an INSERT operation. Therefore an UPDATE operation will return an error if the parent reference is using a Primary Key, unless using CASCADE action, in which case the delete operation will result in the corresponding rows in the child table being deleted. The Engineering team plans to change this behavior in a subsequent preview release.
尚未确认是否支持此类操作。
关于mysql - MySQL.Cluster (NDB) 的外键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14876649/
如果我有一个具有以下定义的Contact 模型: class Contact(ndb.Model): name = ndb.TextProperty(indexed=False) we
我有 webapp2 服务,它在多个不相互依赖的 NDB 模型中插入条目。现在我们要求的是服务应该在事务中。那是服务失败然后它应该恢复完整的交易(例如,如果一个条目插入到第一个和第二个模型中,并且在该
切换到 python GAE 上的 ndb 库。 我可以将 ndb 与之前使用低级 api 创建的实体一起使用吗?还是我必须复制所有旧实体并重新保存它们才能使用 ndb? 谢谢! 最佳答案 ndb 只
是否可以在 pre_put_hook 中找出实体的脏因子? 我想根据put 的内容有条件地执行一些回调。例如。如果实体的特定属性发生更改,我想发送邮件通知。我可以在调用 put() 之前手动执行此操作
我是谷歌应用引擎和 NDB 的初学者。我的问题:如果我在模型中有 1 个实体, 我想防止 2 个并行操作时发生冲突,代码示例: class MyModel(ndb.Model) count = n
假设有一个看起来像这样的 ndb.Model: class Foo(ndb.Model): bar = ndb.StringProperty() 我的问题是,如果我的唯一输入是 Foo.query
给定我构造的 key ,我想访问数据存储区以查看它是否存在,但我想要最便宜(及时)的方法来做到这一点。我正在寻找的就像一个只有键的查询,但是来自 get,例如my_key.get(keys_only=
https://developers.google.com/appengine/docs/python/ndb/ https://developers.google.com/appengine/doc
我有一个 ndb.Model,它有一个 ndb.DateTimeProperty 和一个 ndb.CompulatedProperty,它使用 ndb.DateTimeProperty 创建时间戳。
我计划将 Odoo 移植到 Google App Engine Web 应用程序。当我知道 Odoo 使用 postgresql 时,是否可以将数据库连接、查询和所有从 Postgresql db 移
我有一个 POST 方法,它调用一些 tasklet。这些 tasklet 确实有 yield ,我的代码中确实有一些 x.put_async()。所以我不希望它在所有异步内容完成之前返回。所以我用
我有一个简单的 NDB 模型: from google.appengine.ext import ndb import logging from libs import Api class User(
使用 Python NDB 的新手。 我有类似的东西: class User(ndb.Model): seen_list = nbd.KeyProperty(kind=Survey, repe
我的应用程序中有以下查询 query = cls.query().filter(cls.taskgroup_id == taskgroup_id, cls.availability == True,
我在 NDB 迁移方面遇到问题。目前,我在 NDB Cluster 中有 2 个副本。我想将集群移至新硬件中。因此,在新机器中,我设置了 datanodes 和 sqlnodes 并将管理节点指向旧集
我有一个 mysql ndb 集群(详情如下)。问题是当我做最简单的事情时,例如恢复使用 mysqldump 转储的数据库,它需要绝对的时间! IE 6 小时恢复一个大小为 745MB 且在大约 30
来自 What can be done in a transaction (我的重点): All Datastore operations in a transaction must operate
我正在对 Expense 模型的方法进行单元测试。模型的相关部分如下所示: class Expense(ndb.Model): user = ndb.KeyProperty(User, req
几年来,我一直在使用类似于下面复制的代码片段。 基本思想是 Person 可以结婚,当他们结婚时,我创建一个“Marriage”实体。一个人只能结婚一次,所以我有一个 bool 值来指示这个人是否已婚
我们使用的是 ndb 数据存储、python、标准谷歌应用引擎。我们想使用查询游标。但是为了根据 here 工作和 here ,看起来我们需要实现 datastore_model.query().or
我是一名优秀的程序员,十分优秀!