MySQL Database Quiz Questions

Course Name:MySQL
Chapter Name:Chapter 9 - Advanced Topics
Lesson Content Link:Database View
Current Quiz Count:30
Progress
0%
Q1
True / False

A view in MySQL is a virtual table that is based on the result set of a SQL query.

Q2
True / False

You cannot insert data into a view in MySQL.

Q3
True / False

Creating a view in MySQL requires the CREATE VIEW privilege.

Q4
True / False

In MySQL, views can be used to simplify complex queries.

Q5
True / False

: In MySQL, views automatically update when the underlying base tables are updated

Q6
True / False

You can define a view in MySQL with the WITH CHECK OPTION clause to enforce data integrity.

Q7
True / False

In MySQL, you can use the ALGORITHM clause to specify how a view should be processed.

Q8
True / False

MySQL views can be indexed for faster query performance

Q9
True / False

: In MySQL, a view can be defined to include data from multiple tables using joins.

Q10
True / False

In MySQL, using the CASCADED option in the DROP VIEW statement ensures that all dependent objects are also dropped.

Q11
Single Choice

What is a database view in MySQL?

Q12
Single Choice

Which MySQL command is used to create a view?

Q13
Single Choice

Can a view in MySQL include a WHERE clause?

Q14
Single Choice

How do you update data in a MySQL view?

Q15
Single Choice

Can you index a MySQL view?

Q16
Single Choice

What happens when you drop a table that a MySQL view is based on?

Q17
Single Choice

Which clause in MySQL allows you to specify a check option for a view?

Q18
Single Choice

Can a MySQL view call a stored procedure?

Q19
Single Choice

Which of the following statements correctly drops a view in MySQL?

Q20
Single Choice

What is the correct syntax to create an updatable view in MySQL that selects all columns from a table called employees where the department is 'Sales'?

Q21
Multiple Choice

Identify the correct SQL statement to create a view that displays only active employees.

SQL Code
CREATE VIEW active_employees AS
SELECT * FROM employees
WHERE status = 'Active';
Q22
Multiple Choice

Choose the correct SQL statement to create a view that shows the total sales for each product.

SQL Code
CREATE VIEW product_sales AS
SELECT product_id, SUM(amount) AS total_sales
FROM sales
GROUP BY product_id;
Q23
Multiple Choice

Determine the correct SQL statement to create a view that shows employee details along with their department name.

SQL Code
CREATE VIEW employee_details AS
SELECT e.id, e.name, d.department_name
FROM employees e
JOIN departments d ON e.department_id = d.id;
Q24
Multiple Choice

Which SQL statement correctly creates a view that only includes customers with orders greater than $1000?

SQL Code
CREATE VIEW high_value_customers AS
SELECT c.id, c.name, o.order_total
FROM customers c
JOIN orders o ON c.id = o.customer_id
WHERE o.order_total > 1000;
Q25
Multiple Choice

Select the correct SQL statement to create a view that shows a summary of orders by customer.

SQL Code
CREATE VIEW customer_order_summary AS
SELECT c.id, c.name, COUNT(o.id) AS order_count, SUM(o.total) AS total_spent
FROM customers c
JOIN orders o ON c.id = o.customer_id
GROUP BY c.id, c.name;
Q26
Multiple Choice

Determine the correct SQL statement to create a view that combines data from multiple tables to provide a comprehensive report.

SQL Code
CREATE VIEW comprehensive_report AS
SELECT c.name, p.product_name, o.order_date, o.order_total
FROM customers c
JOIN orders o ON c.id = o.customer_id
JOIN order_details od ON o.id = od.order_id
JOIN products p ON od.product_id = p.id;
Q27
Multiple Choice

Which SQL statement correctly creates a view that restricts the visibility of certain columns from the underlying table?

SQL Code
CREATE VIEW limited_view AS
SELECT id, name, department
FROM employees;
Q28
Multiple Choice

Identify the correct SQL statement to create an updatable view that enforces a constraint using the WITH CHECK OPTION clause.

SQL Code
CREATE VIEW active_products AS
SELECT id, product_name, status
FROM products
WHERE status = 'Active'
WITH CHECK OPTION;
Q29
Multiple Choice

Select the correct SQL statement to create a view that displays aggregated data with a HAVING clause.

SQL Code
CREATE VIEW high_revenue_customers AS
SELECT c.id, c.name, SUM(o.total) AS total_spent
FROM customers c
JOIN orders o ON c.id = o.customer_id
GROUP BY c.id, c.name
HAVING total_spent > 5000;
Q30
Multiple Choice

Determine the correct SQL statement to create a view that combines data from two views into a single view.

SQL Code
CREATE VIEW combined_view AS
SELECT * FROM view1
UNION ALL
SELECT * FROM view2;