mysql 不能创建叫call的表

ShineShineRedStar 2010-07-13 05:15:08
本来数据库中有个表叫calls, 想把它改成call, 结构愣是没有成功,后来才想到call是关键字, 不能作为表名使用. 一群人忙活了半天, 想来真是好笑.

...全文
77 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ShineShineRedStar 2010-07-13
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 wwwwa 的回复:]
create table `call`
ESC键正面、数字1的左边
[/Quote]
原来是这个引号,可以了.
mysql> create table `call` (con1 int);
Query OK, 0 rows affected (0.00 sec)

WWWWA 2010-07-13
  • 打赏
  • 举报
回复
create table `call`
ESC键正面、数字1的左边
ShineShineRedStar 2010-07-13
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 wwwwa 的回复:]
最好不要用关键字做表名,如果要用,加``
create table `call`(....)
[/Quote]
这么试了一下,竟报错了:
mysql> create table 'call' (con1 int);
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 ''call' (con1 int)' at line 1

不过用带数据库名的方法倒是可以:
mysql> create table dbx.call (con1 int);
Query OK, 0 rows affected (0.00 sec)
WWWWA 2010-07-13
  • 打赏
  • 举报
回复
最好不要用关键字做表名,如果要用,加``
create table `call`(....)

56,914

社区成员

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

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