You are on page 1of 48

UNIVERSITY OF MUMBAI

INSTITUTE OF DISTANCE AND OPEN LEARNING (IDOL)*

*(Institute of Distance Education (IDE) is renamed)

CERTIFICATE
THE EXPERIMENTS DULY SIGNED IN THIS JOURNAL REPRESENT THE
BONAFIDE WORK BY Mr. BHAVIN JITENDRA PANCHAL IN SEMESTER IV OF
SECOND YEAR OF MASTER IN COMPUTER APPLICATION (MCA) IN THE
COMPUTER LABORATORY OF PCP CENTER PUNE VIDYATHI GRIHA’S
COLLEGE, GHATKOPAR FOR SUBJECT ADVANCED DATABASE TECHNIQUES
DURING ACADEMIC YEAR 2017-2018.

____________________ ____________________________

LECTURE IN CHARGE HEAD, DEPARTEMENT OF MCA

______________________

EXTERNAL EXAMINER
Advanced Database Techniques
INEDX

Sr no. Program Page No. Signature

1. Intrduction To Weka
2. Application of Pre-processing
Techniques
a)ReplaceMissingValues
b)Discritize
c)PKIDiscritize
d)ADD attribute
e)ADD Expression
3. Creation of .arff file
4. Association Rules
5. Study of Classification Techniques
6. Saving and Loading Model
7. Creating Object Types
8. Table Of Objects
9. Manipulating Objects
10. Creating Object Views
11. Objects with Methods
12. Varray
13. Nested Tables
14. Referencing & De-Referencing
Objects
15. Method Overloading
16. OLAP
i)Ranking Functions
a)Rank
b)Dense_Rank
17. OLAP
a) Roll up
b) Cube
18. Partitioning
a)By Range ,b)By Hash, c) By List
Practical 1: Introduction To Weka
Iris data –

Visualize all- sepallength (NUM) – for 1st column all statistic values listed
Practical 2(a) – Replace Missing Values
Before Replacing: missingdataweather
@RELATION iris

@ATTRIBUTE "sepallength" REAL


@ATTRIBUTE sepalwidth REAL
@ATTRIBUTE petallength REAL
@ATTRIBUTE petalwidth REAL
@ATTRIBUTE class {Iris-setosa,Iris-versicolor,Iris-virginica}

@DATA
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,?,0.2,Iris-setosa
4.7,3.2,?,0.2,Iris-setosa
4.6,3.1,1.5,0.2,Iris-setosa
5.0,3.6,1.4,0.2,Iris-setosa
5.4,3.9,?,0.4,Iris-setosa
,?,3.4,1.4,0.3,Iris-setosa
5.0,3.4,?,0.2,Iris-setosa
4.4,2.9,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.4,?,1.5,0.2,Iris-setosa
4.8,3.4,?,0.2,Iris-setosa
4.8,3.0,1.4,?,Iris-setosa
4.3,3.0,1.1,0.1,Iris-setosa
,?,4.0,1.2,?,Iris-setosa
5.7,4.4,1.5,0.4,Iris-setosa
5.4,3.9,1.3,0.4,Iris-setosa
5.1,3.5,1.4,0.3,Iris-setosa
5.7,3.8,1.7,0.3,Iris-setosa
5.1,3.8,?,0.3,Iris-setosa
5.4,3.4,1.7,0.2,Iris-setosa
5.1,3.7,1.5,0.4,Iris-setosa
4.6,3.6,1.0,0.2,Iris-setosa
5.1,3.3,1.7,0.5,Iris-setosa
4.8,3.4,1.9,0.2,Iris-setosa
5.0,3.0,1.6,0.2,Iris-setosa
5.0,3.4,1.6,0.4,Iris-setosa
5.2,3.5,1.5,0.2,Iris-setosa
5.2,3.4,1.4,0.2,Iris-setosa
4.7,3.2,1.6,0.2,Iris-setosa
4.8,3.1,1.6,0.2,Iris-setosa
5.4,3.4,1.5,0.4,Iris-setosa
5.2,4.1,1.5,0.1,Iris-setosa
5.5,4.2,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.0,3.2,1.2,0.2,Iris-setosa
5.5,3.5,1.3,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
4.4,3.0,1.3,0.2,Iris-setosa
5.1,3.4,1.5,0.2,Iris-setosa
5.0,3.5,1.3,0.3,Iris-setosa
4.5,2.3,1.3,0.3,Iris-setosa
5.3,3.7,1.5,0.2,Iris-setosa
5.0,3.3,1.4,0.2,Iris-setosa
7.0,3.2,4.7,1.4,Iris-versicolor
6.4,3.2,4.5,1.5,Iris-versicolor
6.9,3.1,4.9,1.5,Iris-versicolor
5.5,2.3,4.0,1.3,Iris-versicolor
6.5,2.8,4.6,1.5,Iris-versicolor
5.7,2.8,4.5,1.3,Iris-versicolor
6.3,3.3,4.7,1.6,Iris-versicolor
https://machinelearningmastery.com/how-to-handle-missing-values-in-machine-learning-
data-with-weka/

 How to mark corrupt with values as missing in your dataset.


 How to remove instances missing values from your dataset.
 How to impute mean values for missing values in your dataset.

