Professional Documents
Culture Documents
DBMS LAB - Ex - No-6
DBMS LAB - Ex - No-6
DATE: 23-03-2021
PROBLEM DEFINITION:
Create tables for the Banking system as per the constraints given and execute
queriesas per the requirements mentioned.
TABLE: BRANCH
Name Null? Type
--------------------------------- -------- - - --------------------------
BNAME NOT NULL VARCHAR2(15)
CITY VARCHAR2(15)
BID NOT NULL NUMBER(4)
TABLE: CUSTOMERS
Name Null? Type
------------------------- ------------- -------- ----------------------------
CID NOT NULL NUMBER(4)
CNAME VARCHAR2(20)
AGE NUMBER(2)
LOCATION VARCHAR2(20)
BNAME VARCHAR2(15)
ACTNO VARCHAR(4)
TABLE: LOAN
Name Null? Type
------------------------------- ---------- -------- ----------------------------
CID NUMBER(4)
AMOUNT NUMBER(8)
INTEREST NUMBER(2,2)
ACTNO VARCHAR(4)
TABLE :DEPOSIT
Name Null? Type
------------------------------- ------ -------- ----------------------------
ACTNO VARCHAR2(4)
AMOUNT NUMBER(8,2)
ADATE DATE
CID NUMBER(4)
PROCEDURE:
TABLE:BRANCH
create table branch(bname varchar(20) not null,city varchar(20),BID integer not null);
insert into branch values('Chrompet','Chennai',7847762);
insert into branch values('Pallavaram','Chennai',987654);
insert into branch values('Bombay','Bombay',1234567);
insert into branch values('Tambaram','Chennai',4456798);
insert into branch values('Pallavaram','Mumbai',5438123);
insert into branch values('Delhi','Delhi',56421098);
TABLE:CUSTOMERS
create table customers(CID integer not null,cname varchar(10),age integer,location
varchar(10),bname varchar(10),actno varchar(20));
insert into customers values(4321,'prem',20,'Delhi','Chrompet','987654321');
insert into customers values(5678,'sunil',24,'Chennai','Pallavaram','123456789');
insert into customers values(3456,'vijay',23,'Bombay','Bombay','7465413356');
insert into customers values(6543,'anil',25,'Chennai','Tambaram','46789013478');
insert into customers
values(5320,'Kamalika',30,'Pallavaram','Pallavaram','54217890654');
insert into customers values(1289,'Snekha',26,'Delhi','Delhi','75153420866');
TABLE:LOAN
create table loan(CID integer,amount integer,interest integer,actno varchar(15));
insert into loan values(4321,50000,10,'987654321');
insert into loan values(5678,60000,20,'123456789');
insert into loan values(3456,70000,30,'7465413356');
insert into loan values(6543,80000,40,'46789013478');
insert into loan values(5320,90000,50,'54217890654');
insert into loan values(1289,50000,30,'75153420866');
TABLE:DEPOSIT
create table deposit(actno varchar(20),amount integer,Adate date);
insert into deposit values('987654321',50000,'12-dec-2010');
insert into deposit values('123456789',60000,'13-oct-2005');
insert into deposit values('7465413356',70000,'08-apr-2013');
insert into deposit values('46789013478',80000,'31-dec-2016');
insert into deposit values('54217890654',90000,'06-jun-2006');
insert into deposit values('75153420866',50000,'04-jun-2011');
6. Deposit the sum of the deposits of sunil and vijay in the account of prem
update deposit set amount=(select amount from deposit where actno=(select actno
from customers where cname='vijay'))+(select amount from deposit where
actno=(select actno from customers where cname='sunil')) where actno=(select
actno from customers where cname='prem');
select * from deposit;
8.Replace all the customers names with first character initial letter and others in
lowercase.
update customers set cname=initcap(cname);
select * from customers;
14.List out the customer name and customer id in descending order based on the cid.
select cname,cid from customers order by cid desc;
15.List the customer name and their account numbers who stay in either Chennai or
delhi.
select cname,actno from customers where location= 'Delhi' or location='Chennai';
16.Find all the customers whose city name starts with the letter d.
select * from customers where location like 'D%';
17.List all the senior citizen’s account number with the title ACTNO-SNO
select * from customers where age>=60;
19.List the customer details who is having account in their own native .
select * from customers where location=bname;
20.Find the names of all the customers having ‘a’ as the third letter in their names.
select * from customers where cname like '__a%';
21.Find all the customers whose city names ends with the letter ‘l’ third from the last.
select * from customers where location like '%l__';
24. List the customer name and age with their email id .Give each customer an
email id.The username should be the cnamebname@idbi.ocm. User name should be in
lowercase.
alter table customers add emailid varchar(30);
update customers set emailid=lower(cname||bname||'@idbi.com');
select cname,age,emailid from customers;
26.Find the minimum and maximum deposited amount and rename that as
least_deposit and maximum deposit.
select min(amount) "least deposit",max(amount) "max deposit" from deposit;
27.Count the total number of customer cities.
select city,count(*) from branch group by city;
OUTPUT: