0
0
MySQLquery~10 mins

Updatable 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 create a simple updatable view showing employee names and salaries.

MySQL
CREATE VIEW employee_salaries AS SELECT name, [1] FROM employees;
Drag options to blanks, or click blank then click option'
Aid
Bage
Cdepartment
Dsalary
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a column unrelated to salary like age or department.
Selecting the employee ID instead of salary.
2fill in blank
medium

Complete the code to update the salary of an employee through the view.

MySQL
UPDATE employee_salaries SET [1] = 60000 WHERE name = 'John';
Drag options to blanks, or click blank then click option'
Aname
Bid
Csalary
Ddepartment
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to update the name or department instead of salary.
Using the employee ID which is not shown in the view.
3fill in blank
hard

Fix the error in the view definition to make it updatable by removing the aggregate function.

MySQL
CREATE VIEW avg_salary AS SELECT department, [1] FROM employees;
Drag options to blanks, or click blank then click option'
Asalary
BAVG
CMAX
DSUM
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving the AVG function which prevents updates.
Replacing AVG with another aggregate function like SUM or MAX.
4fill in blank
hard

Fill both blanks to create an updatable view that filters employees by department.

MySQL
CREATE VIEW [1] AS SELECT name, salary FROM employees WHERE [2] = 'Sales';
Drag options to blanks, or click blank then click option'
Asales_employees
Bdepartment
Csalary
Demployee_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic or unrelated view name.
Filtering by salary or name instead of department.
5fill in blank
hard

Fill all three blanks to create an updatable view that shows employee names in uppercase and filters by salary.

MySQL
CREATE VIEW [1] AS SELECT [2](name) AS name_upper, salary FROM employees WHERE salary [3] 50000;
Drag options to blanks, or click blank then click option'
Ahigh_earners
BUPPER
C>
DLOWER
Attempts:
3 left
💡 Hint
Common Mistakes
Using LOWER instead of UPPER for name conversion.
Using <= or < instead of > for the salary filter.