Partitioning in Oracle
Partitioning is a technique used to divide a large table into smaller, more manageable pieces called partitions. Partitioning is used to improve query performance and simplify data management. Here is an example:
CREATE TABLE sales (
sale_id NUMBER(10),
sale_date DATE,
amount NUMBER(10),
region VARCHAR2(20)
)
PARTITION BY RANGE (sale_date)
(
PARTITION sales_q1 VALUES LESS THAN (TO_DATE('01-APR-2022', 'DD-MON-YYYY')),
PARTITION sales_q2 VALUES LESS THAN (TO_DATE('01-JUL-2022', 'DD-MON-YYYY')),
PARTITION sales_q3 VALUES LESS THAN (TO_DATE('01-OCT-2022', 'DD-MON-YYYY')),
PARTITION sales_q4 VALUES LESS THAN (TO_DATE('01-JAN-2023', 'DD-MON-YYYY'))
);
This creates a partitioned table named "sales" that is partitioned by the "sale_date" column into four partitions based on the quarter of the year.
No comments:
Post a Comment