Filter – choose-unsupervised - discrete


After Replacing: missingdataweather1.arff

@RELATION iris

@ATTRIBUTE "sepallength" REAL


@ATTRIBUTE sepalwidth REAL
@ATTRIBUTE petallength REAL
@ATTRIBUTE petalwidth REAL
@ATTRIBUTE class {Iris-setosa,Iris-versicolor,Iris-virginica}

@DATA
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,1.4,0.2,Iris-setosa
4.7,3.2,1.3,0.2,Iris-setosa
4.6,3.1,1.5,0.2,Iris-setosa
5.0,3.6,1.4,0.2,Iris-setosa
5.4,3.9,1.7,0.4,Iris-setosa
4.6,3.4,1.4,0.3,Iris-setosa
5.0,3.4,1.5,0.2,Iris-setosa
4.4,2.9,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.4,3.7,1.5,0.2,Iris-setosa
4.8,3.4,1.6,0.2,Iris-setosa
4.8,3.0,1.4,0.1,Iris-setosa
4.3,3.0,1.1,0.1,Iris-setosa
5.8,4.0,1.2,0.2,Iris-setosa
5.7,4.4,1.5,0.4,Iris-setosa
5.4,3.9,1.3,0.4,Iris-setosa
5.1,3.5,1.4,0.3,Iris-setosa
5.7,3.8,1.7,0.3,Iris-setosa
5.1,3.8,1.5,0.3,Iris-setosa
5.4,3.4,1.7,0.2,Iris-setosa
5.1,3.7,1.5,0.4,Iris-setosa
4.6,3.6,1.0,0.2,Iris-setosa
5.1,3.3,1.7,0.5,Iris-setosa
4.8,3.4,1.9,0.2,Iris-setosa
5.0,3.0,1.6,0.2,Iris-setosa
5.0,3.4,1.6,0.4,Iris-setosa
5.2,3.5,1.5,0.2,Iris-setosa
5.2,3.4,1.4,0.2,Iris-setosa
4.7,3.2,1.6,0.2,Iris-setosa
4.8,3.1,1.6,0.2,Iris-setosa
5.4,3.4,1.5,0.4,Iris-setosa
5.2,4.1,1.5,0.1,Iris-setosa
5.5,4.2,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.0,3.2,1.2,0.2,Iris-setosa
4.4,3.0,1.3,0.2,Iris-setosa
5.1,3.4,1.5,0.2,Iris-setosa
5.0,3.5,1.3,0.3,Iris-setosa
4.5,2.3,1.3,0.3,Iris-setosa
4.6,3.2,1.4,0.2,Iris-setosa
5.3,3.7,1.5,0.2,Iris-setosa
5.0,3.3,1.4,0.2,Iris-setosa
7.0,3.2,4.7,1.4,Iris-versicolor
6.4,3.2,4.5,1.5,Iris-versicolor
6.9,3.1,4.9,1.5,Iris-versicolor
5.5,2.3,4.0,1.3,Iris-versicolor
6.5,2.8,4.6,1.5,Iris-versicolor
5.7,2.8,4.5,1.3,Iris-versicolor
6.3,3.3,4.7,1.6,Iris-versicolor
Practical 2(b)- Discretize
Filename : discretizeweather.arff

