Chapter 2 - Getting Started with the SELECT Statement Flashcards
Why should you explicitly indicate the schema name, such as in the FROM clause?
- It is considered best practice to always explicitly indicate the schema name.
- It can prevent you from ending up with a schema name that you did not intend to be used
- It can also remove the cost involved in the implicit resolution process (although the cost is minor).
True or False.
When using aliases, the convention is to use short names, typically one letter that is somehow indicative of the queried table, like E for Employees.
TRUE
When you use an alias for a table name, is the table name visible for the duration of the query?
No. You must use the alias to refer to the table name.
Although T-SQL supports using an asterisk (*) as an alternative to listing all attributes from the input tables, why is this considered bad practice?
- By returning more attributes than you really need, you can prevent SQL Server from using what would normally be considered covering indexes in respect to the interesting set of attributes.
- You send more data than is needed over the network, which can have a negative impact on system performance.
- The underlying table definition could change over time; even if , when the query was initially authored, * really represented all attributes you needed; it might not be the case anymore at a later point in time.
What are the forms of aliasing an attribute in T-SQL?
The forms are:
- AS
- = .
What is an irregular identifier?
An identifier that does not follow the rules for formatting identifiers; for example, it starts with a digit, has an embedded space, or is a reserved T-SQL keyword.
What is the importance of the ability to assign attribute aliases in T-SQL? (Choose all that apply.)
- The ability to assign attribute aliases is just an aesthetic feature.
- An expression that is based on a computation results in no attribute name unless you assign one with an alias, and this is not relational.
- T-SQL requires all result attributes of a query to have names.
- Using attribute aliases, you can assign your own name to a result attribute if you need it to be different than the source attribute name.
2, 4.
What are the mandatory clauses in a SELECT query, according to T-SQL?
- The FROM and SELECT clauses
- The SELECT and WHERE clauses
- The SELECT clause
- The FROM and WHERE clauses
3.
Which of the following practices are considered bad practices? (Choose all that apply.)
- Aliasing columns by using the AS clause
- Aliasing tables by using the AS clause
- Not assigning column aliases when the column is a result of a computation
- Using * in the SELECT list
3, 4.