0
0
MySQLquery~10 mins

Creating views in MySQL - Interactive 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 view named employee_view that selects all columns from the employees table.

MySQL
CREATE VIEW employee_view AS SELECT * FROM [1];
Drag options to blanks, or click blank then click option'
Aemployees
Bemployee_view
Cemployee
Demployee_table
Attempts:
3 left
💡 Hint
Common Mistakes
Using the view name instead of the table name.
Using a singular form of the table name.
2fill in blank
medium

Complete the code to create a view named active_customers that selects all columns from customers where the status is 'active'.

MySQL
CREATE VIEW active_customers AS SELECT * FROM customers WHERE status = '[1]';
Drag options to blanks, or click blank then click option'
Apending
Binactive
Cactive
Ddeleted
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'inactive' or other statuses instead of 'active'.
Forgetting to put the status value in quotes.
3fill in blank
hard

Fix the error in the code to create a view named order_summary that shows order_id and total_amount from the orders table.

MySQL
CREATE VIEW order_summary AS SELECT order_id, [1] FROM orders;
Drag options to blanks, or click blank then click option'
Atotal_amount
Btotal-amount
CtotalAmount
Dtotalamount
Attempts:
3 left
💡 Hint
Common Mistakes
Using camelCase or missing underscores in column names.
Using hyphens which are invalid in column names.
4fill in blank
hard

Fill both blanks to create a view named high_salary_employees that selects name and salary from employees where salary is greater than 50000.

MySQL
CREATE VIEW high_salary_employees AS SELECT [1], [2] FROM employees WHERE salary > 50000;
Drag options to blanks, or click blank then click option'
Aname
Bsalary
Cage
Ddepartment
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting columns not related to salary or name.
Forgetting to include both required columns.
5fill in blank
hard

Fill all three blanks to create a view named customer_orders that selects customer_id, order_id, and order_date from the orders table where order_date is after '2023-01-01'.

MySQL
CREATE VIEW customer_orders AS SELECT [1], [2], [3] FROM orders WHERE order_date > '2023-01-01';
Drag options to blanks, or click blank then click option'
Acustomer_id
Border_id
Corder_date
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Missing one or more required columns.
Including columns not specified in the instruction.