Why are SQL records written in uppercase?

Possible duplicate:
Why should I use SQL keywords?

hi

I am new to SQL, but I noticed that I am writing

SELECT * FROM column_name 

almost always used when

 SELECT * FROM column_name 

gives exactly the same result. I can not find anything on the Internet about this. Is this just a convention? Or will not use a capitalized script for older systems / systems that I don't know about?

thanks

+7
syntax sql
source share
4 answers

SQL was developed in the 1970s when popular programming languages ​​(like COBOL) used ALL CAPS, and the convention was supposed to get stuck.

+6
source share

They are completely equivalent, uppercase letters simply simplify reading the request.

+2
source share

This is because it is so defined in the ANSI standard. See Section 5, β€œLexical Elements,” I suggest that it is caught from there.

http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt

+2
source share

Note that this really depends on your sql database implementation. Oracle aims to convert everything to uppercase. Postgresql, by contrast, converts the sql keywords or column identifier to lowercase. For identifiers (tables, columns, ...) you can prevent a smart database by double quoting.

select "TeST" from MyTable;

will be transferred to Oracle to select "TEST" FROM MYTABLE; and in Postgresql select "TEST" from my table;

Also consider this behavior when using jdbc, for example, since the column names obtained in the ResultSet will also follow these rules, so double quotation marks can be good practice if you consider portability.

+1
source share

All Articles