Partitioning A table on a data column

Hi,
My requirement is to partition a table using a column with DATE datatype.
Example:
CREATE TABLE parttab
STATUS CHAR(1) DEFAULT 'a' NOT NULL,
UPDATER VARCHAR2(55) NOT NULL,
UPDTIME DATE DEFAULT SYSDATE NOT NULL
TABLESPACE part_tbs
Now i want to RANGE partition the above table on the "UPDTIME" column, so that it will look like:
Partition Value from Value till
P1 01-Jan 31-Mar
P2 01-Apr 30-Jun
P3 01-Jul 30-Sep
P4 MAXVALUE
I tried using the below syntax, but failed with error.
CREATE TABLE parttab
STATUS CHAR(1) DEFAULT 'a' NOT NULL,
UPDATER VARCHAR2(55) NOT NULL,
UPDTIME DATE DEFAULT SYSDATE NOT NULL
TABLESPACE part_tbs
LOGGING
PARTITION BY RANGE (UPDTIME)
PARTITION P1 VALUES LESS THAN (to_date('04','MM')) LOGGING COMPRESS TABLESPACE part_tbs_P1,
PARTITION P2 VALUES LESS THAN (to_date('07','DD-MM')) LOGGING COMPRESS TABLESPACE part_tbs_P2,
PARTITION P3 VALUES LESS THAN (to_date('10','DD-MM')) LOGGING COMPRESS TABLESPACE part_tbs_P3,
PARTITION P4 VALUES LESS THAN (MAXVALUE) LOGGING COMPRESS TABLESPACE part_tbs_P4
COMPRESS
NOCACHE
PARALLEL ( DEGREE 2 INSTANCES Default )
ROWDEPENDENCIES
NOMONITORING
ENABLE ROW MOVEMENT;
Please suggest.
Thanks in advance for the suggestions.

what is the error message and your Oracle version? this sample may assist I guess -
CREATE TABLE range_part (
prof_history_id NUMBER(10),
person_id       NUMBER(10) NOT NULL,
organization_id NUMBER(10) NOT NULL,
record_date     DATE NOT NULL,
ph_comments     VARCHAR2(200))
PARTITION BY RANGE (record_date) (
PARTITION yr0 VALUES LESS THAN (TO_DATE('01-JAN-2000','DD-MON-YYYY'))
TABLESPACE part1,
PARTITION yr1 VALUES LESS THAN (TO_DATE('01-JAN-2001','DD-MON-YYYY'))
TABLESPACE part2,
PARTITION yr2 VALUES LESS THAN (TO_DATE('01-JAN-2002','DD-MON-YYYY'))
TABLESPACE part3,
PARTITION yr9 VALUES LESS THAN (MAXVALUE) TABLESPACE part4);for more examples you may visit - http://psoug.org/reference/partitions.html

