Which two statements about views are true? (Choose two)
-
A view can be created as read only
-
A view can be created as a join on two or more tables.
-
A view cannot have an ORDER BY clause in the SELECT statement
-
A view cannot be created with a GROUP BY clause in the SELECT statement
-
A view must have aliases defined for the column names in the SELECT statement
Explanation: To answer this question, we need to understand the concept of views in the context of databases.
A. A view can be created as read-only - This statement is true. A view can be created with the SELECT statement that restricts the columns and rows that are returned. This can be used to ensure a user only has read access to certain data.
B. A view can be created as a join on two or more tables - This statement is true. A view can be created as a SELECT statement that combines data from two or more tables. This can be used to simplify queries by combining data that is frequently used together.
C. A view cannot have an ORDER BY clause in the SELECT statement - This statement is false. A view can have an ORDER BY clause in the SELECT statement to sort the data returned by the view.
D. A view cannot be created with a GROUP BY clause in the SELECT statement - This statement is false. A view can be created with a GROUP BY clause in the SELECT statement to group the data returned by the view.
E. A view must have aliases defined for the column names in the SELECT statement - This statement is false. A view does not require aliases for the column names in the SELECT statement, although it can be useful to provide more meaningful names for the columns.
Therefore, options A and B are both true statements, making the correct answer B.