Вы находитесь на странице: 1из 19


/*Practical 1 : Studying DDL-create and DML-insert commands*/
/* (i) Creating table according to the following defination*/

create table deposit_e1(actno varchar(15),cname varchar(18), bname varchar(18), amount number(8,2),

adate date);
create table branch_e1(bname varchar(15), city varchar(15));
create table customers_e1(cname varchar(15), city varchar(15));
create table borrow_e1(loanno varchar(15), cname varchar(15), bname varchar(15), amount number(8,2));

/* (ii) Inserting data into the table */

/*"deposit" table commands*/

insert into deposit_e1 values('100','Anil','vrce','1000.00','1-MAR-95');
insert into deposit_e1 values('101','Sunil','ajni','5000.00','4-JAN-96');
insert into deposit_e1 values('102','Mehul','karolbagh','3500.00','17-NOV-95');
insert into deposit_e1 values('104','Madhuri','chandi','1200.00','17-DEC-95');
insert into deposit_e1 values('105','Prmod','m.g. road','3000.00','27-MAR-96');
insert into deposit_e1 values('106','Sandip','andheri','2000.00','31-MAR-96');
insert into deposit_e1 values('107','Shivani','virar','1000.00','05-SEP-95');
insert into deposit_e1 values('108','Kranti','nehru place','5000.00','02-JUL-95');
insert into deposit_e1 values('109','Minu','powai','7000.00','10-AUG-95');

/*"branch" table commands*/

insert into branch_e1 values('vrce','nagpur');
insert into branch_e1 values('ajni','nagpur');
insert into branch_e1 values('karolbagh','delhi');
insert into branch_e1 values('chandi','delhi');
insert into branch_e1 values('dharampeth','nagpur');
insert into branch_e1 values('m.g. road','banglore');
insert into branch_e1 values('andheri','bombay');
insert into branch_e1 values('virar','bombay');
insert into branch_e1 values('nehru place','delhi');
insert into branch_e1 values('powai','bombay');

/*"customers" table commands*/

insert into customers_e1 values('Anil','calcutta');
insert into customers_e1 values('Sunil','delhi');
insert into customers_e1 values('Mehul','baroda');
insert into customers_e1 values('Mandar','patna');
insert into customers_e1 values('Madhuri','nagpur');
insert into customers_e1 values('Pramod','nagpur');
insert into customers_e1 values('Sandip','surat');
insert into customers_e1 values('Shivani','bombay');
insert into customers_e1 values('Kranti','bombay');
insert into customers_e1 values('Naren','bombay');

/*"borrow" table commands*/

insert into borrow_e1 values('201','Anil','vrce','1000.00');
insert into borrow_e1 values('206','Mehul','ajni','5000.00');
insert into borrow_e1 values('311','Sunil','dharampeth','3000.00');
insert into borrow_e1 values('321','Madhuri','Andheri','2000.00');
insert into borrow_e1 values('375','Prmod','virar','8000.00');
insert into borrow_e1 values('481','Kranti','nehru place','3000.00');

/*List of queries (Draw the output of queries accordingly)*/

/*(1)*/ describe deposit_e1;

describe branch_e1;

/*(2)*/describe borrow_e1;
describe customers_e1;

/*(3)*/select * from deposit_e1;


/*(4)*/select * from borrow_e1;


/*(5)*/select * from customers_e1;


/*(6)*/select * from branch_e1;


/*(7)*/select actno,amount from deposit_e1;


/*(8)*/select cname from deposit_e1 where amount>'4000';

/*(9)*/select cname from deposit_e1 where adate>'1-DEC-96';

/* Practical - 2 creating table and studying options of LIKE predicate*/

/*"employee" table commands*/

create table employee_e1(emp_no varchar(15), emp_name varchar(15), emp_sal varchar(15), emp_comm
varchar(15), deptno varchar(15));
insert into employee_e1 values('101','Smith','800','','20');
insert into employee_e1 values('102','Snehal','1600','300','25');
insert into employee_e1 values('103','Adama','1100','0','20');
insert into employee_e1 values('104','Aman','3000','','15');
insert into employee_e1 values('105','Anita','5000','50000','10');
insert into employee_e1 values('106','Sneha','2450','24500','10');
insert into employee_e1 values('107','Anamika','2975','','30');

/*"job" table commands*/

