1.出现问题的 sql 文件
/*
Navicat MySQL Data Transfer
Source Server : 20.0.1.118
Source Server Version : 50631
Source Host : 20.0.1.118:3306
Source Database : nslm
Target Server Type : MYSQL
Target Server Version : 50631
File Encoding : 65001
Date: 2016-11-25 16:16:40
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for areas
-- ----------------------------
DROP TABLE IF EXISTS `areas`;
CREATE TABLE "areas" (
"id" varchar(32) NOT NULL COMMENT '编号',
"name" varchar(30) NOT NULL COMMENT '名称',
"parent_id" varchar(32) NOT NULL,
"code" varchar(2) NOT NULL COMMENT '完整编号',
"level" tinyint(1) NOT NULL COMMENT '层级',
"is_hide" tinyint(1) NOT NULL,
"full_name" varchar(200) NOT NULL,
PRIMARY KEY ("id"),
KEY "index_area_parent_id" ("parent_id") USING BTREE,
KEY "index_area_name" ("name") USING BTREE,
KEY "INDEX_ID" ("id") USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of areas
-- ----------------------------
INSERT INTO `areas` VALUES ('01', '北京市', '0', '01', '1', '0', '北京市');
INSERT INTO `areas` VALUES ('0101', '北京市', '01', '01', '2', '0', '北京市北京市');
INSERT INTO `areas` VALUES ('010101', '东城区', '0101', '01', '3', '0', '北京市北京市东城区');
2.正常导入数据的 sql
/*
Navicat MySQL Data Transfer
Source Server : localhost
Source Server Version : 50634
Source Host : localhost:3306
Source Database : nslm
Target Server Type : MYSQL
Target Server Version : 50634
File Encoding : 65001
Date: 2016-11-25 16:22:11
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for areas
-- ----------------------------
DROP TABLE IF EXISTS `areas`;
CREATE TABLE `areas` (
`id` varchar(32) NOT NULL COMMENT '编号',
`name` varchar(30) NOT NULL COMMENT '名称',
`parent_id` varchar(32) NOT NULL,
`code` varchar(2) NOT NULL COMMENT '完整编号',
`level` tinyint(1) NOT NULL COMMENT '层级',
`is_hide` tinyint(1) NOT NULL,
`full_name` varchar(200) NOT NULL,
PRIMARY KEY (`id`),
KEY `index_area_parent_id` (`parent_id`) USING BTREE,
KEY `index_area_name` (`name`) USING BTREE,
KEY `INDEX_ID` (`id`) USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of areas
-- ----------------------------
INSERT INTO `areas` VALUES ('01', '北京市', '0', '01', '1', '0', '北京市');
INSERT INTO `areas` VALUES ('0101', '北京市', '01', '01', '2', '0', '北京市北京市');
INSERT INTO `areas` VALUES ('010101', '东城区', '0101', '01', '3', '0', '北京市北京市东城区');
3.差别:将所有【”】 替换为 【`】
CREATE TABLE "areas" (
"id" varchar(32) NOT NULL COMMENT '编号',
CREATE TABLE `areas` (
`id` varchar(32) NOT NULL COMMENT '编号',
很明显,第一个文件的建表语句中实用的是双引号,第二个实用的是【`】,这个不是单引号,而是~那个按键所在的下面的那个字符,所以把所有的双引号替换为【`】,结果可以正确的倒入数据了 。