Professional Documents
Culture Documents
SubjectName : DBMS
Subject Code : 203105251
B.Tech CSE Year 2019-20 Semester 4th
Annexure No : 1
PRACTICAL:-1
Aim :- To study DDL-create and DML-insert commands.
(i) Create tables according to the following definition.
(1) Create Table Deposit (ACTNO NUMBER (4), CNAME VARCHAR2 (20), BNAME
VARCHAR2 (20), AMOUNT NUMBER (8, 2), ADATE DATE);
(2) Create Table Branch (BNAME VARCHAR2 (20), CITY VARCHAR2 (20));
(3) Create Table Customer (CNAME VARCHAR2 (20), CITY VARCHAR2 (20));
(4) Create Table Borrow (LOANNO NUMBER (4), CNAME VARCHAR2 (20), BNAME
VARCHAR2 (20), AMOUNT NUMBER (8, 2));
Annexure No : 2
107 SHIVANI VIRAR 10000.00 5-SEP-95
108 KRANTI NEHRU 50000.00 2-JUL-95
PLACE
109 MINU POWAI 70000.00 10-AUG-95
Table 2: BRANCH
BNAME CITY
VRCE NAGPUR
AJNI NAGPUR
KAROLIBAGH DELHI
CHANDI DELHI
DHARAMPETH NAGPUR
M.G.ROAD BANGLORE
ANDHERI BOMBAY
VIRAR BOMBAY
NEHRU_PLACE DELHI
POWAI BOMBAY
Table 3: CUSTOMER
CNAME CITY
ANIL CALCUTTA
SUNIL DELHI
MEHUL BARODA
MANDAR PATNA
MADHURI NAGPUR
PRMOD NAGPUR
SANDIP SURAT
SHIVANI BOMBAY
KRANTI BOMBAY
NAREN BOMBAY
Table 4: BORROW
LOANNO CNAME BNAME AMOUNT
201 ANIL VRCE 10000.00
206 MEHUL AJNI 50000.00
311 SUNIL DHARAMPETH 30000.00
321 MADHURI ANDHERI 20000.00
375 PRAMOD VIRAR 80000.00
481 KRANTI NEHRU_PLACE 30000.00
Solution :-
Description:-
Create:-
Syntax:-
Annexure No : 3
create table table_name(column_name datatype (size),..);
Create statement is used to create a newtable into Database.
Insert:-
Syntax:-
insert into table_name values (content,..);
Insert statement is used to insert a single record or multiple record into a table in Database.
Select:-
Syntax:-
select * from table_name;
Select statement is used to retrive records from one or more table in a Database.
Annexure No : 4
insert into branch values(‘CHANDI’,’DELHI’);
insert into branch values(‘DHARAMPETH’,’NAGPUR’);
insert into branch values(‘M.G.ROAD’,’BANGLORE’);
insert into branch values(‘ANDHERI’,’BOMBAY’);
insert into branch values(‘VIRAR’,’BOMBAY’);
insert into branch values(‘NEHRU_PLACE’,’DELHI’);
insert into branch values(‘POWAI’,’BOMBAY’);
Annexure No : 5
(iii) From the above given tables perform the following queries:
(1) Describe deposit, branch.
Soln:-describe deposit;
describe branch;
Annexure No : 6
Annexure No : 7
Annexure No : 8
(8) Give name of customers who opened account after date ' 5-SEP-95’ .
Soln:- select cname from deposit where adate > ‘5-SEP-95’;
PRACTICAL:-2
Aim:-Create the below given table and insert the data accordingly.
(i) Create tables according to the following definition.
(1) Create Table job (job_id, job_title, min_sal, max_sal).
Annexure No : 9
job_title Varchar2(40)
min_sal Number(7,2)
max_sal Number(7,2)
Annexure No : 10
102 Snehal 160000 300 125
103 Adama 110000 0 120
104 Aman 300000 115
105 Anita 5000000 50000 110
106 Sneha 2400000 24500 110
107 Anamika 29075 130
Solution:-
(1) create table job(job_id varchar2(10),job_title varchar2 (40),min_sal number(7,2),max_sal
number(10,2));
Annexure No : 11
(3) craete table deposit (a_no number (4),cname varchar2(20) bname varchar2(30),amount
number(9,2),a_date DATE);
Annexure No : 12
select * from deposit;
Annexure No : 13
Annexure No : 14
(2)Give details of account no. and deposited rupees of customers having account opened
between dates 01-01-12 and 25-07-16.
Soln:-select a_no,amount from deposit where a_date between ‘1-JAN-12’ and ‘25-JUL-16’;
(3) Display all jobs with minimum salary is greater than 40000.
Soln:-select job_title from job where min_sal > 40000;
Annexure No : 15
(4) Display name and salary of employee whose department no is 120. Give alias name to
name of employee.
Soln:-select emp_name as ‘alias_name”,emp_sal from employee where dept_no=120;;
(5) Display employee no, name and department details of those employee whose
department
lies in(110,120).
Soln:-select emp_no,emp_name,dept_no from employee where dept_no between 110 and
120;
(iv) To study various options of LIKE Predicate
Description:-
Like:-
Syntax:-
select * from <table_name> where <column_name> like <like critation>;
The LIKE predicate compares a column of type CHAR or VARCHAR (string) with a
pattern. This pattern is also a string, but it may contain two characters with a special
meaning. The '_' (underscore) represents exactly one arbitrary character and '%'
(percent) represents a string of zero, one or more characters.
(1) Display all employee whose name start with ‘A’ and third character is ‘a’.
Soln:-select EMP_NAME from employee where EMP_NAME like ‘A_A%”;
(3) Display name, number and salary of those employees whose name is 4 characters
long and first two characters are ‘AM’.
Soln:-select EMP_NAME,EMP_SAL from employee where EMP_NAME like ‘AM__%’;
Annexure No : 16
(4) Display the non-null values of employees and also employee name second
character should be ‘n’ and string should be 5 character long.
Soln:-select * from employee where EMP_COMM is not null and EMP_NAME like ‘_N___’;
(5) Display the null values of employee and also employee name’s third character should be
‘r’.
Soln:-select * from employee where EMP_COMM is null and EMP_NAME like ‘__A%’;
Practical:-03
Aim:-To perform various data manipulation commands, aggregate
functions and sorting concept on all created tables.
(1) List total deposit from deposit.
Soln:-select sum(amount) “TOTAL DEPOSIT” from deposit;
Annexure No : 17
(4) Create table supplier from employee with all the columns.
Soln:-create table supplier as select * from employee;
select * from employee;
Annexure No : 18
Annexure No : 19
(9) Update the value of employee name whose employee number is 105.
Soln:- update employee set EMP_NAME=’PRATIMA’ where EMP_NO=105;
select * from employee;