Question
SQL problem: Create a new table named Customers_Statistics with the following columns: Customer_id, Customer_Last_Name, Number_of_Orders, Number_of_Items Complete the table definition by choosing the appropriate data
SQL problem:
Create a new table named Customers_Statistics with the following columns: Customer_id, Customer_Last_Name, Number_of_Orders, Number_of_Items Complete the table definition by choosing the appropriate data types, primary and foreign keys.
1) Write a merge statement to merge the data of the tables Customers and Customer_Statistics. You should modify the data of table Customer_Statistics by: Compare the records using customer_id If the ids are the same but the last names are different then update table Customer Statistics to match Customers If the ids exist In Customers and not exist in Customer_Statistics then insert the customer with 0 values for items and orders.
2) A. Create a view that holds only the customers that have a Customer_Status ok. B. Now update one of the customers names using the view. Do you see this change transferred to Customers table?
3) Now create a view that holds the customers that have a Customer_Status ok and are from California, using the WITH CHECK option. Now update again one of the customers names using the view. Do you see this change transferred to Customers table? Now update the state, can you do that?
4) Truncate table Customers_Statistics. Can you still see the table definition? What about the data?
5) Drop table Customers_Statistics. Can you still see the table definition?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started