@RELATION iris

@ATTRIBUTE "sepallength" REAL


@ATTRIBUTE sepalwidth REAL
@ATTRIBUTE petallength REAL
@ATTRIBUTE petalwidth REAL
@ATTRIBUTE class {Iris-setosa,Iris-versicolor,Iris-virginica}

@DATA
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,1.4,0.2,Iris-setosa
4.7,3.2,1.3,0.2,Iris-setosa
4.6,3.1,1.5,0.2,Iris-setosa
5.0,3.6,1.4,0.2,Iris-setosa
5.4,3.9,1.7,0.4,Iris-setosa
4.6,3.4,1.4,0.3,Iris-setosa
5.0,3.4,1.5,0.2,Iris-setosa
4.4,2.9,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.4,3.7,1.5,0.2,Iris-setosa
4.8,3.4,1.6,0.2,Iris-setosa
4.8,3.0,1.4,0.1,Iris-setosa
4.3,3.0,1.1,0.1,Iris-setosa
5.8,4.0,1.2,0.2,Iris-setosa
5.7,4.4,1.5,0.4,Iris-setosa
5.4,3.9,1.3,0.4,Iris-setosa
5.1,3.5,1.4,0.3,Iris-setosa
5.7,3.8,1.7,0.3,Iris-setosa
5.1,3.8,1.5,0.3,Iris-setosa
5.4,3.4,1.7,0.2,Iris-setosa
5.1,3.7,1.5,0.4,Iris-setosa
4.6,3.6,1.0,0.2,Iris-setosa
5.1,3.3,1.7,0.5,Iris-setosa
4.8,3.4,1.9,0.2,Iris-setosa
5.0,3.0,1.6,0.2,Iris-setosa
5.0,3.4,1.6,0.4,Iris-setosa
5.2,3.5,1.5,0.2,Iris-setosa
5.2,3.4,1.4,0.2,Iris-setosa
4.7,3.2,1.6,0.2,Iris-setosa
4.8,3.1,1.6,0.2,Iris-setosa
5.4,3.4,1.5,0.4,Iris-setosa
5.2,4.1,1.5,0.1,Iris-setosa
5.5,4.2,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.0,3.2,1.2,0.2,Iris-setosa
4.4,3.0,1.3,0.2,Iris-setosa
5.1,3.4,1.5,0.2,Iris-setosa
5.0,3.5,1.3,0.3,Iris-setosa
4.5,2.3,1.3,0.3,Iris-setosa
4.6,3.2,1.4,0.2,Iris-setosa
5.3,3.7,1.5,0.2,Iris-setosa
5.0,3.3,1.4,0.2,Iris-setosa
7.0,3.2,4.7,1.4,Iris-versicolor
6.4,3.2,4.5,1.5,Iris-versicolor
6.9,3.1,4.9,1.5,Iris-versicolor
5.5,2.3,4.0,1.3,Iris-versicolor
6.5,2.8,4.6,1.5,Iris-versicolor
5.7,2.8,4.5,1.3,Iris-versicolor
6.3,3.3,4.7,1.6,Iris-versicolor
Practical 2(b) - PKIDiscritize
Filename : pkdiscretizeweather.arff

@RELATION iris

@ATTRIBUTE "sepallength" REAL


