Sei sulla pagina 1di 8

Machine Exercise-1

1. CREATE a table ‘EMPLOYEE’ having the following description: -

Column_name Data type Length


EMP_NO INT 4
E_NAME VARCHAR 20
JOB VARCHAR 10
MGR INT 4
HIREDATE DATE
SAL Double 9,2
COMM Double 7,2
DEPT_NO INT 2

2. INSERT the following values into the table ‘EMPLOYEE’ .

EMP_NO E_NAME JOB MGR HIREDATE SAL COMM DEPT_NO


7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
75 21 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SAMESMAN 7698 28-SEPT-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7839 KING PRESIDENT 17-NOV-81 1500 0 30
7844 TURNER SALESMAN 7698 03-DEC-81 950 30
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
7900 FORD CLERK 7782 23-JAN-82 1300 43 10

3. CREATE a table ‘DEPT’ having following values as shown: -


Column name Data type Size
Dept_no Dname Loc
Dept_no INT 2 10 Accounting New York
20 Research Dallas
Dname Varchar 20
30 Sales Chicago
Loc Varchar 10 40 Operation Boston

Create the following table structure:-


a. Table name : Client_master

1
Column Name Data Type Size
client_no INT 6
Name Varchar 20
Address Varchar 30
City Varchar 15
Pincode INT 8
State Varchar 15
Bal_due Double 10,2
b. Table Name: Product_master

Column Data Type Size


name
Product_no INT 6
Description Varchar 15
Profit_percent Double 6,2
Unit_measure Varchar 10
Qty_on_hand INT 8
Reorder_lvl INT 8
Sell_price Double 8,2
Cost_price Double 8,2
2. Insert the following data into tables: -
a) Client_master
Client_ Name City Pincode state Bal_due
no
C00001 Ivan Bayross Bombay 400054 Maharashtra 15000
C00002 Vandana Madras 780001 Tamil Nadu 0
Saitwal
C00003 Pramada Bombay 400057 Maharashtra 5000
Jaguste
C00004 Basu Navindgi Bombay 400056 Maharashtra 0
C00005 Ravi Delhi 100001 2000
Sreedharan
C00006 Rukmini Bombay 400050 Maharashtra 0

b) product_master

Product Description Profit_ Unit_ Qty_ Reorder Sell_ Cost_


_no percent measu on_ha _lvl price price
re nd
P00001 1.44 floppies 5 Piece 100 20 525 500
2
P03453 Monitors 6 Piece 10 3 12000 11280
P06734 Mouse 5 Piece 20 5 1050 1000
P07865 1.22 floppies 5 Piece 100 20 525 500
P07868 keyboards 2 Piece 10 3 3150 3050
P07885 cd Drive 2.5 Piece 10 3 5250 5100
P07965 540 HDD 4 Piece 10 3 8400 8000
P07975 1.44 drive 5 Piece 10 3 1050 1000
P08865 1.22 drive 5 Piece 2 3 1050 1000

4. Create a table Salesman_master:-

Column_name Data_type Size


Salesman_no INT 6
Salesman_name Varchar 20
Address Varchar 30
City Varchar 20
Pincode INT 8
State Varchar 20
Sal_amt Double 8,2
Tgt_to_get Double 6,2
Remarks Varchar 60

5. Insert the following values into salesman_master:-


Sales Salesman Address City Pincode State Sal_ Tgt_to_ remarks
man_no _ name amt get
S001 Kiran A/14 Bombay 400002 Maharashtra 3000 100 Good
S002 Manish 65 Pune 400032 Maharashtra 3000 100 Excellent
S003 Ravi P7 Bombay 400052 Maharashtra 3000 200 Good
S004 Ashish Ky14 Pune 400032 Maharashtra 3500 200 Good

Column Name Data Type Size Attributes


Order_no Varchar 6 Primary Key/Foreign Key references order_no
of the Sales_order table
Product_no Varchar 6 Primary Key/Foreign Key references
product_no of product_master table
qty_ordered INT 8

Qty_disp INT 8
Product_rate Double 10,2

3
Machine Exercise-2
1. Find out the names of all the clients in the client_master table.
2. Retrieve the entire contents of salesman_master table.
3. Retrieve the list of names and cities of all the clients.
4. List the various products available from product_master table.
5. List all clients who are located in Pune.
6. Find the names of salesman who have salary greater than Rs. 3000.
7. List all information about all employee of EMP table.
8. List all employee names along with their salaries from emp table.
9. List all information about all departments from dept table.
10.List all deptno,empno,mgr from emp table.

Machine Exercise-3

1. List dept name and location from dept table.


2. List the employees belonging to dept no 20.
3. List the name and salary of employees whose salary is more than 1000.
4. Retrieve the empno and names of MANAGER.
5. List the names of CLERKS working in Deptno 20.
6. List the names of ANALYSTS and SALESMAN.
7. List the information of clients those belong to Bombay.
8. List all employees who are not MANAGERS.
9. List the names of employees whose empno are
7369,7521,7839,7934,7788.
i) Using IN operator.
ii) Using OR operator.

4
Machine Exercise-4

