Oracle Enhanced query performance-creation of a simple range partitioned table

Source: Internet
Author: User

Advantages of Partitioned Tables:
1. Improve query performance: You only need to search for specific partitions, not the entire table, to improve the query speed.

2. Save maintenance Time: Data loading of single partition, index rebuilding, backup, maintenance is much smaller than the whole table maintenance time.
Let's create a partitioned table below.
First step: Create a dedicated tablespace for the partition table in order to improve IO performance
SELECT NAME from v$datafile;--If you are familiar with the environment, omit this step to view the current file path
--Create table space, if there is a dedicated maintenance table space as far as possible to turn off auto-growth, long-time unmanned maintenance will turn on autogrow, autoextend on SIZE
CREATE tablespace partition_p_name1 datafile '/oradata/orawms/partition_p_name1.dbf ' SIZE 200m autoextend OFF;
CREATE tablespace partition_p_name2 datafile '/oradata/orawms/partition_p_name2.dbf ' SIZE 200m autoextend OFF;
CREATE tablespace partition_p_name3 datafile '/oradata/orawms/partition_p_name3.dbf ' SIZE 200m autoextend OFF;
CREATE tablespace partition_p_name4 datafile '/oradata/orawms/partition_p_name4.dbf ' SIZE 200m autoextend OFF;
CREATE tablespace partition_p_name5 datafile '/oradata/orawms/partition_p_name5.dbf ' SIZE 200m autoextend OFF;
CREATE tablespace goods_inf_max datafile '/oradata/orawms/partition_p_max.dbf ' SIZE 200m autoextend OFF;
Step two: Create a table partition
CREATE TABLE Partition_tab_name
(

Create_date date,
Create_man VARCHAR2 (64),
Modify_date date,
Modify_man VARCHAR2 (64),
create_org VARCHAR2 (20),
Create_orgseq VARCHAR2 (512),
Create_role VARCHAR2 (50),
FIELDS1 VARCHAR2 (200),
FIELDS2 VARCHAR2 (200),
FIELDS3 VARCHAR2 (200),
FIELDS4 VARCHAR2 (200),
FIELDS5 VARCHAR2 (200),
FIELDS6 VARCHAR2 (200),
FIELDS7 VARCHAR2 (200),
FIELDS8 VARCHAR2 (200),
FIELDS9 VARCHAR2 (200),
FIELDS10 VARCHAR2 (200)
)
PARTITION by RANGE (create_date)
--range (partition field, where the creation time does range partitioning)
(
PARTITION partition_p_name1 VALUES Less THAN (to_date (' 2015-01-01 ', ' yyyy-mm-dd ') tablespace partition_p_name1,
PARTITION partition_p_name2 VALUES Less THAN (to_date (' 2016-01-01 ', ' yyyy-mm-dd ') tablespace partition_p_name2,
PARTITION Partition_p_name3 VALUES Less THAN (to_date (' 2017-01-01 ', ' yyyy-mm-dd ') tablespace Partition_p_name3,
PARTITION partition_p_name4 VALUES Less THAN (to_date (' 2018-01-01 ', ' yyyy-mm-dd ') tablespace partition_p_name4,
PARTITION partition_p_name5 VALUES Less THAN (to_date (' 2019-01-01 ', ' yyyy-mm-dd ') tablespace partition_p_name5,
PARTITION Partition_p_max VALUES less THAN (MAXVALUE) tablespace Partition_p_max
);
--Part III: inserting data
INSERT into Partition_tab_name SELECT * from ' source table name ';
Fourth: Query the data Test bar ~

SELECT * from Goods_inf_r1 PARTITION (partition_p_name1);--partition_p_name2,partition_p_name3~~~

Oracle Enhanced query performance-creation of a simple range partitioned table

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.