mysql让我郁闷的字符串,分享大家一起涨姿势

xb278xb 2014-09-22 04:00:59
今天测试东西,由于系统是生成任务的key作为标识,结果就到一个任务一直报错,就是过不去,生成的mysql表名为

37e77d189af09d5d480ca0e3e2058ce7

感兴趣的同学可以试试,结果各种insert select报错~ 提示1064,我欲哭无泪呀,惯性的查了各种语法,各种过程,最后实在没办法了,手动修改下标识,结果过了~ 这个表名是关键字?天哪。。

朋友们在使用mysql的时候,建议表名都加上`表名`,`列名` ,不要像我一样,图一时的简单,结果遇到这个么个问题。。。

注意:`不是单引号,是半角输入状态下的 ~ 这个键(1前面的,esc下面的),共勉
...全文
187 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
飞啊子 2014-09-23
  • 打赏
  • 举报
回复
生成的mysql表名. 请楼主以 字母开头。 就可以不用加 ` 标识符了。 create table A37e77d189af09d5d480ca0e3e2058ce7 (name varchar(20));
codeMyLife 2014-09-23
  • 打赏
  • 举报
回复
感觉楼主重点在‘与`的问题
xb278xb 2014-09-23
  • 打赏
  • 举报
回复
to: mchdba 赞一个,我是没顾得上写出来,谢谢了~ 就是这个意思的,哈哈。让我昨儿个郁闷了好久的。
九月茅 2014-09-22
  • 打赏
  • 举报
回复
情景再现,嘿嘿,楼主是想说的··符号吧。 如下所示:

mysql> create table 37e77d189af09d5d480ca0e3e2058ce7 (name varchar(20));
ERROR 1064 (42000): 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 '37e77d189af09d5d480ca0e3e2058ce7 (name varchar(20))' at line 1
mysql> create table `37e77d189af09d5d480ca0e3e2058ce7` (name varchar(20));
Query OK, 0 rows affected (0.02 sec)

mysql> insert into 37e77d189af09d5d480ca0e3e2058ce7 select 'a';
ERROR 1064 (42000): 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 '37e77d189af09d5d480ca0e3e2058ce7 select 'a'' at line 1
mysql> insert into `37e77d189af09d5d480ca0e3e2058ce7` select 'a';
Query OK, 1 row affected (0.01 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> select * from 37e77d189af09d5d480ca0e3e2058ce7;
ERROR 1064 (42000): 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 '37e77d189af09d5d480ca0e3e2058ce7' at line 1
mysql> select * from `37e77d189af09d5d480ca0e3e2058ce7`;
+------+
| name |
+------+
| a    |
+------+
1 row in set (0.01 sec)

mysql> 
九月茅 2014-09-22
  • 打赏
  • 举报
回复
关键字是· 吧 例如: mysql> SELECT * FROM `A` LIMIT 1; +-------+ | id | +-------+ | 1-0-1 | +-------+ 1 row in set (0.00 sec) mysql> insert into `A` select '1-1-15'; Query OK, 1 row affected (0.00 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> insert into A select '2-1-13'; Query OK, 1 row affected (0.00 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql>
ACMAIN_CHM 2014-09-22
  • 打赏
  • 举报
回复
没看懂楼主说的是什么。

56,866

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