当我尝试将我的SQL文件上传到PHPMyAdmin时,我收到此错误。
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!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 */;
--
-- Database: `datasorter`
--
-- --------------------------------------------------------
--
-- Table structure for table `data`
--
CREATE TABLE IF NOT EXISTS `data` (
`id` int(20) NOT NULL AUTO_INCREMENT,
`name` varchar(1000) NOT NULL,
`dt` varchar(500) NOT NULL,
`console` varchar(1000) NOT NULL,
`age` varchar(1000) NOT NULL, PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
--
-- Dumping data for table `data`
--
INSERT INTO `data` (`id`, `name`, `dt`, `console`, `age`) VALUES
(1, 'abc', '1/june/2015', 'abc','123'),
;
/*!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 */;
phpMyAdmin SQL Dump
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="methods" thread-count="5">
<listeners>
<listener class-name="com.pages.LocalWebDriverListener"></listener>
</listeners>
<test name="Test" parallel="methods" thread-count="5">
<parameter name="browserName" value="firefox"></parameter>
<classes>
<class name="com.pages.CucumberRunner" />
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
答案 0 :(得分:2)
在分号前删除逗号:
INSERT INTO `data` (`id`, `name`, `dt`, `console`, `age`) VALUES
(1, 'abc', '1/june/2015', 'abc','123'),
;
应该是:
INSERT INTO `data` (`id`, `name`, `dt`, `console`, `age`) VALUES
(1, 'abc', '1/june/2015', 'abc','123');
的 SqlFiddleDemo
强>
将dt
存储为VARCHAR
是非常糟糕的做法。请考虑使用正确的数据类型。
Age
应计算/生成列,除非您希望每年更新它。
答案 1 :(得分:0)
删除<!-- MathJax: Fall back to local if CDN offline -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML"></script>
<script>window.MathJax || document.write('<script type="text/x-mathjax-config">MathJax.Hub.Config({"HTML-CSS":{imageFont:null}});<\/script><script src="<<PATH_TO_YOUR_LOCAL_MATHJAX>>MathJax.js?config=TeX-AMS_HTML-full"><\/script>')</script>
'age')
答案 2 :(得分:0)
查询结尾处有一个额外的逗号:
INSERT INTO `data` (`id`, `name`, `dt`, `console`, `age`) VALUES
(1, 'abc', '1/june/2015', 'abc','123'),;
^^
Here
只需将其更改为:
INSERT INTO `data` (`id`, `name`, `dt`, `console`, `age`) VALUES
(1, 'abc', '1/june/2015', 'abc','123');