Alias is an associate name to the actual-Table column name in SQL query. The alias also called user defined column name. You can hide original column name with alias and legibility of SQL query is good. Alias you can use small length name, so that you SQL query looks simple and easy to understand.
SELECT CUSTOMER_NAME as CNAME, CUSTOMER_ID as "CUST ID" , PRODUCT_ID as "AVG" FROM PRODUCT_TABLE WHERE PRODUCT_ID = '120'
Notes: The “CUST ID” has space and “AVG” is reserved word
3 Top rules to give alias
- ‘AS’ is optional-but if you miss the ‘,’ it will take column name as alias
- You need to give double quotes, when you have space in alias name
- If the alias name is reserved word, then you need to give double quotes
In SQL query you never need double quotes unless you use alias name with ‘spaces’ or reserved word
Read more on
- DB2 Five key areas to improve Performance
- Real logic you need to connect DB2 using PHP engine
- Top DB2 privileges really useful for certification seekers