SQL worksheet
SQL worksheet
CTYPE CHAR 10
Table 2: product
QUANTITY INT
PRICE MONEY
Table 3: order_details
1. Add the pk on customer table and Add the pk on product table by using alter command
2. show the relationship the above three table by using alter command
product
order_details Cid pid qty
Pid Pname Pdate Quantity price C101 P001 Level-I
4. Display the name of all customer name that do not have any order details
5. Retrieve names of product that have 2 or more order details
6. Display all product name that product date is current date
7. Display the name of all customer name that have any order details
8. Find the name of product whose name start with ‘P’
9. Display all customer name in upper case
10. Display ctype, address and count for which similar address count would be >= 2 for customer table
11. Display record for the same total salary would be more than or equal to 3000 for customer table
12. Delete the constraint of salary for customer table
13. Updates salary by 25% times in customer table for all the customers whose salary is >=3000
14. Display salary and count for which similar salary count would be more than one for customer table
15. Retrieve product name, quantity, price and customer name
16. Display customer id, customer name, pid, product name and price of the product is more than 300
17. Delete the record of product from product table whose price is less than or equal to 400 birrs
18. Sort customer in descending order of their name and display only the top three customer record
19. Rename the database ABC_CAMPANY to ABC
20. Write SQL statement that create a backup for ABC database in local disk (d:)
21. Assume ABC database was dropped accidentally. Write SQL query that restore dropped database from
the backup.