开发者

MYSQL Create table + Alter table incorrect syntax?

开发者 https://www.devze.com 2022-12-07 23:57 出处:网络
I\'m trying to create a table in Navicat and immediately add a foreign key relation after that. The syntax however seems to be incorrect... Is this even possible?

I'm trying to create a table in Navicat and immediately add a foreign key relation after that. The syntax however seems to be incorrect... Is this even possible?

    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
    );


you are missing a comma:

CREATE TABLE `Bld` (
  `id` int(10) NOT NULL, -- <- there
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
0

精彩评论

暂无评论...
验证码 换一张
取 消