mysql - ERROR 1064 (42000) when using keywords as column name(mysql - 使用关键字作为列名时出现错误 1064 (42000))
问题描述
这有什么问题吗?在 Gentoo 系统上成功运行此程序,但现在在 Debian-Squeeze (Raspberry PI) 上无法运行.
What's wrong with this? Ran this successfully on a Gentoo system, but now on a Debian-Squeeze (Raspberry PI) it won't work.
数据库设置正常
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| arduino1 |
| mysql |
| performance_schema |
| test |
| tmp |
+--------------------+
6 rows in set (0.01 sec)
mysql>
命令是:
#mysql -u root -p******* arduino1 < arduino-tables.sql
导致:
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(8),
currentTime DATETIME,
timeDiff INT(10),
unixTime INT(10),
currentR1 FL' at line 3
arduino-tables.sql 的内容:
Content of arduino-tables.sql:
#cat arduino-tables.sql:
CREATE TABLE pulseLog (
id INT(10) UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,
timeStamp TIMESTAMP(8),
currentTime DATETIME,
timeDiff INT(10),
unixTime INT(10),
currentR1 FLOAT,
currentS2 FLOAT,
currentT3 FLOAT,
currentAverageR1 FLOAT,
currentAverageS2 FLOAT,
currentAverageT3 FLOAT,
temp0 FLOAT,
temp1 FLOAT,
temp2 FLOAT,
temp3 FLOAT,
temp4 FLOAT,
temp5 FLOAT,
pulses INT,
event char(255),
) CHARACTER SET UTF8;
推荐答案
有一些拼写错误,比如 timestamp 是一个关键词,你有一个额外的逗号事件字符(255),.
There where some typo errors, like timestamp is a key word, you had an extra comma after
event char(255),.
试试这个:
CREATE TABLE pulseLog (
id INT(10) UNSIGNED PRIMARY KEY NOT NULL AUTO_INCREMENT,
`timeStamp` TIMESTAMP,
`currentTime` DATETIME,
`timeDiff` INT(10),
`unixTime` INT(10),
`currentR1` FLOAT,
`currentS2` FLOAT,
`currentT3` FLOAT,
`currentAverageR1` FLOAT,
`currentAverageS2` FLOAT,
`currentAverageT3` FLOAT,
`temp0` FLOAT,
`temp1` FLOAT,
`temp2` FLOAT,
`temp3` FLOAT,
`temp4` FLOAT,
`temp5` FLOAT,
`pulses` INT,
`event` char(255)
) CHARACTER SET UTF8;
这是SQL Fiddle DEMO
除此之外,不支持您的时间戳语法.有关日期、日期时间和时间戳的参考检查此处
Apart from that your syntax for timestamp was not supported. For reference on date, datetime and timestamp check here
这篇关于mysql - 使用关键字作为列名时出现错误 1064 (42000)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:mysql - 使用关键字作为列名时出现错误 1064 (42000)
基础教程推荐
- 带更新的 sqlite CTE 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
