Convert column names to lowercase in Oracle SQL query results
Advertisements
When you run a SELECT query on an Oracle database instance, it usually returns the results with column names in Uppercase. In some instances you might need to get the column names in lowercase or camel case. How would you do it? Read on.
EXAMPLE
Query: SELECT * FROM contacts WHERE last_name = 'Kumar' Result: ID FIRST_NAME LAST_NAME PHONE_NUMBER 345 Anand Kumar 8967537252 123 Naveen Baby 7658908333 674 Arthi Ranjith 7856341209 124 Rani Selvi 9994456345 76 Chandra Ambi 9345678211
Advertisements
COLUMN NAMES IN LOWERCASE
To get the column names in lowercase you can use ‘as column_name’ in the SQL statement.
Query: SELECT ID as "id", FIRST_NAME as "first_name", LAST_NAME as "last_name", PHONE_NUMBER as "phone_number" FROM contacts WHERE last_name = 'Kumar' Result: id first_name last_name phone_number 345 Anand Kumar 8967537252 123 Naveen Baby 7658908333 674 Arthi Ranjith 7856341209 124 Rani Selvi 9994456345 76 Chandra Ambi 9345678211