0

你知道我在外键哪里有问题吗?

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(  `countryId` bigint(20) NOT NULL AUTO_INCREMENT,  `personId` bigint(20) NOT ' at line 1

带外键的表 1

ALTER TABLE `country` (
  `countryId` bigint(20) NOT NULL AUTO_INCREMENT,
  `personId` bigint(20) NOT NULL,
  `Name` varchar(5000) DEFAULT NULL,
  PRIMARY KEY (`countryId`),
  UNIQUE KEY `personId` (`personId`),
  CONSTRAINT fk_PerOrders FOREIGN KEY (`personId`) REFERENCES perosn(`PersonId`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=0;

表2

CREATE TABLE `perosn` (
  `PersonId` bigint(20) NOT NULL AUTO_INCREMENT,
  `Name` varchar(5000) DEFAULT NULL,
  `Surname` varchar(5000) NOT NULL,
  PRIMARY KEY (`PersonId`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=0;
4

1 回答 1

1
ALTER TABLE `country` (
^^^^^--- should be CREATE

CREATE TABLE `perosn` (
              ^^^^^^--- should be person
于 2013-03-04T14:50:12.033 回答