Add sub partition on another column in oracle

I have a table which has two partitions (by range): first_half and second_half based on a column "INSERT_DAY".
I need to add subpartitions "SUCCESS" and "NONSUCCESS" based on the values of another column "STATUS" (subpartition by list) i.e. I need to transform my range partition to composite (range-list) partition.
I do not wish to drop existing tables or partitions. What is the ALTER query for this?
PS: The database is Oracle 9i

Ok, my bad. The project is about charging GPRS customers for data usage.
Here is the real DDL:
CREATE TABLE CDR_EVENT_RCD_FILE_MOB_AGG
   (    "MOBILE_NO" VARCHAR2(16 BYTE),
    "DATA_VOLUME" NUMBER(*,0),
    "CHARGE" NUMBER(*,0),
    "RECORD_COUNT" NUMBER(*,0),
    "COUNTER" NUMBER(*,0) DEFAULT 0,
    "INSERT_DAY" NUMBER(*,0),
    "MAX_FILE_SEQ_NO" NUMBER(*,0),
    "MIN_FILE_SEQ_NO" NUMBER(*,0),
    "REQUEST_ID" VARCHAR2(21 BYTE),
    "TRANSACTION_ID" VARCHAR2(21 BYTE),
    "RESPONSE_TIME" TIMESTAMP (6),
    "RETURN_CODE" CHAR(2 BYTE),
    "FAILURE_REASON" VARCHAR2(1024 BYTE),
    "CHARGED_AMOUNT" NUMBER(*,2)
  PARTITION BY RANGE ("INSERT_DAY")
(PARTITION "FIRST_HALF"  VALUES LESS THAN (16)  ,
PARTITION "SECOND_HALF"  VALUES LESS THAN (MAXVALUE) ) ;
  CREATE INDEX "CDRDEVTBS"."MAX_FILE_SEQ_NO_INDEX" ON "CDRDEVTBS"."CDR_EVENT_RCD_FILE_MOB_AGG" ("MAX_FILE_SEQ_NO") ;
  CREATE INDEX "CDRDEVTBS"."MOBILE_NO_INDEX" ON "CDRDEVTBS"."CDR_EVENT_RCD_FILE_MOB_AGG" ("MOBILE_NO") ;
As you can see, it is partitioned by range on "Insert_day".
The requirement is to delete all the records having counter=3 (which means successful charging) for the records which are older than 15 days.
So I thought, why not create sub partitions with counter so that final DDL would be something like the following. I would then avoid writing a DELETE query, which would take a lot of time to execute.
CREATE TABLE CDR_EVENT_RCD_FILE_MOB_AGG (
    insert_day INT,
    counter INT,
--other columns
PARTITION BY RANGE (insert_day)
SUBPARTITION BY LIST(counter)
SUBPARTITION TEMPLATE
    SUBPARTITION SUCCESS VALUES(3),
    SUBPARTITION NONSUCCESS VALUES(DEFAULT)
    PARTITION first_half VALUES LESS THAN (16),
    PARTITION second_half VALUES LESS THAN (maxvalue)
So that I could execute queries:
alter table CDR_EVENT_RCD_FILE_MOB_AGG  truncate subpartition first_half_success; --execute on last day of every month
alter table CDR_EVENT_RCD_FILE_MOB_AGG  truncate subpartition second_half_success; -- execute on 16th day of every month
to remove unnecessary records.
I would like to create subpartitions without dropping the existing table.

Similar Messages

  • Need to get sequence value in another column in oracle

    Hi ALL,
    I have sql query as below
    select header_id,order_number from oe_order_headers_all.
    and data it is displaying as
    heder_id     order_number
    111            500001
    121            500400
    I need to display  another field with some sequence value like as below
    id     heder_id     order_number
    1      111                    500001
    2      121                    500400
    so how to get sequence value in another column please help me on this.
    Thnaks

    You can just use ROWNUM Pseudocolumn
    select rownum id, header_id,order_number from oe_order_headers_all

  • Add New partition

    Hello,
    Oracle 11.2.0.1
    Windows
    I am having one partitioned IOT something like this :
    create table my_table (
    col1 number(10) not null,
    col2 varchar2(7) not null,
    col3 varchar2(20) not null,
    col4 varchar2(20) not null,
    col5 varchar2(20) not null,
    col6 date not null,
    col7 number(4) not null,
    col8 varchar2(1) not null,
    col9 varchar2(1) not null,
    primary key(col1,col2,col3,col4,col5,col6,col7,col8,col9)
    organization index
    partition by range (col3,col4,col5)
    (partition p1 values less than('A%','A%','A%'),
    partition p2 values less than('B%','B%','B%'),
    partition p3 values less than('C%','C%','C%'),
    PARTITION p27 VALUES LESS THAN (MAXVALUE,MAXVALUE,MAXVALUE))
    Now, I want to add new range partition on column col7. There is an index exist on col7 too, but since table is carrying around 200 million rows, only having index is not looking good, so I thought to add similar type of partition on col7. In col7 there are range value between 2000 to 2010 only.
    Kindly tell me how do I proceed to add new partition on another column of existing partitioned IOT please.
    Thanks.

    i thought that I am having the data of all student_name, father_name and mother_name whose name starts from A in partition p2 (because B is less than A) and like wise upto Z. Am I clear this ? I mean, if I says a student whose name is Boby John (partition p3), father name Robert (partition p19) and mother name Lilly (partition p13) ?A row can be in exactly one partition. It can't be in three different partitions. If you want to create 26*26*26 partitions, then you could have a separate partition for each possible combination. If you want just 26 partitions, you would realistically only want to partition by one column (presumably student_name).
    select * from my_table where student_name like '%Boby%' and father_name like '%Robert%' and mother_name like '%Lilly%' and passing_year=2001. This would prevent Oracle from doing any sort of partition pruning since you're looking for a string anywhere within the name. You'd be better off not partitioning the table at all if you want to run this sort of query. You'd be much better off using Oracle Text and turning your LIKE conditions into CONTAINS conditions.
    So, I think oracle is using 3 partitions i.e. P3 for Boby, P19 for Robert and P13 for Lilly. Upto this query is running fine and very good, no issue of slowness, but when ever query gets year=something other than 2001, it takes time. So, I thought I should have partitions on passing_year column too.No. A row exists in exactly 1 partition. Oracle has to scan all 26 partitions to satisfy this query. It would be more efficient not to partition the table at all. Even if you created 26*26*26*10 partitions, Oracle would still have to scan 26*26*26 partitions since passing_year is the only predicate on which you could do partition pruning. But that is unlikely to be useful-- you'd almost certainly be better off with no partitioning.
    Justin

  • Any overhead with sub partitioning within a time based column?

    We have a table that's partitioned based on a weekly partition and it has records of Type A and records of Type B and there are processes that are only interested in records of Type B.
    Right now the table is partitioned as interval on the timestamp column as a weekly partitioning but I'm considering introducing sub partitioning into the mix based on these record Types.
    Is that feasible?

    >
    We have a table that's partitioned based on a weekly partition and it has records of Type A and records of Type B and there are processes that are only interested in records of Type B.
    >
    Whether to partition on the 'type' column depends on the data skew and how the type data is accessed.
    If the access and skew is such that an index would be used then just use an index - no need to partition. For example if only 5% of the data is Type B then you could probably use an index effectively for accessing only Type B data.
    For Type A data (95%) a full table scan will be used and Oracle will skip/ignore the 5% of the data this Type B so no partitioning is needed.
    Subpartitioning would be useful if an index won't help filter the data and you want Oracle to filter it automatically.
    You will need to either redefine the table (using DBMS_REDEFINITION) or recreate the table to if you want to add subpartitioning.

  • F-32:Add another column

    Dear all,
    Iu2019m in F-32 and Iu2019m trying to add another column (field BSEG-XREF3) but I cannot find the button u201Cchange layoutu201D .
    Is it possible modify this screen?
    Thanks in advance

    Hi
    BSEG contains large amount of data. It is not advisiable to add a column.
    You need to contact the ABAPer for this and depends upon the Industry. How large it was?
    Please raise a OSS not for your requirement after getting advise from Technical Consultant.
    Regards
    Odaiah Pelley

  • Design question - add another table or another column?

    Hi there,
    quick design question:
    I have the following tables:
    Traveler
    CreditCard
    Group
    A traveler is going with group X and pay (creditCard) with Y. he can go on multiple groups and can pay with Y or Z...
    my question is this:
    should I make another table CrditCard_Group which will have the following columns:
    user_id
    group_id
    creditCard_id
    or simply to have in the creditCard table another column: Group_id
    thanks for any advise

    This is not JDBC nor Java, it's database modeling.
    Said this, the answer is: it depends; if you have to record the fact that a traveler belonging to a group pays with credit card X you need the table with three ids. If you just need to record the traveler using a credit card and the traveler belonging to a group you need two tables each with the two ids.

  • How to move rows from one partition to another?

    We have a data retention requirement for 6 months and after 6 months the data can be removed except for few records with certain statuses (which cannot be removed even if they are over 6 months). We have Oracle 11g.
    I wanted to see if the following strategy works:
    I will have monthly partitions and 8 sub partitions (hash) in each of the main partitions. The hash sub-partitions are to spread the load of application data and balance the data insertion to avoid any contention.
    At the end of 6 months, is it possible for me to move the row that needs to be kept to a different partition and drop the last partition. I wanted to avoid data deletion because we only have very little database downtime and data deletion require us to coelize the database to avoid fragmentation.
    If I can move the data to another partition, how will I do it?
    Thanks

    I think you didn't get intentions correctly.
    My intention is to move the required data to a partition and then drop the original partition. that because the amount of data required to keep for future use is less than 1%.
    I understood what you meant to convey. Thanks a lot.
    I laid out eh plan something like the following.
    1. Add a new date column to facilitate the partitioning (say its called PARTITION_DT. PARTITION_DT will have the same data as ROW_CREAT_DTTM without the timestamp portion of the date.)
    2. We will start with monthly partition using PARTITION_DT, Create a 'Default' partition as well.
    3. Add hash sub-partitions on MSG_ID to spread the application data load and avoid contention (so the application load is balanced just like how its balanced through the hash partitions today)
    4. At the end of the data retention period, identify the records that needs to be retained (because of some trade statuses, etc ) and update the PARTITION_DT with a distant past date so the row will automatically move to the Default partition. The identification of the records to be retained and updating the PARTITION_DT can be done through a batch job. since this step involve very few records, it can be done in minutes or seconds.
    5. Now, we can drop the oldest partition and rebuild the index if required.
    6 The process should add sufficient number of monthly and its sub-partitions ahead of time to make sure we always have partitions available for new data.
    The entire process can be automated and executed through a scheduled job.

  • Sub Partitioning does not have considerable impact Explain Plan

    Hi Guys,
    I have a table that is list - list sub partitioned on Oracle 11g - 11.2.0.3.
    The first partition is on the CIRCLE_ID column and the second sub partition is on the LOAD_DTTM.
    Now i have tried 2 queries on the database
    1 - select MOBILENUMBER, CLOSING_BAL from GSM_PRR_SUM a1
    where A1.CIRCLE_ID ='AK'
    AND a1.LOAD_DTTM BETWEEN '28-MAR-2012' AND '03-APR-2012';
    2 - select MOBILENUMBER, CLOSING_BAL from GSM_PRR_SUM a1
    where A1.CIRCLE_ID ='AK'
    AND to_char(a1.LOAD_DTTM) like '%MAR%'
    Ideally the 2nd query should take a much higher time than the first query.
    But the explain plan shows a difference of less than 1%.
    Can you pls provide some insights as why Oracle is not understanding that subpartitioning will be faster?
    Thanks,
    Manish

    Hi Dom
    Thanks for your reply.
    Is the first query using partition pruning? - Yes
    Have you gathered stats, etc, etc? - No. All our queries always need to access the entire table and not a particular subset and the where criteria always uses partition and sub partition columns. so we dont see the need to collect stats. Can you pls advise what stats need to be collected and what will be the advantage of those?
    Below are the output of the Explain Plan and Trace Output -
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> show parameter optimizer;
    NAME TYPE VALUE
    optimizer_capture_sql_plan_baselines boolean FALSE
    optimizer_dynamic_sampling integer 2
    optimizer_features_enable string 11.2.0.3
    optimizer_index_caching integer 0
    optimizer_index_cost_adj integer 100
    optimizer_mode string ALL_ROWS
    optimizer_secure_view_merging boolean TRUE
    optimizer_use_invisible_indexes boolean FALSE
    optimizer_use_pending_statistics boolean FALSE
    optimizer_use_sql_plan_baselines boolean TRUE
    SQL> show parameter db_file_multi;
    NAME TYPE VALUE
    db_file_multiblock_read_count integer 128
    SQL> show parameter cursor_sharing
    NAME TYPE VALUE
    cursor_sharing string EXACT
    SQL> column sname format a20
    SQL> column pname foramt 20
    SP2-0158: unknown COLUMN option "foramt"
    SQL> column pname format a20
    SQL> column pval2 format a20
    SQL> select
    2 sname
    3 , pname
    4 , pval1
    5 ,pval2
    6 from sys.aux_stats$;
    from sys.aux_stats$
    ERROR at line 6:
    ORA-00942: table or view does not exist
    SQL> explain plan for
    select MOBILENUMBER, CLOSING_BAL from GSM_PRR_SUM_NEW a1
    where A1.CIRCLE_ID ='KA'
    AND a1.LOAD_DTTM BETWEEN '28-MAR-2012' AND '03-APR-2012'
    SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3032220315
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)
    | Time | Pstart| Pstop |
    PLAN_TABLE_OUTPUT
    | 0 | SELECT STATEMENT | | 41M| 1643M| 548M(100)
    |999:59:59 | | |
    | 1 | PARTITION LIST SINGLE | | 41M| 1643M| 548M(100)
    |999:59:59 | KEY | KEY |
    | 2 | PARTITION LIST ITERATOR| | 41M| 1643M| 548M(100)
    |999:59:59 | KEY | KEY |
    | 3 | TABLE ACCESS FULL | GSM_PRR_SUM_NEW | 41M| 1643M| 548M(100)
    |999:59:59 | KEY | KEY |
    PLAN_TABLE_OUTPUT
    Note
    - dynamic sampling used for this statement (level=2)
    14 rows selected.
    SQL> explain plan for
    select MOBILENUMBER, CLOSING_BAL from GSM_PRR_SUM_NEW a1
    where A1.CIRCLE_ID ='KA'
    AND to_char(a1.LOAD_DTTM) like '%MAR%';
    2 3 4
    Explained.
    SQL> SQL> SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
    PLAN_TABLE_OUTPUT
    Plan hash value: 189546713
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| T
    ime | Pstart| Pstop |
    PLAN_TABLE_OUTPUT
    | 0 | SELECT STATEMENT | | 62M| 2521M| 5435M(100)|99
    9:59:59 | | |
    | 1 | PARTITION LIST SINGLE| | 62M| 2521M| 5435M(100)|99
    9:59:59 | KEY | KEY |
    | 2 | PARTITION LIST ALL | | 62M| 2521M| 5435M(100)|99
    9:59:59 | 1 | 305 |
    |* 3 | TABLE ACCESS FULL | GSM_PRR_SUM_NEW | 62M| 2521M| 5435M(100)|99
    9:59:59 | KEY | KEY |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
    3 - filter(TO_CHAR(INTERNAL_FUNCTION("A1"."LOAD_DTTM")) LIKE '%MAR%')
    Note
    PLAN_TABLE_OUTPUT
    - dynamic sampling used for this statement (level=2)
    19 rows selected.
    SQL>
    SQL> SET AUTOTRACE TRACEONLY ARRAYSIZE 100
    SQL> select MOBILENUMBER, CLOSING_BAL from GSM_PRR_SUM_NEW a1
    where A1.CIRCLE_ID ='KA'
    AND a1.LOAD_DTTM BETWEEN '28-MAR-2012' AND '03-APR-2012' 2 3 ;
    49637012 rows selected.
    Execution Plan
    Plan hash value: 3032220315
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)
    | Time | Pstart| Pstop |
    | 0 | SELECT STATEMENT | | 41M| 1643M| 546M(100)
    |999:59:59 | | |
    | 1 | PARTITION LIST SINGLE | | 41M| 1643M| 546M(100)
    |999:59:59 | KEY | KEY |
    | 2 | PARTITION LIST ITERATOR| | 41M| 1643M| 546M(100)
    |999:59:59 | KEY | KEY |
    | 3 | TABLE ACCESS FULL | GSM_PRR_SUM_NEW | 41M| 1643M| 546M(100)
    |999:59:59 | KEY | KEY |
    Note
    - dynamic sampling used for this statement (level=2)
    Statistics
    0 recursive calls
    7 db block gets
    530220 consistent gets
    33636 physical reads
    0 redo size
    644311477 bytes sent via SQL*Net to client
    5460594 bytes received via SQL*Net from client
    496372 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    49637012 rows processed
    SQL> SET AUTOTRACE TRACEONLY ARRAYSIZE 100
    SQL> select MOBILENUMBER, CLOSING_BAL from GSM_PRR_SUM_NEW a1
    where A1.CIRCLE_ID ='KA'
    AND to_char(a1.LOAD_DTTM) like '%MAR%' 2 3
    4 ;
    219166976 rows selected.
    Execution Plan
    Plan hash value: 189546713
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| T
    ime | Pstart| Pstop |
    | 0 | SELECT STATEMENT | | 228M| 9155M| 3552M(100)|99
    9:59:59 | | |
    | 1 | PARTITION LIST SINGLE| | 228M| 9155M| 3552M(100)|99
    9:59:59 | KEY | KEY |
    | 2 | PARTITION LIST ALL | | 228M| 9155M| 3552M(100)|99
    9:59:59 | 1 | 274 |
    |* 3 | TABLE ACCESS FULL | GSM_PRR_SUM_NEW | 228M| 9155M| 3552M(100)|99
    9:59:59 | KEY | KEY |
    Predicate Information (identified by operation id):
    3 - filter(TO_CHAR(INTERNAL_FUNCTION("A1"."LOAD_DTTM")) LIKE '%MAR%')
    Note
    - dynamic sampling used for this statement (level=2)
    Statistics
    38 recursive calls
    107 db block gets
    2667792 consistent gets
    561765 physical reads
    0 redo size
    2841422984 bytes sent via SQL*Net to client
    24108883 bytes received via SQL*Net from client
    2191671 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    219166976 rows processed
    SQL>
    Thanks,
    Manish

  • Create local spatial index on range sub-partitions?

    Is is possible to create a local spatial index on a table with range sub-partitions? We're trying to do this on a table that contains lots of x,y,z point data.
    Trying to do so gives me the error: ORA-29846: cannot create a local domain index on a composite partitioned tableAccording to the spatial documentation:The following restrictions apply to spatial index partitioning:
    - The partition key for spatial tables must be a scalar value, and must not be a spatial column.
    - Only range partitioning is supported on the underlying table. All other kinds of partitioning are not currently
    supported for partitioned spatial indexes.So there is nothing saying it can or can't be done. The examples I've seen in the documentation tend to partition based on a single value and don't use subpartitioning.
    Example of what we're trying to do:SQL> SELECT * FROM V$VERSION;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE    11.1.0.7.0      Production
    TNS for 64-bit Windows: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    SQL>
    SQL> --- Create a table, partioned by X and subpartitioned by Y
    SQL> CREATE TABLE sub_partition_test
      2  (
      3      x               NUMBER,
      4      y               NUMBER,
      5      z               NUMBER,
      6      geometry        MDSYS.SDO_GEOMETRY
      7  )
      8  PARTITION BY RANGE (x)
      9  SUBPARTITION BY RANGE (y)
    10     (
    11     PARTITION p_x100 VALUES LESS THAN (100)
    12     (
    13                     SUBPARTITION sp_x100_y100 VALUES LESS THAN (100),
    14                     SUBPARTITION sp_x100_y200 VALUES LESS THAN (200),
    15                     SUBPARTITION sp_x100_yMAXVALUE VALUES LESS THAN (MAXVALUE)
    16     ),
    17     PARTITION p_x200 VALUES LESS THAN (200)
    18     (
    19                     SUBPARTITION sp_x200_y100 VALUES LESS THAN (100),
    20                     SUBPARTITION sp_x200_y200 VALUES LESS THAN (200),
    21                     SUBPARTITION sp_x200_yMAXVALUE VALUES LESS THAN (MAXVALUE)
    22     ),
    23     PARTITION p_xMAXVALUE VALUES LESS THAN (MAXVALUE)
    24     (
    25                     SUBPARTITION sp_xMAXVALUE_y100 VALUES LESS THAN (100),
    26                     SUBPARTITION sp_xMAXVALUE_y200 VALUES LESS THAN (200),
    27                     SUBPARTITION sp_xMAXVALUE_yMAXVALUE VALUES LESS THAN (MAXVALUE)
    28     )
    29  );
    Table created.
    SQL>
    SQL> -- Insert some sample data
    SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
      2  VALUES (1, 1, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(1, 1, 50), NULL, NULL));
    1 row created.
    SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
      2  VALUES (50, 150, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(50, 150, 50), NULL, NULL));
    1 row created.
    SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
      2  VALUES (150, 150, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(150, 150, 50), NULL, NULL));
    1 row created.
    SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
      2  VALUES (150, 250, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(150, 250, 50), NULL, NULL));
    1 row created.
    SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
      2  VALUES (150, 300, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(150, 300, 50), NULL, NULL));
    1 row created.
    SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
      2  VALUES (220, 210, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(220, 210, 50), NULL, NULL));
    1 row created.
    SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
      2  VALUES (220, 150, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(220, 150, 50), NULL, NULL));
    1 row created.
    SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
      2  VALUES (220, 250, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(220, 250, 50), NULL, NULL));
    1 row created.
    SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
      2  VALUES (220, 300, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(220, 300, 50), NULL, NULL));
    1 row created.
    SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
      2  VALUES (320, 250, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(320, 250, 50), NULL, NULL));
    1 row created.
    SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
      2  VALUES (320, 160, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(320, 160, 50), NULL, NULL));
    1 row created.
    SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
      2  VALUES (320, 290, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(320, 290, 50), NULL, NULL));
    1 row created.
    SQL> INSERT INTO sub_partition_test (x, y, z, geometry)
      2  VALUES (320, 320, 50, SDO_GEOMETRY(3001, 2157, SDO_POINT_TYPE(320, 320, 50), NULL, NULL));
    1 row created.
    SQL>
    SQL> -- Create some metadata
    SQL> DELETE FROM user_sdo_geom_metadata WHERE TABLE_NAME = 'SUB_PARTITION_TEST';
    1 row deleted.
    SQL> INSERT INTO user_sdo_geom_metadata VALUES ('SUB_PARTITION_TEST','GEOMETRY',
      2  SDO_DIM_ARRAY(
      3     SDO_DIM_ELEMENT('X', 0, 1000, 0.005),
      4     SDO_DIM_ELEMENT('Y', 0, 1000, 0.005)
      5  ), 262152);
    1 row created.
    SQL>
    SQL> -- Create an Unusable Local Spatial Index
    SQL> CREATE INDEX sub_partition_test_spidx ON sub_partition_test (geometry)
      2    INDEXTYPE IS MDSYS.SPATIAL_INDEX
      3  LOCAL
      4  UNUSABLE;
    CREATE INDEX sub_partition_test_spidx ON sub_partition_test (geometry)
    ERROR at line 1:
    ORA-29846: cannot create a local domain index on a composite partitioned tableThanks,
    John

    Ok, thanks. That's what we're planning on doing now.
    SQL> CREATE TABLE partition_test
      2  (
      3      x               NUMBER,
      4      y               NUMBER,
      5      z               NUMBER,
      6      geometry        MDSYS.SDO_GEOMETRY
      7  )
      8  PARTITION BY RANGE (x, y)
      9     (
    10     PARTITION p_x100y100 VALUES LESS THAN (100, 100),
    11     PARTITION p_x100y200 VALUES LESS THAN (100, 200),
    12     PARTITION p_x100yMAX VALUES LESS THAN (100, MAXVALUE),
    13     PARTITION p_x200y100 VALUES LESS THAN (200, 100),
    14     PARTITION p_x200y200 VALUES LESS THAN (200, 200),
    15     PARTITION p_x200yMAX VALUES LESS THAN (200, MAXVALUE),
    16     PARTITION p_x300y100 VALUES LESS THAN (300, 100),
    17     PARTITION p_x300y200 VALUES LESS THAN (300, 200),
    18     PARTITION p_x300yMAX VALUES LESS THAN (MAXVALUE, MAXVALUE)
    19  );
    Table created.
    SQL>
    SQL> INSERT INTO user_sdo_geom_metadata VALUES ('PARTITION_TEST','GEOMETRY',
      2     SDO_DIM_ARRAY(
      3        SDO_DIM_ELEMENT('X', 0, 1000, 0.005),
      4        SDO_DIM_ELEMENT('Y', 0, 1000, 0.005)
      5     ), 262152);
    1 row created.
    SQL> CREATE INDEX partition_test_spidx ON partition_test (geometry)
      2     INDEXTYPE IS MDSYS.SPATIAL_INDEX
      3  LOCAL
      4  UNUSABLE;
    Index created.

  • Count Distinct based on another column in the same table

    Hello,
    My question in short: is is it possible to add a new column to a view which holds the DISTINCT COUNTS of values/domains of another column in the same view?
    For example, in the below table the column "Distinct Count of Occurence" shows how many distinct values a person has in the Occurence column. So AAA has 1 and 2 therefore it is 2 distinct values etc.
    My issues is that I can retrieve unique values bu Count (Select Occurence)but I can not add the new column that would add the records to the corresponding Persons in the above table.
    Is there an easy way to achieve this on the DWH level or should it be done with MDX in the cube?
    Thanks

    Hi,
    Below a solution to use the view by adding a column with window functioning, maybe this will help.
    CREATE TABLE #TMP
    PERSON VARCHAR(10),
    OCCURENCE SMALLINT
    --DROP TABLE #TMP
    INSERT INTO #TMP(PERSON,OCCURENCE)
    VALUES
    ('AAA','1'),
    ('AAA','2'),
    ('BBB','1'),
    ('BBB','1'),
    ('BBB','1'),
    ('CCC','1'),
    ('CCC','2'),
    ('CCC','3');
    --TRUNCATE TABLE #TMP
    WITH CTE
    AS
    SELECT PERSON
    ,OCCURENCE
    ,ROW_NUMBER() OVER(PARTITION BY PERSON ORDER BY OCCURENCE) AS RN
    FROM #TMP
    SELECT PERSON, MAX(RN) AS RN
    FROM CTE
    GROUP BY PERSON
    Regards,
    Reshma
    Please Vote as Helpful if an answer is helpful and/or Please mark Proposed as Answer or Mark As Answer when question is answered

  • Radio group in classic report based on another column on the same row.

    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    Application Express 4.1.0.00.32
    How can I have a radio group column based on an LOV utilizing another column on the same row of the report?
    For example: what if I had a survey application and depending on the likert scale that was assigned to the question there would be different possible answer choices:
    Question 1 on row 1 of the report: The class instructor was friendly?
    Likert scale choice is Agreement.
    Choices on Radio Group: Strongly Agree, Agree, Undecided, Strongly Disagree
    Question 2 on row 2 of the report: The class offered good materials?
    Likert scale choice is Quality.
    Choices on Radio Group: Excellent, Below Average, Average, Above Average, Excellent
    The radio group can change per row depending on the Likert scale assigned to the question which is assigned to a different column on the row.
    Can LOV utilize the column? :
    SELECT scale_text
    FROM scale_choices
    WHERE scale_category_choice_id = 2 <<= this would be the Likert scale identifier
    ORDER
    BY display_order

    Here is the answer:
    APEX_ITEM.SELECT_LIST_FROM_QUERY(
    p_idx IN NUMBER,
    p_value IN VARCHAR2 DEFAULT NULL,
    p_query IN VARCHAR2,
    p_attributes IN VARCHAR2 DEFAULT NULL,
    p_show_null IN VARCHAR2 DEFAULT 'YES',
    p_null_value IN VARCHAR2 DEFAULT '%NULL%',
    p_null_text IN VARCHAR2 DEFAULT '%',
    p_item_id IN VARCHAR2 DEFAULT NULL,
    p_item_label IN VARCHAR2 DEFAULT NULL,
    p_show_extra IN VARCHAR2 DEFAULT 'YES')
    RETURN VARCHAR2;

  • How to place one column under another column in obiee report?

    Hi all,
    I am new to obiee, so need some help from obiee experts. Can anyone tell me how to place one column data under another column in obiee report?
    i need the report to be as below
    category total_students Course_enrollment Test_attended pass_test
    total N % N % N %
    all students ##### ## ## ## ## ## ##
    Ethnicity
    Asian ###### ## ## ## ## ## ##
    African American ###### ## ## ## ## ## ##
    white ######
    Filipino ######
    Gender
    Male ##### ## ## ## ## ## ##
    Female ##### ## ## ## ## ## ##
    and similarly for other columns
    where ethnicity, gender are columns in the table and Course_enrollment, Test_attended, pass_test are calculated columns.
    Please help me to create a report as above if anyone knows how to do it.
    Edited by: Shailaja on Jul 19, 2010 12:23 AM

    Two ideas I can think of:
    1) Create multiple pivot tables and then display them one under the other
    2) Create multiple measure columns such as "male_amt", "female_amt", "white_amt", "asian_amt", "black_amt", etc. for all the columns you need. Then you could simple stack them in a single pivot table.
    Option #2 might give you the prettiest results - but also requires a lot more maintenance (for instance, if you reclassify ethnic groups, you'd have to go through the reports to add additional metric columns).
    Hope this helps,
    Scott

  • How to make column range based on a column in Oracle BI 11g

    Hello everyone!
    I want to know, how to make column range from a column in oracle bi 11g.
    for example!
    I have a column amounts and I want to build on this with other values of quantity, other column range 1-9,10-49,50-99,100-249, 249 o more.
    regards!
    when I try to make the range I have error.
    Syntax error [nQSError: 26012] . (HY000)
    SQL Issued: SELECT CASE WHEN "CUBO_DEEE_TAB"."CANTIDAD" BETWEEN 1 AND 9 THEN 1 a 9 ELSE "CUBO_DEEE_TAB"."CANTIDAD" END FROM "DM_DEEE"
    Edited by: 964157 on 09-oct-2012 11:50

    You cannot add columns dynamically. But you can define a maximum number of numbers and then hide unused columns in your form useing SET_ITEM_PROPERTY(..,VISIBLE, PROPERTY_FALSE);

  • Case INSENSITIVE Columns on Oracle

    Hello Friends,
    Good Monday for everyone....
    I would like to ask you guys if there is a way to create a case INSENSITIVE Columns on Oracle. I used on Sqlserver before the COLLATE sintax, and I was able to make a columns (just that one) INSENSITIVE.
    I'm using oracle 10gr2 on Windows plataform and herte is my nls_parameters. My ideia is to search on this column without the need of performing a function UPPER and LOWER and etc...
    NLS_LANGUAGE BRAZILIAN PORTUGUESE
    NLS_TERRITORY BRAZIL
    NLS_CURRENCY Cr$
    NLS_ISO_CURRENCY BRAZIL
    NLS_NUMERIC_CHARACTERS ,.
    NLS_CALENDAR GREGORIAN
    NLS_DATE_FORMAT DD/MM/RR
    NLS_DATE_LANGUAGE BRAZILIAN PORTUGUESE
    NLS_CHARACTERSET WE8MSWIN1252
    NLS_SORT WEST_EUROPEAN
    NLS_TIME_FORMAT HH24:MI:SSXFF
    NLS_TIMESTAMP_FORMAT DD/MM/RR HH24:MI:SSXFF
    NLS_TIME_TZ_FORMAT HH24:MI:SSXFF TZR
    NLS_TIMESTAMP_TZ_FORMAT DD/MM/RR HH24:MI:SSXFF TZR
    NLS_DUAL_CURRENCY Cr$
    NLS_NCHAR_CHARACTERSET AL16UTF16
    NLS_COMP BINARY
    NLS_LENGTH_SEMANTICS BYTE
    NLS_NCHAR_CONV_EXCP FALSE
    tks a lot
    Keen

    APC wrote:
    No, they mean a setting which makes "APC" or "apc" match "Apc".
    There is nothing to be done on 10g, other than building a function based index on the column in question, so that any UPPER() searches are optimized.
    Well, as Kamran Agayev already noted CI is available in 10g too. It also worth mentioning FBI creates a hidden column. Also, your statement
    In 11g we have the option to set the NLS_SORT parameter so that any searches are case-insensitive (or indeed accent insensitive). Find out more.
    is incomplete. NLS_SORT affects nothing but sort:
    SQL> connect scott
    Enter password: *****
    Connected.
    SQL> select * from v$version
      2  /
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    order by name
    12  /
    NAM
    Joe
    Max
    Sam
    joe
    max
    sam
    6 rows selected.
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    where name = 'max'
    12  /
    NAM
    max
    SQL> alter session set nls_sort = binary_ci
      2  /
    Session altered.
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    order by name
    12  /
    NAM
    Joe
    joe
    max
    Max
    Sam
    sam
    6 rows selected.
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    where name = 'max'
    12  /
    NAM
    max
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    where name like 'm%'
    12  /
    NAM
    max
    SQL> select 'Max' name from dual union
      2  select 'max' name from dual
      3  /
    NAM
    Max
    max
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  distinct name
    10    from  t
    11  /
    NAM
    sam
    Joe
    joe
    max
    Sam
    Max
    6 rows selected.
    SQL> As you can see, NLS_SORT alone works on sort but not on "searches". We also need to set NLS_COMP, which by default is BINARY. Prior to 10g R2 (I am not 100% sure, it could be prior 10g), the only NLS_COMP choice, besides BINARY, was ANSI. However, ANSI does not work with all comparison operators (e.g. does not work for LIKE, UNION, DISTINCT):
    SQL> alter session set nls_sort = binary_ci
      2  /
    Session altered.
    SQL> alter session set nls_comp=ansi
      2  /
    Session altered.
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    order by name
    12  /
    NAM
    Joe
    joe
    max
    Max
    Sam
    sam
    6 rows selected.
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    where name = 'max'
    12  /
    NAM
    Max
    max
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    where name like 'm%'
    12  /
    NAM
    max
    SQL> select 'Max' name from dual union
      2  select 'max' name from dual
      3  /
    NAM
    Max
    max
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  distinct name
    10    from  t
    11  /
    NAM
    sam
    Joe
    joe
    max
    Sam
    Max
    6 rows selected.
    SQL> Starting 10g R2 NLS_COMP can be set to LINGUISTIC, which will also work for LIKE and UNION but not for DISTINCT:
    SQL> alter session set nls_sort = binary_ci
      2  /
    Session altered.
    SQL> alter session set nls_comp=linguistic
      2  /
    Session altered.
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    order by name
    12  /
    NAM
    Joe
    joe
    max
    Max
    Sam
    sam
    6 rows selected.
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    where name = 'max'
    12  /
    NAM
    Max
    max
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  name
    10    from  t
    11    where name like 'm%'
    12  /
    NAM
    Max
    max
    SQL> select 'Max' name from dual union
      2  select 'max' name from dual
      3  /
    NAM
    Max
    SQL> with t as (
      2             select 'Max' name from dual union all
      3             select 'sam' name from dual union all
      4             select 'Joe' name from dual union all
      5             select 'max' name from dual union all
      6             select 'joe' name from dual union all
      7             select 'Sam' name from dual
      8            )
      9  select  distinct name
    10    from  t
    11  /
    NAM
    sam
    Joe
    joe
    max
    Sam
    Max
    6 rows selected.
    SQL> However even LINGUISTIC does not work with:
    • CLOB or NCLOB data types
    • Object data types
    • Table partitions
    • Index-organized tables
    SY.

  • How to create an automatically increment column in Oracle DB Table?

    Hi To All
    Here I am trying to create a table in Oracle that creates an automatically increment column in Oracle DB Table. i searched almost all Forums.(Even in Oracle). They are saying that, that logic u must implement in Java Code.(*Takes Maximum no from table, add +1 to it, and store it back again)*. apart from this, while creating an table in Oracle, is there any facility like MySQL Database? please help me. Thanks in advance.

    Hi BalusC
    Thanks for Your Response and clue. with that, i succeeded in my application. Thank you very much. here i am giving you the details which i did.
    1. I Created a table named orders in Oracle like this.
       CREATE TABLE ORDERS (ORDER_ID NUMBER, CUSTOMER_ID NUMBER, ISBN NUMBER,
                                   DESCRIPTION NCHAR(5));
                       2. I created one sequence in Oracle like    CREATE SEQUENCE SEQ01 INCREMENT BY 1 START WITH 1000     3. Then i have written jdbc program like this
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    public class SequenceTest {
         public static void main(String[] args)throws Exception{
              try {
              Class.forName("oracle.jdbc.driver.OracleDriver");
              Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.135:1521:orcl","scott","tiger");
              String cols[] = {"ORDER_ID", "DESCRIPTION"};
              PreparedStatement pstmt = con.prepareStatement("INSERT INTO ORDERS (ORDER_ID, CUSTOMER_ID, ISBN,DESCRIPTION) VALUES            (SEQ01.NEXTVAL, 104, 966431505,?)", cols);
              pstmt.setString(1,"Desc3");          
              pstmt.executeUpdate();
              ResultSet rs=pstmt.getGeneratedKeys();     
                    System.out.println("---- One Row Inserted ----");
              } catch (Exception e) {
                   System.out.println("---- Failed Due To "+e);               
       4. When i ran above program 5 times, i got the following Data into my Oracle Table (select * from orders)
      ORDER_ID CUSTOMER_ID       ISBN DESCR
          1000         101  966431502 Desc0
          1001         102  966431503 Desc1
          1002         103  966431504 Desc2
          1003         104  966431505 Desc3
          1004         104  966431505 Desc3
          1005         105  966431506 Desc4
    6 rows selected.
      But i dont know how to do this type of program with out using prepared statements. i tried, and i got exception *"Missing Expression"* .
    Once again Thank You very much for your clue.

Maybe you are looking for

  • Garageband 11 will not open in Mac os 10.7.5

    I've just re-installed Ilife 11 on my Mac pro.  Movie and Photo work but Garageband doesn't.  When I launch Garageband it has a large screen open with a bunch of programming language.  It mentions celemony, propellerhead, which are not installed on t

  • St.conf parameters for SDLT tape drive / Solaris 8

    Hello, I need the parameters for the SDLT tape drive from Tandberg for the st kernel driver. In the st.conf there is no entry for Tandberg SDLT. With the st.conf, shipped with Solaris 8 10/01, my V880 crashes when accessing the SDLT with the mt comma

  • Email outlook 2010

    I have tried to set up my company's owa 2010 for the past month on my curve. They upgraded from 2003. Every time I attempt to set up 2010 it takes about 10 tries through the setup program. Finally, I receive the congratulations email and receive all

  • OS 10.5.8 to Snow Leopard

    I have a MacBook that I have had since Oct 2008. It currently runs on Leopard 10.5.8, with Intel Core 2 Duo and 1GB 667 MHz DDR2 SDRAM. I'm starting school in a few days and will have to work with new editions of Photoshop and Illustrator. Does it ma

  • Coherence cache query - distinct

    Hi, I am trying to find out how to do a distinct query in coherence cache. For example, if my key object has LastName, FirstName. How do I get the collection of keys of distinct last names? In another words, I am trying to find out what are the disti