This set of MySQL Database Multiple Choice Questions & Answers (MCQs) focuses on “Using Views”.
1. Which of these is also known as a virtual table?
Explanation: In MySQL, a ‘View’ is also called a virtual table. It does not contain any data but only appears as a table. It is an alternative way to show or describe a table similar to the original table.
2. A View can be used to select a subset of the table columns.
Explanation: In MySQL, a ‘View’ is used to present a table in the database. It is a virtual table. It is also used to present a subset of the columns that are present in the original table of the database.
3. What is xyz in the following statement?
CREATE VIEW xyz AS SELECT a, b FROM t;
Explanation: A ‘View’ is created in MySQL by writing the clause ‘CREATE VIEW’ followed by the view name. Then follows the list of column names of the table that are to be presented as the view.
4. What is abc in the following statement?
CREATE VIEW xyz (abc) AS SELECT a FROM t;
a) row name
b) column name
Explanation: Column names for a view can be explicitly provided in the ‘CREATE VIEW’ clause itself. It presents the table view with the aliased column names instead of the original column names.
5. A view can refer to multiple tables via __________
Explanation: In MySQL, a ‘View’ can refer to multiple tables. This makes it a lot simpler to execute the queries involving joins. When a selection is made from the view, the join is executed producing the results.
6. Views are not updatable.
Explanation: In MySQL, some ‘Views’ are updatable. The operators ‘INSERT’, ‘DELETE’ and ‘UPDATE’ can be used. They can be operated on the ‘Views’ to make changes to it. A table can be created and set as a view.
7. A view can be deleted using the command __________
Explanation: In MySQL, ‘Views’ act as virtual tables. Many operations can be performed on views like the operations on tables. A view can be created, displayed and dropped. They can also be used to perform calculations.
8. What cannot be done on a view?
Explanation: In MySQL, ‘Views’ act as virtual tables. It is not possible to create indexes on a view. However, they can be used for the views that are processed using the merge algorithm.
9. What can be used to check for views that have been invalidated by DROP or ALTER operations?
a) CREATE TABLE
b) VERIFY TABLE
c) DETAILS TABLE
d) CHECK TABLE
Explanation: A ‘View’ is created in MySQL by writing the clause ‘CREATE VIEW’ followed by the view name. Once a view is dropped or altered after being created, it can be checked by the ‘CHECK TABLE’ clause.
10. Which of the following does not support materialized view?
Explanation: In MySQL, ‘Views’ are treated a little differently than Oracle, PostgreSQL and SybaseSQL since they support materialized views and MySQL does not use the materialized view.
Sanfoundry Global Education & Learning Series – MySQL Database.
To practice all areas of MySQL Database, here is complete set of 1000+ Multiple Choice Questions and Answers.