mySQL 表创建失败 - 错误 1064
我正在使用 mysql 管理 GUI 工具来创建表。以下是导致错误的查询语言:
CREATE TABLE `environment`.`moisture` (
`city_id` INT,
`date_holding` VARCHAR,
`time_holding` VARCHAR,
`open` REAL,
`high` REAL,
`low` REAL,
`close` REAL,
)
CHARACTER SET utf8;
我的日期和时间不是 mysql 喜欢的格式,因此我选择 VARCHAR 作为这些列的类型,并将它们称为保留列,直到我可以运行查询来进行必要的转换。
当我尝试通过 GUI 执行此操作时,我得到以下信息:
执行 SQL 命令创建表时出错。
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在 'NOT NULL,
附近使用的正确语法 `time_holding` VARCHAR NOT NULL,
`open` REAL NOT NULL,
第 3 行的“high”RE(错误 1064)
知道为什么我会收到此消息吗?我已经检查过是否使用了任何保留字,但情况似乎并非如此。
我们将非常感谢您的帮助。
I am using the mysql admin GUI tool to create a table. Here is the query language that results in an error:
CREATE TABLE `environment`.`moisture` (
`city_id` INT,
`date_holding` VARCHAR,
`time_holding` VARCHAR,
`open` REAL,
`high` REAL,
`low` REAL,
`close` REAL,
)
CHARACTER SET utf8;
My date and time are not of the format mysql likes so I selected VARCHAR as the type for those columns and referred to them as holding columns until I can run queries to make the necessary conversions.
When I try to execute this via the GUI I get the following:
Error executing SQL commands to create table.
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 'NOT NULL,
`time_holding` VARCHAR NOT NULL,
`open` REAL NOT NULL,
`high` RE' at line 3 (error 1064)
Any idea why I am getting this? I have checked to see if I am using any reserved words but that does not seem to be the case.
Your help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您遇到的第一个错误是由于
VARCHAR
字段需要这样的长度:VARCHAR(30)
。第二个错误(如果修复 2 个 varchar,则会出现)是最后一个括号之前的逗号。
旁注:您确实知道 MySQL 有特定的类型来处理日期和时间,不是吗?所以你可以:
The first error you have is due to that
VARCHAR
fields need a length like this:VARCHAR(30)
.The second error (you'll get if you fix the 2 varchars) is the comma before the last parenthesis.
Side note: You do know that MySQL has specific types to handle dates and times, don't you? So you could have: