Professional Documents
Culture Documents
Example of Script To Create A Composite RANGE-HASH Partition Table
Example of Script To Create A Composite RANGE-HASH Partition Table
1
Copyright (c) 2019, Oracle. All rights reserved. Oracle Confidential.
APPLIES TO:
Oracle Server - Enterprise Edition - Version 8.1.5.0 to 11.2.0.3 [Release 8.1.5 to 11.2]
Information in this document applies to any platform.
***Checked for relevance on 24-May-2012***
PURPOSE
name of each partitioned table created with both methods. The content
the execution.
REQUIREMENTS
Execution Environment:
CONFIGURING
The user which will execute this script must be granted at least with
privileges.
INSTRUCTIONS
PROOFREAD THIS SCRIPT BEFORE USING IT! Due to differences in the way text
editors, e-mail packages, and operating systems handle text formatting (spaces,
tabs, and carriage returns), this script may not be in an executable state
when you first receive it. Check over the script to ensure that errors of
this type are corrected.The script will produce an output file named [outputfile].
The script will ask you to give 8 tablespace names. These tablespaces
free space.
You must choose the output file name which will trace the information
displayed. This file can be viewed in a browser or uploaded for support analysis.
CAUTION
This sample code is provided for educational purposes only and not supported by Oracle Support Services. It has been
tested internally, however, and works as documented. We do not guarantee that it will work for you, so be sure to test it
in your environment before relying on it.
Proofread this sample code before using it! Due to the differences in the way text editors, e-mail packages and
operating systems handle text formatting (spaces, tabs and carriage returns), this sample code may not be in
an executable state when you first receive it. Check over the sample code to ensure that errors of this type are
corrected.
SCRIPT
set feedback on
prompt *****************************************************************************
prompt * It's necessary to dispose of eight tablespaces with sufficient free space *
prompt *****************************************************************************
spool &OUTPUTFILE
prompt **************************************************************************
prompt * Two methods may be used for create a COMPOSITE partitioned table. *
prompt * *
prompt * The first one, below, is range partitioned on the columns ord_year, *
prompt **************************************************************************
prompt
accept TAB1 prompt 'Choose a table name for the first creation method: '
prompt )
prompt )
prompt /
ord_id NUMBER(10),
ord_day NUMBER(2),
ord_month NUMBER(2),
ord_year NUMBER(4)
STORE IN (&&TBS1,&&TBS2,&&TBS3,&&TBS4,&&TBS5,&&TBS6,&&TBS7,&&TBS8)
prompt
***********************************************************************************
prompt * The second method will explicitly named and stored each subpartition *
prompt
***********************************************************************************
prompt
accept TAB2 prompt 'Choose a table name for the second creation method: '
prompt )
prompt SUBPARTITIONS 8
prompt ),
prompt ),
prompt ),
prompt )
prompt )
prompt /
ord_id NUMBER(10),
ord_day NUMBER(2),
ord_month NUMBER(2),
ord_year NUMBER(4)
PARTITION BY RANGE(ord_year,ord_month,ord_day)
SUBPARTITION BY HASH(ord_id)
SUBPARTITIONS 8
),
),
),
--
--
set heading on
https://support.oracle.com/epmos/faces/DocContentD splay?_adf.ctrl-state=6v ry7tjf_297& d=165924.1 7/12
18.07.2019 Document 165924.1
prompt ==========================
partition_count, def_subpartition_count,
partitioning_key_count, subpartitioning_key_count
FROM dba_part_tables
prompt ===========================================================
subpartition_count, tablespace_name
FROM dba_tab_partitions
prompt =======================
prompt **************************************************************************
prompt * Note the subpartition names in the first table (system generated) *
prompt * versus the second table (explicitly named) and the tablespaces defined *
prompt **************************************************************************
prompt
prompt =====================================
prompt ========================================
prompt ======================
--
-- Temporary/Rollback space.
--
--
/
https://support.oracle.com/epmos/faces/DocContentD splay?_adf.ctrl-state=6v ry7tjf_297& d=165924.1 10/12
18.07.2019 Document 165924.1
BEGIN
END LOOP;
END LOOP;
END LOOP;
END;
commit;
set feedback on
prompt ******************************************************************
prompt * The twice tables have been now analyzed so the statistics will *
prompt * be accurate. *
prompt ******************************************************************
prompt ========================================
prompt **************************************************************
prompt * you can verify now that the rows are evenly distributed on *
prompt **************************************************************
SAMPLE OUTPUT