Course: Database (DML + Subquries) Instructor: Syed Adnan It Fall 2017 Lab-07

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Course: DATABASE ( DML + SubQuries )

Instructor: Syed Adnan


IT Fall 2017
LAB-07
Issue Date: Friday – November 8th, 2018

Total marks : 110

Instructions!
1. This is an individual lab and absolutely NO collaboration is allowed with your peers. If you face any
difficulty feel free to discuss with TAs.
2. Cheating will result in a ZERO for the lab. (Finding solutions online is cheating, Copying someone
else's solution is cheating). Also, do not hand your work over to another student to read/copy. If you allow
anyone to copy your work, in part or in whole, you are liable as well.
3. No late submissions will be accepted after due time (5:00) so manage emergencies beforehand.
4. Perform all the tasks given in this document on Oracle10g (Sql command line)

Task1: write schema [1+1+1+7 Mark]

run the given schema


Show all tables then show total number of lines in every tables (note it on notepad++).
Describe all the tables

1 ProductTypes
2 Orders
3 Customers
4 OrderDetail
5 Products
6 DEPARTMENT
7 EMPLOYEES

Now
Write their schema on a notepad and write total number of lines in them each table too,

NOTE: Write schema in proper format and in appropriate order that defines which should be
made first
EG: Emp (SSN,NAME,AGE,SEX)
Task2: DML tasks [5*16 Marks]

NOTE:
 for inserting new record in the table assume
name numbers etc. yourself, if not mentioned.
 To fulfill DML TASKS u are allowed to apply
multiple quires one after another
 Save your SQL command on notepad
1) Create a new customer with id as 8787 and FNAME as your name with null in all other fields
except CNIC.
2) Insert an dummy order(112) against a customer with id 7777
3) Change employees’ (with id 7876) hire date to current date
4) delete employ with id 7788
5) delete customer with id 4
6) swap id’s (7 and 10) of customers.
7) Insert employ (0000) against a department number (1000) department table without making
any changing to department table. Why are u able to do it ?
8) Retrieve names of employees who make at least 6.25 times more than the employee who is
paid least in the company
9) Delete all those records where two or more employees have same name.
10) Promote every salesmen to manager.
11) Insert a new department named ‘Information Technology’ having an id 50. Manager of this
department is a new employee named ‘JIM’ having an id 7999 and a salary of 5000.
12) Display first and last names of those customers whose first name don’t matches with the last
name of any customers
13) Display the names of customers who have placed exactly 2 orders and there fnames must
include at least 1 out of 3 vowel [u,o,e].
14) Display the 3rd max salary among those employees who have worked more than 10 days
15) Empty all the tables (write the commands in sequence) then return to saved state (save state
is state before emptying all the table. U need to explicitly make it a safe state)
16) Give the list of 1 highly paid employ of each department except department number 50 and
arrange them in descending order w.r.t department number
17) Show all the product type ids and their corresponding product names.
18) Replace the salary of the employ 7900 with ten times the salary of most highly paid employ
19) You are going to Display only the name of those employees’ who are manager. Show the top
2 managers with the highest salary
20) Write a single query to update the names of all the products such that each product’s name
become: Ouantity-Original_Name
EG: 4-football.

You might also like