实际上,我曾使用此sql脚本在mysql 5.0.24上创建表方案,并且运行良好,问题是当我在mysql 5.5.16上尝试相同的脚本时出现以下错误消息:


  服务器发出的一般错误消息:“无法创建表'amdb.am_wta_methodtree'(错误号:150)”


这是我的sql:

create table AM_WTA_MethodInstance(
"ID" BIGINT NOT NULL,
"TRANSACTIONID" BIGINT NOT NULL,
"INVOCATIONTIME" BIGINT NOT NULL,
"METHODIDENTIFIERID" BIGINT NOT NULL,
"THREADID" VARCHAR(255) NOT NULL,
"INCLUSIVETIME" BIGINT NOT NULL DEFAULT 0,
"EXCLUSIVETIME" BIGINT NOT NULL DEFAULT 0,
"STATUS" INTEGER(1) NOT NULL DEFAULT 0,
"EXCEPTIONMESSAGE" TEXT,
PRIMARY KEY ("ID"),
FOREIGN KEY(METHODIDENTIFIERID) REFERENCES AM_WTA_MethodIdentifier(ID),
FOREIGN KEY(TRANSACTIONID) REFERENCES AM_WTA_Transaction(TRANSACTIONID) ON DELETE CASCADE)

create table AM_WTA_MethodTree(
"PARENTID" BIGINT NOT NULL,
"CHILDID" BIGINT NOT NULL,
"INVOCATIONTIME" BIGINT NOT NULL,
PRIMARY KEY ("PARENTID","CHILDID"),
FOREIGN KEY(PARENTID,CHILDID) REFERENCES AM_WTA_MethodInstance(ID,ID) ON DELETE CASCADE)

最佳答案

如果创建表commit,并且在创建外键之后它应该起作用。

谢谢

关于mysql - MySQL-用外键创建表-错误150,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18966912/

10-17 03:06