New Brokerage Platform Partitions Document: Index
New Brokerage Platform Partitions Document: Index
Purpose: 2
Daily Partitions 6
Weekly Partitions 13
Monthly Partitions 21
Advance compression 30
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Purpose: To Create Partitions regularly on the tables with daily, weekly and monthly using the routines.
To create the partitions we need to pass the following arguments to the procedures
1) Schema name: Owner of the Table
2) Table name: Will give the table name
3) Start date: The beginning date of the partition we will give.***
4) End date: The end date to which we will have the partitions.***
5) Compress type: Here we specify the compress type we want to have. Please refer to the End of doc for more Info.
Two options for compress type are i) CFAO (compress for all operations) ( ii) CO (compress)iii)None
6) Tablespace_type (SML) : We will be having 3 Types of Tablespaces on which we will create the partitions
(S for small,M for medium , L for Large). ***
7) V_error
Purpose of the function: Business Date
This function will be skipping the Saturdays and Sundays. It is used by the procedures.
If the date parmeters are passed for weekend they will be ignored
Daily Table partitions with the compress Option and the Tablespace selection (SML).
How to execute:
Pre requisites: 1) Date Function should be created.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
IF (v_table_count > 0)
THEN
SELECT COUNT ( * )
INTO v_record_count
FROM dba_tab_partitions
WHERE table_name = UPPER (p_table_name)
AND table_owner = UPPER (p_schema_name);
IF (v_record_count > 0)
THEN
SELECT TO_DATE (SUBSTR (MAX (partition_name), -8), 'YYYYMMDD'),
RTRIM (MAX (partition_name), '0123456789'),
MAX (tablespace_name)
INTO v_last_partition, v_partition_name, v_tblspc_name
FROM dba_tab_partitions
WHERE table_name = UPPER (p_table_name)
AND table_owner = UPPER (p_schema_name)
AND SUBSTR (partition_name, -8) != '99999999';
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
v_last_partition := v_partition_date;
END LOOP;
p_message := 'Successful';
ELSE
p_message :=
'End date specified is less than the last available partition date: '
|| v_last_partition
;
END IF;
ELSE
p_message := 'There are currently no partitions on the table';
END IF;
ELSE
RAISE v_no_table_found;
END IF;
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
EXCEPTION
WHEN v_no_table_found
THEN
RAISE_APPLICATION_ERROR (
-20735,
'Please Check the table name you may be entered wrong table name or table does not exists'
);
WHEN v_invalid_data
THEN
RAISE_APPLICATION_ERROR (-20734, 'you can only enter CFAO,None or CO');
WHEN OTHERS
THEN
RAISE;
DBMS_OUTPUT.put_line (p_message);
END;
/
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
After the procedure is created: to check the validity create a sample table:
CREATE TABLE DLY_TEST
(
BATCH_DTE_CYMD DATE NOT NULL,
ACCT_NO number
)
TABLESPACE TSHODSTAB1
PARTITION BY RANGE (BATCH_DTE_CYMD)
(
PARTITION P_ACT_RLS_D_20100301 VALUES LESS THAN (TO_DATE(' 2010-03-02 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
'NLS_CALENDAR=GREGORIAN'))
TABLESPACE TS201003)
/
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
set serveroutput on
set define off
variable v_error varchar2(100);
exec Gen_Part_DLY ('TDF1496','DLY_TEST','02-MAR-2010','06-mar-2010','NONE','M',:v_error);
set serveroutput on
set define off
variable v_error varchar2(100);
exec Gen_Part_DLY ('TDF1496','DLY_TEST', to_date('03-24-2010','mm-dd-yyyy'),to_date( '03-31-2010','mm-dd-yyyy'),'CFAO','M', :v_error);
alter table TDF1496.DLY_TEST add partition P_ACT_RLS_D_20100309 values less than (to_date (' 2010-03-10 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
'NLS_CALENDAR=GREGORIAN')) tablespace TSM201003 compress
alter table TDF1496.DLY_TEST add partition P_ACT_RLS_D_20100310 values less than (to_date (' 2010-03-11 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
'NLS_CALENDAR=GREGORIAN')) tablespace TSM201003 compress
PL/SQL procedure successfully completed.
Weekly Table partitions with the compress Option and the Tablespace selection (SML).
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
How to execute:
Pre requisites: 1) Date Function should be created.
2) User who is executing should have the required permissions.
IF (v_table_count > 0)
THEN
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
SELECT COUNT ( * )
INTO v_record_count
FROM dba_tab_partitions
WHERE table_name = UPPER (p_table_name)
AND table_owner = UPPER (p_schema_name);
SELECT COUNT ( * )
INTO v_record_count
FROM dba_tab_partitions
WHERE table_name = UPPER (p_table_name)
AND table_owner = UPPER (p_schema_name)
AND SUBSTR (partition_name, -8) != '99999999';
IF (v_record_count > 0)
THEN
SELECT TO_DATE (SUBSTR (MAX (partition_name), -8), 'YYYYMMDD'),
RTRIM (MAX (partition_name), '0123456789'),
MAX (tablespace_name)
INTO v_last_partition, v_partition_name, v_tblspc_name
FROM dba_tab_partitions
WHERE table_name = UPPER (p_table_name)
AND table_owner = UPPER (p_schema_name)
AND SUBSTR (partition_name, -8) != '99999999';
v_actual_end_date :=
p_end_date + (7 - TO_NUMBER (TO_CHAR (p_end_date, 'D')));
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
v_sql :=
'alter table '
|| p_schema_name
|| '.'
|| p_table_name
|| ' add partition '
|| v_partition_name
|| TO_CHAR (v_last_partition, 'YYYYMMDD')
|| ' values less than (to_date ('''
|| TO_CHAR (v_last_partition + 1, 'SYYYY-MM-DD HH24:MI:SS')
|| ''', ''SYYYY-MM-DD HH24:MI:SS'', ''NLS_CALENDAR=GREGORIAN'')) tablespace '
|| SUBSTR (v_tblspc_name, 1, 2)
|| p_sml
|| TO_CHAR (v_last_partition, 'YYYYMM')
|| v_compress_type;
DBMS_OUTPUT.put_line (v_sql);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
p_message := 'Succesful';
ELSE
p_message :=
'End date specified is less than the last available partition date: '
|| v_last_partition;
END IF;
ELSE
p_message := 'There are currently no partitions on the table';
END IF;
ELSE
RAISE v_no_table_found;
END IF;
EXCEPTION
WHEN v_no_table_found
THEN
raise_application_error (
-20735,
'Please Check the table name you may be entered wrong table name or table doesnot exists');
WHEN v_invalid_data
THEN
raise_application_error (-20734, 'you can only enter CFAO or CO');
WHEN OTHERS
THEN
RAISE;
DBMS_OUTPUT.put_line (p_message);
END;
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
After the procedure is created: to check the validity create a sample table:
CREATE TABLE WKY_TEST
(
BATCH_DTE_CYMD DATE NOT NULL,
BA_RECCODE CHAR(1 BYTE) NOT NULL,
SEC_NO NUMBER(38) NOT NULL,
ACCT_NO NUMBER(38) NOT NULL,
ACCT_TYPE NUMBER(38) NOT NULL,
FIRM_NO NUMBER(38) NOT NULL,
REP CHAR(4 BYTE)
)
TABLESPACE TSHODSTAB1
PARTITION BY RANGE (BATCH_DTE_CYMD)
(
PARTITION P_RCK_W_20100306 VALUES LESS THAN (TO_DATE(' 2010-03-07 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
'NLS_CALENDAR=GREGORIAN'))
TABLESPACE TS201003)
/
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
EX:
alter table TDF1496.WKY_TEST add partition P_RCK_W_20100313 values less than (to_date (' 2010-03-14 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
'NLS_CALENDAR=GREGORIAN')) tablespace TSS201003
alter table TDF1496.WKY_TEST add partition P_RCK_W_20100320 values less than (to_date (' 2010-03-21 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
'NLS_CALENDAR=GREGORIAN')) tablespace TSS201003
PL/SQL procedure successfully completed.
set serveroutput on
set define off
Variable v_error varchar2(100);
exec Gen_Part_Wkly ('TDF1496','WKY_TEST','06-APR-2010','cfao','S',:v_error);
alter table TDF1496.WKY_TEST add partition P_RCK_W_20100327 values less than (to_date (' 2010-03-28 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
'NLS_CALENDAR=GREGORIAN')) tablespace TSS201003 compress for all operations
alter table TDF1496.WKY_TEST add partition P_RCK_W_20100403 values less than (to_date (' 2010-04-04 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
'NLS_CALENDAR=GREGORIAN')) tablespace TSS201004 compress for all operations
alter table TDF1496.WKY_TEST add partition P_RCK_W_20100410 values less than (to_date (' 2010-04-11 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
'NLS_CALENDAR=GREGORIAN')) tablespace TSS201004 compress for all operations
PL/SQL procedure successfully completed.
Monthly Table partitions with the compress Option and the Tablespace selection (SML).
How to execute:
Pre requisites: 1) Date Function should be created.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
IF (v_table_count > 0)
THEN
SELECT COUNT ( * )
INTO v_record_count
FROM dba_tab_partitions
WHERE table_name = UPPER (p_table_name)
AND table_owner = UPPER (p_schema_name);
SELECT COUNT ( * )
INTO v_record_count
FROM dba_tab_partitions
WHERE table_name = UPPER (p_table_name)
AND table_owner = UPPER (p_schema_name)
AND SUBSTR (partition_name, -8) != '99999999';
IF (v_record_count > 0)
THEN
SELECT SUBSTR (MAX (partition_name), -6),
RTRIM (MAX (partition_name), '0123456789'),
MAX (tablespace_name)
INTO v_last_partition, v_partition_name, v_tblspc_name
FROM dba_tab_partitions
WHERE table_name = UPPER (p_table_name)
AND table_owner = UPPER (p_schema_name)
AND SUBSTR (partition_name, -8) != '99999999';
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
LOOP
IF v_last_partition_month = 12
THEN
v_last_partition_year := v_last_partition_year + 1;
v_last_partition_month := 1;
ELSE
v_last_partition_month := v_last_partition_month + 1;
END IF;
IF v_last_partition_month = 12
THEN
v_sql :=
'alter table '
|| p_schema_name
|| '.'
|| p_table_name
|| ' add partition '
|| v_partition_name
|| TO_CHAR (v_last_partition_year)
|| TRIM (TO_CHAR (v_last_partition_month, '00'))
|| ' values less than (to_date ('' '
|| TO_CHAR (v_last_partition_year + 1)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|| '-01-01 00:00:00'
|| ''', ''SYYYY-MM-DD HH24:MI:SS'', ''NLS_CALENDAR=GREGORIAN'')) tablespace '
|| SUBSTR (v_tblspc_name, 1, 2)
|| UPPER (p_sml)
|| v_last_partition_year
|| TRIM (TO_CHAR (v_last_partition_month, '00'))
|| v_compress_type;
ELSE
v_sql :=
'alter table '
|| p_schema_name
|| '.'
|| p_table_name
|| ' add partition '
|| v_partition_name
|| v_last_partition_year
|| TRIM (TO_CHAR (v_last_partition_month, '00'))
|| ' values less than (to_date ('' '
|| v_last_partition_year
|| '-'
|| TRIM (TO_CHAR (v_last_partition_month + 1, '00'))
|| '-01 00:00:00'
|| ''', ''SYYYY-MM-DD HH24:MI:SS'', ''NLS_CALENDAR=GREGORIAN'')) tablespace '
|| SUBSTR (v_tblspc_name, 1, 2)
|| UPPER (p_sml)
|| v_last_partition_year
|| TRIM (TO_CHAR (v_last_partition_month, '00'))
|| v_compress_type;
END IF;
DBMS_OUTPUT.put_line (v_sql);
p_message := 'Successful';
ELSE
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
p_message :=
'End date specified is less than the last available partition date: '
|| v_last_partition;
END IF;
ELSE
p_message := 'There are currently no partitions on the table';
END IF;
ELSE
RAISE v_no_table_found;
END IF;
EXCEPTION
WHEN v_no_table_found
THEN
raise_application_error (
-20735,
'Please Check the table name you may be entered wrong table name or table doesnot exists');
WHEN v_invalid_data
THEN
raise_application_error (-20734, 'you can only enter CFAO,None or CO');
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (SQLCODE || ':' || SQLERRM);
END;
/
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
After the procedure is created: to check the validity create a sample table:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Ex:
alter table tdf1496.MTH_TEST add partition P_ACTL_RLS_M_201004 values less than (to_date (' 2010-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
'NLS_CALENDAR=GREGORIAN')) tablespace TSS201004 compress for all operations
PL/SQL procedure successfully completed.
set serveroutput on size 100000
set define off
variable v_error varchar2(100);
exec Gen_Part_Mtly ('tdf1496','MTH_TEST','08','2010','None','S',:v_error);
alter table tdf1496.MTH_TEST add partition P_ACTL_RLS_M_201005 values less than (to_date (' 2010-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
'NLS_CALENDAR=GREGORIAN')) tablespace TSS201005
alter table tdf1496.MTH_TEST add partition P_ACTL_RLS_M_201006 values less than (to_date (' 2010-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
'NLS_CALENDAR=GREGORIAN')) tablespace TSS201006
alter table tdf1496.MTH_TEST add partition P_ACTL_RLS_M_201007 values less than (to_date (' 2010-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
'NLS_CALENDAR=GREGORIAN')) tablespace TSS201007
alter table tdf1496.MTH_TEST add partition P_ACTL_RLS_M_201008 values less than (to_date (' 2010-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
'NLS_CALENDAR=GREGORIAN')) tablespace TSS201008
PL/SQL procedure successfully completed.
set serveroutput on size 100000
set define off
variable v_error varchar2(100);
exec Gen_Part_Mtly ('tdf1496','MTH_TEST','12','2010','co','S',:v_error);
alter table tdf1496.MTH_TEST add partition P_ACTL_RLS_M_201009 values less than (to_date (' 2010-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
'NLS_CALENDAR=GREGORIAN')) tablespace TSS201009 compress
alter table tdf1496.MTH_TEST add partition P_ACTL_RLS_M_201010 values less than (to_date (' 2010-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
'NLS_CALENDAR=GREGORIAN')) tablespace TSS201010 compress
alter table tdf1496.MTH_TEST add partition P_ACTL_RLS_M_201011 values less than (to_date (' 2010-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
'NLS_CALENDAR=GREGORIAN')) tablespace TSS201011 compress
alter table tdf1496.MTH_TEST add partition P_ACTL_RLS_M_201012 values less than (to_date (' 2011-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
'NLS_CALENDAR=GREGORIAN')) tablespace TSS201012 compress
PL/SQL procedure successfully completed.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Compress:
Table compression was introduced in Oracle 9i as a space saving feature for data warehousing projects. In 11g it is now considered a
mainstream feature that is acceptable for OLTP databases. In addition to saving storage space, compression can result in increased I/O
performance and reduced memory use in the buffer cache. These advantages do come at a cost, since compression incurs a CPU
overhead, so it won't be of benefit to everyone.
The compression clause can be specified at the tablespace, table or partition level with the following options:
NOCOMPRESS - The table or partition is not compressed. This is the default action when no compression clause is specified.
COMPRESS - This option is considered suitable for data warehouse systems. Compression is enabled on the table or partition
during direct-path inserts only.
COMPRESS FOR DIRECT_LOAD OPERATIONS - This option has the same affect as the simple COMPRESS keyword.
COMPRESS FOR ALL OPERATIONS - This option is considered suitable for OLTP systems. As the name implies, this option
enables compression for all operations, including regular DML statements. This option requires the COMPATIBLE initialization
parameter to be set to 11.1.0 or higher.
Please note that there is common misconception that 11g table compression decompresses data while reading and holds it in the
uncompressed form in the cache. That is not quite correct since one of the salient features of the database compression is that we do
not have to uncompress the data before reading it and the data stays in the compressed form even in the cache. As a result, Oracle
table compression not only helps customers save disk space, it also helps to increase cache efficiency since more blocks can now fit in
the memory.
Overhead at DML time - Whenever a SQL update, insert of delete changes a data block in RAM, Oracle must determine if the data
block should be unlinked from the freelist (this threshold is defined by the PCTFREE parameter). Compression on write - An
outbound data block must be compressed to fit into it's tertiary block size (as defined by db_block_size and the tablespace blocksize
keyword). For example, an uncompressed block in RAM might occupy up to 96k in RAM and be compressed into it's tertiary disk
blocksize of 32k upon a physical disk write. Decompress on read - At physical read time, incoming disk blocks must be expanded
once and stored in the RAM data buffer. The exact mechanism for this expansion is not published in the Oracle11g documentation,
but it's most likely a block versioning scheme similar to the one used for maintaining read consistency. Increased likelihood of disk
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
contention - Because the data is tightly compressed on the data blocks, more rows can be stored, thus increasing the possibility of
"hot" blocks on disk. Of course, using large data buffers and/or solid-state disk (RAM-SAN) will alleviate this issue.
The restrictions associated with table compression include:
Compressed tables can only have columns added or dropped if the COMPRESS FOR ALL OPERATIONS option was used.
Compressed tables must not have more than 255 columns.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Partitioned Indexes Provide the same Functionality as the Table Partitions( Improve Manageability, availability, performance,
scalability)
Types of indexes:
i) Global Indexes (Useful for the OLTP systems, Tougher to Manage)
ii) Local Indexes (Useful for the DSS, DWh systems, easier to manage Usually recommended by oracle)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Local partitioned indexes support more availability when there are partition or subpartition maintenance operations on the table. A
type of index called a local nonprefixed index is very useful for historical databases. In this type of index, the partitioning is not
on the left prefix of the index columns.
You cannot explicitly add a partition to a local index. Instead, new partitions are added to local indexes only when you add a
partition to the underlying table. Likewise, you cannot explicitly drop a partition from a local index. Instead, local index partitions
are dropped only when you drop a partition from the underlying table.
A local index can be unique. However, in order for a local index to be unique, the partitioning key of the table must be part of the
index's key columns.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
These indexes can be maintained by appending the clause UPDATE INDEXES to the SQL statements for the operation. The
two advantages to maintaining global indexes:
The index remains available and online throughout the operation. Hence no other applications are affected by this operation.
The index doesn't have to be rebuilt after the operation.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>