0
0
MySQLquery~5 mins

Dropping and altering views in MySQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a view in a database?
A view is a virtual table that shows data from one or more tables. It does not store data itself but displays data based on a query.
Click to reveal answer
beginner
How do you drop a view in MySQL?
Use the command DROP VIEW view_name; to remove a view from the database.
Click to reveal answer
intermediate
Can you alter a view directly in MySQL?
No, MySQL does not support direct alteration of views. Instead, you drop the view and recreate it with the new definition.
Click to reveal answer
intermediate
What is the correct way to change a view's query in MySQL?
First drop the existing view using DROP VIEW, then create a new view with the updated query using CREATE VIEW.
Click to reveal answer
beginner
What happens if you try to drop a view that does not exist?
MySQL will return an error unless you use DROP VIEW IF EXISTS view_name; which avoids errors if the view is missing.
Click to reveal answer
Which command removes a view named 'sales_view' in MySQL?
ADELETE VIEW sales_view;
BDROP VIEW sales_view;
CALTER VIEW sales_view;
DREMOVE VIEW sales_view;
How do you modify the query of an existing view in MySQL?
ADrop the view and recreate it with CREATE VIEW
BUse MODIFY VIEW command
CUpdate the view directly with UPDATE VIEW
DUse ALTER VIEW with new query
What does the command DROP VIEW IF EXISTS view_name; do?
ACreates the view if it does not exist
BAlters the view if it exists
CDrops the view only if it exists, avoiding errors
DRenames the view if it exists
Which of the following is true about views?
AViews are virtual tables based on queries
BViews store data physically in the database
CViews cannot be dropped once created
DViews automatically update their structure
If you want to change a view's structure, what is the first step?
AUse ALTER VIEW command
BRename the view
CUpdate the underlying tables
DDrop the existing view
Explain how to safely remove a view in MySQL and what happens if the view does not exist.
Think about how to prevent errors when dropping something that might not be there.
You got /3 concepts.
    Describe the process to change the query of an existing view in MySQL.
    Remember MySQL's limitation on altering views.
    You got /3 concepts.