SlideShare a Scribd company logo
1 of 79
Download to read offline
Data warehouse Design Using Oracle
https://www.oercommons.org/authorin
g/edit/21861
Dr. Girija Narasimhan 1
OER- UNIT 4 PARTITION
PARTITION
TABLESPACE
2Dr.Girija Narasimhan
Oracle Database allocates logical
space for all data in the
database.
The logical units of database
space allocation are data blocks,
extents, segments, and
tablespaces.
At a physical level, the data is
stored in data files on disk
The data in the data files is
stored in operating system
blocks.
3Dr.Girija Narasimhan
Data blocks are the smallest
units storing data in the
oracle database
An extent is a set of logically
contiguous data blocks
allocated for storing a specific
type of information
A segment is a set of extents
allocated for a specific
database object, such as a
table.
Each segment belongs to one
and only one tablespace
4Dr.Girija Narasimhan
The database has one or more table space.
Table space is called as logical storage unit within an oracle
database.
The meaning of logical is table space is not visible in the file
system.
Table space has at least had one data file. Each table space has
unique data file.
Each table space is divided into based on the size mentioned in
the “Create tablespace” statement.
The table space builds the bridge between the oracle database
and the file system in which the table’s or index data is stored
5Dr.Girija Narasimhan
CREATE TABLESPACE dwuser01a
DATAFILE 'c:tempdwuser1a.dbf' SIZE 40M
BLOCKSIZE 8192
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 256K
SEGMENT SPACE MANAGEMENT AUTO ONLINE;
In the Lab session students are sharing single server, then each
user created different dbf file in the c:temp- otherwise “already
.dbf” file exist error will occur.
For example: ‘c:tempuser1.dbf’. .c:tempuser2.dbf’
6Dr.Girija Narasimhan
DROP TABLE SPACE
7Dr.Girija Narasimhan
Dr.Girija Narasimhan 8
You can drop a tablespace and its contents (the segments contained
in the tablespace) from the database if the tablespace and its
contents are no longer required
Once a tablespace has been dropped, the data in the tablespace is
not recoverable.
Therefore, make sure that all data contained in a tablespace to be
dropped will not be required in the future
SQL> drop tablespace ica;
This will drop the tablespace only if it is empty
Dr.Girija Narasimhan 9
Tablespace is not empty and if you want to drop it anyhow then add
the following keyword
SQL>drop tablespace ica including contents;
This will drop the tablespace even if it is not empty.
But the data files will not be deleted you have to use operating
system command to delete the files.
But If you include data files keyword then, the associated data files
will also be deleted from the disk.
SQL>drop tablespace ica including contents and
datafiles;
various types of partition
10Dr.Girija Narasimhan
Dr.Girija Narasimhan 11
CREATE TABLE <Table name>
RANGE PARTITION LIST
PARTITION
HASH
PARTITION
RANGE PARTITION
Using Number Values
RANGE PARTITION
Using Alphabet Values
RANGE PARTITION
Using DATE Values
Partition Type Partition
Type
Partition Type
COMPOSITE
PARTITION
12Dr.Girija Narasimhan
RANGE PARTITION
Using Number Values
13Dr.Girija Narasimhan
Dr.Girija Narasimhan 14
create table interval_part(pid number(5) not null,
fname varchar2(30),
lname varchar2(30) )
partition by range(pid)
(
partition p1 values less than(101)
)
tablespace dwuser01a;
Insert into INTERVAL_PART values(100,’Ali’,’Ahmed’);
Insert into INTERVAL_PART values(101,’Zahra’,’Khamis’);
PARTITION TYPE
PARTITION NAME
COLUMN NAME
Insert values into the interval_part and check whether the records are storing in the assign
partition
As per given condition, the maximum value is 100, it will store only the first record only. It
will give error message, for the value of product id 101 no partition was assigned
Dr.Girija Narasimhan 15
SELECT PARTITION_NAME, TABLESPACE_NAME, HIGH_VALUE FROM USER_TAB_PARTITIONS;
PARTITION_NAME TABLESPACE_NAME HIGH_VALUE
-----------------------------------------------------------------------------
P1 dwuser01a 101
SELECT * FROM INTERVAL_PART PARTITION(P1);
PID FNAME LNAME
---------- --------------- -----------------
100 Ali Ahmed
Insert into interval_part values(101,'zahra','khamis')
*
ERROR at line 1:
ORA-14400: inserted partition key does not map to any
partition
The USER_TAB_PARTITIONS describes the partition information as name of the
partition, tablespace name, storage parameter or value range of the partition .
Display the values stored in the partition.
RANGE PARTITION
Using Alphabet Values
16Dr.Girija Narasimhan
Dr.Girija Narasimhan 17
Create table product_alpha(Pid number(4) primary key , pname
varchar2(25),pcategory varchar2(20))
PARTITION BY RANGE(pcategory)(
Partition pcategoy_ae VALUES LESS THAN(‘F%’) TABLESPACE part1,
Partition pcategoy_fl VALUES LESS THAN(‘M%’) TABLESPACE part2,
Partition pcategoy_mr VALUES LESS THAN(‘S%’) TABLESPACE part3,
Partition pcategoy_sz VALUES LESS THAN(MAXVALUE) TABLESPACE part4);
Range partition using partition key based on character based values.
This type of partition is useful for based on location name, country
and supplier based analysis in the data warehousing.
This is the alternative to numeric based values.
It will store the values “a,b,c,d,e”
It will store the exceed
values of all the partition
Store each partition in
different tablespace
Dr.Girija Narasimhan 18
SELECT PARTITION_NAME,TABLESPACE_NAME,HIGH_VALUE FROM
USER_TAB_PARTITIONS;
PARTITION_NAME TABLESPACE_NAME HIGH_VALUE
----------------------------- -------------------------------- -------------------
PCATEGOY_SZ PART4 MAXVALUE
PCATEGOY_AE PART1 'F%'
PCATEGOY_FL PART2 'M%'
PCATEGOY_MR PART3 'S%‘
Insert into Product_alpha values(100,’Sony LCD 32”’,’TV’);
Insert into Product_alpha values(200,’Sony POWER SHOT’,’CAMERA’);
Insert into Product_alpha values(300,’Sony 3G Dual SIM’,’MOBILE’);
Insert into product_alpha values(400,’Cannon Digit power’,’DIGITAL CAMERA’);
Dr.Girija Narasimhan 19
SELECT * FROM Product_alpha PARTITION(PCATEGOY_AE);
PID PNAME PCATEGORY
---------- --------------------------- --------------------
200 Sony POWER SHOT CAMERA
400 Cannon Digit power DIGITAL CAMERA
SELECT * FROM Product_alpha PARTITION(PCATEGOY_FL);
no rows selected
SELECT * FROM Product_alpha PARTITION(PCATEGOY_MR);
PID PNAME PCATEGORY
---------- ------------------------- --------------------
300 Sony 3G Dual SIM MOBILE
SELECT * FROM Product_alpha PARTITION(PCATEGOY_SZ);
PID PNAME PCATEGORY
--------- ------------------------- --------------------
100 Sony LCD 32” TV
RANGE PARTITION
Using DATE Values
20Dr.Girija Narasimhan
Dr.Girija Narasimhan 21
CREATE TABLE Productrange_date (
Pid number(4) Primary key,pname varchar2(25),expdate date NOT Null)
PARTITION BY RANGE(expdate)(
PARTITION yr0 VALUES LESS THAN (TO_DATE('01-JAN-2007','DD-MON-YYYY')) TABLESPACE part1,
PARTITION yr1 VALUES LESS THAN (TO_DATE('01-JAN-2008','DD-MON-YYYY')) TABLESPACE part2,
PARTITION yr2 VALUES LESS THAN (TO_DATE('01-JAN-2009','DD-MON-YYYY')) TABLESPACE part3,
PARTITION yr3 VALUES LESS THAN (MAXVALUE) TABLESPACE part4);
INSERT INTO Productrange_date VALUES (1001, ‘Orange’, ’21-MAY-08’);
INSERT INTO Productrange_date VALUES (1002, ‘Sugar’, ’16-MAY-09’);
INSERT INTO Productrange_date VALUES (1003, ‘Biscutt’, ’12-NOV-09’);
SQL> select * from productrange_date;
PID PNAME EXPDATE
---------- ------------------------- -------------
1001 Orange 21-MAY-08
1002 Sugar 16-MAY-09
1003 Biscutt 12-NOV-09
The partition key in the range partition to be Date based.
It is useful for analyzing table data week wise or day wise.
Store values upto 31-dec-2006
Dr.Girija Narasimhan 22
SELECT * FROM productrange_date PARTITION(yr1);
no rows selected
SELECT * FROM productrange_date PARTITION(yr2);
PID PNAME EXPDATE
---------- -- ------------- -------------
1001 Orange 21-MAY-08
SELECT * FROM productrange_date PARTITION(yr3);
PID PNAME EXPDATE
--------- --------------- -------------
1002 Sugar 16-MAY-09
1003 Biscutt 12-NOV-09
ALTER TABLE
ADD PARTITION
23Dr.Girija Narasimhan
Dr.Girija Narasimhan 24
ALTER TABLE <Table name>
ADD PARTITION
RANAME PARTITION
DROP PARTITION
MERGE PARTITION
ADD PARTITION
Using Alter table – ADD Partition statement, it is possible to
insert new partition details of already existed partition
Alter table INTERVAL_PART
ADD partition p2 values less than(201);
SELECT PARTITION_NAME,TABLESPACE_NAME,HIGH_VALUE FROM
USER_TAB_PARTITIONS;
PARTITION_NAME TABLESPACE_NAME HIGH_VALUE
-------------------------- ---------------- -----------------
P1 UWDATA 101
P2 UWDATA 201
SELECT * FROM INTERVAL_PART partition(P1);
PID FNAME LNAME
---------- ------------------------- --------------
100 Ali Ahmed
SELECT * FROM INTERVAL_PART partition(P2);
PID FNAME LNAME
---------- ------------------------- --------------
101 Zahra Khamis
200 Mohammed Omar
Insert into INTERVAL_PART values(101,'zahra','khamis');
Insert into INTERVAL_PART values(200,'Mohammed','omar');
SELECT * FROM INTERVAL_PART;
PID FNAME LNAME
---------- ------------------------- --------------
100 Ali Ahmed
101 Zahra Khamis
200 Mohammed Omar
ALTER TABLE
RENAME PARTITION
27Dr.Girija Narasimhan
ALTER TABLE INTERVAL_PART
RENAME PARTITION P1 TO P9;
SQL> SELECT partition_name FROM user_tab_partitions WHERE
PARTITION_NAME='P9';
PARTITION_NAME
--------------------------
P9
SQL> SELECT * FROM INTERVAL_PART partition(P9);
PID FNAME LNAME
---------- -------------- ---------------
100 Ali Ahmed
ALTER TABLE
MERGE PARTITION
29Dr.Girija Narasimhan
Dr.Girija Narasimhan 30
SELECT * FROM productrange_date PARTITION(yr2);
PID PNAME EXPDATE
---------- -- ------------- -------------
1001 Orange 21-MAY-08
SELECT * FROM productrange_date PARTITION(yr3);
PID PNAME EXPDATE
--------- --------------- -------------
1002 Sugar 16-MAY-09
1003 Biscutt 12-NOV-09
Alter table productrange_date merge partitions yr2,yr3
into partition yr6;
SELECT * FROM productrange_date PARTITION(yr6)
PID PNAME EXPDATE
--------- ------------------ ---------
1001 Orange 22-MAY-08
1002 Sugar 16-MAY-09
1003 Biscutt 12-NOV-09
Merge partition
creates a new
partition called yr6
It copies the values
from yr2 and yr3
ALTER TABLE
DROP PARTITION
31Dr.Girija Narasimhan
Dr.Girija Narasimhan 32
Alter table Product_alpha drop partition pcategoy_ae;
SELECT * FROM Product_alpha PARTITION(PCATEGOY_AE);
PID PNAME PCATEGORY
---------- --------------------------- --------------------
200 Sony POWER SHOT CAMERA
400 Cannon Digit power DIGITAL CAMERA
SELECT * FROM Product_alpha;
PID PNAME PCATEGORY
---------- ----------------------------- --------------------
200 Sony POWER SHOT CAMERA
400 Cannon Digit power DIGITAL CAMERA
300 Sony 3G Dual SIM MOBILE
100 Sony LCD 32" TV
Dr.Girija Narasimhan 33
SELECT * FROM Product_alpha;
PID PNAME PCATEGORY
---------- ----------------------------- --------------------
300 Sony 3G Dual SIM MOBILE
100 Sony LCD 32" TV
it merely updates the data dictionary to indicate that the
pcategoy_AE partition no longer belongs to the
Product_alpha table.
It also remove the partition values from the table.
LIST PARTITION
34Dr.Girija Narasimhan
Dr.Girija Narasimhan 35
The syntax of list partition is three parts:
1) partition method: Partition by list
2) Specify the partition column, example (slocation)
3) Partition description: Partition “partition_name” values (list of values)
list partition is organizing the data allows unordered and unrelated
sets of data to be grouped and organized together.
It is controls each and every row values and mapping with partition
CREATE TABLE STORE_LIST(
STORENO NUMBER(5)PRIMARY KEY,STORENAME VARCHAR2(20),
SPROFIT NUMBER(5),SLOCATION VARCHAR2(15),SDATE DATE)
PARTITION BY LIST (SLOCATION)
(
PARTITION LOC_Muscat VALUES(‘Al-khuwair’,’Ruwi’),
PARTITION LOC_Al Batinah VALUES(‘Barka’, ‘Musannah’),
PARTITION LOC_Dakhliyah VALUES(‘Nizwa’,’ Sumail’));
Dr.Girija Narasimhan 36
SELECT * FROM STORE_LIST;
STORENO STORENAME SPROFIT SLOCATION SDATE
-----------------------------------------------------------
11 RELIANCE FRESH 5000 Al-khuwair 10-APR-09
13 SPENCER PLAZA 6000 Nizwa 18-DEC-05
12 RELIANCE FRESH 4500 Barka 12-SEP-07
15 Apollo Medical 3000 Musanna 21-JUN-06
14 Apollo Medical 8000 Ruwi 24-DEC-08
SELECT * FROM STORE_LIST PARTITION(LOC_Muscat);
STORENO STORENAME SPROFIT SLOCATION SDATE
-----------------------------------------------------------
11 RELIANCE FRESH 5000 Al-khuwair 10-APR-09
14 Apollo Medical 8000 Ruwi 24-DEC-08
SELECT * FROM STORE_LIST PARTITION(LOC_Al_Batinah);
STORENO STORENAME SPROFIT SLOCATION SDATE
-----------------------------------------------------------
12 RELIANCE FRESH 4500 Barka 12-SEP-07
15 Apollo Medical 3000 Musanna 21-JUN-06
SELECT * FROM STORE_LIST PARTITION(LOC_Dakhliyah);
STORENO STORENAME SPROFIT SLOCATION SDATE
-----------------------------------------------------------
13 SPENCER PLAZA 6000 Nizwa 18-DEC-05
LIST PARTITION
ADD PARTITION USING “DEFAULT” VALUE
37Dr.Girija Narasimhan
Dr.Girija Narasimhan 38
The special capability of list partition is default partition.
The benefit of using default partition is, it don’t generate an
error suppose all rows don’t map with any partition in the list.
Using alter table statement, it is possible to add new partition
in the already existed list partition.
ALTER TABLE STORE_LIST
ADD PARTITION LOC_OTHER
VALUES(DEFAULT)TABLESPACE PART4;
INSERT INTO STORE_LIST VALUES(16,'SPENCER PLAZA',4300,
‘Salalah',’29-MAY-2004’);
SELECT * FROM STORE_LIST PARTITION(LOC_OTHER);
STORENO STORENAME SPROFIT SLOCATION SDATE
-------- -------------- -------- ---------- --------
16 SPENCER PLAZA 4300 Salalah 29-MAY-04
ALTER TABLE
MODIFY PARTITION
ADD “List values”
39Dr.Girija Narasimhan
Dr.Girija Narasimhan 40
ALTER TABLE <table Name> MODIFY PARTITION
ADD “List values”
It will add new values in the already existing
partition.
Like update statement, it will change the
specific values of the table
DROP “List values”
Remove the specific value from the already
existing partition.
Like delete statement, how it will delete
specific information from the table.
Values of the partition
Dr.Girija Narasimhan 41
ALTER TABLE STORE_LIST MODIFY PARTITION LOC_Muscat
ADD VALUES (' Bowsher ', ' Seeb ');
INSERT INTO STORE_LIST VALUES(17,'SPENCER PLAZA',3300, 'seeb',’02-APR-2004’);
SELECT * FROM STORE_LIST PARTITION(LOC_Muscat);
STORENO STORENAME SPROFIT SLOCATION SDATE
---------- -------------------- ------------- ------------------ -------------
11 RELIANCE FRESH 5000 Al-khuwair 10-APR-09
14 Apollo Medical 8000 Ruwi 24-DEC-08
17 SPENCER PLAZA 3300 seeb 02-APR-04
In the list partition “LOC_MUSCAT” partition had values “SEEB,
BOWSHER”.
Suppose to change already existed list value in the list partition,
use ALTER TABLE –MODIFY statement to change the new values.
ALTER TABLE
MODIFY PARTITION
DROP “List values”
42Dr.Girija Narasimhan
Dr.Girija Narasimhan 43
Suppose to remove particular list value from the partition, that
partition has the specific values then oracle trigger the error.
The partition doesn’t have that values or data then error free.
Avoiding the error message, first delete the specific values in the
partition and then drop the values from the list partition.
ALTER TABLE STORE_LIST
MODIFY PARTITION LOC_Muscat
DROP VALUES(‘Ruwi’);
ERROR at line 1:
ORA-14518: partition contains rows corresponding to values being
dropped
Delete from store_list where storeno=14
ALTER TABLE STORE_LIST
MODIFY PARTITION LOC_Muscat
DROP VALUES (‘Ruwi’);
TRUNCATE PARTITION
44Dr.Girija Narasimhan
Dr.Girija Narasimhan 45
Truncate statement delete all the values in the mentioned partition.
So, partition which is truncated is empty or without any value. So
error don’t occur like drop values.
But it will retain the Partition without values.
Alter table STORE_LIST truncate partition LOC_Muscat DROP STORAGE;
select * from store_list;
STORENO STORENAME SPROFIT SLOCATION SDATE
---------- -------------------- ---------- --------------------------
13 SPENCER PLAZA 6000 Nizwa 18-DEC-05
12 RELIANCE FRESH 4500 Barka 12-SEP-07
15 Apollo Medical 3000 Musanna 21-JUN-06
16 SPENCER PLAZA 4300 Salalah 29-MAY-04
MOVE PARTITION
46Dr.Girija Narasimhan
Dr.Girija Narasimhan 47
ALTER TABLE products MOVE PARTITION PARTNO1 TABLESPACE
uwdata;
select tablespace_name,partition_name from
user_tab_partitions where table_name='PRODUCTS';
TABLESPACE_NAME PARTITION_NAME
------------------------------ ------------------------
UWDATA PARTNO1
PART2 PARTNO2
PART3 PARTNO3
select tablespace_name,partition_name from
user_tab_partitions where table_name='PRODUCTS';
TABLESPACE_NAME PARTITION_NAME
------------------------------ ------------------------
PART1 PARTNO1
PART2 PARTNO2
PART3 PARTNO3
Here tablespace name is case sensitive. Now “PARTNO1” partition is moved
from tablespace “PART1” to “UMDATA”.
It will move the most active partition to a tablespace. It also create new segment for
the tablespace for the moving partition and it also drops the moved partition's
Previous segment.
SPLIT PARTITION
48Dr.Girija Narasimhan
Dr.Girija Narasimhan 49
It splits the partition into more than one and also move the
specified values into corresponding split partition
SELECT * FROM STORE_LIST PARTITION(LOC_OTHER);
STORENO STORENAME SPROFIT SLOCATION SDATE
--------------------------------- -------------------------
16 SPENCER PLAZA 4300 Salalah 29-MAY-04
18 Apollo Medical 8000 Ibra 24-DEC-08
19 Apollo Medical 3000 Ibra 21-JUN-06
20 SPENCER PLAZA 4300 Shinas 29-MAY-04
21 SPENCER PLAZA 4300 Amrath 29-MAY-04
ALTER TABLE STORE_LIST
SPLIT PARTITION LOC_OTHER VALUES('Ibra')
INTO (PARTITION LOC_Ibra,PARTITION LOC_OTHER);
Dr.Girija Narasimhan 50
SELECT * FROM STORE_LIST PARTITION(LOC_Ibra);
STORENO STORENAME SPROFIT SLOCATION SDATE
---------- ------------------------------------------------
18 Apollo Medical 8000 Ibra 24-DEC-08
19 Apollo Medical 3000 Ibra 21-JUN-06
SELECT * FROM STORE_LIST PARTITION(LOC_OTHER);
STORENO STORENAME SPROFIT SLOCATION SDATE
---------- ------------------------------------------------
16 SPENCER PLAZA 4300 Salalah 29-MAY-04
20 SPENCER PLAZA 4300 Shinas 29-MAY-04
21 SPENCER PLAZA 4300 Amrath 29-MAY-04
HASH PARTITION
51Dr.Girija Narasimhan
Dr.Girija Narasimhan 52
Hash partition is using hashing algorithm.
The key feature of hashing algorithm into it evenly distributes rows
among partitions, so all the partitions are almost the same size.
This feature is useful for spreading the data into sufficient number of
devices to maximizing the I/O devices.
The oracle database uses a linear hashing algorithm.
Suppose any add or merge a hashed partition, the oracle
automatically rearranges the rows within the partition and sub
partition.
Dr.Girija Narasimhan 53
CREATE TABLE products(partno NUMBER,
description VARCHAR2 (60))
PARTITION BY HASH (partno)
(PARTITION partno1 TABLESPACE part1,
PARTITION partno2 TABLESPACE part2,
PARTITION partno3 TABLESPACE part3,
PARTITION partno4 TABLESPACE part4);
Insert into products values(11,’ice cream’);
Insert into products values(12,’coffee’);
Insert into products values(13,’tea’);
Insert into products values(14,’sugar’);
Dr.Girija Narasimhan 54
SELECT * FROM products partition(partno1);
PARTNO DESCRIPTION
---------- ------------------------------------
11 ice cream
13 tea
SELECT * FROM products partition(partno2);
PARTNO DESCRIPTION
---------- -----------------------------------
12 coffee
SELECT * FROM products partition(partno4);
PARTNO DESCRIPTION
---------- -----------------------------------
14 sugar
HASH PARTITION
Using Coalescing
55Dr.Girija Narasimhan
Dr.Girija Narasimhan 56
Select table_name, partition_name from
user_tab_partitions where TABLE_NAME='PRODUCTS';
TABLE_NAME PARTITION_NAME
------------------------------ ------------------------
PRODUCTS PARTNO1
PRODUCTS PARTNO2
PRODUCTS PARTNO3
PRODUCTS PARTNO4
SELECT * FROM products partition(partno4);
PARTNO DESCRIPTION
---------- -------------------------------------------
14 sugar
SELECT * FROM products partition(partno2);
PARTNO DESCRIPTION
---------- --------------------------------------
12 coffee
Dr.Girija Narasimhan 57
Coalescing partitions is a way of reducing
the number partitions in a hash-partitioned
table.
When a hash partition is coalesced, its
contents are redistributed into one or more
remaining partitions determined by the hash
function.
The specific partition that is coalesced is
selected by oracle, and is dropped after
its contents have been redistributed.
Dr.Girija Narasimhan 58
ALTER TABLE PRODUCTS COALESCE PARTITION;
SQL> Select table_name, partition_name from
user_tab_partitions where TABLE_NAME='PRODUCTS';
TABLE_NAME PARTITION_NAME
------------------------------ ----------------------
PRODUCTS PARTNO1
PRODUCTS PARTNO2
PRODUCTS PARTNO3
SQL> SELECT * FROM products partition(partno2);
PARTNO DESCRIPTION
---------- ------------------------------------------
12 coffee
14 sugar
Here PARTNO4 is dropped and PARTNO4 partition values are distributed into
PARTNO2 partition.
Compare
Truncate, Drop list values, Drop,Coalsec
59Dr.Girija Narasimhan
Dr.Girija Narasimhan 60
Truncate
Partition
Drop Partition
coalesce
Drop List value
It retains the
partition, but
deletes all
values from the
partition or from
the table. So,
partition
without any
value or empty.
It will drop partition and
the values also.
It will delete the
partition and
redistribute the
value to other
partition.
Suppose coalesce
partition p1, then
it will
redistributed the
p1 values or
information to
another partition
p2.
In the List partition, For
example
Loc_Muscat (‘Ruwi’,’Seeb’). I
want to delete only Ruwi
value. Suppose any one
record or row in the partition
have ruwi value.
Step1: delete the record
having ‘ruwi’ value from the
table. otherwise it will give
error.
Step 2: alter table modify
partition drop values (ruwi) .
COMPOSITE PARTITION
61Dr.Girija Narasimhan
62Dr.Girija Narasimhan
The types of composite partitioning are:
 Composite Range-Range Partitioning
 Composite Range-Hash Partitioning
 Composite Range-List Partitioning
 Composite List-Range Partitioning
 Composite List-Hash Partitioning
 Composite List-List Partitioning
 Composite Hash-Hash Partitioning
 Composite Hash-List Partitioning
 Composite Hash-Range Partitioning
Composite partitioning is a combination of the two partition method. Table is partitioned by
one data distribution method for example Range Partition. Each partition is further
subdivided into another Partition method for example List.
63Dr.Girija Narasimhan
Conn hr/hr
CREATE TABLE STORE_COMPOSITLIST(
STORENO NUMBER(5)PRIMARY KEY,STORENAME VARCHAR2(20),
SPROFIT NUMBER(5),SLOCATION VARCHAR2(15),SDATE DATE)
PARTITION BY RANGE(STORENO)
SUBPARTITION BY LIST (SLOCATION)
SUBPARTITION TEMPLATE(
SUBPARTITION LOC_Muscat VALUES (‘Al-khuwair’,’Ruwi’) TABLESPACE part1
SUBPARTITION LOC_Dakhliyah VALUES (‘Nizwa’,’Sumail’)TABLESPACE part1)
(
partition p1 values less than(13),
partition p2 values less than(maxvalue));
Composite Partitioned Table - By
Range And List
CREATE TABLESPACE part1
DATAFILE 'c:temppart1.dbf' SIZE 40M
BLOCKSIZE 8192
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 256K
SEGMENT SPACE MANAGEMENT AUTO ONLINE;
Conn sys as sysdba
sys
Dr.Girija Narasimhan 64
• Partition Type : RANGE
• Partition Key column: STORENO
• Sub partition Type: LIST
• Sub partition key column : SLOCATION
• Sub partition: LOC_Muscat , LOC_Dakhliyah
• Sub partition Values :
LOC_Muscat VALUES (‘Al-khuwair’,’Ruwi’)
LOC_Dakhliyah VALUES (‘Nizwa’,’Sumail’)
• Partition Name and Values: p1 (value <13), p2 (Maxvalue)
Components of composite partition
Dr.Girija Narasimhan 65
set linesize 450;
SELECT table_name, partition_name, composite, high_value
FROM user_tab_partitions;
insert into store_compositlist values(11,'Reliance Fresh',500,'Al-khuwair','10-apr-17');
insert into store_compositlist values(12,'Reliance Fresh',450,'Sumail','12-sep-17');
insert into store_compositlist values(13,'Spencer Plaza',600,'Nizwa','11-Nov-17');
insert into store_compositlist values(14, 'Apollo Medical',300,'Ruwi','21-Jun-17');
insert into store_compositlist values(15,'Apollo Medical',800,'Ruwi','27-may-17');
Display the partition Information
Dr.Girija Narasimhan 66
SELECT table_name, partition_name, subpartition_name,
num_rows FROM user_tab_subpartitions;
Display the sub partition information
Here Num_rows column is empty. For getting values in the Num_rows column analyze the
statistics.
Dr.Girija Narasimhan 67
Display the Partition values in the partition P1 and P2
Dr.Girija Narasimhan 68
Display the Sub Partition values, don’t give sub partition name, then it will give error
message. <partition name> _<subpartition name> in the select statement
69Dr.Girija Narasimhan
PARTITIONED INDEX
Dr.Girija Narasimhan 70
Local Partitioned Index
Global Partitioned Index
Partitioned Indexes
Dr.Girija Narasimhan
71
Partitioned Indexes
Local Index Global Index
one-to-one mapping between a index
partition and a table partition
(equipartitioned)
created with the LOCAL keyword and support
partition independence
one-to-many relationship, allowing one index
partition to map to many table partitions
number of index partitions will match the
number of partitions in the base table.
index partition gets deleted when the
underlying table partition dropped, can’t
drop partition index
Drop a non-empty global index partition will
cause the next highest partition to be marked
unusable.
Column mentioned in the partition index is
not primary key column but it must be “NOT
NULL” column.
Local Non-Prefixed
Indexes
Local Prefixed Indexes
indexed column does not
match the partition key
indexed column match
the partition key
At least one partition should have MAX
VALUE
Global Index don’t have Non-
prefixed Indexes
Dr.Girija Narasimhan 72
CREATE INDEX <index_name>
ON <table_name> <column_name_list>
LOCAL
Partition(partition name);
The primary key column not allowed for indexing
Same partition name as given in the
table.
Local Index
Dr.Girija Narasimhan 73
Local
Prefixed
Indexes
Dr.Girija Narasimhan 74
Local Non-
Prefixed
Indexes
Display the Status of the partition index
Dr.Girija Narasimhan 75
Dropping the Partition from the Local index is not allowed.
Instead of dropping from index, drop the partition from the table, it automatically drop
the partition from the index.
Dr.Girija Narasimhan 76
Global Index
In the global
index max
value should
be include in
partition.
Dr.Girija Narasimhan 77
Display the status of the global index
Unlike local index, it is possible to remove or drop partition from the global index
Dr.Girija Narasimhan 78
Entire global index can’t be rebuild, only specific partition to be rebuild is possible.
Partition name actual name given in
the index no need to mention
indexname_partition name.
Dr.Girija Narasimhan 79
https://www.morganslibrary.org/reference/partitions.html#rlp
http://www.acehints.com/2011/06/global-index-vs-local-index-difference.html
https://oracle-base.com/articles/8i/partitioned-tables-and-indexes
References

More Related Content

What's hot

Understanding SAS Data Step Processing
Understanding SAS Data Step ProcessingUnderstanding SAS Data Step Processing
Understanding SAS Data Step Processingguest2160992
 
Data Warehouse and Business Intelligence - Recipe 1
Data Warehouse and Business Intelligence - Recipe 1Data Warehouse and Business Intelligence - Recipe 1
Data Warehouse and Business Intelligence - Recipe 1Massimo Cenci
 
Trivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried Färber
Trivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried FärberTrivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried Färber
Trivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried FärberTrivadis
 
Sas-training-in-mumbai
Sas-training-in-mumbaiSas-training-in-mumbai
Sas-training-in-mumbaiUnmesh Baile
 
Data Warehouse and Business Intelligence - Recipe 3
Data Warehouse and Business Intelligence - Recipe 3Data Warehouse and Business Intelligence - Recipe 3
Data Warehouse and Business Intelligence - Recipe 3Massimo Cenci
 
Introduction to SAS Data Set Options
Introduction to SAS Data Set OptionsIntroduction to SAS Data Set Options
Introduction to SAS Data Set OptionsMark Tabladillo
 
SQL Server 2008 Performance Enhancements
SQL Server 2008 Performance EnhancementsSQL Server 2008 Performance Enhancements
SQL Server 2008 Performance Enhancementsinfusiondev
 
New T-SQL Features in SQL Server 2012
New T-SQL Features in SQL Server 2012 New T-SQL Features in SQL Server 2012
New T-SQL Features in SQL Server 2012 Richie Rump
 
MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017Dave Stokes
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive TechandMate
 
Oracle basic queries
Oracle basic queriesOracle basic queries
Oracle basic queriesPRAKHAR JHA
 
BIS06 Physical Database Models
BIS06 Physical Database ModelsBIS06 Physical Database Models
BIS06 Physical Database ModelsPrithwis Mukerjee
 
ata Warehouse and Business Intelligence - Recipe 7 - A messaging system for O...
ata Warehouse and Business Intelligence - Recipe 7 - A messaging system for O...ata Warehouse and Business Intelligence - Recipe 7 - A messaging system for O...
ata Warehouse and Business Intelligence - Recipe 7 - A messaging system for O...Massimo Cenci
 
SAS Proc SQL
SAS Proc SQLSAS Proc SQL
SAS Proc SQLguest2160992
 
MIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresMIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresSteven Johnson
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsAshwin Dinoriya
 
ETL Patterns with Postgres
ETL Patterns with PostgresETL Patterns with Postgres
ETL Patterns with PostgresMartin Loetzsch
 
Oracle Data Redaction
Oracle Data RedactionOracle Data Redaction
Oracle Data RedactionAlex Zaballa
 
Base SAS Statistics Procedures
Base SAS Statistics ProceduresBase SAS Statistics Procedures
Base SAS Statistics Proceduresguest2160992
 

What's hot (20)

Understanding SAS Data Step Processing
Understanding SAS Data Step ProcessingUnderstanding SAS Data Step Processing
Understanding SAS Data Step Processing
 
Data Warehouse and Business Intelligence - Recipe 1
Data Warehouse and Business Intelligence - Recipe 1Data Warehouse and Business Intelligence - Recipe 1
Data Warehouse and Business Intelligence - Recipe 1
 
Trivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried Färber
Trivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried FärberTrivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried Färber
Trivadis TechEvent 2017 SQL Server 2016 Temporal Tables by Willfried Färber
 
Sas cheat
Sas cheatSas cheat
Sas cheat
 
Sas-training-in-mumbai
Sas-training-in-mumbaiSas-training-in-mumbai
Sas-training-in-mumbai
 
Data Warehouse and Business Intelligence - Recipe 3
Data Warehouse and Business Intelligence - Recipe 3Data Warehouse and Business Intelligence - Recipe 3
Data Warehouse and Business Intelligence - Recipe 3
 
Introduction to SAS Data Set Options
Introduction to SAS Data Set OptionsIntroduction to SAS Data Set Options
Introduction to SAS Data Set Options
 
SQL Server 2008 Performance Enhancements
SQL Server 2008 Performance EnhancementsSQL Server 2008 Performance Enhancements
SQL Server 2008 Performance Enhancements
 
New T-SQL Features in SQL Server 2012
New T-SQL Features in SQL Server 2012 New T-SQL Features in SQL Server 2012
New T-SQL Features in SQL Server 2012
 
MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
 
Oracle basic queries
Oracle basic queriesOracle basic queries
Oracle basic queries
 
BIS06 Physical Database Models
BIS06 Physical Database ModelsBIS06 Physical Database Models
BIS06 Physical Database Models
 
ata Warehouse and Business Intelligence - Recipe 7 - A messaging system for O...
ata Warehouse and Business Intelligence - Recipe 7 - A messaging system for O...ata Warehouse and Business Intelligence - Recipe 7 - A messaging system for O...
ata Warehouse and Business Intelligence - Recipe 7 - A messaging system for O...
 
SAS Proc SQL
SAS Proc SQLSAS Proc SQL
SAS Proc SQL
 
MIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome MeasuresMIS5101 WK10 Outcome Measures
MIS5101 WK10 Outcome Measures
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and Joins
 
ETL Patterns with Postgres
ETL Patterns with PostgresETL Patterns with Postgres
ETL Patterns with Postgres
 
Oracle Data Redaction
Oracle Data RedactionOracle Data Redaction
Oracle Data Redaction
 
Base SAS Statistics Procedures
Base SAS Statistics ProceduresBase SAS Statistics Procedures
Base SAS Statistics Procedures
 

Similar to OER UNIT 4 PARTITION

Sql for dbaspresentation
Sql for dbaspresentationSql for dbaspresentation
Sql for dbaspresentationoracle documents
 
Ground Breakers Romania: Explain the explain_plan
Ground Breakers Romania: Explain the explain_planGround Breakers Romania: Explain the explain_plan
Ground Breakers Romania: Explain the explain_planMaria Colgan
 
Introduction to Oracle Database.pptx
Introduction to Oracle Database.pptxIntroduction to Oracle Database.pptx
Introduction to Oracle Database.pptxSiddhantBhardwaj26
 
Sap abap material
Sap abap materialSap abap material
Sap abap materialKranthi Kumar
 
Part3 Explain the Explain Plan
Part3 Explain the Explain PlanPart3 Explain the Explain Plan
Part3 Explain the Explain PlanMaria Colgan
 
Basics on SQL queries
Basics on SQL queriesBasics on SQL queries
Basics on SQL queriesKnoldus Inc.
 
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)Michael Rys
 
