我想創建一個基於Magento數據庫結構的表。我在安裝過程中不斷收到錯誤,所以我正在嘗試創建與問題相關的三個表。我一直在使用OAuth安裝發生錯誤。新版本的Magento在MySQL中將進程分成3個表。因此,三個表中的兩個已創建,這裏是第三個表的MySQL腳本 - 這裏是運行錯誤的表。1005 mysql無法創建表外鍵erno 150
DROP TABLE IF EXISTS `oauth_token`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `oauth_token` (
`entity_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Entity ID',
`consumer_id` int(10) unsigned NOT NULL COMMENT 'Consumer ID',
`admin_id` int(10) unsigned DEFAULT NULL COMMENT 'Admin user ID',
`customer_id` int(10) unsigned DEFAULT NULL COMMENT 'Customer user ID',
`type` varchar(16) NOT NULL COMMENT 'Token Type',
`token` varchar(32) NOT NULL COMMENT 'Token',
`secret` varchar(32) NOT NULL COMMENT 'Token Secret',
`verifier` varchar(32) DEFAULT NULL COMMENT 'Token Verifier',
`callback_url` varchar(255) NOT NULL COMMENT 'Token Callback URL',
`revoked` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Is Token revoked',
`authorized` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT 'Is Token authorized',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Token creation timestamp',
PRIMARY KEY (`entity_id`),
UNIQUE KEY `UNQ_OAUTH_TOKEN_TOKEN` (`token`),
KEY `IDX_OAUTH_TOKEN_CONSUMER_ID` (`consumer_id`),
KEY `FK_OAUTH_TOKEN_ADMIN_ID_ADMIN_USER_USER_ID` (`admin_id`),
KEY `FK_OAUTH_TOKEN_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID` (`customer_id`),
CONSTRAINT `FK_OAUTH_TOKEN_ADMIN_ID_ADMIN_USER_USER_ID` FOREIGN KEY (`admin_id`) REFERENCES `admin_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_OAUTH_TOKEN_CONSUMER_ID_OAUTH_CONSUMER_ENTITY_ID` FOREIGN KEY (`consumer_id`) REFERENCES `oauth_consumer` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_OAUTH_TOKEN_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID` FOREIGN KEY (`customer_id`) REFERENCES `customer_entity` (`entity_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='OAuth Tokens';
/*!40101 SET character_set_client = @saved_cs_client */;
那麼我應該怎麼做,或者我該如何改變MySQL腳本的工作?
你可以發佈你在外鍵constarints中引用的表的創建語句嗎? –
[MySQL「ERROR 1005(HY000):Can not create table'foo。#sql-12c_4'(errno:150)」]可能重複(http://stackoverflow.com/questions/2799021/mysql-error- 1005-hy000-cant-create-table-foo-sql-12c-4-errno-150) – invertedSpear