0
0
SQLquery~10 mins

Dropping and altering views in SQL - 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'.

SQL
DROP [1] employee_view;
Drag options to blanks, or click blank then click option'
AINDEX
BVIEW
CTABLE
DDATABASE
Attempts:
3 left
💡 Hint
Common Mistakes
Using DROP TABLE instead of DROP VIEW.
Forgetting the keyword VIEW.
Trying to drop a database instead of a view.
2fill in blank
medium

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

SQL
ALTER [1] old_view RENAME TO new_view;
Drag options to blanks, or click blank then click option'
ATABLE
BDATABASE
CVIEW
DINDEX
Attempts:
3 left
💡 Hint
Common Mistakes
Using ALTER TABLE instead of ALTER VIEW.
Trying to rename a database or index instead of a view.
3fill in blank
hard

Fix the error in the code to modify the view 'sales_view' to select only sales above 1000.

SQL
CREATE OR REPLACE [1] sales_view AS SELECT * FROM sales WHERE amount > 1000;
Drag options to blanks, or click blank then click option'
AVIEW
BINDEX
CDATABASE
DTABLE
Attempts:
3 left
💡 Hint
Common Mistakes
Using CREATE OR REPLACE TABLE instead of VIEW.
Trying to replace a database or index.
4fill in blank
hard

Fill in the blank to drop a view only if it exists, avoiding errors if it does not.

SQL
DROP [1] IF EXISTS customer_view;
Drag options to blanks, or click blank then click option'
ANOT
BTABLE
CINDEX
DVIEW
Attempts:
3 left
💡 Hint
Common Mistakes
Using TABLE instead of VIEW.
Using INDEX instead of VIEW.
5fill in blank
hard

Fill all three blanks to recreate a view named 'active_users' selecting users with status 'active'.

SQL
CREATE OR [1] [2] active_users AS SELECT * FROM users WHERE status [3] 'active';
Drag options to blanks, or click blank then click option'
AREPLACE
BVIEW
C=
DTABLE
Attempts:
3 left
💡 Hint
Common Mistakes
Using TABLE instead of VIEW.
Omitting REPLACE when updating a view.
Using wrong comparison operator instead of '='.