2015-01-07 86 views
0

當試圖這樣做,我得到以下錯誤:具有外部約束的子表可以是臨時表嗎?

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

我希望那是因爲真正的表super_table不存在,只是暫時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; 

回答

1

不是,它是不可能的,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

+0

謝謝。是的,它肯定會在那裏顯示。我在看http://dev.mysql.com/doc/refman/5.1/en/create-table.html,並沒有討論它。 – user1032531