2. List the employee details not belonging to department number 10,30 and 40.
3. List the employee’s names and salary whose salary is between 1000 and 2000.
4. List the employee’s names who are not eligible for commission.
5. List the names of employees and designation (job) of the employee who doesn’t
report to anybody (managers is NULL).
6. List the employees not assigned to any department.
7. List the employee who are eligible for commission.
8. List the details of employes whose salary is greater than 2000 and commission
is NULL.
9. List the employees who names start with ‘S’(not ‘s’).
10. List the names of employees whose names have exactly 5 characters.

Machine Exercise-5
1. List the employee names having ‘I’ as the 2nd character.
2. List the name ,salary and PF amount of all the employees(PF is calculated
as 10% of salary).
3. List the names of employees who are more than 2year old in the
organization
4. List the Clients having no balance.
5. List the client information of those clients whose name have 2nd character as
‘a’.
6. List the actual profit from product_master.
7. List the actual cost price for each product.
8. List the product information for those items in which the actual profit (Rs.)
is more than 50.
9. Retrieve the total cost for each product.(Total Cost= qty X cost price).
10. Retrieve the sales amount of ‘excellent’ salesman.
5
11.Retrieve the contents of the column product_no, description and compute
5% of the values contained in the column sell_price and 1.05% of values
contained in the field sell_price for each row from the table product_master.
12. Rename sell_price * 0.05 filed as Increase and sell_price *1.05 as new price
in the above query.
13. Retrive the contents of colum product_no ,description ,profit_percent from
the table product_master where the values contained in the field
profit_percent is between 10 and 20 both inclusive.
14. List specified client information for the clients who are not in ‘Bombay’.
15. List the information of clients whose name includes ‘g’ as a character.

Machine Exercise-6

1. Update the table Client_Master change the contents of the Field name to ‘Vijay
Kadam’ and the contents of the field address to ‘SCT jay Apartments’ for the
Record identified by the field Client_no containing the value’c02000’;
2. Give every employee a bonus of 15%. Calculate the 15% amount based on the
value held in the column basic_sal of the table emp_master and update the
values held in the column net_sal.
3. Add the fields Client_tel,which is the field that can hold a number up to 8 digits
in length and Client_fax that can hold number up to 15 digits in length.
4. Modify the field Client_name of the table Client_master to now hold a
maximum of 25 character values.
5. Rename the table Client_master to Client_master 1;
6. Destroy the table Client_master and all the data held in it;
7. Delete rows from the table Client_Master where the value in the Bal_due field
is less than 500;
8. Promote the employee who has empno ‘7876’ to ‘ANALYST’
9. Increment the salary of ‘james’ by 10% of existing pay of emp table.
6
10. Update the record of ‘SMITH’ in such a way that salary of ‘smith’ should be
incremented by 20% and commission allocation is 5% of existing salary.
11. Rename the table ‘dept’ to ‘Department’.

Machine Exercise-7

1. Calculate the minimum balance due from client_master.


2. Calculate the count of products in the product_master table.
3. Calculate the sum of all balance due from client_master table.
4. Return the absolute value of –30,190,-34.5,89.3.
5. Return the 3rd power of 5. (ii) Round of the values of 15.19,20.69,51.85.
6. Calculate the square root of 144,49,64,78.
7. Calculate the average selling price of all the products in the product_master
table.
8. Calculate the modulus of 200 by 30.
9. Calculate the sign of values obtained after (comm.- salary) from emp table
where dept is 10.
10. Return char, with all letters in lower case of “AMRITSAR COLLEGE OF
ENGINEERING” with a heading as Name.

Machine Exercise-8
1. Return String with first letter in Upper Case of “AMRITSAR
ENGINEERING COLLEGE” with heading AS Title Name.
2. Return char, with all letters in upper case of “Amritsar College ” with a
heading as Upper.
3. Return a portion of char “ENGINEERING”, beginning at character ‘4’
exceeding upto end.
4. Return a portion of char “ENGINEERING”, beginning at character ‘4’
exceeding upto ‘9’ character.

7
5. Return the Length of character “ENGINEERING”.
6. Return the Length of character “AMRITSAR COLLEGE”.
7. Remove characters from left to char with initial chars removed upto first
character not in set of “COLLEGE”.
8. Return char with final character removed after the last character not in set
of “COLLEGE”.
9. Return char, left padded to length ‘20’ with ‘*’ inserted in padded space
of word “ENGINEERING”.
10. Return the greatest of the following values (20, ‘8’, -3)

Machine Exercise-9

1. Return the least value in the list of expressions (‘lord’ , ‘LORD’, ‘b’ , ‘xyz’).
2. Update the comm as null where comm is 0 in the employee table.
3. Return ename, sal, comm.,sal+comm gross, sal+NVL as New Gross from
employee table.
4. Translate the character e in the ename column of employee table to 1.
5. Translate the character a in the ename table such that a gets removed
from wherever it exists in the ename column of employee table.
6. Replace the Job clerk to executive and manager to RM in the employe
table.
7. Display the order number and day on which clients placed their orders.
8. Display the month (in alphabets) and date the order must be delivered.
9. Display the order_date in the format ‘DD-Month-YY’ . e.g. 12-
February-96.
10. Find the Date, 15 days after today’s date.
11. Find the number of days elapsed between today’s date and the delivery
date of the orders placed by the clients.

Potrebbero piacerti anche