Query to retrieve from partitioned table

i have a table called xyz which is having 5 columns
(client,datmonth,productid,productname,productdesc)
and it is partitioned as
column client is the primary partition
column datamonth is subpartitioned based on client
if i have to select both client and datamonth how to do it by select query
i arrived till
select * from xyz partition <clientid-partition>
but unable to proceed further
any help?

Like that ?
DROP TABLE XYZ ;
CREATE TABLE XYZ
( client_No NUMBER(10) Not Null check (CLIENT_NO > 0)
, datmonth DATE Not Null
PARTITION BY RANGE( client_No )
SUBPARTITION BY LIST (datmonth)
SUBPARTITION TEMPLATE
( SUBPARTITION SP_2005 VALUES (To_Date('20050101','YYYYMMDD'))
, SUBPARTITION SP_2006 VALUES (To_Date('20060101','YYYYMMDD'))
, SUBPARTITION SP_2007 VALUES (To_Date('20070101','YYYYMMDD'))
, SUBPARTITION SP_DEFAULT VALUES (DEFAULT)
( PARTITION P_0001 VALUES LESS THAN (2)
, PARTITION P_0002 VALUES LESS THAN (3)
, PARTITION P_0003 VALUES LESS THAN (4)
, PARTITION P_0004 VALUES LESS THAN (5)
, PARTITION P_Others VALUES LESS THAN (MAXVALUE)
INSERT INTO XYZ
SELECT Mod( RowNum,6)+1 Client_No
, Add_Months( Trunc( SysDate, 'YYYY') , Mod( DBMS_RANDOM.random, 24)) DateMOnth
FROM DUAL CONNECT BY ROWNUM <= 100
SELECT * FROM XYZ PARTITION (P_0001) A;
SELECT * FROM XYZ SUBPARTITION (P_0001_SP_2006) A;
SELECT * FROM XYZ SUBPARTITION (P_0002_SP_2006) A;
mi

Similar Messages

  • How to delete the data from partition table

    Hi all,
    Am very new to partition concepts in oracle..
    here my question is how to delete the data from partition table.
    is the below query will work ?
    delete from table1 partition (P_2008_1212)
    we have define range partition ...
    or help me how to delete the data from partition table.
    Thanks
    Sree

    874823 wrote:
    delete from table1 partition (P_2008_1212)This approach is wrong - as Andre pointed, this is not how partition tables should be used.
    Oracle supports different structures for data and indexes. A table can be a hash table or index organised table. It can have B+tree index. It can have bitmap indexes. It can be partitioned. Etc.
    How the table implements its structure is a physical design consideration.
    Application code should only deal with the logical data structure. How that data structure is physically implemented has no bearing on application. Does your application need to know what the indexes are and the names of the indexes,in order to use a table? Obviously not. So why then does your application need to know that the table is partitioned?
    When your application code starts referring directly to physical partitions, it needs to know HOW the table is partitioned. It needs to know WHAT partitions to use. It needs to know the names of the partitions. Etc.
    And why? All this means is increased complexity in application code as this code now needs to know and understand the physical data structure. This app code is now more complex, has more moving parts, will have more bugs, and will be more complex to maintain.
    Oracle can take an app SQL and it can determine (based on the predicates of the SQL), which partitions to use and not use for executing that SQL. All done totally transparently. The app does not need to know that the table is even partitioned.
    This is a crucial concept to understand and get right.

  • Shortest way to retrieve from KONM Table

    Hi,
    Can anyone tell me how to write a query for, the shortest and quickest way to retrieve the data from KONM Table?
    Sample Record in the KONM Table will be as given below.
    KNUMH          KSTBM             KBETR
    007......... 1 .......... 50
    007......... 11 ........ 45
    007......... 55 .........40
    When i give my input Quantity (KSTBM) as 4, i should get the price (KBETR) as 50. i.e., input quantity between 1 to 10 is 50. Input Quantity between 11 and 54 is 45. Anything Greater than 55 to next greater quantity is 40,...
    Is there any function module available to retrieve the record?
    Also best optimized logic, will be given a full mark.

    Hello Vijay
    I am assuming that you have value in KNUMH with you...
    here's the idea in brief..
    select the values.. sort by quantity descending.. then populate a range with LE option... the first entry in the interal table which meets the condition is the value u require..
    Sort of Pseudo code:
    ranges: r_kstbm for kstbm.
    r_kstbm-sign = 'I'.
    r_kstbm-option = 'LE'.
    r_kstbm-low = p_kstbm.    <your quantity value comes here> 
    select <your fields> from KONM into table i_konm where KNUMH eq p_knumh.
    if sy-subrc = 0.
    sort i_konm by kstbm descending.
    loop at i_knom where kstbm in r_kstbm.
        <The price required> = i_konm-kbetr.
        exit.
    endloop.
    endif.
    Message was edited by:
            Arun Nair

  • Simple Query Failure? from 2 tables: pull First [DATE] Where [OIL] 0

    I am a novice Access 2010 user, and I do not know how to write VBA code.  I have written many queries, some built upon others and packaged them into macros, but that's about the extent of my experience, to date. 
    My problem.  I built a query from 2 tables: [AC_PROPERTY] and [AC_PRODUCT]
    I have linked the tables by PROPNUM.  Designed the query to give me every PROPNUM in the db, then give me the 'First' [DATE] 'Where' [OIL] is >0.
    When I run the query with 1 PROPNUM qualified, it works brilliant.  Every case I check is working, on a one-PROPNUM-at-a-time basis.  As soon as I remove the PROPNUM from criteria, so it will pull all PROPNUMs in the db, it appear to work -- that
    is, until you check the data.
    For some reason, it's not consistently picking the correct First date where Oil >0.  I cannot figure out why it's working on some and not on others.  I thought it was a date format problem, but haven't been able to determine or solve the issue.
    I have always (historically) figured out my query problems, but this one has me stumped!  Help!?
    thank you :-)

    I have linked the tables by PROPNUM.  Designed the query to give me every PROPNUM in the db, then give me the 'First' [DATE] 'Where' [OIL] is >0.
    The problem is that FIRST will not always give you the oldest date. Access uses FIRST to get the first record it finds, not the earliest date.
    Use MIN to find oldest date.
    Build a little, test a little

  • Select query for fetching from 3 tables.

    Can we have a single Select query for fetching same fields (kappl,kschl,vkorg,vtweg,spart,kunwe,datbi,knuma,datab,knumh)
    from 3 tables >> KOTE707,KOTE708 and KOTE709 into an internal table for a particular KUNNR?
    Regards,
    Shashank.

    Hi,
    If you have kunnr field in all the 3 tables then it is possible. use inner join as below
    PARAMETERS: p_cityfr TYPE spfli-cityfrom,
                p_cityto TYPE spfli-cityto.
    DATA: BEGIN OF wa,
             fldate TYPE sflight-fldate,
             carrname TYPE scarr-carrname,
             connid   TYPE spfli-connid,
           END OF wa.
    DATA itab LIKE SORTED TABLE OF wa
                   WITH UNIQUE KEY fldate carrname connid.
    SELECT c~carrname p~connid f~fldate
           INTO CORRESPONDING FIELDS OF TABLE itab
           FROM ( ( scarr AS c
             INNER JOIN spfli AS p ON p~carrid   = c~carrid
                                  AND p~cityfrom = p_cityfr
                                  AND p~cityto   = p_cityto )
             INNER JOIN sflight AS f ON f~carrid = p~carrid
                                    AND f~connid = p~connid ).
    LOOP AT itab INTO wa.
      WRITE: / wa-fldate, wa-carrname, wa-connid.
    ENDLOOP.
    <b>Reward Points if this helps,</b>
    Satish

  • Creating a Query with Data from 4 Tables.

    Hey guys. I'm having a small problem figuring out the best way for me to handle this query.
    I'm trying to make a query which outputs the amount of appointments a GP has furfilled, and the total amount allowed.
    I have 4 tables, for each I'm just gonna list the relevent columns:
    Appointment: ID, Patient_ID.
    Patient: ID, GP_ID.
    GP: ID, Trust_ID.
    Trust: ID, Quota.
    Appointment table has 400 entries (2 per patient atm).
    Patient table has 200 entries.
    GP Table has 30 entries (GP's can be assigned to more than one person) .
    Trust table has 6 entries.
    What I need to do is, look at the appointment table and get the number of times each patient has an appointment.
    Go through the patient table, and find out which GP the patient in the appointment belongs to.
    Add each occurance to the correct GP.
    Find out which Trust each GP belongs to, and add the total for each GP to the correct Trust.
    Check the quota in the Trust table, to see if the total is more than the allowed.
    I can't seem to think of an easy or simple way for me to do this. Can anyone help please? Many thanks.

    Hi,
    That sounds like a job for JOIN.
    To check the quotas against the total, use the SUM function; either the aggregate SUM or the analytic SUM, depending on your requirements.
    Sorry this answer is so vague, but that's the bes I can do with the information provided so far.
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved. In this case, between 2 and 10 rows of data per table should be enough to show what you need to do.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    Always say which version of Oracle you're using.

  • Fast data retrieval from large tables

    Hello,
    we have created a table in oracle 10g DB. at an average there are around 20-30 rows inserted onto the table. so in 1 mnth the record count for the table is around 800-900 rows.
    in one year which is becoming to 10,000 rows. so speed up data retreval from this bulk data we need suggestion. various things that come to my mind are -
    Indexing of table/# Index of table/partitioning of table/materialized view etc.
    but not sure what exactly needs to be done here. please suggest on how smooth data retreival can be chaived whatever be the size of the table.
    Thanks,
    Sam

    Here is a simple look of your data progression.
    year        Row
    1           10,000
    5           50,000
    10          1,00,000
    50          5,00,000
    100         10,00,000You need to wait another 100 years to reach a million. And million is not a big number when it comes to Oracle.
    So as others have stated what the objective behind your question?
    basically the choice of Index or Partition mainly depends on how the data is going to be accessed from a table. If I am going to access all the rows of a table every time then there is no use of both the features. I would just prefer a FTS. In that situation i would be looking how to optimize my FTS.
    So you need to set you objective clear before picking up the solution. Just because you have a hammer you cant go around banging the wall ;)

  • Data retrieval from ZL table

    I need to retrieve data from ZL table and prepare a report comparing the Actual, Previous and Old records in the table for an employee for a particular period.
    Are there any particular function modules for this data retrieval?
    Thanks.

    Hi bala,
    I did not get what you were trying to tell me. I went to SE37 and tried for anything that starts with "zlit" .. but returned no results.
    And also I dont want time management to payroll.
    I want to retrieve data from the B2 in PCL2 cluster.
    i.e I want to retrieve data from the ZL table in the cluster for a particular payperiod and particular employee.
    Thanks very much in advance!

  • How to Query Multiple Fields from different Tables using Toplink Expression

    Hi,
    I am trying to prepare an Oracle Toplink Expression to qurey the multiple columns of different tables. the query as following. Please can anyone help?
    SELECT CYCLE.CYCLE_ID,
    CYCLE.ASPCUSTOMER_ID,
    CYCLE.FACILITYHEADER_ID,
    CYCLE.ADDUSER,
    ASP.FIRSTNAME || ' ' || ASP.LASTNAME ADDUSERNAME,
    CYCLE.ADDDATE,
    CYCLE.LASTUPDATEUSER,
    ASP.FIRSTNAME || ' ' || ASP.LASTNAME LASTUPDATEUSERNAME,
    CYCLE.LASTUPDATEDATE,
    CYCLE.CYCLENAME,
    CYCLE.CYCLENUMBER,
    CYCLE.DESCRIPTION
    FROM CYCLE,ASPUSER ASP
    WHERE CYCLE.ADDUSER = ASP.ASPUSER_ID
    and then i want to send that expression to readAllObjects method as a parameter
    Expression exp = (..............this is the required qurey expression...................)
    Vector employees = session.readAllObjects(getClass(), exp);
    thanks,

    You havent given any information on the mapping between Cycle and Asp. I presume there is a one to one mapping between them. Also it appears there is no "WHERE" clause to limit the number of cycles being retrieved. If that is the case then I presume you want to load all cycles in the system.
    Thats just a clientSession.readAllObjects(Cycle.class). If you have indirection turned on the Asp should get loaded when you do a cycle.getAsp().
    I presume that SQL you posted loads all the columns of CYCLE and ASP. If you are interested in a subset of CYCLE or ASP then you should do a ReportQuery or partial object read.
    Hi,
    I am trying to prepare an Oracle Toplink Expression
    to qurey the multiple columns of different tables.
    the query as following. Please can anyone help?
    SELECT CYCLE.CYCLE_ID,
    CYCLE.ASPCUSTOMER_ID,
    CYCLE.FACILITYHEADER_ID,
    CYCLE.ADDUSER,
    ASP.FIRSTNAME || ' ' || ASP.LASTNAME ADDUSERNAME,
    CYCLE.ADDDATE,
    CYCLE.LASTUPDATEUSER,
    ASP.FIRSTNAME || ' ' || ASP.LASTNAME
    LASTUPDATEUSERNAME,
    CYCLE.LASTUPDATEDATE,
    CYCLE.CYCLENAME,
    CYCLE.CYCLENUMBER,
    CYCLE.DESCRIPTION
    FROM CYCLE,ASPUSER ASP
    WHERE CYCLE.ADDUSER = ASP.ASPUSER_ID
    and then i want to send that expression to
    readAllObjects method as a parameter
    Expression exp = (..............this is the required
    qurey expression...................)
    Vector employees = session.readAllObjects(getClass(),
    exp);
    thanks,

  • Function modules for data retrieval from diff. tables

    Hi,
    I would just like to ask if there are function modules that can be used to retrieve data from the ff. tables:
    TSAD3T
    KNVV
    ESTRH
    for TSAD3T i need to get the value of title_medi
    for KNVV    i need to get the fields klabc vkorg vtweg
    for ESTRH  i need to get the fields subcat subid.
    Thanks.

    I doubt if you have such a FM

  • Seeking help in extracting data from partitioned table"YEARWISE".

    Hi Experts,
    I need a favour in extracting data YEARWISE like 'from 1999 to 2000.
    Table is partitioned with around 40 partitions, and data I want to extract with sign ',' separating columns.So that I can move it to application as text file directly.
    Plateform : Wind2k
    Oracle Version : 8i
    nls_date_format ...shows nothing..
    sysdate is in : dd-mm-yyyy format
    Here is my script, but so far it didn't yield anything...It looks like it is running, but I can see spool file with just 0 bytes.
    Please check the script "May be I m doing something wrong" , help me out.
    Let me also inform you that column  ENDRETTID is with datatype DATE, so I put this column for sorting.
    ===========================================================================================
    connect / as sysdba
    spool e:\dumps\frdz_fintrans_txt.log
    set heading off;
    set pagesize 0;
    set feedback off;
    set echo off;
    set pause off;
    set termout off;
    select BATCHID||','||
    PRODUKTKODE||','||
    OKODATO||','||
    SAKSBEHANDLERID||','||
    PRODDATO||','||
    KJOPSDATO||','||
    FRABINNR||','||
    POSENTRYMODE||','||
    ARSAKSKODE||','||
    BELOPVAL||','||
    BELOP||','||
    BRANSJEKODE||','||
    BRBREGNR||','||
    BINNR||','||
    POSTNR||','||
    TRANSKODE||','||
    FIRMANR||','||
    KJOPSTYPEID||','||
    KHBREGNR||','||
    SENTRALNR||','||
    REIMBURSMENTKODE||','||
    AUTORISERT||','||
    VALUTAKODE||','||
    PRECARIND||','||
    PAYMENTIND||','||
    ATMACCOUNT||','||
    POSTERMCAP||','||
    POSPINCAP||','||
    MAILTLFIND||','||
    SPESCOND||','||
    PROVISJON||','||
    LANDKODE||','||
    DATOID||','||
    CHIDMETHOD||','||
    ENDRETTID||','||
    TERMINALID||','||
    BRAND||','||
    KURSPASLAG||','||
    MCGEBYR||','||
    ACQBIN||','||
    LAND||','||
    CARDTYPE||','||
    DEBCRE||','||
    DOMAIN||','||
    CHIP||','||
    REGION from vdv.fintrans WHERE ENDRETTID >= to_date('01-01-1999','DD-MM-YYYY') and ENDRETTID <=to_date('01-01-2000','DD-MM-YYYY');
    spool off
    exit

    No Sir, no indexing on that column. Please help me with some easiest way to extract the data Yearwise.
    COLUMN_NAME    
    COLUMN_POSITION TABLE_NAME
    BATCHID                      
    1 FINTRANS
    KHBREGNR                     
    1 FINTRANS
    PRODDATO                     
    1 FINTRANS
    SQL>
    ======================
    Description of the table is as:
    SQL> desc vdv.fintrans;
    Navn                                      Null?    Type
    BATCHID                                   NOT NULL NUMBER
    PRODUKTKODE                                        VARCHAR2(1)
    OKODATO                                            NUMBER(8)
    SAKSBEHANDLERID                                    VARCHAR2(8)
    PRODDATO                                           NUMBER(8)
    KJOPSDATO                                          NUMBER(8)
    FRABINNR                                           VARCHAR2(19)
    POSENTRYMODE                                       VARCHAR2(2)
    ARSAKSKODE                                         NUMBER(2)
    BELOPVAL                                           NUMBER(14)
    BELOP                                              NUMBER(14)
    BRANSJEKODE                                        NUMBER(4)
    BRBREGNR                                           NUMBER(4)
    BINNR                                              NUMBER
    POSTNR                                             NUMBER(4)
    TRANSKODE                                          NUMBER(2)
    FIRMANR                                            NUMBER(11)
    KJOPSTYPEID                                        NUMBER(2)
    KHBREGNR                                           NUMBER(4)
    SENTRALNR                                          NUMBER(3)
    REIMBURSMENTKODE                                   VARCHAR2(2)
    AUTORISERT                                         NUMBER
    VALUTAKODE                                         NUMBER(3)
    PRECARIND                                          VARCHAR2(1)
    PAYMENTIND                                         VARCHAR2(1)
    ATMACCOUNT                                         VARCHAR2(1)
    POSTERMCAP                                         VARCHAR2(1)
    POSPINCAP                                          VARCHAR2(1)
    MAILTLFIND                                         VARCHAR2(1)
    SPESCOND                                           VARCHAR2(2)
    PROVISJON                                          NUMBER(10,2)
    LANDKODE                                           VARCHAR2(2)
    DATOID                                             NUMBER(8)
    CHIDMETHOD                                         VARCHAR2(1)
    ENDRETTID                                          DATE
    TERMINALID                                         VARCHAR2(8)
    BRAND                                              VARCHAR2(1)
    KURSPASLAG                                         NUMBER(14)
    MCGEBYR                                            NUMBER(14)
    ACQBIN                                             NUMBER(6)
    LAND                                               VARCHAR2(2)
    CARDTYPE                                           VARCHAR2(2)
    DEBCRE                                             VARCHAR2(1)
    DOMAIN                                             VARCHAR2(1)
    CHIP                                               VARCHAR2(1)
    REGION                                             NUMBER(1)
    =========
    Tried also to create new table for a month...but it is just going on without any table creation or data insertion...just hung kind of thing
    CREATE TABLE vdv.frdz AS (SELECT * FROM vdv.fintrans WHERE ENDRETTID >=to_date('01-01-1999','DD-MM-YYYY') AND ENDRETTID <=to_date('01-02-1999','DD-MM-YYYY'));

  • Query and retrieval of SAP table data

    Hi,
    Within PI Is it possible to use a select query on an ECC table and retrieve the relevant data. The data will then need to be mapped to the output.
    Can this be achieved through an RFC call?
    Thanks

    Hi,
    You can use RFC lookup and map the output to target field.
    view this article for step by step process...
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/40b64ca6-b1e3-2b10-4c9b-c48234ccea35
    Hope this helps....

  • Data Retrieval from Cluster Table - BSEG

    Hi all,
    I need to retreive data related to document line items from BSEG whose CLEARING DATE (AUGDT) is greater than a user given date for TWO COMPANY CODES (say 0010/0200).
    as BSEG is a cluster table, it has huge data and taking large amt of time can anybody suggest a better way of retrieving data for the above conditions(fastly)
    Thanks in Advance,
    Lakshmi

    hi,
    use second. index tables:
    customers:  BSAD
    vendors:    BSAK
    G/L acc.:   BSAS
    sample:
      SELECT (felder) FROM  bsad into TABLE stab
             WHERE  bukrs  = bukrs
             AND    kunnr  IN kunnr
             AND    gsber IN gsber
             AND    augbl  <>  space
             AND    hkont  IN akont
             AND    augdt GT p_date.
    regards Andreas
    Message was edited by: Andreas Mann

  • Update query - updating data from another table.

    I have the following tables and data
    CREATE TABLE UPD_TEST1
    T1_COL1 NUMBER(10),
    T1_COL2 VARCHAR2(10 BYTE),
    T1_COL3 VARCHAR2(10 BYTE)
    INSERT INTO UPD_TEST1 ( T1_COL1, T1_COL2, T1_COL3 ) VALUES (
    1, 'raji', 'sis');
    INSERT INTO UPD_TEST1 ( T1_COL1, T1_COL2, T1_COL3 ) VALUES (
    2, 'manju', 'sis');
    INSERT INTO UPD_TEST1 ( T1_COL1, T1_COL2, T1_COL3 ) VALUES (
    3, 'chinnu', 'sis');
    COMMIT;
    CREATE TABLE UPD_TEST2
    T2_COL1 NUMBER(10),
    T2_COL2 VARCHAR2(10 BYTE),
    T2_COL3 VARCHAR2(10 BYTE)
    INSERT INTO UPD_TEST2 ( T2_COL1, T2_COL2, T2_COL3 ) VALUES (
    1, 'muralee', 'bro');
    INSERT INTO UPD_TEST2 ( T2_COL1, T2_COL2, T2_COL3 ) VALUES (
    2, 'manoj', 'bro');
    INSERT INTO UPD_TEST2 ( T2_COL1, T2_COL2, T2_COL3 ) VALUES (
    3, 'manoop', 'bro');
    COMMIT;
    I need to update the columns of UPD_TEST1 with some values from UPD_TEST2 based on some conditions.
    i wanted to update multiple rows at a time.Can it be done using one query..
    Anyone please help me.
    I have dome some search and got the following query but it can update only one record at a time
    UPDATE upd_test1
    SET ( t1_col2,t1_col3) =(SELECT t2_col2,t2_col3 FROM upd_test2 WHERE t2_col1 =2)
    the following query won't work
    UPDATE upd_test1
    SET ( t1_col2,t1_col3) =(SELECT t2_col2,t2_col3 FROM upd_test2 WHERE t2_col1 IN (2,3))
    ORA-01427: single-row subquery returns more than one row
    I wanted to update multiple records at a time

    bit weird approach though, but you could try merge
    SQL> Select * From Upd_Test1;
       T1_COL1 T1_COL2    T1_COL3
             1 raji       sis
             2 manju      sis
             3 chinnu     sis
    SQL> Merge Into Upd_Test1 A Using Upd_Test2 B
      2  On (a.T1_Col1 = b.T2_Col1 and b.t2_col1 in (2,3))
      3  When Matched Then
      4     Update Set
      5                     A.T1_Col2 = B.T2_Col2
      6                     ,a.T1_Col3 = b.T2_Col3;
    2 rows merged.
    SQL> Select * From Upd_Test1;
       T1_COL1 T1_COL2    T1_COL3
             1 raji       sis
             2 manoj      bro
             3 manoop     broVivek L

  • Data retrieve from one table control to another table control

    Hi all,
    I had an requirement like to create Two table controls.
    for first Table control i had an sel field defined as 'MARK'.
    when i check the row in the first table control think it  is header data for sales order .
    all the item details have to retrieve in the second table control.
    This is my requirement, i am not able to trigger when selecting the row in table control.
    will anybody had an experience like this.
    Regards,
    Madhavi

    Hi Madhavi,
    If  we need the case to display header and item as mentioned in 2 table controls....
    we can display in table control 2/item only (the line items of the one selected in the table control 1 or the header )...so ,at a time we need to display line items for only 1 header ....
    so ...first disable the selections/multiple selections to disable the row selector
    We have already declared a field type C to capture the value for the field selector...so we can convert this field to a radio button and then assign a function code to the radio button at screen level
    Whenever you click on the radio button ..immediately the function code is triggered..then in PAI ..we can check and find the header record with 'X' and populate the data for the table control 2
    Hope it helps
    Regards
    Byju

Maybe you are looking for