在表或列的标题中使用SQL关键字 [英] Using SQL keyword in title of table or column
问题描述
我想将我的一张桌子命名为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屋!