11.07.2015 Views

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 12 ■ DATA WAREHOUSING 547Let’s create our first baseline interval partition and see how <strong>Oracle</strong> maintains partitions forus. Here’s a table called EBDA_ALERT_NOTIFICATIONS that houses all the database alerts for theDBAs:CREATE TABLE edba_alert_notifications(alert_notification_id number,subject varchar2(2000),hostname varchar2(55),database_name varchar2(55),severity varchar2(1),alert_log_id number,message varchar2(4000),creation_date date default sysdate,created_by varchar2(55),modification_date date default sysdate,modified_by varchar2(55))partition by range (creation_date)interval (numtoyminterval(1,'MONTH'))( PARTITION p_jan2007 VALUESLESS THAN (TO_DATE('01-JAN-2007','DD-MON-RRRR')))/Table created.You can see that CREATION_DATE is the partitioning key for this table using the numtoymintervalfunction based on the month. Let’s query USER_TAB_PARTITIONS to verify that this table wascreated accordingly. The following query example shows that high_value for the partition is2007-01-01 00:00:00:SQL> col partition_name for a20SQL> col high_value for a50 word_wrappedSQL> select partition_name, high_value2 from user_tab_partitions3 where table_name='EDBA_ALERT_NOTIFICATIONS'4* order by partition_position5 /PARTITION_NAME HIGH_VALUE---------------- -------------------------------------P_JAN2007TO_DATE(' 2007-01-01 00:00:00', 'SYYYY-MM-DDHH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')Now, let’s insert 12 rows to simulate 12 months of rolling partitions. These rows are fabricated,but the key point is that the CREATION_DATE column has the first day of each month forthe year 2007.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!