DBMS Lab Assg
DBMS Lab Assg
SALESMANNO
SALESMANNAME
ADDRESS1
ADDRESS2
CITY
PINCODE
STATE
SALAMT
TGTTOGET
VARCHAR2(6)
VARCHAR2(20)
VARCHAR2(30)
VARCHAR2(30)
VARCHAR2(20)
NUMBER(8)
VARCHAR2(20)
NUMBER(8,2)
NUMBER(6,2)
1 row created
command-insert into PRODUCT_MASTER values('P07865','Jeans',5,'piece',100,20,750,500);
1 row created
command-insert into PRODUCT_MASTER values('P07868','TTrousers',2,'piece',150,50,850,550);
1 row created
command-insert into PRODUCT_MASTER values('P07885','Pull
Overs,2.5,'piece',80,30,700,450);
1 row created
command-insert into PRODUCT_MASTER values('P07965','Denim
shirts',4,'piece',100,40,350,250);
1 row created
command-insert into PRODUCT_MASTER values('P07975','Lycra tops',5,'piece',70,30,300,175);
1 row created
command-insert into PRODUCT_MASTER values('P08865','Skirts',5,'piece',75,30,450,300);
1 row created
SQL> select * from PRODUCT_MASTER;
PRODUC DESCRIPTION PROFTPERCENT UNITMEASUR QTYONHAND REORDERLVL
SELLPRICE COSTPRICE
------ --------------- ------------ ---------- ---------- ---------- ---------- ---------P00001 T-Shirt
5 Piece
200
50
350
250
P0345
Shirt
6 Piece
150
50
500
350
P06734 Cotten Jeans
5 Piece
100
20
600
450
P07865
Jeans
5 Piece
100
20
750
500
P07868 Trousers
2 Piece
150
50
850
550
P07885 Pull Overs
2.5 Piece
80
30
700
450
P07965 Denim Shirts
4 Piece
100
40
350
250
P07975 Lycra Tops
5 Piece
70
30
300
175
P08865
Skirts
5 Piece
75
30
450
300
9 rows selected.
C)Data for SALESMAN_MASTER table:
Command-insert into
SALESMAN_MASTER('S00001','Aman','A/14','Worli','Mumbai',400002,'Maharashtra',3000,100,50
,'good');
1 row created
Command-insert into
SALESMAN_MASTER('S00002','Omkar','65','Nariman','Mumbai',400001,'Maharashtra'
3000,200,100,'good');
1 row created
Command-insert into SALESMAN_MASTER('S00003','Raj','P7','Bandra','Mumbai',400032,'Maharashtra',3000,200,100,'good');
1 row created
Command-insert into
SALESMAN_MASTER('S00004','Ashish','A/5,'Juhu','Mumbai',400044,'Maharashtra',3500,200,15
0,'good');
1 row created
SQL> select * from SALESMAN_MASTER;
SALESM SALESMANNAME
ADDRESS1
ADDRESS2
PINCODE STATE
SALAMT TGTTOGET
------ -------------------- ------------------------------ ------------------------------ ----------
CITY
S00001
400002
S00002
400001
S00003
400032
S00004
400044
Aman
A/14
Maharashtra
3000
100
Omkar
65
Maharashtra
3000
200
Raj
P-7
Maharasthra
3000
200
Ashish
A/5
Maharasthra
3500
200
YTDSALES
50
100
100
150
Worli
Nariman
Mumbai
Mumbai
Bandra
Mumbai
Juhu
Mumbai
REMARKS
good
good
good
good
4 row selected
Question 3- Exercise on retrieving records from a table:
a. Find out the names of all the clients.
SQL> select name from CLIENT_MASTER;
NAME
-------------------Ivan Bayross
Mamta Muzumdar
Chhaya Bankar
Ashwini Joshi
Hansel Colaco
Deepak Sharma
Chhaya Bankar
7 rows selected.
b.Retrieve the entire contents of the CLIENT_MASTER table.
SQL>select * from CLIENT_MASTER;CLIENT
NAME
ADDRESS1
CITY
BALDUE
------ -------------------- ------------------------------ --------------- ---------- ---------C0001
Ivan Bayross
Maharashtra
Mumbai
C0002
Mamta Muzumdar
Tamil Nadu
Madras
C0003
Chhaya Bankar
Maharashtra
Mumbai
5000
C0004
Ashwini Joshi
Karnataka
Bangalore
C0005
Hansel Colaco
Maharashtra
Mumbai
C0006
Deepak Sharma
Karnataka
Mangalore
6 rows selected.
c.Retrieve the list of names,city and the sate of all the clients.
SQL> select name,city,address1 from CLIENT_MAASTER;
NAME
CITY
ADDRESS1
-------------------- --------------- ------------------------------
PINCODE
400054
15000
780001
0
400057
560001
400060
560050
0
2000
0
Ivan Bayross
Mumbai
Maharashtra
Mamta Muzumdar
Madras
Tamil Nadu
Chhaya Bankar
Mumbai
Maharashtra
Ashwini Joshi
Bangalore
Karnataka
Hansel Colaco
Mumbai
Maharashtra
Deepak Sharma
Mangalore
Karnataka
Chhaya Bankar
Mumbai
Maharashtra
7 rows selected.
d.List the various products available from the PRODUCT_MASTER.
SQL> select description from PRODUCT_MASTER;
DESCRIPTION
--------------T-Shirt
Shirt
Cotten Jeans
Jeans
Trousers
Pull Overs
Denim Shirts
Lycra Tops
Skirts
9 rows selected.
e.List all the clients who are located in Mumbai.
SQL> select name from CLIENT_MASTER where city='Mumbai';
NAME
-------------------Ivan Bayross
Chhaya Bankar
Hansel Colaco
f.find the names of salesmen who have a salary equal to Rs.3000.
SQL> select salesmanname from SALESMAN_MASTER where salamt=3000;
SALESMANNAME
-------------------Aman
Omkar
Raj
ques 4-Exercise on updating records in a table.
a.change the city of clientno 'C00005' to'Bangalore';
command-update client_master set city='Bangalore' where clientno='C00005';
1 row updated
SQL>select * from CLIENT_MASTER;
;CLIENT NAME
ADDRESS1
CITY
PINCODE BALDUE
------ -------------------- ------------------------------ --------------- ---------- ---------C0001 Ivan Bayross
Maharashtra
Mumbai
400054
15000
C0002 Mamta Muzumdar
Tamil Nadu
Madras
780001
0
C0003
C0004
C0005
C0006
Chhaya Bankar
Ashwini Joshi
Hansel Colaco
Deepak Sharma
Maharashtra
Karnataka
Maharashtra
Karnataka
Mumbai
Bangalore
Bangalore
Mangalore
400057
560001
400060
560050
5000
0
2000
0
6 rows selected.
b.Change the baldue of clientno 'C00001' to Rs.1000.
command-update client_master set baldue=1000 where clientno='C00001';
1 row updated
SQL> select * from CLIENT_MASTER;
;CLIENT NAME
ADDRESS1
CITY
PINCODE BALDUE
------ -------------------- ------------------------------ --------------- ---------- ---------C0001 Ivan Bayross
Maharashtra
Mumbai
400054
1000
C0002 Mamta Muzumdar
Tamil Nadu
Madras
780001
0
C0003 Chhaya Bankar
Maharashtra
Mumbai
400057
5000
C0004 Ashwini Joshi
Karnataka
Bangalore
560001
0
C0005 Hansel Colaco
Maharashtra
Bangalore
400060
2000
C0006 Deepak Sharma
Karnataka
Mangalore
560050
0
6 rows selected.
c.change the costprice of 'Trousers' to Rs. 950.00
command-update PRODUCT_MASTER set costprise =950 where description='Trousers';
1 row updated
SQL>select * from PRODUCT_MASTER;
PRODUC DESCRIPTION PROFTPERCENT UNITMEASUR QTYONHAND REORDERLVL
SELLPRICE COSTPRICE
------ --------------- ------------ ---------- ---------- ---------- ---------- ---------P00001
T-Shirt
5 Piece
200
50
350
250
P0345
Shirt
6 Piece
150
50
500
350
P06734
Cotten Jeans
5 Piece
100
20
600
450
P07865
Jeans
5 Piece
100
20
750
500
P07868
Trousers
2 Piece
150
50
850
950
P07885
Pull Overs
2.5 Piece
80
30
700
450
P07965
Denim Shirts
4 Piece
100
40
350
250
P07975
Lycra Tops
5 Piece
70
30
300
175
P08865
Skirts
5 Piece
75
30
450
300
9 rows selected.
d.change the city of the salesman to pune.
SQL> update SALESMAN_MASTER set city='Pune';
4 rows updated.
SQL> select* from SALESMAN_MASTER;
SALESM SALESMANNAME
ADDRESS1
ADDRESS2
PINCODE ST
------ -------------------- ------------------------------ ------------------------------ ---------S00001 Aman
A/14
Worli
Pune
CITY
400002
Ma
S00002 Omkar
Ma
S00003 Raj
Ma
S00004 Ashish
Ma
65
P-7
Nariman
Bandra
A/5
Juhu
Pune
Pune
400001
400032
Pune
400044
CITY
400002
400001
400032
b.Delete all products from PRODUCT_MASTER where the quantity on hand is equal to 100.
SQL> delete from PRODUCT_MASTER where qtyonhand=100;
3 rows deleted.
SQL> select * from PRODUCT_MASTER;
PRODUC DESCRIPTION PROFTPERCENT UNITMEASUR QTYONHAND REORDERLVL
SELLPRICE COSTPRICE
------ --------------- ------------ ---------- ---------- ---------- ---------- ---------P00001
T-Shirt
5 Piece
200
50
350
250
P0345
Shirt
6 Piece
150
50
500
350
P07868
Trousers
2 Piece
150
50
850
550
P07885
Pull Overs
2.5 Piece
80
30
700
450
P07975
Lycra Tops
5 Piece
70
30
300
175
P08865
Skirts
5 Piece
75
30
450
300
6 rows selected.
c.Delete from client_master where the column state holds the value 'Tamil Nadu'.
SQL> delete from CLIENT_MAASTER where address1='Tamil Nadu';
1 row deleted.
Table dropped.
SQL> select * from CLIENT_MASTER;
select * from CLIENT_MASTER
*
ERROR at line 1:
ORA-00942: table or view does not exist
ques8- Exercise on renaming the table.
a.change the name of the salesman_master table to sman_mast.
SQL> rename SALESMAN_MASTER to SMAN_MAST;
Table renamed.
SQL> select * from SMAN_MAST;
SALESM SALESMANNAME
ADDRESS1
ADDRESS2
PINCODE ST
------ -------------------- ------------------------------ ------------------------------ ---------S00001 Aman
A/14
Worli
Pune
Ma
S00002 Omkar
65
Nariman
Pune
Ma
S00003 Raj
P-7
Bandra
Pune
CITY
400002
400001
400032 Ma