InterviewSolution
| 1. |
What do you mean by alias in SQL? |
|
Answer» In SQL, we can provide temporary names to EITHER columns or table, these are called as aliases for a specific query. When we don’t want to USE the original name of the table or column, then we use alias to provide temporary names to them. The scope of the alias is temporary and up to that specified query only. We use alias to increase the readability of a column or a table name. This change is temporary and the original names that are stored in the database never GET changed. Sometimes the names of table or column are complex so it is always preferred to use alias to GIVE them an easy name TEMPORARILY. Below is the syntax to use alias for both table and column names. Column Alias: Syntax: SELECT column as alias_name FROM table_name;Explanation: Here alias_name is the temporary name that is given to column name in the given table table_name. Table Alias: Syntax: SELECT column FROM table_name as alias_name;Explanation: Here alias_name is the temporary name that is given to table table_name. |
|