gpt4 book ai didi

mysql - 具有外部约束的子表可以是临时表吗?

转载 作者:行者123 更新时间:2023-11-29 12:29:19 25 4
gpt4 key购买 nike

当尝试这样做时,我收到以下错误:

1005 - Can't create table 'bidjunction.parent_table' (errno: 150)

我希望这是因为真正的表super_table不存在,只有临时表super_table

可以这样做吗?它记录在哪里?

CREATE TEMPORARY TABLE IF NOT EXISTS super_table (
id INT NOT NULL,
data VARCHAR(45) NULL,
PRIMARY KEY (id))
ENGINE = InnoDB;

CREATE TEMPORARY TABLE IF NOT EXISTS parent_table (
id INT NOT NULL,
data VARCHAR(45) NULL,
PRIMARY KEY (id),
CONSTRAINT fk_parent_super
FOREIGN KEY (id)
REFERENCES super_table (id)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;

最佳答案

不,这不可能,here已记录在案

The FOREIGN KEY clause is specified in the child table. The parent and child tables must use the same storage engine. They must not be TEMPORARY tables

关于mysql - 具有外部约束的子表可以是临时表吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27826038/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com