[英]An ERROR 1064 occurs while creating a table using MySQL
I'm creating a new table after starting MySQL service.启动 MySQL 服务后,我正在创建一个新表。
I code it at Win10, on MySQL 8.0 command line Client.我在 Win10 的 MySQL 8.0 命令行客户端上对其进行编码。 The code now is shown as below:
现在的代码如下所示:
create table 't8' ('id1' timestamp not null default current_timestamp,'id2' datetime default null);
Then I got an error while I was executing it:然后我在执行它时遇到错误:
ERROR 1064 (42000): You have an error in your SQL syntax;
错误 1064 (42000):您的 SQL 语法有错误; check the manual that corresponds to your MySQL server version for the right syntax to use near ''t8' ('id1' timestamp not null default current_timestamp,'id2' datetime defaul' at line 1
检查与您的 MySQL 服务器版本相对应的手册,以获得在“t8”附近使用的正确语法(“id1”时间戳不是 null 默认 current_timestamp,第 1 行的“id2”日期时间默认值
What should I do to fix it?我应该怎么做才能修复它?
Use it like this.像这样使用它。
create table t8 (
`id1` timestamp not null default current_timestamp,
`id2` datetime default null
);
Try below - instead of single quote '' you need to use back tick `` or you can keep it just id1 or id2试试下面 - 而不是单引号 '' 你需要使用反引号 `` 或者你可以只保留 id1 或 id2
create table t8
(
id1 timestamp not null default current_timestamp,
id2 datetime null
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.