1

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

1 回答 1

4

you are missing a comma:

CREATE TABLE `Bld` (
  `id` int(10) NOT NULL, -- <- there
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
于 2009-10-06T11:37:10.280 回答