这是一个错误:错误 #78955:使用 InnoDB 全文索引和约束导入转储失败
尝试以下更改,首先创建引用的表:
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `avalues`;
DROP TABLE IF EXISTS `mask_values`;
DROP TABLE IF EXISTS `object`;
CREATE TABLE `mask_values` (
`MVALUES_ID` INT(11) AUTO_INCREMENT PRIMARY KEY
) ENGINE=INNODB DEFAULT CHARSET=utf8;
CREATE TABLE `object` (
`OBJECT_ID` INT(11) AUTO_INCREMENT PRIMARY KEY
) ENGINE=INNODB DEFAULT CHARSET=utf8;
CREATE TABLE `avalues` (
`AVALUES_ID` INT(11) NOT NULL AUTO_INCREMENT,
`AVALUES_MVALUES_ID` INT(11) NOT NULL DEFAULT '0',
`AVALUES_OBJECT_ID` INT(11) NOT NULL DEFAULT '0',
`AVALUES_VALUE` LONGTEXT,
`AVALUES_RANG` INT(11) NOT NULL DEFAULT '0',
`AVALUES_VALUE_NUM` DOUBLE DEFAULT NULL,
`AVALUES_VALUE_DATE` DATETIME DEFAULT NULL,
`AVALUES_VALUE_TIME` TIME DEFAULT NULL,
`AVALUES_TOBJECT_ID` INT(11) DEFAULT NULL,
PRIMARY KEY (`AVALUES_ID`),
UNIQUE KEY `UK_AVALUES_MVALUES_OBJECT_RANG` (`AVALUES_MVALUES_ID`,`AVALUES_OBJECT_ID`,`AVALUES_RANG`),
KEY `I_AVALUES_MVALUES` (`AVALUES_MVALUES_ID`),
KEY `I_AVALUES_OBJECT` (`AVALUES_OBJECT_ID`),
KEY `I_AVALUES_MVALUES_NUM` (`AVALUES_MVALUES_ID`,`AVALUES_VALUE_NUM`),
KEY `I_AVALUES_MVALUES_DATE` (`AVALUES_MVALUES_ID`,`AVALUES_VALUE_DATE`),
KEY `i_avalues_object_mvalues` (`AVALUES_OBJECT_ID`,`AVALUES_MVALUES_ID`),
KEY `I_AVALUES_VALUE` (`AVALUES_VALUE`(255)),
KEY `I_AVALUES_MVALUES_VALUE` (`AVALUES_MVALUES_ID`,`AVALUES_VALUE`(255)),
KEY `i_avalues_tobject_value` (`AVALUES_TOBJECT_ID`,`AVALUES_VALUE`(255)),
KEY `i_avalues_object_mvalues_value` (`AVALUES_OBJECT_ID`,`AVALUES_MVALUES_ID`,`AVALUES_VALUE`(255)),
CONSTRAINT `FK_AVALUES_MVALUES_ID` FOREIGN KEY (`AVALUES_MVALUES_ID`) REFERENCES `mask_values` (`MVALUES_ID`) ON DELETE CASCADE,
CONSTRAINT `FK_AVALUES_OBJECT_ID` FOREIGN KEY (`AVALUES_OBJECT_ID`) REFERENCES `object` (`OBJECT_ID`) ON DELETE CASCADE,
FULLTEXT KEY `I_AVALUES_VALUE_FULLTEXT` (`AVALUES_VALUE`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
/*
CREATE TABLE `mask_values` (
`MVALUES_ID` INT(11) AUTO_INCREMENT PRIMARY KEY
) ENGINE=INNODB DEFAULT CHARSET=utf8;
CREATE TABLE `object` (
`OBJECT_ID` INT(11) AUTO_INCREMENT PRIMARY KEY
) ENGINE=INNODB DEFAULT CHARSET=utf8;
*/
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
mysql> /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
Query OK, 0 rows affected (0.00 sec)
mysql> /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
Query OK, 0 rows affected (0.00 sec)
mysql> /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
Query OK, 0 rows affected (0.00 sec)
mysql> /*!40101 SET NAMES utf8 */;
Query OK, 0 rows affected (0.00 sec)
mysql> /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
Query OK, 0 rows affected (0.00 sec)
mysql> /*!40103 SET TIME_ZONE='+00:00' */;
Query OK, 0 rows affected (0.00 sec)
mysql> /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
Query OK, 0 rows affected (0.00 sec)
mysql> /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
Query OK, 0 rows affected (0.00 sec)
mysql> /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
Query OK, 0 rows affected (0.00 sec)
mysql> DROP TABLE IF EXISTS `avalues`;
Query OK, 0 rows affected (0.01 sec)
mysql> DROP TABLE IF EXISTS `mask_values`;
Query OK, 0 rows affected (0.01 sec)
mysql> DROP TABLE IF EXISTS `object`;
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE TABLE `mask_values` (
-> `MVALUES_ID` INT(11) AUTO_INCREMENT PRIMARY KEY
-> ) ENGINE=INNODB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE TABLE `object` (
-> `OBJECT_ID` INT(11) AUTO_INCREMENT PRIMARY KEY
-> ) ENGINE=INNODB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE TABLE `avalues` (
-> `AVALUES_ID` INT(11) NOT NULL AUTO_INCREMENT,
-> `AVALUES_MVALUES_ID` INT(11) NOT NULL DEFAULT '0',
-> `AVALUES_OBJECT_ID` INT(11) NOT NULL DEFAULT '0',
-> `AVALUES_VALUE` LONGTEXT,
-> `AVALUES_RANG` INT(11) NOT NULL DEFAULT '0',
-> `AVALUES_VALUE_NUM` DOUBLE DEFAULT NULL,
-> `AVALUES_VALUE_DATE` DATETIME DEFAULT NULL,
-> `AVALUES_VALUE_TIME` TIME DEFAULT NULL,
-> `AVALUES_TOBJECT_ID` INT(11) DEFAULT NULL,
-> PRIMARY KEY (`AVALUES_ID`),
-> UNIQUE KEY `UK_AVALUES_MVALUES_OBJECT_RANG` (`AVALUES_MVALUES_ID`,`AVALUES_OBJECT_ID`,`AVALUES_RANG`),
-> KEY `I_AVALUES_MVALUES` (`AVALUES_MVALUES_ID`),
-> KEY `I_AVALUES_OBJECT` (`AVALUES_OBJECT_ID`),
-> KEY `I_AVALUES_MVALUES_NUM` (`AVALUES_MVALUES_ID`,`AVALUES_VALUE_NUM`),
-> KEY `I_AVALUES_MVALUES_DATE` (`AVALUES_MVALUES_ID`,`AVALUES_VALUE_DATE`),
-> KEY `i_avalues_object_mvalues` (`AVALUES_OBJECT_ID`,`AVALUES_MVALUES_ID`),
-> KEY `I_AVALUES_VALUE` (`AVALUES_VALUE`(255)),
-> KEY `I_AVALUES_MVALUES_VALUE` (`AVALUES_MVALUES_ID`,`AVALUES_VALUE`(255)),
-> KEY `i_avalues_tobject_value` (`AVALUES_TOBJECT_ID`,`AVALUES_VALUE`(255)),
-> KEY `i_avalues_object_mvalues_value` (`AVALUES_OBJECT_ID`,`AVALUES_MVALUES_ID`,`AVALUES_VALUE`(255)),
-> CONSTRAINT `FK_AVALUES_MVALUES_ID` FOREIGN KEY (`AVALUES_MVALUES_ID`) REFERENCES `mask_values` (`MVALUES_ID`) ON DELETE CASCADE,
-> CONSTRAINT `FK_AVALUES_OBJECT_ID` FOREIGN KEY (`AVALUES_OBJECT_ID`) REFERENCES `object` (`OBJECT_ID`) ON DELETE CASCADE,
-> FULLTEXT KEY `I_AVALUES_VALUE_FULLTEXT` (`AVALUES_VALUE`)
-> ) ENGINE=INNODB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.02 sec)
mysql> /*
/*> CREATE TABLE `mask_values` (
/*> `MVALUES_ID` INT(11) AUTO_INCREMENT PRIMARY KEY
/*> ) ENGINE=INNODB DEFAULT CHARSET=utf8;
/*>
/*> CREATE TABLE `object` (
/*> `OBJECT_ID` INT(11) AUTO_INCREMENT PRIMARY KEY
/*> ) ENGINE=INNODB DEFAULT CHARSET=utf8;
/*> */
mysql> /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
Query OK, 0 rows affected (0.00 sec)
mysql> /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
Query OK, 0 rows affected (0.00 sec)
mysql> /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
Query OK, 0 rows affected (0.00 sec)
mysql> /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
Query OK, 0 rows affected (0.00 sec)
mysql> /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Query OK, 0 rows affected (0.00 sec)
mysql> /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
Query OK, 0 rows affected (0.00 sec)
我正在寻找行为的原因。
更新
当您在创建表后尝试SHOW ENGINE INNODB STATUS
(参见13.7.5.15 SHOW ENGINE 语法)时,您可以阅读以下内容:
...
------------------------
LATEST FOREIGN KEY ERROR
------------------------
2000-01-01 00:00:01 0x901ffb40 Error in foreign key constraint of table test/avalues:
FOREIGN KEY (`AVALUES_MVALUES_ID`) REFERENCES `mask_values` (`MVALUES_ID`) ON DELETE CASCADE,
CONSTRAINT `FK_AVALUES_OBJECT_ID` FOREIGN KEY (`AVALUES_OBJECT_ID`) REFERENCES `object` (`OBJECT_ID`) ON DELETE CASCADE,
FULLTEXT KEY `I_AVALUES_VALUE_FULLTEXT` (`AVALUES_VALUE`)
) ENGINE=INNODB DEFAULT CHARSET=utf8:
Cannot resolve table name close to:
(`MVALUES_ID`) ON DELETE CASCADE,
CONSTRAINT `FK_AVALUES_OBJECT_ID` FOREIGN KEY (`AVALUES_OBJECT_ID`) REFERENCES `object` (`OBJECT_ID`) ON DELETE CASCADE,
FULLTEXT KEY `I_AVALUES_VALUE_FULLTEXT` (`AVALUES_VALUE`)
) ENGINE=INNODB DEFAULT CHARSET=utf8
...