Stack It And Unpack It
Stack It And Unpack ItStack It And Unpack It
Stack It And Unpack ItJeff Moss
 
MySQL Indexes
MySQL IndexesMySQL Indexes
MySQL IndexesAnton Zhukov
 
Page Cache in Linux 2.6.pdf
Page Cache in Linux 2.6.pdfPage Cache in Linux 2.6.pdf
Page Cache in Linux 2.6.pdfycelgemici1
 
vFabric SQLFire Introduction
vFabric SQLFire IntroductionvFabric SQLFire Introduction
vFabric SQLFire IntroductionJags Ramnarayan
 
15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performanceguest9912e5
 
Sql server lesson5
Sql server lesson5Sql server lesson5
Sql server lesson5Ala Qunaibi
 
Less08 Schema
Less08 SchemaLess08 Schema
Less08 Schemavivaankumar
 
Sql server lesson7
Sql server lesson7Sql server lesson7
Sql server lesson7Ala Qunaibi
 
Unit 4 data storage and querying
Unit 4   data storage and queryingUnit 4   data storage and querying
Unit 4 data storage and queryingRavindran Kannan
 
lovely
lovelylovely
lovelylove0323
 

Similar to OER UNIT 4 PARTITION (20)

Sql for dbaspresentation
Sql for dbaspresentationSql for dbaspresentation
Sql for dbaspresentation
 