Similar Messages

  • Range partition the table ( containing huge data ) by month

    There ia a table with huge data ard 9GB.This needs to range patitioned by month
    to improve performance.
    Can any one suggest me the best option to implement partitioning in this.

    I have a lot of tables like this. My main tip is to never assign 'MAXVALUE' for your last partition, because it will give you major headaches when you need to add a partition for a future month.
    Here is an example of one of my tables. Lots of columns are omitted, but this is enough to illustrate the partitioning.
    CREATE TABLE "TSER"."TERM_DEPOSITS"
    ( "IDENTITY_CODE" NUMBER(10), "ID_NUMBER" NUMBER(25),
    "GL_ACCOUNT_ID" NUMBER(14) NOT NULL ,
    "ORG_UNIT_ID" NUMBER(14) NOT NULL ,
    "COMMON_COA_ID" NUMBER(14) NOT NULL ,
    "AS_OF_DATE" DATE,
    "ISO_CURRENCY_CD" VARCHAR2(15) DEFAULT 'USD' NOT NULL ,
    "IDENTITY_CODE_CHG" NUMBER(10)
    CONSTRAINT "TERM_DEPOSITS"
    PRIMARY KEY ("IDENTITY_CODE", "ID_NUMBER", "AS_OF_DATE") VALIDATE )
    TABLESPACE "DATA_TS" PCTFREE 10 INITRANS 1 MAXTRANS 255
    STORAGE ( INITIAL 0K BUFFER_POOL DEFAULT)
    LOGGING PARTITION BY RANGE ("AS_OF_DATE")
    (PARTITION "P2008_06" VALUES LESS THAN (TO_DATE(' 2008-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    TABLESPACE "DATA_TS_PART1" PCTFREE 10 INITRANS 1
    MAXTRANS 255 STORAGE ( INITIAL 1024K BUFFER_POOL DEFAULT)
    LOGGING NOCOMPRESS , PARTITION "P2008_07" VALUES LESS THAN (TO_DATE(' 2008-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
    'NLS_CALENDAR=GREGORIAN'))
    TABLESPACE "DATA_TS_PART2" PCTFREE 10 INITRANS 1 MAXTRANS 255
    STORAGE ( INITIAL 1024K BUFFER_POOL DEFAULT) LOGGING NOCOMPRESS )
    PARALLEL 3

  • Partition a table after loading data

    Hi there,
    Is it possible to partition a table after loading the data in OWB?
    Thanks

    Yes, it is. You would add a partition information (type, key, storage) in OWB Configuration menu of your table. More on this in User's Guide, Chapter 5 "Creating Indexes and Partitions". Next, when you deploy your changed table, Warehouse Builder detects that the table was previously deployed and offers the default action called 'Upgrade'. That action performs all the necessary steps for you without any manual work: RENAME existing table, CREATE new table with partitions, INSERT data from old to new table, DROP old table. Throughout this operation you have an added benefit of automatic recovery if anything goes wrong.
    Nikolai

  • Partitioning on the base of date

    hi,
    im having a PROBLEM IN CREATING A TABLE containing a date column having range partitioning on it. my table an accompanying error is :
    CREATE TABLE A123 (A NUMBER, B DATE)
    PARTITION BY RANGE (B)
    (PARTITION B1 VALUES LESS THAN (TO_DATE((SYSDATE - INTERVAL '30' DAY),'DD-MON-YYYY')))
    (PARTITION B1 VALUES LESS THAN (TO_DATE((SYSDATE - INTERVAL '30' DAY),'DD-MON-YYYY')))
    ERROR at line 3:
    ORA-14019: partition bound element must be one of: string, datetime or interval literal, number, or MAXVALUE
    i'v also tried it as:
    CREATE TABLE A123 (A NUMBER, B DATE)
    PARTITION BY RANGE (B)
    (PARTITION B1 VALUES LESS THAN (TO_DATE(SYSDATE - INTERVAL '30' DAY,'DD-MON-YYYY')))
    (PARTITION B1 VALUES LESS THAN (TO_DATE(SYSDATE - INTERVAL '30' DAY,'DD-MON-YYYY')))
    ERROR at line 3:
    ORA-14019: partition bound element must be one of: string, datetime or interval literal, number, or MAXVALUE
    as shown above,,i want to create partitions of the table A123 column b which is of date datatype,,i want to have a partition which stores data of SYSDATE - 30,.
    Any suggestions/recommendations would be appreciated.
    thanx
    Regards

    hi,
    sorry im calling u again for support,,
    the way u told for creating a table based on date column partitions creates a table with fixed date as a HIGH/UPPER BOUND,,for example if i create a table A123 as :
    begin
    execute immediate 'CREATE TABLE A123 (A NUMBER, B DATE)
    PARTITION BY RANGE (B)
    (PARTITION B4 VALUES LESS THAN (TO_DATE(('''||to_char(SYSDATE - INTERVAL '90' DAY,'DD-MON-YYYY')||'''),''DD-MON-YYYY''))
    ,PARTITION B3 VALUES LESS THAN (TO_DATE(('''||to_char(SYSDATE - INTERVAL '60' DAY,'DD-MON-YYYY')||'''),''DD-MON-YYYY''))
    ,PARTITION B2 VALUES LESS THAN (TO_DATE(('''||to_char(SYSDATE - INTERVAL '30' DAY,'DD-MON-YYYY')||'''),''DD-MON-YYYY''))
    ,PARTITION B1 VALUES LESS THAN (MAXVALUE))';
    end;
    ALTER TABLE A123 ENABLE ROW MOVEMENT
    now the HIGH VALUE for partition B2 is January 03,2005...
    while i want it to be dynamic.
    means after 2 months the high value for B2 partition should be (Jan 03,2005 + 2 months)..
    can we do this in oracle??
    Regards.

  • ViewObject (Date column) works fine in 9.0.3 but causes errors in 9.0.5

    Good Morning,
    I have generated entity/view objects, from the same table, for JDev9.0.3 and JDev9.0.5. The application runs fine under JDev9.0.3.
    When I drag/drop a view onto the design panel within 9.0.5 and run its associated dataAction two unexpected thing occur.
    1. The table displays 'no records found' in the browser. I am certain the table has thousand's of records.
    2. When I refresh the browser (hold the ctrl key and click MS Explorers refresh button) I receive the following error:
    oracle.jbo.domain.DataCreationException: JBO-25009: Cannot create an object of type:oracle.jbo.domain.Date with value:oracle.sql.TIMESTAMP@2228
    I can reproduce this error on 'any' table which have date columns. Again, the same view displays fine under 9.0.3. Can this problem be reproduced on your end using 9.0.5? If so, there a work-around? If not, do you have any ideal on what would cause this? Is there a workaround or a patch?
    Thank you

    I am basically following the procedures described here:
    http://otn.oracle.com/products/jdev/collateral/tutorials/9050/adfuix_tut.html
    My Date column attributes are set as follows:
    Entity Attribute Tab;
    a. The name is DateCreated
    b. The type is Date
    c. Updateable is Always
    d. Persistend and Queriable is checked.
    Attribute Properties Tab:
    Default values
    Control Hints Tab:
    a. Display Hint: Display
    b. Format Type: Simple Date
    c. Format: yyyy-MM-dd
    d. Control Type: Default
    e. Form Type: Detail
    My business components were created from my
    'Business Components Diagram'. I created the diagram using dnd from a table located under the 'Connections --> Database' pane.
    I also have a StrutsPageFlow diagram. When I dnd a viewobject onto one of my "uix" pages, I do not see 'EL' binding syntax on any date columns. I can see this information within my other columns.
    I understand the Emp table has a HireDate column. Are you able to display the 'HireDate' column on a uix page? If you are and were using the same build of JDeveloper, then I need to figure out what Im doing wrong. My first guess is the way 9.0.2/9.0.3 handled dates and the way 9.0.5 is handling dates is different.
    Thanks

  • Query on a table with indexed date field

    I have a table with a date column which is indexed. If I run a query like "select column1 where date_field='20-JAN-04' for example it is fast and uses index.
    If I run select column1 where date < '20-JAN-04' it is slow and doesnt use the index. I logged a TAR and Oracle told me that this is to be expected as not using the index in this case is the most effiecient way of doing the query.
    Now my concept of an index is like the index of Yellow Pages(telephone directory) for example. In this example if I look for a name that is say "Halfords" or below, I can see all entries for Halfords and all the way to ZZZ in one block.
    I just cant see , in a common sense way why Oracle wont use the index in this type of query.
    George

    Using the concept of a telephone directory is wrong. In a telephone directory you have all information order by the name. However in your table (if it is not an IOT) you don't have all information/rows ordered by your date_field. Rather think at the document "Oracle9i Database Concepts" and it's index.
    Let's say you want to find all indexed words larger then "ISO SQL standard" (ok that doesn't make sense but it is just an example). So would it be faster to read the whole document or to lookup each word in the index and then read the entire page (Oracle block) to find the word.
    It's not allways easy to know in advance if the query will be faster over the index or a full table scan. what you need to do is to well analyze (dbms_stats) the table and it's index, in most cases Oracle chooses the right way. You may also use the hint /*+ index(table_name index_name) */ and will see if it would be faster over the index or not.
    A good document about that subject is:
    http://www.ioug.org/tech/IOUGinDefense.pdf
    HTH
    Maurice

  • 2 date columns and one dimension hierarchy

    Hi,
    I have one question in OBIEE 10g.
    I have one dimension table with 2 date columns (insertedOn, updatedOn)
    I created insertedOnYear, insertedOnMonth and updatedOnYear, updatedOnMonth columns from my date columns.
    I have hierarchy
    Year -> Month -> Day for that dimension table
    and I would like to dril down both columns insertedOnYear and updatedOnYear
    insertedOnYear -> insertedOnMonth -> insertedOn
    updatedOnYear-> updatedOnMonth -> updatedOn
    I am able to do it only for one of these columns and not for both.
    I can place both columns to appropriate levels, but drilling doesn´t work as I want
    Can you tell me how to solve my problem?

    Oops, I was talking about 11G. Ok no problem. Do this. In the physical layer, cretea 2 alias tables. Both pointing to the table where you have these 2 fields. The put everything in your BMM. There create the 2 hierarchies using the 2 different tables (that will point to the 2 alias tables create in the physical layer). This will make them unique.

  • Grouping by week using Date column

    I have a table with a date column. I'd like to generate a report grouping all entries by week. Is this possible with the date expressions/functions within Oracle?
    Thanks

    What is your definition of a week?
    select to_char(sysdate, 'IW') from dual
    will return 21 which is the week of the year according to the ISO standard
    So a query such as
    SELECT TO_CHAR(mydate, 'IW'), col1, col2
    FROM mytable
    GROUP BY TO_CHAR(mydate, 'IW')
    will group the data by the ISO week.
    You may also want to select the year as part of the query.
    null

  • How to insert date column entry for new row from adf bc tester

    Hi,
    JDeveloper version 11.1.1.5.0
    I have a table with a DATE column. I am trying to insert a new row into the table from the ADF BC Tester. While providing value to the DATE column I am hitting the below error:
    (oracle.jbo.domain.DataCreationException) JBO-25009: Cannot create an object of type:oracle.jbo.domain.Date from type:java.lang.String with value:2011/12/06
    Please let me know what should be the format to specify date value while inserting entry using BC Tester.
    Thanks
    Rathnam

    Hi,
    Check
    operation not allowed on java.lang.object

  • What is the best way to dynamically create table partition by year and month based on a date column?

    Hi,
    I have a huge table and it will keep growing. I have a date column in this table and thought of partition the table by year and month. Can any you suggest better approach so that partition will create automatically for new data also along with the existing
    data? Nothing but automatically/dynamically partition should create along with file group and partition files.
    Thanks in advance!
    Palash 

    Also this one
    http://weblogs.sqlteam.com/dang/archive/2008/08/30/Sliding-Window-Table-Partitioning.aspx
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Table partition based multiple date columns

    Hi , I am using Oracle 10G db. One of the source table has 26 million rows. Partition is based on business send date(Quaterly). Now the query that used to load the target table is based on ETL load date. Since the load date is not the partition column,the source query is taking long time to fetch.Can someone please suggest how to include ETL load date in the partition column or if any other way to improve the performance of the source query will be greatly appreciated.Thanks

    Partition is based on business send date(Quaterly).
    Can someone please suggest how to include ETL load date in the partition column
    Technically? Sure - just redefine the table (DBMS_REDEFINITION) and partition it on ETL load data.
    But someone partitioned on 'send date' for a reason didn't they? Don't you think you might want to find out WHY before you even think about changing it?
    The only info you have provided so far is that someone 'thinks' that a single query is 'taking long time to fetch'. That doesn't even mean anything. What is 'long time': 5 seconds, 5 days? How many rows are being fetched out of 26 million: 1, 20 million?
    1. post the table and index DDL
    2. post the query and execution plan
    3. post the command you executed to produce the stats on the table and indexes
    4. post the number of rows for the query predicates
    5. post info about the number of rows in the result set and what you are doing with them

  • Performance tuning -index on big table on date column

    Hi,
    I am working on Oracle 10g with Oracle Apps 11i on Sun.
    we have a large non-partition table "GL_JE_HEADERS" with 7 million rows.
    Now we want to run the query for selecting rows using between clause on date column.
    I have created Btree index on the this table.
    Now how can I tune the query? Which hint should I use for the query?
    Thanks,
    rane

    Hi Rane,
    Now how can I tune the query?Indexes on DATE datatypes are tricky, as the SQL queries must match the index!
    For example, an index on ship_date would NOT match a query:
    WHERE trunc(ship_date) > trunc(sysdate-7);
    WHERE to_char(ship_date,’YYYY-MM-DD’) = ‘2004-01-04’;
    You may need to create an function-basd index, so that the DATE reference in your SQL matches the index:
    http://www.dba-oracle.com/oracle_tips_index_scan_fbi_sql.htm
    To start testing, go into SQL*Plus and "set autotrace on" and run the queries.
    Then confirm that your index is being used.
    Which hint should I use for the query?Hints are a last resort!
    Your query is fully tuned when it fetches the rows you need with a minimum of block touches (logical reads, consistent gets).
    See here for details:
    http://www.dba-oracle.com/art_sql_tune.htm
    Hope this helps . . .
    Donald K. Burleson
    Oracle Press author
    Author of "Oracle Tuning: The Definitive Reference"
    http://www.rampant-books.com/book_2005_1_awr_proactive_tuning.htm

  • ADF Unable to filter / sort date column in table

    Hi,
    I am using JDeveloper 11.1.1.7.
    I have a read only table inside a panel collection. One of the columns in the table is a date field. I have filterable and sortable properties set to true for all columns. Filter and sort property works for all columns expect the date column. The filter and sort options is not even shown for the date field (shown below).
    <af:column headerText="#{bindings.ASRTCreateRequestVO1.hints.CreationDate.label}"
                                             id="c7" sortable="true" width="100"
                                             filterable="true">
                                    <af:outputText value="#{row.CreationDate}"
                                                   id="ot7">
                                      <af:convertDateTime pattern="#{bindings.ASRTCreateRequestVO1.hints.CreationDate.format}"/>
                                    </af:outputText>
                                  </af:column>
    Please let me know if I am missing anything here.
    Thanks,
    Ashwin

    Hi Ashwin,
    As mentioned by Timo, for me also the filtering is working as usual.
    But while browsing through the ADF UI Guide I came across with below note
    If you want to use a component other than an inputText component for your filter (for example, an inputDate component), then instead of setting filterVisible to true, you can add the needed component to the filter facet.
    To do so:
    1. In the Structure window, right-click the column to be filtered and choose Insert inside af:column > JSF Core > Filter facet.
    2. From the Component Palette, drag and drop a component into the facet.
    3. Set the value of the component to the corresponding attribute within the FilterableQueryDescriptor class created in Step 1(not above step but you can find it in pg:390). Note that the value must take into account the variable used for the row, for example:
    #{af:inputDate label="Select Date" id="name" value="row.filterCriteria.date"}.
    This is in the section: 12.5.1 How to Add Filtering to a Table(pg:390).
    I hope it helps.
    Regards,
    Peddi.

  • Date Column not getting sorted in a table in web Dynpro Java

    Hi All,
    I am facing an issue while sorting the date column in a table in my web dynpro java application.
    When the date is displayed in the sql format in tha table, I am able to sort the date column successfully but when we convert the date field from sql format to util format in our table and then sort it does not work.
    Kindly let us know the steps to be followed in this case to sort the date column of a table in Simple Date format as we do not want date in the sql format to be displayed.
    Thanks & Regards,
    Anurag

    Hi,
    You might want to check whether both your browser's language settings are identical. The browser language could also determine the date format.
    As a workaround, you could add an extra attribute to your context, and set the calculated property to 'true'.
    In your table, add a new column and bind to this new attribute, and hide your original date column
    If you sort using the date column that's hidden now, you could use the calculated field to fixed-format your date the way you prefer (by using the SimpleDateFormatter class for instance)
    Cheers,
    Robin

  • Merge Two Tables with the same columns but different data

    I have a table that has the following columns:
    Current Table Definition
    commonname
    family
    genus
    species
    subspecies
    code
    I have a number of entries that don’t fit the current table definition – that is that they only have a common name or description and a code. These records don’t actually represent a species but are needed for data entry because they represent an object that may be encountered in the study (Bare Ground – which isn’t a species but would need to be recorded if encountered). So I would really like 2 tables:
    Table 1 Miscellaneous
    name
    code
    Table 2 Plant Species
    commonname
    family
    genus
    species
    subspecies
    code
    I would like two tables so I can enforce certain constraints on my species table like requiring that the family, genus, species, subspecies combination is unique. I can’t do this if I have all the “other” records that don’t have a family, genus, species, or subspecies unless I put in a lot of dummy data into the fields to make each record unique. I don’t really want to do this because these miscellaneous records really don’t represent a specific species.
    So – the problem is that while I want this data separate I will need to point a column from another table to the code column in both tables.
    How is this best done? Table? View? Merge?

    Hi,
    Actually you don't have to use scope refs. Sorry but I misunderstood you earlier. Here is a complete example that does exactly what you want. Notice how I added the constraint to the materialized view. Also notice when we try to insert a code in tbl3 that doesn't exist in the view, we get an error. HTH.
    SQL> create table tbl1 (name varchar2(10), code varchar2(3) primary key);
    Table created.
    SQL> create table tbl2 (commonname varchar2(10), code varchar2(3) primary key);
    Table created.
    SQL> insert into tbl1 values ('n1','c1');
    1 row created.
    SQL> insert into tbl1 values ('n2','c2');
    1 row created.
    SQL> insert into tbl1 values ('n3','c3');
    1 row created.
    SQL> insert into tbl2 values ('name1','c1');
    1 row created.
    SQL> insert into tbl2 values ('name2','c2');
    1 row created.
    SQL> insert into tbl2 values ('name3','c3');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> create materialized view view1 as select name, commonname, tbl1.code from tbl1, tbl2 where tbl1.code = tbl2.code;
    Materialized view created.
    SQL> select * from view1;
    NAME COMMONNAME COD
    n1 name1 c1
    n2 name2 c2
    n3 name3 c3
    SQL> create table tbl3 (code varchar2(3), record varchar2(1));
    Table created.
    SQL> alter table view1 add constraint view1pk primary key (code); -- <-Note how I added a constraint to the view
    Table altered.
    SQL> alter table tbl3 add constraint tbl3fk foreign key (code) references view1(code);
    Table altered.
    SQL> insert into tbl3 values ('c1','r');
    1 row created.
    SQL> insert into tbl3 values ('c99','r');
    insert into tbl3 values ('c99','r')
    ERROR at line 1:
    ORA-02291: integrity constraint (RAJS.TBL3FK) violated - parent key not found
    SQL> spool of;
    -Raj Suchak
    [email protected]

Maybe you are looking for