@ATTRIBUTE sepalwidth REAL
@ATTRIBUTE petallength REAL
@ATTRIBUTE petalwidth REAL
@ATTRIBUTE class {Iris-setosa,Iris-versicolor,Iris-virginica}

@DATA
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,1.4,0.2,Iris-setosa
4.7,3.2,1.3,0.2,Iris-setosa
4.6,3.1,1.5,0.2,Iris-setosa
5.0,3.6,1.4,0.2,Iris-setosa
5.4,3.9,1.7,0.4,Iris-setosa
4.6,3.4,1.4,0.3,Iris-setosa
5.0,3.4,1.5,0.2,Iris-setosa
4.4,2.9,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.4,3.7,1.5,0.2,Iris-setosa
4.8,3.4,1.6,0.2,Iris-setosa
4.8,3.0,1.4,0.1,Iris-setosa
4.3,3.0,1.1,0.1,Iris-setosa
5.8,4.0,1.2,0.2,Iris-setosa
5.7,4.4,1.5,0.4,Iris-setosa
5.4,3.9,1.3,0.4,Iris-setosa
5.1,3.5,1.4,0.3,Iris-setosa
5.7,3.8,1.7,0.3,Iris-setosa
5.1,3.8,1.5,0.3,Iris-setosa
5.4,3.4,1.7,0.2,Iris-setosa
5.1,3.7,1.5,0.4,Iris-setosa
4.6,3.6,1.0,0.2,Iris-setosa
5.1,3.3,1.7,0.5,Iris-setosa
4.8,3.4,1.9,0.2,Iris-setosa
5.0,3.0,1.6,0.2,Iris-setosa
5.0,3.4,1.6,0.4,Iris-setosa
5.2,3.5,1.5,0.2,Iris-setosa
5.2,3.4,1.4,0.2,Iris-setosa
4.7,3.2,1.6,0.2,Iris-setosa
4.8,3.1,1.6,0.2,Iris-setosa
5.4,3.4,1.5,0.4,Iris-setosa
5.2,4.1,1.5,0.1,Iris-setosa
5.5,4.2,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.0,3.2,1.2,0.2,Iris-setosa
4.4,3.0,1.3,0.2,Iris-setosa
5.1,3.4,1.5,0.2,Iris-setosa
5.0,3.5,1.3,0.3,Iris-setosa
4.5,2.3,1.3,0.3,Iris-setosa
4.6,3.2,1.4,0.2,Iris-setosa
5.3,3.7,1.5,0.2,Iris-setosa
5.0,3.3,1.4,0.2,Iris-setosa
7.0,3.2,4.7,1.4,Iris-versicolor
6.4,3.2,4.5,1.5,Iris-versicolor
6.9,3.1,4.9,1.5,Iris-versicolor
5.5,2.3,4.0,1.3,Iris-versicolor
6.5,2.8,4.6,1.5,Iris-versicolor
5.7,2.8,4.5,1.3,Iris-versicolor
6.3,3.3,4.7,1.6,Iris-versicolor
Filter – choose-unsupervised - Pkidiscretize
Practical 2(c) - Add

Basic difference in layman terms : In supervisedlearning, the output datasets are


provided which are used to train the machine and get the desired outputs
whereas in unsupervised learning no datasets are provided, instead the data is
clustered into different classes .

Filter – choose –unsupervised-addexpression - ^2


Practical 2(d) – Add Expression
Practical 3- Creating an ARFF file

Fig. CSV file created in Microsoft Excel 2007


File Name : sales.arff

@RELATION sales

@ATTRIBUTE Name {Bread,Butter,Cheese}


@ATTRIBUTE Price REAL
@ATTRIBUTE Category {Expensive,Cheap}
@ATTRIBUTE Purchase {yes,no}