create table job_e1(job_id varchar(15), job_name varchar(25), min_sal varchar(15), max_sal varchar(15));
insert into job_e1 values('it_prog','programmer','4000','10000');
insert into job_e1 values('mk_mgr','marketing manager','9000','15000');
insert into job_e1 values('fi_mgr','finance manager','8200','12000');
insert into job_e1 values('fi_acc','account','4200','9000');
insert into job_e1 values('lec','lecturer','6000','17000');
insert into job_e1 values('comp_op','computer operator','1500','3000');

/*"deposit" table commands*/

create table deposit2_e1(a_no varchar(15), cname varchar(15), bname varchar(15), amount varchar(15),
ddate date );
insert into deposit2_e1 values('101','Anil','andheri','7000','01-JAN-06');
insert into deposit2_e1 values('102','Sunil','virar','5000','15-JUL-06');
insert into deposit2_e1 values('103','Jay','villeparle','6500','12-MAR-06');
insert into deposit2_e1 values('104','Vijay','andheri','8000','17-SEP-06');
insert into deposit2_e1 values('105','Keyur','dadar','7500','19-NOV-06');
insert into deposit2_e1 values('106','Mayur','borivali','5500','21-DEC-06');

/*List of queries 1: */

/*(1)*/ select * from employee_e1;

select * from job_e1;
select * from deposit2_e1;

/*(2)*/ select a_no,amount from deposit2_e1 where ddate between '01-JAN-06' and '25-JUL-06';

/*(3)*/ select job_name from job_e1 where min_sal>'4000';


/*(4)*/ select emp_name as first_name,emp_sal from employee_e1 where deptno='20';

/*(5)*/ select emp_no, emp_name, deptno from employee_e1 where deptno in('10','20');

/*List of queries 2 (LIKE predicate): */

/*(1)*/ select * from employee_e1 where emp_name like 'A_a%';

/*(2)*/ select emp_name,emp_no,emp_sal from employee_e1 where emp_name like 'Ani__';


/*(3)*/ select * from employee_e1 where emp_comm is not null and emp_name like '_n___';

/*(4)*/ select * from employee_e1 where emp_comm is null and emp_name like '__a%';

/*(5)*/ select * from job_e1 where job_id like '%\_%'escape'\';

/*Practical 3 : Performing various data manipulation commands,
aggregate functions and sorting concept on all created tables*/

/*List of queries : */

/*(1)*/ select sum(amount) from deposit2_e1;

/*(2)*/ select sum(amount) from deposit_e1 where bname='karolbagh';

/*Note as mistake in manual : Here borrow_e1 is replaced to deposit_e1 as no 'karolbagh' value is present
in borow_e1*/

/*(3)*/ select max(amount) from borrow_e1 where bname='vrce';


/*(4)*/ select count(cname) from customers_e1;

/*(5)*/ select count(distinct city) from customers_e1;

/*(6)*/ create table supplier_e1 as select * from employee_e1;

/*(7)*/ create table sup1_e1 as select emp_no,emp_name from employee_e1;

/*(8)*/ create table sup2_e1 as select * from employee_e1 where emp_no='NULL';


/*(9)*/ insert into sup2_e1 (emp_no) select emp_no from employee_e1 where emp_name like '_n___';

/*(10)*/ truncate table sup1_e1;

/*(11)*/ delete from supplier_e1 where emp_no='103';

/*(12)*/ rename sup2_e1 to sup3_e1;

/*(13)*/ drop table sup1_e1;

/*(14)*/ update employee_e1 set deptno='10' where emp_name like '_m%';

/*(15)*/ update employee_e1 set emp_name='Jay' where emp_no='103';

/*Practical 4 : Studying single-row functions*/
/*List of queries : */
/*(1)*/ select sysdate as "date" from dual;

/*(2)*/ select emp_no,emp_sal,emp_sal+(emp_sal*15/100) as

"new salary" from employee_e1;

/*(3)*/ select emp_no,emp_sal,emp_sal+(emp_sal*15/100) as

"new salary",emp_sal+(emp_sal*15/100)-emp_sal as 'increase'
from employee_e1;

/*(4)*/ select initcap(emp_name) as "name", length(emp_name)

as "name length" from employee_e1 where emp_name like
'J%'or emp_name like 'A%'or emp_name like 'M%' order by

/*(5)*/ select emp_name||' earns '||emp_sal||' monthly ' from


/*(6)*/ select emp_sal+emp_comm as "compensation" from