Ground Breakers Romania: Explain the explain_plan
Ground Breakers Romania: Explain the explain_planGround Breakers Romania: Explain the explain_plan
Ground Breakers Romania: Explain the explain_plan
 
Introduction to Oracle Database.pptx
Introduction to Oracle Database.pptxIntroduction to Oracle Database.pptx
Introduction to Oracle Database.pptx
 
Sap abap material
Sap abap materialSap abap material
Sap abap material
 
Part3 Explain the Explain Plan
Part3 Explain the Explain PlanPart3 Explain the Explain Plan
Part3 Explain the Explain Plan
 
Basics on SQL queries
Basics on SQL queriesBasics on SQL queries
Basics on SQL queries
 
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
Tuning and Optimizing U-SQL Queries (SQLPASS 2016)
 
w_dzon05
w_dzon05w_dzon05
w_dzon05
 
Stack It And Unpack It
Stack It And Unpack ItStack It And Unpack It
Stack It And Unpack It
 
MySQL Indexes
MySQL IndexesMySQL Indexes
MySQL Indexes
 
Oracle 11g SQL Overview
Oracle 11g SQL OverviewOracle 11g SQL Overview
Oracle 11g SQL Overview
 
Page Cache in Linux 2.6.pdf
Page Cache in Linux 2.6.pdfPage Cache in Linux 2.6.pdf
Page Cache in Linux 2.6.pdf
 