@DATA
Bread,10,Cheap,yes
Butter,15,Cheap,no
Bread,20,Expensive,yes
Butter,30,Expensive,no
Cheese,50,Cheap,yes
Cheese,75,Expensive,yes
Cheese,50, Expensive,no
Bread,5,?,?
Butter,25,?,yes
Cheese,95,?,?
Butter,?,Expensive,yes
Cheese,?,Expensive,no
Cheese,?,Expensive,yes
?,75,Expensive,?

Weather.nominal arff
C:\Pooja\ADT
Practical 4 - Study of Association Rules

No. of Rules: 10
=== Run information ===

Scheme: weka.associations.Apriori -N 10 -T 0 -C 0.9 -D 0.05 -U 1.0 -M 0.1 -S -1.0 -c -1

Relation: sales

Instances: 15

Attributes: 4

age

income

profession

buy_comp

=== Associator model (full training set) ===

Apriori

=======

Minimum support: 0.15 (2 instances)

Minimum metric <confidence>: 0.9

Number of cycles performed: 17

Generated sets of large itemsets:

Size of set of large itemsets L(1): 11

Size of set of large itemsets L(2): 30

Size of set of large itemsets L(3): 12

Size of set of large itemsets L(4): 1

Best rules found:

1. age=old 4 ==> profession=retired 4 conf:(1)

2. income=high profession=retired 3 ==> age=old 3 conf:(1)

3. age=old income=high 3 ==> profession=retired 3 conf:(1)

4. income=low profession=retired 3 ==> buy_comp=yes 3 conf:(1)

5. profession=working 2 ==> age=middle 2 conf:(1)

6. profession=working 2 ==> income=medium 2 conf:(1)

7. age=young buy_comp=no 2 ==> profession=student 2 conf:(1)

8. income=medium profession=working 2 ==> age=middle 2 conf:(1)

9. age=middle profession=working 2 ==> income=medium 2 conf:(1)

10. profession=working 2 ==> age=middle income=medium 2 conf:(1)


Iris dataset.Classify – j48 – right click the result list-visualise tree-detailed
accuracy by class n confusion matrix related
Practical 5 - Study of Classification Techniques

Buy_comp.arff

@RELATION sales

@ATTRIBUTE age {young,middle,old}


@ATTRIBUTE income {high,medium,low}
@ATTRIBUTE profession {student,working,retired}
@ATTRIBUTE buy_comp {yes,no}

@data
young,high,student,yes
middle,medium,working,no
old,low,retired,yes
young,medium,student,no
middle,medium,retired,no
old,high,retired,no
young,low,retired,yes
middle,medium,working,yes
old,high,retired,no
young,low,student,no
middle,medium,student,yes
old,high,retired,yes
middle,low,student,yes
middle,high,student,no
middle,low,retired,yes

J48
=== Run information ===

Scheme:weka.classifiers.trees.J48 -C 0.25 -M 2

Relation: sales

Instances: 15

Attributes: 4

age

income

profession

buy_comp
Test mode:10-fold cross-validation

=== Classifier model (full training set) ===

J48 pruned tree

------------------

: yes (15.0/7.0)

Number of Leaves : 1

Size of the tree : 1

Time taken to build model: 0.02 seconds

=== Stratified cross-validation ===

=== Summary ===

Correctly Classified Instances 4 26.6667 %

Incorrectly Classified Instances 11 73.3333 %

Kappa statistic -0.5138

Mean absolute error 0.5762

Root mean squared error 0.6144

Relative absolute error 113.3489 %

Root relative squared error 120.5838 %

Total Number of Instances 15

=== Detailed Accuracy By Class ===

TP Rate FP Rate Precision Recall F-Measure ROC Area Class

0.5 1 0.364 0.5 0.421 0.25 yes

0 0.5 0 0 0 0.25 no

Weighted Avg. 0.267 0.767 0.194 0.267 0.225 0.25

=== Confusion Matrix ===

a b <-- classified as

4 4 | a = yes

7 0 | b = no
ID3
=== Run information ===

Scheme:weka.classifiers.trees.Id3

Relation: sales

Instances: 15

