在表或列的标题中使用SQL关键字 [英] Using SQL keyword in title of table or column

查看:80
本文介绍了在表或列的标题中使用SQL关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的一张桌子命名为ORDER.我可以在SQL关键字中使用名称吗?这种做法有多糟糕?是否这样做?

I want to name one of my tables as ORDER. Can I to use in SQL keywords as names? How bad is this practice? Whether to do so?

如果这种情况已经存在,那么如何在查询中使用该表的名称?例如,我想要:

And if such situation already exists then how do I use name of this table in queries? For example, I want:

SELECT * FROM ORDER;

SELECT * FROM ORDER ORDER BY NAME;

推荐答案

使用反引号将tableName换行,因为ORDER是保留关键字.

wrap the tableName with backtick as ORDER is a reserved keyword.

SELECT * FROM `ORDER` ORDER BY NAME;

  • MySQL保留关键字列表
    • MySQL Reserved Keywords List
    • 我个人认为,使用保留关键字是可以的,但您不要忘记正确地处理它,因为它会给您带来脖子上的痛苦.

      In my own opinion, using reserved keywords are fine except that you do not forget to handle it properly as it will give you such pain in the neck.

      但是在设计架构的多年中,我从未使用过保留关键字:D

      But through the years of designing schema, I never had used reserved keywords :D

      这篇关于在表或列的标题中使用SQL关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