DATA-MANAGEMENT-FOUNDATIONS practice question 3 of 15

Which expression can be used to create a temporary name for a table?

Full set: 60 questions

Domain Data Querying

Answer options
A: HAVING
B: NEW
C: ALIAS Correct answer
D: UNION
Correct Answer:
C. ALIAS
Explanation

In SQL, an ALIAS is a temporary name assigned to a table or a column for the duration of a particular query. This is done using the AS keyword (or sometimes without it, depending on the SQL dialect). Aliases are primarily used to make column names more readable, to shorten long table names, or to distinguish between tables when performing a self-join (joining a table to itself). For example, SELECT C.CustomerName FROM Customers AS C; uses C as an alias for the Customers table.

Why Incorrect

A. HAVING: This clause is used with GROUP BY to filter groups based on the results of aggregate functions, not to rename tables.
B. NEW: This is not a standard SQL keyword for creating a temporary name for a table.
D. UNION: This is an operator used to combine the result sets of two or more SELECT statements into a single result set.

References

1. PostgreSQL 16 Documentation, Chapter 7. Queries, Section 7.2.1.2. Table and Column Aliases. The documentation states, "A temporary name can be given to tables and columns... This temporary name is called an alias."

2. Oracle Database SQL Language Reference, 23c, SELECT Statement, tablereference clause. The documentation explains that an alias can be specified for a table or view, noting it "can be used to refer to the item and is particularly useful in joins."

3. Stanford University, CS 145 Introduction to Databases, Lecture Notes on SQL. The notes describe aliasing: "The AS keyword can be used to rename attributes or relations in the SELECT or FROM clause... This is called aliasing."

Scroll to Top