Attributes: 4

age

income

profession

buy_comp

Test mode:10-fold cross-validation

=== Classifier model (full training set) ===

Id3

income = high

| age = young: yes

| age = middle: no

| age = old: no

income = medium

| age = young: no

| age = middle

| | profession = student: yes

| | profession = working: yes

| | profession = retired: no

| age = old: null

income = low

| age = young

| | profession = student: no

| | profession = working: null


| | profession = retired: yes

| age = middle: yes

| age = old: yes

Time taken to build model: 0 seconds

=== Stratified cross-validation ===

=== Summary ===

Correctly Classified Instances 3 20 %

Incorrectly Classified Instances 9 60 %

Kappa statistic -0.5882

Mean absolute error 0.6667

Root mean squared error 0.7906

Relative absolute error 165.8604 %

Root relative squared error 175.5212 %

UnClassified Instances 3 20 %

Total Number of Instances 15

=== Detailed Accuracy By Class ===

TP Rate FP Rate Precision Recall F-Measure ROC Area Class

0.429 1 0.375 0.429 0.4 0.384 yes

0 0.571 0 0 0 0.321 no

Weighted Avg. 0.25 0.821 0.219 0.25 0.233 0.358

=== Confusion Matrix ===

a b <-- classified as

3 4 | a = yes

5 0 | b = no
Practical 6 – Saving & Loading Model

Fig. Saving Model


Fig. Loading Model
********Object Oriented Relational Database*********
8

Practical 7 – Creating Object types


Practical 8 – Table of Objects

Inserting values

Set The Depth For Display


Practical 9 – Manipulating Objects
Practical 10 – Creating Object views
Practical 11(a) – Objects with Methods

Practical 11(b) – Inserting Values & Retrieving Data


Practical 12 – Varrays
Practical 13 – Creating Nested Tables

Inserting & Updating Values in Nested Tables


(find names of doctors who have checked more than 2 patients)
Practical 14 – Referencing & De-referencing Objects
Create & Insert values: lecturers

Create & Insert values: course


De-Referencing Objects
Practical 15 – Method Overloading
Practical 16 – Ranking Functions

Rank
Selecting top 5 ranks based on salary
OLAP
1. Roll Up

2. Cube
Practical 17 – Ranking Functions
(Range partitioning)
SQL> create table partition_by_range
2 (
3 fname varchar2(25),
4 mname varchar2(25),
5 lname varchar2(25),
6 birth_mm int not null,
7 birth_dd int not null,
8 birth_yyyy int not null
9 )
10 PARTITION BY RANGE (BIRTH_YYYY,BIRTH_MM,BIRTH_DD)
11 {
12 PARTITION DOBS_LESS_1971 VALUES LESS THAN(1972,01,01);
13 PARTITION DOBS_LESS_1971 VALUES LESS THAN(1973,01,01);
14 PARTITION DOBS_LESS_1971 VALUES LESS THAN(1974,01,01);
15 PARTITION DOBS_1975_OR_LATER VALUES LESS THAN(MAXVALUE,MAXVALUE,MAXVALUE)
16 }
17 ENABLE ROW MOVEMENT;

Table created.

SQL> insert into partition_by_range values('A','K','GG',11,22,1971);


1 row created.

SQL> insert into partition_by_range values('B','K','DD',11,22,1972);


1 row created.

SQL> insert into partition_by_range values('C','K','EE',11,22,1973);


1 row created.

SQL> insert into partition_by_range values('D','K','FF',11,22,1974);


1 row created.

SQL> insert into partition_by_range values('E','K','CC',11,22,1986);


1 row created.

SQL> insert into partition_by_range values('I','K','RR',11,22,1974);


1 row created.

