220410116115
SYIT3-B
PRACTICAL– 1
Aim: To study DDL-create and DML-insert commands.
1) Describe deposit, branch.
desc deposit;
actno varchar(5) YES
cname varchar(18) YES
bname varchar(18) YES
amount int(8) YES
adate date YES
desc branch;
bname varchar(18) YES
city varchar(18) YES
2) Describe borrow, customers.
desc borrow;
loanno varchar(5) YES
cname varchar(18) YES
bname varchar(18) YES
amount int(8) YES
desc customers;
cname varchar(19) YES
city varchar(18) YES
3) List all data from table DEPOSIT.
select * from deposit;
100Anil vrce 1000 1995-03-01
101Sunil ajni 5000 1996-01-04
102Mehul karolbagh 3500 1995-11-17
103Madhuri chandi 1200 1995-12-17
1
SYIT3-B 220410116115
104Pramod m.g.road 3000 1996-03-27
105Sandip andheri 2000 1996-03-31
106Shivani virar 1000 1995-09-05
107Kranti nehru place 5000 1995-07-02
108Minu powai 7000 1995-08-10
4) List all data from table BORROW.
select * from borrow;
201Anil vrce 1000
206Mehul ajni 5000
311Sunil dharampeth 3000
321Madhuri andheri 2000
375Pramod virar 8000
481Kranti nehru place 3000
5) List all data from table CUSTOMERS.
select * from customers;
Anil Calcutta
Sunil Delhi
Mehul Baroda
Mandar Patna
Madhuri Nagpur
Pramod Nagpur
Sandip Surat
Shivani Bombay
Kranti Bombay
Naren Bombay
6) List all data from table BRANCH.
select * from branch;
vrce Nagpur
ajni Nagpur
karolbagh Delhi
chandi Delhi
dharampeth Nagpur
m.g.road Banglore
andheri Bombay
2
SYIT3-B 220410116115
virar Bombay
nehru place Delhi
powai Bombay
7) Give account no and amount of depositors.
select actno,amount from deposit;
100 1000
101 5000
102 3500
103 1200
104 3000
105 2000
106 1000
107 5000
108 7000
8) Give name of depositors having amount greater than 4000.
select cname from deposit where amount>4000;
Sunil
Kranti
Minu
9) Give name of customers who opened account after date '1-12-96'.
select cname from deposit where adate>'1996-01-12';
Pramod
Sandip
3
SYIT3-B 220410116115
PRACTICAL- 2
Aim: Create table and insert sample data in tables.
1) Insert following values in the table job.
desc job;
job_ID varchar(15) YES
job_title varchar(30) YES
min_sal int YES
max_sal int YES
select * from job;
IT_PROG Programmer 4000 10000
IT_PROG Programmer 4000 10000
MK_MGR Marketing manager 9000 15000
FI_MGR Finance manager 8200 12000
FI_ACC Account 4200 9000
LEC Lecturer 6000 17000
COMP_OP Computer operator 1500 3000
2) Insert following values in the table Employee.
desc employee;
emp_no int YES
emp_name varchar(30) YES
emp_sal int YES
emp_comm int YES
hiredate date YES
dept_no int YES
select * from employee;
101 Smith 800 0 1994-07-01 20
102 Snehal 1600 300 1998-03-04 25
103 Adama 1100 0 1996-12-01 20
104 Aman 3000 0 1995-09-07 15
105 Anita 5000 50000 1996-06-27 10
106 Sneha 2450 24500 1996-08-31 10
107 Anamika 2975 0 1995-09-05 30
4
SYIT3-B 220410116115
3) Create table deposite
desc deposite;
a_no varchar(5) YES
Cname varchar(15) YES
Bname varchar(10) YES
amount int(7) YES
a_date Date YES
4) Create table borrow2.
desc borrow2;
loanno varchar(5) YES
cname varchar(15) YES
bname varchar(10) YES
amount int(7) YES
5) Insert following values in the table department.
desc department;
dept_no Int YES
dept_name varchar(15) YES
location varchar(7) YES
select * from department;
10 EC wing2
15 IC wing1
20 IT wing3
25 COMPUTER wing4
30 CIVIL wing5
5
SYIT3-B 220410116115
PRACTICAL – 3
Aim: Perform queries involving predicates LIKE, BETWEEN,IN etc.
1) Retrieve all data from employee, jobs.
select * from job;
IT_PROG Programmer 4000 10000
IT_PROG Programmer 4000 10000
MK_MGR Marketing manager 9000 15000
FI_MGR Finance manager 8200 12000
FI_ACC Account 4200 9000
LEC Lecturer 6000 17000
COMP_OP Computer operator 1500 3000
select * from employee;
101Smith 800 0 1994-07-01 20
102Snehal 1600 300 1998-03-04 25
103Adama 1100 0 1996-12-01 20
104Aman 3000 0 1995-09-07 15
105Anita 5000 50000 1996-06-27 10
106Sneha 2450 24500 1996-08-31 10
107Anamika 2975 0 1995-09-05 30
2) Give details of account no. and deposited rupees of customers having
account opened between dates 01-01-95 and 25-07-96.
select actno,amount from deposit where adate between '1995-01-01' and '1996-07-01';
100 1000
101 5000
102 3500
104 1200
100 3000
107 1000
108 5000
109 7000
6
SYIT3-B 220410116115
3) Display all jobs with minimum salary is greater than 4000.
select job_title from job where min_sal>4000;
Marketing manager
Finance manager
Account
Lecturer
4) Display name and salary of employee whose department no is 20. Give alias name
to name of employee.
select emp_name as employee_name,emp_no from employee where dept_no = 20;
Smith 101
Adama 103
5) Display employee no,name and department details of those employee
whose department lies in(10,20).
select emp_no,emp_name,dept_no from employee where dept_no in (10,20);
101 Smith 20
103 Adama 20
105 Anita 10
106 Sneha 10
6) Display all employee whose name start with ‘A’ and third character is ‘a’.
select emp_name from employee where emp_name like 'A_a%';
Adama
Aman
Anamika
7) Display name, number and salary of those employees whose name is 5
characters long and first three characters are ‘Ani’.
select emp_no,emp_name,emp_sal from employee where emp_name like 'Ani__';
105 Anita 5000
8) Display the non-null values of employees and also employee name second character
should be ‘n’ and string should be 5 character long.
7
SYIT3-B 220410116115
select emp_name from employee where emp_name like '_n___';
Anita
Sneha
9) Display the null values of employee and also employee name’s third character
should be ‘a’.
select emp_name from employee where emp_name like '__a%';
Adama
Aman
Anamika
10) What will be output if you are giving LIKE predicate as ‘%\_%’.(Here is ESCAPE
‘\’character).
select emp_name from employee where emp_name like '%\_%';
Ans: no data found.
8
SYIT3-B 220410116115
PRACTICAL – 4
Aim: To perform various data manipulation commands,
aggregate functions and sorting concept on all created tables.
1) List total deposit from deposit.
select sum(amount) from deposit;
28700
2) List total loan from karolbagh branch.
select sum(amount) from deposit where bname='karolbagh';
3500
3) Give maximum loan from branch vrce.
select max(amount) from deposit where bname=’vrce’;
1000
4) Count total number of customers
select count(*) from customers; 10
5) Count total number of customer’s cities.
select count(city) from customers;
10
6) Create table supplier from employee with all the columns.
create table supplier as select emp_no,emp_name,emp_sal,hiredate,dept_no from
employee;
select * from supplier;
101Smith 800 1994-07-01 20
102Snehal 1600 1998-03-04 25
103Adama 1100 1996-12-01 20
104Aman 3000 1995-09-07 15
105Anita 5000 1996-06-27 10
106Sneha 2450 1996-08-31 10
107Anamika 2975 1995-09-05 30
9
SYIT3-B 220410116115
7) Create table sup1 from employee with first two columns.
create table supplier1 as select emp_no,emp_name from
employee; select * from supplier1;
101 Smith
102 Snehal
103 Adama
104 Aman
105 Anita
106 Sneha
107 Anamika
8) Create table sup2 from employee with no data.
create table sup2 as select * from employee where
1=0; select * from sup2;
9) Insert the data into sup2 from employee whose second character should be ‘n’ and
string should be 5 characters long in employee name field.
insert into sup2 select * from employee where emp_name like '_n___';
select * from sup2;
105 Anita 5000 50000 1996-06-27 10
106 Sneha 2450 24500 1996-08-31 10
10) Delete all the rows from sup1.
delete from supplier1;
select * from supplier1;
11) Delete the detail of supplier whose sup_no is 103.
delete from supplier where emp_no=103;
select * from supplier;
101 Smith 800 1994-07-01 20
10
SYIT3-B 220410116115
102Snehal 1600 1998-03-04 25
104Aman 3000 1995-09-07 15
105Anita 5000 1996-06-27 10
106Sneha 2450 1996-08-31 10
107 Anamika 2975 1995-09-05 30
12) Rename the table sup2.
alter table sup2 rename to supplier2;
13) Destroy table sup1 with all the data.
drop table supplier1;
show tables;
14) Update the value dept_no to 10 where second character of emp. name is ‘m’.
update employee set dept_no=10 where emp_name like '_m
%'; select * from employee;
101Smith 800 0 1994-07-01 10
102Snehal 1600 300 1998-03-04 25
103Adama 1100 0 1996-12-01 20
104Aman 3000 0 1995-09-07 10
105Anita 5000 50000 1996-06-27 10
106Sneha 2450 24500 1996-08-31 10
107Anamika 2975 0 1995-09-05 30
15) Update the value of employee name whose employee number is
103. update employee set emp_name = 'Heta' where emp_no=103; select *
from employee;
101Smith 800 0 1994-07-01 10
102Snehal 1600 300 1998-03-04 25
103Heta 1100 0 1996-12-01 20
104Aman 3000 0 1995-09-07 10
105Anita 5000 50000 1996-06-27 10
106Sneha 2450 24500 1996-08-31 10
107Anamika 2975 0 1995-09-05 30
11
SY IT 3 - B 220410116120
12