Practical No 1

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

Mca L13-ABDBMS LAB

Practical no 1
Aim: Implementation of data partitioning to range and list partitioning
Objective: understand partition concept with range and list partitioning
Theory:
What is paetitionig:
Partitioning enable tables and index to be subdivided into individual smaller
pieces. Each piece of database object is called partition. Partition has its own name and may have
its own storage characters
.
Type of partitioning:
1.range partition: the data is distributed based on a range of value of partition key.
2.list partition: the data is distributed based on a descrete of list of value of partition key

Range partition:
create table sales3_range
(
salesman_id number(5),
salesman_name varchar2(30),
sales_amount number(10),
sales_date date)
partition by range(sales_date)
(
partition sales_jan2000 values less than(to_date('01/02/2000','DD/MM/YYYY')),
partition sales_feb2000 values less than(to_date('01/03/2000','DD/MM/YYYY')),
partition sales_mar2000 values less than(to_date('01/04/2000','DD/MM/YYYY')),
partition sales_apr2000 values less than(to_date('01/05/2000','DD/MM/YYYY'))
Mca L13-ABDBMS LAB

)
;

insert into sales3_range values(1,'john wick',1000,to_date('10/01/2000','DD/MM/YY'));


insert into sales3_range values(2,'zoro',10000,to_date('03/01/2000','DD/MM/YY'));
insert into sales3_range values(3,'luffy',3000,to_date('25/04/2000','DD/MM/YY'));
insert into sales3_range values(4,'sanji',2500,to_date('11/02/2000','DD/MM/YY'));
insert into sales3_range values(5,'nami',2560,to_date('10/04/2000','DD/MM/YY'));
insert into sales3_range values(6,'chopper',4500,to_date('16/03/2000','DD/MM/YY'));
insert into sales3_range values(7,'brook',6000,to_date('2/03/2000','DD/MM/YY'));
Mca L13-ABDBMS LAB

select * from sales3_range;

SALESMAN_ID SALESMAN_NAME SALES_AMOUNT SALES_DAT


----------- ------------------------------ ------------ ---------
1 john wick 1000 10-JAN-00
2 zoro 10000 03-JAN-00
4 sanji 2500 11-FEB-00
6 chopper 4500 16-MAR-00
7 brook 6000 02-MAR-00
3 luffy 3000 25-APR-00
5 nami 2560 10-APR-00

7 rows selected.

SQL> select * from sales3_range partition(sales_feb2000);

SALESMAN_ID SALESMAN_NAME SALES_AMOUNT SALES_DAT


----------- ------------------------------ ------------ ---------
4 sanji 2500 11-FEB-00

SQL> select * from sales3_range partition(sales_jan2000);

SALESMAN_ID SALESMAN_NAME SALES_AMOUNT SALES_DAT


----------- ------------------------------ ------------ ---------
1 john wick 1000 10-JAN-00
2 zoro 10000 03-JAN-00

SQL> select * from sales3_range partition(sales_mar2000);

SALESMAN_ID SALESMAN_NAME SALES_AMOUNT SALES_DAT


----------- ------------------------------ ------------ ---------
6 chopper 4500 16-MAR-00
7 brook 6000 02-MAR-00

SQL> select * from sales3_range partition(sales_apr2000);

SALESMAN_ID SALESMAN_NAME SALES_AMOUNT SALES_DAT


----------- ------------------------------ ------------ ---------
3 luffy 3000 25-APR-00
5 nami
Mca L13-ABDBMS LAB

PRACTICAL NO 2

Aim: implementation of analytical queries like: ROLL_UP, CUBE, ROW_NUMBER, RANK, DENSE_RANK,
LEAD,LAG, FIRST,LAST

Objective: understand the different types of analytical queries or function

Theory: analaticl function computer an aggregate value based on a group of rows.

They differ from aggregate function in that they return

create table employee1

employee_id number(5),

departmen_id number(5),

employee_name varchar(30),

salary number(10),

dob date,

doj date,

job varchar(20)

);
Mca L13-ABDBMS LAB

insert into employee1 values(1,2,'john


wick',1000,to_date('10/01/2000','DD/MM/YY'),to_date('12/03/2000','dd/mm/yyyy),'clerk');

ERROR:

ORA-01756: quoted string not properly terminated

SQL> insert into employee1 values(1,2,'john


wick',1000,to_date('10/01/2000','DD/MM/YYYY'),to_date('12/03/2000','dd/mm/yyyy),'clerk');

ERROR:

ORA-01756: quoted string not properly terminated

SQL> insert into employee1 values(1,2,'john


wick',1000,to_date('10/01/2000','DD/MM/YYYY'),to_date('12/03/2000','dd/mm/yyyy),'clerk');

ERROR:

ORA-01756: quoted string not properly terminated

SQL> insert into employee1 values(1,2,'john


wick',1000,to_date('10/01/2000','DD/MM/YYYY'),to_date('12/03/2000','dd/mm/yyyy'),'clerk');

1 row created.

SQL> insert into employee1 values(2,3,'Khn


wick',2000,to_date('20/01/2000','DD/MM/YYYY'),to_date('11/03/2000','dd/mm/yyyy'),'clerk');

1 row created.
Mca L13-ABDBMS LAB

SQL> insert into employee1 values(3,4,'VIVEK


wick',3000,to_date('20/01/2000','DD/MM/YYYY'),to_date('11/03/2000','dd/mm/yyyy'),'clerk');

1 row created.

SQL> insert into employee1 values(4,5,'ketan


wick',2000,to_date('20/01/2000','DD/MM/YYYY'),to_date('11/03/2000','dd/mm/yyyy'),'clerk');

1 row created.

SQL> insert into employee1 values(5,6,'bhavesh


wick',6000,to_date('20/11/2000','DD/MM/YYYY'),to_date('11/06/2000','dd/mm/yyyy'),'clerk');

1 row created.

SQL> insert into employee1 values(6,7,'yogesh


wick',7000,to_date('5/11/2002','DD/MM/YYYY'),to_date('12/06/2004','dd/mm/yyyy'),'clerk');

1 row created.

SQL> insert into employee1 values(7,8,'hdfhfh


wick',8000,to_date('23/11/2022','DD/MM/YYYY'),to_date('14/06/2004','dd/mm/yyyy'),'clerk');

1 row created.

SQL> insert into employee1 values(8,9,'swati


wick',9000,to_date('25/11/2022','DD/MM/YYYY'),to_date('15/06/2004','dd/mm/yyyy'),'clerk');

1 row created.
Mca L13-ABDBMS LAB

SQL> insert into employee1 values(9,9,'sarthak


wick',9000,to_date('25/11/2022','DD/MM/YYYY'),to_date('15/06/2004','dd/mm/yyyy'),'clerk');

SQL> insert into employee1 values(10,4,'pratham


wick',3000,to_date('25/11/2022','DD/MM/YYYY'),to_date('15/06/2004','dd/mm/yyyy'),'clerk');

SQL

select * from employee1;


Mca L13-ABDBMS LAB

insert into employee1 values(6,7,'yogesh wick',7000,

aim: display department id ,job ,count, sum of salary and group them using rollup function in the order
of department id and job.

Select department_id,job,count(*),sum (salary) from employee1 group by rollup(department_id,job);


Mca L13-ABDBMS LAB

Display department id , job, count, sum of salary , group them up using cub function in the order of
department id and job

Select departmen_id, job, count(*),sum (salary) from employee1 group by cube(departmen_id,job);

You might also like