SQL Questions and Answers – SQL Aliases

This set of SQL Multiple Choice Questions & Answers (MCQs) focuses on “SQL Aliases”.

1. Temporary names given to a table or a column for the purpose of a particular SQL query are known as __________
a) Aliases
b) Temp
c) Temporary
d) Rename
View Answer

Answer: a
Explanation: The use of table aliases is to rename a table in a specific SQL statement. SQL ALIASES can be used to create a temporary name for columns or tables.

2. An SQL ALIAS exists even after the execution of a query.
a) True
b) False
View Answer

Answer: b
Explanation: Using SQL ALIAS we can rename a column or a table temporarily. An alias exists only during the execution of the query. After its execution those temporary names cannot be used as the changes are not permanent in the database.

3. Which of the following is used to rename a table or a column in a specific SQL statement?
a) Rename
b) Change
c) Alias
d) Modify
View Answer

Answer: c
Explanation: The alias is used to rename a table or a column in a specific SQL statement. The renaming is a temporary change and the actual table name or column name does not change in the database.
advertisement
advertisement

4. What is the basic syntax for a column alias?
a)

SELECT column_name AS alias_name
FROM TABLE_NAME;

b)

SELECT column_name ALIAS alias_name
FROM TABLE_NAME;

c)

advertisement
SELECT column_name COLUMN ALIAS alias_name
FROM TABLE_NAME;

d)

advertisement
SELECT column_name COLUMN AS alias_name
FROM TABLE_NAME;
View Answer
Answer: a
Explanation: Aliases are the temporary names given to table or column for the purpose of a particular SQL query. Basic syntax for a column alias is:

SELECT column_name AS alias_name
FROM TABLE_NAME;

5. What is the basis syntax for a table alias?
a)

SELECT column_name
FROM TABLE_NAME ALIAS alias_name;

b)

SELECT column_name
FROM TABLE_NAME TABLE AS alias_name;

c)

SELECT column_name
FROM TABLE_NAME AS alias_name;

d)

SELECT column_name
FROM TABLE_NAME TABLE ALIAS alias_name;
View Answer
Answer: c
Explanation: SQL ALIASES can be used to create a temporary name for columns or tables. Basic syntax for a table alias is:

SELECT column_name
FROM TABLE_NAME AS alias_name;

6. Alias name should not contain any spaces.
a) True
b) False
View Answer

Answer: b
Explanation: It is acceptable to use spaces in an alias name. If the alias name contains spaces, we must enclose the alias name in double quotes or square brackets. This alias name is only valid within the scope of the SQL statement.

7. ALIAS can be used with which of the following clause(s)?
a) Insert
b) Update
c) Select
d) Delete
View Answer

Answer: c
Explanation: Aliases are the temporary names given to table or column for the purpose of a particular SQL query. It can be used with SELECT clause of a query. We cannot use ALIAS with insert, update or delete clauses.

8. When creating table aliases _______
a) It is not necessary to create aliases for all of the tables listed in the FROM clause
b) It is necessary to create aliases for at least two of the tables listed in the FROM clause
c) It is necessary to create aliases for all of the tables listed in the FROM clause
d) It is necessary to create aliases for at least three of the tables listed in the FROM clause
View Answer

Answer: a
Explanation: When creating table aliases, it is not necessary to create aliases for all of the tables listed in the FROM clause. We can choose to create aliases on any or all of the tables.

9. During the execution of a query, the temporary names of columns or tables can be used for ______
a) Only one time
b) Specified number of times
c) Any number of times
d) Maximum three times
View Answer

Answer: c
Explanation: The temporary names of columns or tables can be used for any number of times within the specified query.

Sanfoundry Global Education & Learning Series – SQL.

To practice all areas of SQL, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.