我一直在尝试导入我在数据库上创建的转储文件,该数据库包含服务器MariaDB版本10.1.9上的虚拟列表。这是.sql文件的一部分:
DROP TABLE IF EXISTS `abc`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `abc` (
`a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` + 1)) VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
-- Dumping data for table `abc`
LOCK TABLES `abc` WRITE;
/*!40000 ALTER TABLE `abc` DISABLE KEYS */;
INSERT INTO `abc` VALUES (2,3),(3,4),(3,4),(56,57);
/*!40000 ALTER TABLE `abc` ENABLE KEYS */;
UNLOCK TABLES;
既然MySQL最新版本支持虚拟列,我预计导入会成功,但它没有给出错误:
Error Code: 3105 - The value specified for generated column 'b' in table 'abc' is not allowed.
有什么办法可以避免这个错误?我可以将转储文件导入到数据到MySQL服务器版本5.7.11 ??
答案 0 :(得分:0)
我已经检查了版本10.1.10,这很好用。我首先使用您的CREATE创建了表,然后我将其转储并导入它。
-- MySQL dump 10.16 Distrib 10.1.10-MariaDB, for osx10.11 (x86_64)
--
-- Host: localhost Database: bernd
-- ------------------------------------------------------
-- Server version 10.1.10-MariaDB-log
/*!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 */;
--
-- Table structure for table `abc`
--
DROP TABLE IF EXISTS `abc`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `abc` (
`a` int(11) DEFAULT NULL,
`b` int(11) AS ((`a` + 1)) VIRTUAL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `abc`
--
LOCK TABLES `abc` WRITE;
/*!40000 ALTER TABLE `abc` DISABLE KEYS */;
INSERT INTO `abc` VALUES (1,2),(2,3),(3,4),(99,100);
/*!40000 ALTER TABLE `abc` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!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 */;
-- Dump completed on 2016-02-15 13:50:24