0

尝试将我的网站数据库导入另一台服务器时,我不断收到此错误。

错误:

Error at the line 3034: ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Catalog Product Website Index Table';

询问:

CREATE TABLE `catalog_product_index_website` (
`website_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Website ID',
`website_date` date DEFAULT NULL COMMENT 'Website Date',
`rate` float DEFAULT '1' COMMENT 'Rate',
PRIMARY KEY (`website_id`),
KEY `IDX_CATALOG_PRODUCT_INDEX_WEBSITE_WEBSITE_DATE` (`website_date`),
CONSTRAINT `FK_CAT_PRD_IDX_WS_WS_ID_CORE_WS_WS_ID` FOREIGN KEY (`website_id`) REFERENCES `core_website` (`website_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Catalog Product Website Index Table'

MySQL: Can't create table './myhairdev/catalog_product_index_website.frm' (errno: 150)

我尝试SET FOREIGN_KEY_CHECKS=0;在开头添加并 SET FOREIGN_KEY_CHECKS=1; 最后但仍然得到同样的错误。

这是相关数据库行中的代码:

DROP TABLE IF EXISTS `catalog_product_index_website`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `catalog_product_index_website` (
  `website_id` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Website ID',
  `website_date` date DEFAULT NULL COMMENT 'Website Date',
  `rate` float DEFAULT '1' COMMENT 'Rate',
  PRIMARY KEY (`website_id`),
  KEY `IDX_CATALOG_PRODUCT_INDEX_WEBSITE_WEBSITE_DATE` (`website_date`),
  CONSTRAINT `FK_CAT_PRD_IDX_WS_WS_ID_CORE_WS_WS_ID` FOREIGN KEY (`website_id`) REFERENCES `core_website` (`website_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Catalog Product Website Index Table';
/*!40101 SET character_set_client = @saved_cs_client */;

帮助请帮助:)

4

1 回答 1

0

你必须删除约束

CONSTRAINT `FK_CAT_PRD_IDX_WS_WS_ID_CORE_WS_WS_ID` FOREIGN KEY (`website_id`) REFERENCES `core_website` (`website_id`) ON DELETE CASCADE ON UPDATE CASCADE

并在创建所有表、主键和索引时将其添加到最后。

在您的情况下,您必须先创建表core_website并将列声明website_id为索引,然后再创建与该索引和该表相关的外键。

于 2013-09-23T19:24:26.680 回答