vFabric SQLFire Introduction
vFabric SQLFire IntroductionvFabric SQLFire Introduction
vFabric SQLFire Introduction
 
15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance
 
SAS Commands
SAS CommandsSAS Commands
SAS Commands
 
Sql server lesson5
Sql server lesson5Sql server lesson5
Sql server lesson5
 
Less08 Schema
Less08 SchemaLess08 Schema
Less08 Schema
 
Sql server lesson7
Sql server lesson7Sql server lesson7
Sql server lesson7
 
Unit 4 data storage and querying
Unit 4   data storage and queryingUnit 4   data storage and querying
Unit 4 data storage and querying
 
lovely
lovelylovely
lovely
 

More from Girija Muscut

Visualization using Tableau
Visualization using TableauVisualization using Tableau
Visualization using TableauGirija Muscut
 
Introduction to ml
Introduction to mlIntroduction to ml
Introduction to mlGirija Muscut
 
Effective Visualization with Tableau
Effective Visualization with TableauEffective Visualization with Tableau
Effective Visualization with TableauGirija Muscut
 
Guruvayoor song with audio-Udayasthamana puja
Guruvayoor song with audio-Udayasthamana puja Guruvayoor song with audio-Udayasthamana puja
Guruvayoor song with audio-Udayasthamana puja Girija Muscut
 
Lakshmi lalli with audio
Lakshmi lalli with audioLakshmi lalli with audio
Lakshmi lalli with audioGirija Muscut
 
Bagyada laskhmi purandara dasa
Bagyada laskhmi purandara dasaBagyada laskhmi purandara dasa
Bagyada laskhmi purandara dasaGirija Muscut
 
Amba nee irangaayenil - papanasam sivan song
Amba nee irangaayenil - papanasam sivan songAmba nee irangaayenil - papanasam sivan song
Amba nee irangaayenil - papanasam sivan songGirija Muscut
 
Mahalakshmi jagan madha - papanasm sivan tamil song
Mahalakshmi jagan madha  - papanasm sivan tamil songMahalakshmi jagan madha  - papanasm sivan tamil song
Mahalakshmi jagan madha - papanasm sivan tamil songGirija Muscut
 
Sowbhagayaha laskhmi varuvai nee tamil song
Sowbhagayaha laskhmi varuvai nee tamil songSowbhagayaha laskhmi varuvai nee tamil song
Sowbhagayaha laskhmi varuvai nee tamil songGirija Muscut
 
Bega baro Bega baro Neela Megha Varna-Vadhiraja Theertha
Bega baro Bega baro Neela Megha Varna-Vadhiraja TheerthaBega baro Bega baro Neela Megha Varna-Vadhiraja Theertha
Bega baro Bega baro Neela Megha Varna-Vadhiraja TheerthaGirija Muscut
 
Rama Nama Bhajan
Rama Nama BhajanRama Nama Bhajan
Rama Nama BhajanGirija Muscut
 
Saratha devi song 1
Saratha devi song 1Saratha devi song 1
Saratha devi song 1Girija Muscut
 
Saraswathi bhajan 1 with tamil meaning
Saraswathi bhajan 1 with tamil meaningSaraswathi bhajan 1 with tamil meaning
Saraswathi bhajan 1 with tamil meaningGirija Muscut
 
Aneyu karadare -Purandara Dasar.
Aneyu karadare -Purandara Dasar.Aneyu karadare -Purandara Dasar.
Aneyu karadare -Purandara Dasar.Girija Muscut
 
Maithriam Bhajatha with tamil meaning (lyrics)
Maithriam Bhajatha with tamil meaning (lyrics)Maithriam Bhajatha with tamil meaning (lyrics)
Maithriam Bhajatha with tamil meaning (lyrics)Girija Muscut
 
Unit 4 scd2-exercise 1-solution
Unit 4 scd2-exercise 1-solutionUnit 4 scd2-exercise 1-solution
Unit 4 scd2-exercise 1-solutionGirija Muscut
 
Unit 2 - Slowly Changing Dimension Type 1 (SCD1) (insert)
Unit 2  - Slowly Changing Dimension Type 1 (SCD1) (insert)Unit 2  - Slowly Changing Dimension Type 1 (SCD1) (insert)
Unit 2 - Slowly Changing Dimension Type 1 (SCD1) (insert)Girija Muscut
 
Slowly Changing Dimension Type 1 (SCD 1) exercise 2 solution insert and update
Slowly Changing Dimension Type 1 (SCD 1) exercise 2 solution insert and updateSlowly Changing Dimension Type 1 (SCD 1) exercise 2 solution insert and update
Slowly Changing Dimension Type 1 (SCD 1) exercise 2 solution insert and updateGirija Muscut
 

More from Girija Muscut (20)

Tamil Nalvar
Tamil Nalvar Tamil Nalvar
Tamil Nalvar
 
Visualization using Tableau
Visualization using TableauVisualization using Tableau
Visualization using Tableau
 
Introduction to ml
Introduction to mlIntroduction to ml
Introduction to ml
 
Effective Visualization with Tableau
Effective Visualization with TableauEffective Visualization with Tableau
Effective Visualization with Tableau
 
Guruvayoor song with audio-Udayasthamana puja
Guruvayoor song with audio-Udayasthamana puja Guruvayoor song with audio-Udayasthamana puja
Guruvayoor song with audio-Udayasthamana puja
 
Lakshmi lalli with audio
Lakshmi lalli with audioLakshmi lalli with audio
Lakshmi lalli with audio
 
Bagyada laskhmi purandara dasa
Bagyada laskhmi purandara dasaBagyada laskhmi purandara dasa
Bagyada laskhmi purandara dasa
 
Lakshmi lalli
Lakshmi lalliLakshmi lalli
Lakshmi lalli
 
Amba nee irangaayenil - papanasam sivan song
Amba nee irangaayenil - papanasam sivan songAmba nee irangaayenil - papanasam sivan song
Amba nee irangaayenil - papanasam sivan song
 
Mahalakshmi jagan madha - papanasm sivan tamil song
Mahalakshmi jagan madha  - papanasm sivan tamil songMahalakshmi jagan madha  - papanasm sivan tamil song
Mahalakshmi jagan madha - papanasm sivan tamil song
 
Sowbhagayaha laskhmi varuvai nee tamil song
Sowbhagayaha laskhmi varuvai nee tamil songSowbhagayaha laskhmi varuvai nee tamil song
Sowbhagayaha laskhmi varuvai nee tamil song
 
Bega baro Bega baro Neela Megha Varna-Vadhiraja Theertha
Bega baro Bega baro Neela Megha Varna-Vadhiraja TheerthaBega baro Bega baro Neela Megha Varna-Vadhiraja Theertha
Bega baro Bega baro Neela Megha Varna-Vadhiraja Theertha
 
Rama Nama Bhajan
Rama Nama BhajanRama Nama Bhajan
Rama Nama Bhajan
 
Saratha devi song 1
Saratha devi song 1Saratha devi song 1
Saratha devi song 1
 
Saraswathi bhajan 1 with tamil meaning
Saraswathi bhajan 1 with tamil meaningSaraswathi bhajan 1 with tamil meaning
Saraswathi bhajan 1 with tamil meaning
 
Aneyu karadare -Purandara Dasar.
Aneyu karadare -Purandara Dasar.Aneyu karadare -Purandara Dasar.
Aneyu karadare -Purandara Dasar.
 
Maithriam Bhajatha with tamil meaning (lyrics)
Maithriam Bhajatha with tamil meaning (lyrics)Maithriam Bhajatha with tamil meaning (lyrics)
Maithriam Bhajatha with tamil meaning (lyrics)
 
Unit 4 scd2-exercise 1-solution
Unit 4 scd2-exercise 1-solutionUnit 4 scd2-exercise 1-solution
Unit 4 scd2-exercise 1-solution
 
Unit 2 - Slowly Changing Dimension Type 1 (SCD1) (insert)
Unit 2  - Slowly Changing Dimension Type 1 (SCD1) (insert)Unit 2  - Slowly Changing Dimension Type 1 (SCD1) (insert)
Unit 2 - Slowly Changing Dimension Type 1 (SCD1) (insert)
 
Slowly Changing Dimension Type 1 (SCD 1) exercise 2 solution insert and update
Slowly Changing Dimension Type 1 (SCD 1) exercise 2 solution insert and updateSlowly Changing Dimension Type 1 (SCD 1) exercise 2 solution insert and update
Slowly Changing Dimension Type 1 (SCD 1) exercise 2 solution insert and update
 

Recently uploaded

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 

Recently uploaded (20)

HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 

