为什么MySQL查询几乎总是以大写形式编写 [英] Why are MySQL queries almost always written in Capital

查看:300
本文介绍了为什么MySQL查询几乎总是以大写形式编写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到大多数程序员在编写MySQL查询时都使用大写字母,例如

I've seen most coders use Capital letters while writing MySQL queries, something like

 "SELECT * FROM `table` WHERE `id` = 1 ORDER BY `id` DESC"

我尝试用小写字母编写查询,但仍然可以使用.

I've tried writing the queries in small caps and it still works.

那么,不使用小型股有什么特别的原因吗?还是只是选择问题?

So is there any particular reason for not using small caps or is it just a matter of choice?

推荐答案

这只是可读性问题.关键字保持大写,表/列名保持小写,这意味着在扫描语句时更容易将两者分开:

It's just a matter of readability. Keeping keywords in upper case and table/column names lower case means it's easier to separate the two when scan reading the statement .: better readability.

大多数SQL实现都不区分大小写,因此您可以在90年代后期写《 LeEt CoDeR StYLe》中的语句,如果您愿意的话,它仍然可以工作.

Most SQL implementations are case-insensitive, so you could write your statement in late 90s LeEt CoDeR StYLe, if you felt so inclined, and it would still work.

这篇关于为什么MySQL查询几乎总是以大写形式编写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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