0
0
MySQLquery~10 mins

Dropping and altering views in MySQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to drop a view named 'employee_view'.

MySQL
DROP VIEW [1];
Drag options to blanks, or click blank then click option'
Aemployee_view
Bemployee
Cview_employee
Demployees_view
Attempts:
3 left
💡 Hint
Common Mistakes
Using the table name instead of the view name.
Forgetting to include the view name after DROP VIEW.
2fill in blank
medium

Complete the code to rename a view from 'old_view' to 'new_view'.

MySQL
RENAME TABLE [1] TO [2];
Drag options to blanks, or click blank then click option'
Aold_view
Bnew_view
Cold_table
Dnew_table
Attempts:
3 left
💡 Hint
Common Mistakes
Using DROP VIEW instead of RENAME TABLE.
Swapping the old and new view names.
3fill in blank
hard

Fix the error in the code to modify the view 'sales_view' to select only 'product' and 'amount'.

MySQL
CREATE OR REPLACE VIEW sales_view AS SELECT [1] FROM sales;
Drag options to blanks, or click blank then click option'
A*
Bproduct, amount
Cproduct amount
Dproduct; amount
Attempts:
3 left
💡 Hint
Common Mistakes
Using * selects all columns, not just product and amount.
Missing commas between column names causes syntax errors.
4fill in blank
hard

Fill both blanks to drop a view only if it exists, named 'customer_view'.

MySQL
DROP VIEW [1] IF [2] EXISTS customer_view;
Drag options to blanks, or click blank then click option'
AIF
BNOT
COR
DAND
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping IF and EXISTS.
Adding NOT which is not part of the syntax here.
5fill in blank
hard

Fill all three blanks to alter the view 'order_view' to select 'order_id' and 'order_date' from 'orders' table.

MySQL
CREATE [1] REPLACE VIEW [2] AS SELECT [3] FROM orders;
Drag options to blanks, or click blank then click option'
AOR
Border_view
Corder_id, order_date
DAND
Attempts:
3 left
💡 Hint
Common Mistakes
Using AND instead of OR.
Forgetting to include REPLACE.
Listing columns without commas.