SQL>_
//select values from partition
Hash Partitioning
Create table and Insert values
SQL> create table partition_by_hash
2 (
3 fname varchar2(20),
4 mname varchar2(20),
5 lname varchar2(20),
6 age number not null
7 )
8 PARTITION BY HASH(AGE)
9 (
10 PARTITION P1_AGE,
11 PARTITION P2_AGE,
13 PARTITION P3_AGE,
14 PARTITION P4_AGE,
15 PARTITION P5_AGE
16 )
17 ENABLE ROW MOVEMENT;

Table created.

SQL> INSERT INTO PARTITION_BY_HASH VALUES('A','KK','HH',1);


1 row created.

SQL> INSERT INTO PARTITION_BY_HASH VALUES('B','KL','II',10);


1 row created.

SQL> INSERT INTO PARTITION_BY_HASH VALUES('C','BB','JJ',20);


1 row created.

SQL> INSERT INTO PARTITION_BY_HASH VALUES('D','CC','KK',30);


1 row created.

SQL> INSERT INTO PARTITION_BY_HASH VALUES('E','DD','LL',40);


1 row created.

SQL> INSERT INTO PARTITION_BY_HASH VALUES('K','EE','MM',100);


1 row created.

SQL> INSERT INTO PARTITION_BY_HASH VALUES('L','FF','NN',22);


1 row created.

SQL>_
DISPLAY OF PARTITION

SQL> SELECT * FROM PARTITION_BY_HASH;

FNAME MNAME LNAME AGE


-------------------- -------------------- -------------------- ----------
A KK HH 1
B KL II 10
C BB JJ 20
D CC KK 30
E DD LL 40
K EE MM 100
L FF NN 22

7 rows selected.

SQL> SELECT * FROM PARTITION_BY_HASH PARTITION(P1_AGE);

FNAME MNAME LNAME AGE


-------------------- -------------------- -------------------- ----------
D CC KK 30

SQL> SELECT * FROM PARTITION_BY_HASH PARTITION(P2_AGE);

FNAME MNAME LNAME AGE


-------------------- -------------------- -------------------- ----------
B KL II 10
L FF NN 22

SQL> SELECT * FROM PARTITION_BY_HASH PARTITION(P2_AGE);

FNAME MNAME LNAME AGE


-------------------- -------------------- -------------------- ----------
C BB JJ 20
K EE MM 100

SQL>_
LIST Partitioning
Creating table

SQL> CREATE TABLE PARTITION_BY_LIST


2 (
3 DEPTID NUMBER,
4 DEPTNAME VARCHAR2(2),
5 STATE VARCHAR2(10)
6 )
7 PARTITION BY LIST(STATE)
8(
9 PARTITION NORTH VALUES(‘DL’,’UP,’JK’,’PUN’);
10 PARTITION WEST VALUES (‘GUJ’,’RAJ,’HH’,’SUN’);
11 PARTITION EAST VALUES(‘WB’,’BH,’AS’,’MI2’);
12 PARTITION SOUTH VALUES(‘KER’,’AP,’KAR’,’TN’);
13 ENABLE ROW MOVEMENT;

Table created.

SQL>_
Inserting Values
Selecting Values

SQL> SELECT * FROM PARTITION_BY_LIST;


DEPTID DE STATE
---------- -- ----------
1 A DL
2 B UP
3 C GUJ
4 D RAJ
5 E BH
6 F WB
7 G AS
8 H KAR
8 rows selected.

SQL>SELECT * FROM PARTITION_BY_LIST PARTITION(EAST);


DEPTID DE STATE
---------- -- ----------
5 E BH
6 F WB
7 G AS

SQL>SELECT * FROM PARTITION_BY_LIST PARTITION(NORTH);


DEPTID DE STATE
---------- -- ----------
1 A DL
2 B UP

SQL>SELECT * FROM PARTITION_BY_LIST PARTITION(WEST);


DEPTID DE STATE
---------- -- ----------
3 C GUJ
4 D RAJ

SQL>SELECT * FROM PARTITION_BY_LIST PARTITION(SOUTH);


DEPTID DE STATE
---------- -- ----------
8 H KAR

You might also like