OER UNIT 4 PARTITION

  • 1. Data warehouse Design Using Oracle https://www.oercommons.org/authorin g/edit/21861 Dr. Girija Narasimhan 1 OER- UNIT 4 PARTITION
  • 3. Oracle Database allocates logical space for all data in the database. The logical units of database space allocation are data blocks, extents, segments, and tablespaces. At a physical level, the data is stored in data files on disk The data in the data files is stored in operating system blocks. 3Dr.Girija Narasimhan
  • 4. Data blocks are the smallest units storing data in the oracle database An extent is a set of logically contiguous data blocks allocated for storing a specific type of information A segment is a set of extents allocated for a specific database object, such as a table. Each segment belongs to one and only one tablespace 4Dr.Girija Narasimhan
  • 5. The database has one or more table space. Table space is called as logical storage unit within an oracle database. The meaning of logical is table space is not visible in the file system. Table space has at least had one data file. Each table space has unique data file. Each table space is divided into based on the size mentioned in the “Create tablespace” statement. The table space builds the bridge between the oracle database and the file system in which the table’s or index data is stored 5Dr.Girija Narasimhan
  • 6. CREATE TABLESPACE dwuser01a DATAFILE 'c:tempdwuser1a.dbf' SIZE 40M BLOCKSIZE 8192 EXTENT MANAGEMENT LOCAL UNIFORM SIZE 256K SEGMENT SPACE MANAGEMENT AUTO ONLINE; In the Lab session students are sharing single server, then each user created different dbf file in the c:temp- otherwise “already .dbf” file exist error will occur. For example: ‘c:tempuser1.dbf’. .c:tempuser2.dbf’ 6Dr.Girija Narasimhan
  • 8. Dr.Girija Narasimhan 8 You can drop a tablespace and its contents (the segments contained in the tablespace) from the database if the tablespace and its contents are no longer required Once a tablespace has been dropped, the data in the tablespace is not recoverable. Therefore, make sure that all data contained in a tablespace to be dropped will not be required in the future SQL> drop tablespace ica; This will drop the tablespace only if it is empty
  • 9. Dr.Girija Narasimhan 9 Tablespace is not empty and if you want to drop it anyhow then add the following keyword SQL>drop tablespace ica including contents; This will drop the tablespace even if it is not empty. But the data files will not be deleted you have to use operating system command to delete the files. But If you include data files keyword then, the associated data files will also be deleted from the disk. SQL>drop tablespace ica including contents and datafiles;
  • 10. various types of partition 10Dr.Girija Narasimhan
  • 11. Dr.Girija Narasimhan 11 CREATE TABLE <Table name> RANGE PARTITION LIST PARTITION HASH PARTITION RANGE PARTITION Using Number Values RANGE PARTITION Using Alphabet Values RANGE PARTITION Using DATE Values Partition Type Partition Type Partition Type COMPOSITE PARTITION
  • 13. RANGE PARTITION Using Number Values 13Dr.Girija Narasimhan
  • 14. Dr.Girija Narasimhan 14 create table interval_part(pid number(5) not null, fname varchar2(30), lname varchar2(30) ) partition by range(pid) ( partition p1 values less than(101) ) tablespace dwuser01a; Insert into INTERVAL_PART values(100,’Ali’,’Ahmed’); Insert into INTERVAL_PART values(101,’Zahra’,’Khamis’); PARTITION TYPE PARTITION NAME COLUMN NAME Insert values into the interval_part and check whether the records are storing in the assign partition As per given condition, the maximum value is 100, it will store only the first record only. It will give error message, for the value of product id 101 no partition was assigned
  • 15. Dr.Girija Narasimhan 15 SELECT PARTITION_NAME, TABLESPACE_NAME, HIGH_VALUE FROM USER_TAB_PARTITIONS; PARTITION_NAME TABLESPACE_NAME HIGH_VALUE ----------------------------------------------------------------------------- P1 dwuser01a 101 SELECT * FROM INTERVAL_PART PARTITION(P1); PID FNAME LNAME ---------- --------------- ----------------- 100 Ali Ahmed Insert into interval_part values(101,'zahra','khamis') * ERROR at line 1: ORA-14400: inserted partition key does not map to any partition The USER_TAB_PARTITIONS describes the partition information as name of the partition, tablespace name, storage parameter or value range of the partition . Display the values stored in the partition.
  • 16. RANGE PARTITION Using Alphabet Values 16Dr.Girija Narasimhan
  • 17. Dr.Girija Narasimhan 17 Create table product_alpha(Pid number(4) primary key , pname varchar2(25),pcategory varchar2(20)) PARTITION BY RANGE(pcategory)( Partition pcategoy_ae VALUES LESS THAN(‘F%’) TABLESPACE part1, Partition pcategoy_fl VALUES LESS THAN(‘M%’) TABLESPACE part2, Partition pcategoy_mr VALUES LESS THAN(‘S%’) TABLESPACE part3, Partition pcategoy_sz VALUES LESS THAN(MAXVALUE) TABLESPACE part4); Range partition using partition key based on character based values. This type of partition is useful for based on location name, country and supplier based analysis in the data warehousing. This is the alternative to numeric based values. It will store the values “a,b,c,d,e” It will store the exceed values of all the partition Store each partition in different tablespace
  • 18. Dr.Girija Narasimhan 18 SELECT PARTITION_NAME,TABLESPACE_NAME,HIGH_VALUE FROM USER_TAB_PARTITIONS; PARTITION_NAME TABLESPACE_NAME HIGH_VALUE ----------------------------- -------------------------------- ------------------- PCATEGOY_SZ PART4 MAXVALUE PCATEGOY_AE PART1 'F%' PCATEGOY_FL PART2 'M%' PCATEGOY_MR PART3 'S%‘ Insert into Product_alpha values(100,’Sony LCD 32”’,’TV’); Insert into Product_alpha values(200,’Sony POWER SHOT’,’CAMERA’); Insert into Product_alpha values(300,’Sony 3G Dual SIM’,’MOBILE’); Insert into product_alpha values(400,’Cannon Digit power’,’DIGITAL CAMERA’);
  • 19. Dr.Girija Narasimhan 19 SELECT * FROM Product_alpha PARTITION(PCATEGOY_AE); PID PNAME PCATEGORY ---------- --------------------------- -------------------- 200 Sony POWER SHOT CAMERA 400 Cannon Digit power DIGITAL CAMERA SELECT * FROM Product_alpha PARTITION(PCATEGOY_FL); no rows selected SELECT * FROM Product_alpha PARTITION(PCATEGOY_MR); PID PNAME PCATEGORY ---------- ------------------------- -------------------- 300 Sony 3G Dual SIM MOBILE SELECT * FROM Product_alpha PARTITION(PCATEGOY_SZ); PID PNAME PCATEGORY --------- ------------------------- -------------------- 100 Sony LCD 32” TV
  • 20. RANGE PARTITION Using DATE Values 20Dr.Girija Narasimhan
  • 21. Dr.Girija Narasimhan 21 CREATE TABLE Productrange_date ( Pid number(4) Primary key,pname varchar2(25),expdate date NOT Null) PARTITION BY RANGE(expdate)( PARTITION yr0 VALUES LESS THAN (TO_DATE('01-JAN-2007','DD-MON-YYYY')) TABLESPACE part1, PARTITION yr1 VALUES LESS THAN (TO_DATE('01-JAN-2008','DD-MON-YYYY')) TABLESPACE part2, PARTITION yr2 VALUES LESS THAN (TO_DATE('01-JAN-2009','DD-MON-YYYY')) TABLESPACE part3, PARTITION yr3 VALUES LESS THAN (MAXVALUE) TABLESPACE part4); INSERT INTO Productrange_date VALUES (1001, ‘Orange’, ’21-MAY-08’); INSERT INTO Productrange_date VALUES (1002, ‘Sugar’, ’16-MAY-09’); INSERT INTO Productrange_date VALUES (1003, ‘Biscutt’, ’12-NOV-09’); SQL> select * from productrange_date; PID PNAME EXPDATE ---------- ------------------------- ------------- 1001 Orange 21-MAY-08 1002 Sugar 16-MAY-09 1003 Biscutt 12-NOV-09 The partition key in the range partition to be Date based. It is useful for analyzing table data week wise or day wise. Store values upto 31-dec-2006
  • 22. Dr.Girija Narasimhan 22 SELECT * FROM productrange_date PARTITION(yr1); no rows selected SELECT * FROM productrange_date PARTITION(yr2); PID PNAME EXPDATE ---------- -- ------------- ------------- 1001 Orange 21-MAY-08 SELECT * FROM productrange_date PARTITION(yr3); PID PNAME EXPDATE --------- --------------- ------------- 1002 Sugar 16-MAY-09 1003 Biscutt 12-NOV-09
  • 24. Dr.Girija Narasimhan 24 ALTER TABLE <Table name> ADD PARTITION RANAME PARTITION DROP PARTITION MERGE PARTITION
  • 25. ADD PARTITION Using Alter table – ADD Partition statement, it is possible to insert new partition details of already existed partition Alter table INTERVAL_PART ADD partition p2 values less than(201); SELECT PARTITION_NAME,TABLESPACE_NAME,HIGH_VALUE FROM USER_TAB_PARTITIONS; PARTITION_NAME TABLESPACE_NAME HIGH_VALUE -------------------------- ---------------- ----------------- P1 UWDATA 101 P2 UWDATA 201
  • 26. SELECT * FROM INTERVAL_PART partition(P1); PID FNAME LNAME ---------- ------------------------- -------------- 100 Ali Ahmed SELECT * FROM INTERVAL_PART partition(P2); PID FNAME LNAME ---------- ------------------------- -------------- 101 Zahra Khamis 200 Mohammed Omar Insert into INTERVAL_PART values(101,'zahra','khamis'); Insert into INTERVAL_PART values(200,'Mohammed','omar'); SELECT * FROM INTERVAL_PART; PID FNAME LNAME ---------- ------------------------- -------------- 100 Ali Ahmed 101 Zahra Khamis 200 Mohammed Omar
  • 28. ALTER TABLE INTERVAL_PART RENAME PARTITION P1 TO P9; SQL> SELECT partition_name FROM user_tab_partitions WHERE PARTITION_NAME='P9'; PARTITION_NAME -------------------------- P9 SQL> SELECT * FROM INTERVAL_PART partition(P9); PID FNAME LNAME ---------- -------------- --------------- 100 Ali Ahmed
  • 30. Dr.Girija Narasimhan 30 SELECT * FROM productrange_date PARTITION(yr2); PID PNAME EXPDATE ---------- -- ------------- ------------- 1001 Orange 21-MAY-08 SELECT * FROM productrange_date PARTITION(yr3); PID PNAME EXPDATE --------- --------------- ------------- 1002 Sugar 16-MAY-09 1003 Biscutt 12-NOV-09 Alter table productrange_date merge partitions yr2,yr3 into partition yr6; SELECT * FROM productrange_date PARTITION(yr6) PID PNAME EXPDATE --------- ------------------ --------- 1001 Orange 22-MAY-08 1002 Sugar 16-MAY-09 1003 Biscutt 12-NOV-09 Merge partition creates a new partition called yr6 It copies the values from yr2 and yr3
  • 32. Dr.Girija Narasimhan 32 Alter table Product_alpha drop partition pcategoy_ae; SELECT * FROM Product_alpha PARTITION(PCATEGOY_AE); PID PNAME PCATEGORY ---------- --------------------------- -------------------- 200 Sony POWER SHOT CAMERA 400 Cannon Digit power DIGITAL CAMERA SELECT * FROM Product_alpha; PID PNAME PCATEGORY ---------- ----------------------------- -------------------- 200 Sony POWER SHOT CAMERA 400 Cannon Digit power DIGITAL CAMERA 300 Sony 3G Dual SIM MOBILE 100 Sony LCD 32" TV
  • 33. Dr.Girija Narasimhan 33 SELECT * FROM Product_alpha; PID PNAME PCATEGORY ---------- ----------------------------- -------------------- 300 Sony 3G Dual SIM MOBILE 100 Sony LCD 32" TV it merely updates the data dictionary to indicate that the pcategoy_AE partition no longer belongs to the Product_alpha table. It also remove the partition values from the table.
  • 35. Dr.Girija Narasimhan 35 The syntax of list partition is three parts: 1) partition method: Partition by list 2) Specify the partition column, example (slocation) 3) Partition description: Partition “partition_name” values (list of values) list partition is organizing the data allows unordered and unrelated sets of data to be grouped and organized together. It is controls each and every row values and mapping with partition CREATE TABLE STORE_LIST( STORENO NUMBER(5)PRIMARY KEY,STORENAME VARCHAR2(20), SPROFIT NUMBER(5),SLOCATION VARCHAR2(15),SDATE DATE) PARTITION BY LIST (SLOCATION) ( PARTITION LOC_Muscat VALUES(‘Al-khuwair’,’Ruwi’), PARTITION LOC_Al Batinah VALUES(‘Barka’, ‘Musannah’), PARTITION LOC_Dakhliyah VALUES(‘Nizwa’,’ Sumail’));
  • 36. Dr.Girija Narasimhan 36 SELECT * FROM STORE_LIST; STORENO STORENAME SPROFIT SLOCATION SDATE ----------------------------------------------------------- 11 RELIANCE FRESH 5000 Al-khuwair 10-APR-09 13 SPENCER PLAZA 6000 Nizwa 18-DEC-05 12 RELIANCE FRESH 4500 Barka 12-SEP-07 15 Apollo Medical 3000 Musanna 21-JUN-06 14 Apollo Medical 8000 Ruwi 24-DEC-08 SELECT * FROM STORE_LIST PARTITION(LOC_Muscat); STORENO STORENAME SPROFIT SLOCATION SDATE ----------------------------------------------------------- 11 RELIANCE FRESH 5000 Al-khuwair 10-APR-09 14 Apollo Medical 8000 Ruwi 24-DEC-08 SELECT * FROM STORE_LIST PARTITION(LOC_Al_Batinah); STORENO STORENAME SPROFIT SLOCATION SDATE ----------------------------------------------------------- 12 RELIANCE FRESH 4500 Barka 12-SEP-07 15 Apollo Medical 3000 Musanna 21-JUN-06 SELECT * FROM STORE_LIST PARTITION(LOC_Dakhliyah); STORENO STORENAME SPROFIT SLOCATION SDATE ----------------------------------------------------------- 13 SPENCER PLAZA 6000 Nizwa 18-DEC-05
  • 37. LIST PARTITION ADD PARTITION USING “DEFAULT” VALUE 37Dr.Girija Narasimhan
  • 38. Dr.Girija Narasimhan 38 The special capability of list partition is default partition. The benefit of using default partition is, it don’t generate an error suppose all rows don’t map with any partition in the list. Using alter table statement, it is possible to add new partition in the already existed list partition. ALTER TABLE STORE_LIST ADD PARTITION LOC_OTHER VALUES(DEFAULT)TABLESPACE PART4; INSERT INTO STORE_LIST VALUES(16,'SPENCER PLAZA',4300, ‘Salalah',’29-MAY-2004’); SELECT * FROM STORE_LIST PARTITION(LOC_OTHER); STORENO STORENAME SPROFIT SLOCATION SDATE -------- -------------- -------- ---------- -------- 16 SPENCER PLAZA 4300 Salalah 29-MAY-04
  • 39. ALTER TABLE MODIFY PARTITION ADD “List values” 39Dr.Girija Narasimhan
  • 40. Dr.Girija Narasimhan 40 ALTER TABLE <table Name> MODIFY PARTITION ADD “List values” It will add new values in the already existing partition. Like update statement, it will change the specific values of the table DROP “List values” Remove the specific value from the already existing partition. Like delete statement, how it will delete specific information from the table. Values of the partition
  • 41. Dr.Girija Narasimhan 41 ALTER TABLE STORE_LIST MODIFY PARTITION LOC_Muscat ADD VALUES (' Bowsher ', ' Seeb '); INSERT INTO STORE_LIST VALUES(17,'SPENCER PLAZA',3300, 'seeb',’02-APR-2004’); SELECT * FROM STORE_LIST PARTITION(LOC_Muscat); STORENO STORENAME SPROFIT SLOCATION SDATE ---------- -------------------- ------------- ------------------ ------------- 11 RELIANCE FRESH 5000 Al-khuwair 10-APR-09 14 Apollo Medical 8000 Ruwi 24-DEC-08 17 SPENCER PLAZA 3300 seeb 02-APR-04 In the list partition “LOC_MUSCAT” partition had values “SEEB, BOWSHER”. Suppose to change already existed list value in the list partition, use ALTER TABLE –MODIFY statement to change the new values.
  • 42. ALTER TABLE MODIFY PARTITION DROP “List values” 42Dr.Girija Narasimhan
  • 43. Dr.Girija Narasimhan 43 Suppose to remove particular list value from the partition, that partition has the specific values then oracle trigger the error. The partition doesn’t have that values or data then error free. Avoiding the error message, first delete the specific values in the partition and then drop the values from the list partition. ALTER TABLE STORE_LIST MODIFY PARTITION LOC_Muscat DROP VALUES(‘Ruwi’); ERROR at line 1: ORA-14518: partition contains rows corresponding to values being dropped Delete from store_list where storeno=14 ALTER TABLE STORE_LIST MODIFY PARTITION LOC_Muscat DROP VALUES (‘Ruwi’);
  • 45. Dr.Girija Narasimhan 45 Truncate statement delete all the values in the mentioned partition. So, partition which is truncated is empty or without any value. So error don’t occur like drop values. But it will retain the Partition without values. Alter table STORE_LIST truncate partition LOC_Muscat DROP STORAGE; select * from store_list; STORENO STORENAME SPROFIT SLOCATION SDATE ---------- -------------------- ---------- -------------------------- 13 SPENCER PLAZA 6000 Nizwa 18-DEC-05 12 RELIANCE FRESH 4500 Barka 12-SEP-07 15 Apollo Medical 3000 Musanna 21-JUN-06 16 SPENCER PLAZA 4300 Salalah 29-MAY-04
  • 47. Dr.Girija Narasimhan 47 ALTER TABLE products MOVE PARTITION PARTNO1 TABLESPACE uwdata; select tablespace_name,partition_name from user_tab_partitions where table_name='PRODUCTS'; TABLESPACE_NAME PARTITION_NAME ------------------------------ ------------------------ UWDATA PARTNO1 PART2 PARTNO2 PART3 PARTNO3 select tablespace_name,partition_name from user_tab_partitions where table_name='PRODUCTS'; TABLESPACE_NAME PARTITION_NAME ------------------------------ ------------------------ PART1 PARTNO1 PART2 PARTNO2 PART3 PARTNO3 Here tablespace name is case sensitive. Now “PARTNO1” partition is moved from tablespace “PART1” to “UMDATA”. It will move the most active partition to a tablespace. It also create new segment for the tablespace for the moving partition and it also drops the moved partition's Previous segment.
  • 49. Dr.Girija Narasimhan 49 It splits the partition into more than one and also move the specified values into corresponding split partition SELECT * FROM STORE_LIST PARTITION(LOC_OTHER); STORENO STORENAME SPROFIT SLOCATION SDATE --------------------------------- ------------------------- 16 SPENCER PLAZA 4300 Salalah 29-MAY-04 18 Apollo Medical 8000 Ibra 24-DEC-08 19 Apollo Medical 3000 Ibra 21-JUN-06 20 SPENCER PLAZA 4300 Shinas 29-MAY-04 21 SPENCER PLAZA 4300 Amrath 29-MAY-04 ALTER TABLE STORE_LIST SPLIT PARTITION LOC_OTHER VALUES('Ibra') INTO (PARTITION LOC_Ibra,PARTITION LOC_OTHER);
  • 50. Dr.Girija Narasimhan 50 SELECT * FROM STORE_LIST PARTITION(LOC_Ibra); STORENO STORENAME SPROFIT SLOCATION SDATE ---------- ------------------------------------------------ 18 Apollo Medical 8000 Ibra 24-DEC-08 19 Apollo Medical 3000 Ibra 21-JUN-06 SELECT * FROM STORE_LIST PARTITION(LOC_OTHER); STORENO STORENAME SPROFIT SLOCATION SDATE ---------- ------------------------------------------------ 16 SPENCER PLAZA 4300 Salalah 29-MAY-04 20 SPENCER PLAZA 4300 Shinas 29-MAY-04 21 SPENCER PLAZA 4300 Amrath 29-MAY-04
  • 52. Dr.Girija Narasimhan 52 Hash partition is using hashing algorithm. The key feature of hashing algorithm into it evenly distributes rows among partitions, so all the partitions are almost the same size. This feature is useful for spreading the data into sufficient number of devices to maximizing the I/O devices. The oracle database uses a linear hashing algorithm. Suppose any add or merge a hashed partition, the oracle automatically rearranges the rows within the partition and sub partition.
  • 53. Dr.Girija Narasimhan 53 CREATE TABLE products(partno NUMBER, description VARCHAR2 (60)) PARTITION BY HASH (partno) (PARTITION partno1 TABLESPACE part1, PARTITION partno2 TABLESPACE part2, PARTITION partno3 TABLESPACE part3, PARTITION partno4 TABLESPACE part4); Insert into products values(11,’ice cream’); Insert into products values(12,’coffee’); Insert into products values(13,’tea’); Insert into products values(14,’sugar’);
  • 54. Dr.Girija Narasimhan 54 SELECT * FROM products partition(partno1); PARTNO DESCRIPTION ---------- ------------------------------------ 11 ice cream 13 tea SELECT * FROM products partition(partno2); PARTNO DESCRIPTION ---------- ----------------------------------- 12 coffee SELECT * FROM products partition(partno4); PARTNO DESCRIPTION ---------- ----------------------------------- 14 sugar
  • 56. Dr.Girija Narasimhan 56 Select table_name, partition_name from user_tab_partitions where TABLE_NAME='PRODUCTS'; TABLE_NAME PARTITION_NAME ------------------------------ ------------------------ PRODUCTS PARTNO1 PRODUCTS PARTNO2 PRODUCTS PARTNO3 PRODUCTS PARTNO4 SELECT * FROM products partition(partno4); PARTNO DESCRIPTION ---------- ------------------------------------------- 14 sugar SELECT * FROM products partition(partno2); PARTNO DESCRIPTION ---------- -------------------------------------- 12 coffee
  • 57. Dr.Girija Narasimhan 57 Coalescing partitions is a way of reducing the number partitions in a hash-partitioned table. When a hash partition is coalesced, its contents are redistributed into one or more remaining partitions determined by the hash function. The specific partition that is coalesced is selected by oracle, and is dropped after its contents have been redistributed.
  • 58. Dr.Girija Narasimhan 58 ALTER TABLE PRODUCTS COALESCE PARTITION; SQL> Select table_name, partition_name from user_tab_partitions where TABLE_NAME='PRODUCTS'; TABLE_NAME PARTITION_NAME ------------------------------ ---------------------- PRODUCTS PARTNO1 PRODUCTS PARTNO2 PRODUCTS PARTNO3 SQL> SELECT * FROM products partition(partno2); PARTNO DESCRIPTION ---------- ------------------------------------------ 12 coffee 14 sugar Here PARTNO4 is dropped and PARTNO4 partition values are distributed into PARTNO2 partition.
  • 59. Compare Truncate, Drop list values, Drop,Coalsec 59Dr.Girija Narasimhan
  • 60. Dr.Girija Narasimhan 60 Truncate Partition Drop Partition coalesce Drop List value It retains the partition, but deletes all values from the partition or from the table. So, partition without any value or empty. It will drop partition and the values also. It will delete the partition and redistribute the value to other partition. Suppose coalesce partition p1, then it will redistributed the p1 values or information to another partition p2. In the List partition, For example Loc_Muscat (‘Ruwi’,’Seeb’). I want to delete only Ruwi value. Suppose any one record or row in the partition have ruwi value. Step1: delete the record having ‘ruwi’ value from the table. otherwise it will give error. Step 2: alter table modify partition drop values (ruwi) .
  • 62. 62Dr.Girija Narasimhan The types of composite partitioning are:  Composite Range-Range Partitioning  Composite Range-Hash Partitioning  Composite Range-List Partitioning  Composite List-Range Partitioning  Composite List-Hash Partitioning  Composite List-List Partitioning  Composite Hash-Hash Partitioning  Composite Hash-List Partitioning  Composite Hash-Range Partitioning Composite partitioning is a combination of the two partition method. Table is partitioned by one data distribution method for example Range Partition. Each partition is further subdivided into another Partition method for example List.
  • 63. 63Dr.Girija Narasimhan Conn hr/hr CREATE TABLE STORE_COMPOSITLIST( STORENO NUMBER(5)PRIMARY KEY,STORENAME VARCHAR2(20), SPROFIT NUMBER(5),SLOCATION VARCHAR2(15),SDATE DATE) PARTITION BY RANGE(STORENO) SUBPARTITION BY LIST (SLOCATION) SUBPARTITION TEMPLATE( SUBPARTITION LOC_Muscat VALUES (‘Al-khuwair’,’Ruwi’) TABLESPACE part1 SUBPARTITION LOC_Dakhliyah VALUES (‘Nizwa’,’Sumail’)TABLESPACE part1) ( partition p1 values less than(13), partition p2 values less than(maxvalue)); Composite Partitioned Table - By Range And List CREATE TABLESPACE part1 DATAFILE 'c:temppart1.dbf' SIZE 40M BLOCKSIZE 8192 EXTENT MANAGEMENT LOCAL UNIFORM SIZE 256K SEGMENT SPACE MANAGEMENT AUTO ONLINE; Conn sys as sysdba sys
  • 64. Dr.Girija Narasimhan 64 • Partition Type : RANGE • Partition Key column: STORENO • Sub partition Type: LIST • Sub partition key column : SLOCATION • Sub partition: LOC_Muscat , LOC_Dakhliyah • Sub partition Values : LOC_Muscat VALUES (‘Al-khuwair’,’Ruwi’) LOC_Dakhliyah VALUES (‘Nizwa’,’Sumail’) • Partition Name and Values: p1 (value <13), p2 (Maxvalue) Components of composite partition
  • 65. Dr.Girija Narasimhan 65 set linesize 450; SELECT table_name, partition_name, composite, high_value FROM user_tab_partitions; insert into store_compositlist values(11,'Reliance Fresh',500,'Al-khuwair','10-apr-17'); insert into store_compositlist values(12,'Reliance Fresh',450,'Sumail','12-sep-17'); insert into store_compositlist values(13,'Spencer Plaza',600,'Nizwa','11-Nov-17'); insert into store_compositlist values(14, 'Apollo Medical',300,'Ruwi','21-Jun-17'); insert into store_compositlist values(15,'Apollo Medical',800,'Ruwi','27-may-17'); Display the partition Information
  • 66. Dr.Girija Narasimhan 66 SELECT table_name, partition_name, subpartition_name, num_rows FROM user_tab_subpartitions; Display the sub partition information Here Num_rows column is empty. For getting values in the Num_rows column analyze the statistics.
  • 67. Dr.Girija Narasimhan 67 Display the Partition values in the partition P1 and P2
  • 68. Dr.Girija Narasimhan 68 Display the Sub Partition values, don’t give sub partition name, then it will give error message. <partition name> _<subpartition name> in the select statement
  • 70. Dr.Girija Narasimhan 70 Local Partitioned Index Global Partitioned Index Partitioned Indexes
  • 71. Dr.Girija Narasimhan 71 Partitioned Indexes Local Index Global Index one-to-one mapping between a index partition and a table partition (equipartitioned) created with the LOCAL keyword and support partition independence one-to-many relationship, allowing one index partition to map to many table partitions number of index partitions will match the number of partitions in the base table. index partition gets deleted when the underlying table partition dropped, can’t drop partition index Drop a non-empty global index partition will cause the next highest partition to be marked unusable. Column mentioned in the partition index is not primary key column but it must be “NOT NULL” column. Local Non-Prefixed Indexes Local Prefixed Indexes indexed column does not match the partition key indexed column match the partition key At least one partition should have MAX VALUE Global Index don’t have Non- prefixed Indexes
  • 72. Dr.Girija Narasimhan 72 CREATE INDEX <index_name> ON <table_name> <column_name_list> LOCAL Partition(partition name); The primary key column not allowed for indexing Same partition name as given in the table. Local Index
  • 74. Dr.Girija Narasimhan 74 Local Non- Prefixed Indexes Display the Status of the partition index
  • 75. Dr.Girija Narasimhan 75 Dropping the Partition from the Local index is not allowed. Instead of dropping from index, drop the partition from the table, it automatically drop the partition from the index.
  • 76. Dr.Girija Narasimhan 76 Global Index In the global index max value should be include in partition.
  • 77. Dr.Girija Narasimhan 77 Display the status of the global index Unlike local index, it is possible to remove or drop partition from the global index
  • 78. Dr.Girija Narasimhan 78 Entire global index can’t be rebuild, only specific partition to be rebuild is possible. Partition name actual name given in the index no need to mention indexname_partition name.