我正在尝试在Navicat中创建一个表,然后立即添加一个外键关系。然而,语法似乎不正确......这甚至可能吗?
CREATE TABLE `Bld` (
`id` int(10) NOT NULL
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `Bld` (
CONSTRAINT `fk_Bld_Bld_Ref` FOREIGN KEY (`id`) REFERENCES `Bld_Ref` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
);
答案 0 :(得分:4)
CREATE TABLE `Bld` (
`id` int(10) NOT NULL, -- <- there
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;