NUMTODSINTERVAL

How NUMTODSINTERVAL works?

Oracle/PLSQL: NUMTODSINTERVAL Function

what it means

Select

NUMTODSINTERVAL (150, 'DAY') of the double

Hello

Regarding the previous post, the + sign indicates the difference of the day, followed by the hour: Minutes: seconds. Therefore, with the expression 'Day', the result would be 150 days apart, or + 000000150. The result is in the form of an interval. If NUMTODSINTERVAL(1500,'Hour'), there are 24 hours in a day, so the result would be + 000000062 (1500 / 24 = 62.5), do not forget, the result with + sign is the difference of the day, followed by the length of time, where would be 0.5.

If you need more information, this link would allow: Oracle/PLSQL: NUMTODSINTERVAL function

Hope that clarifies,

Warm greetings,

Jjun

Tags: Database

Similar Questions

  • NUMTODSINTERVAL function

    Hello

    This thread continues:

    Display the missing months

    I get different results when you run the same query in database version 11.2.0.1. I was running at the origin of the request in the 11.2.0.3 version and it worked fine. Is this related to the numtodsinterval function, because the query only returns one row for each customer with the date min.

    Can anyone help?

    Thank you

    sliderrules wrote:
    its strange that the left outer join is what he should do but returns incorrect values in the calculation.
    Can you offer me that I have to use the connection request to capture every month:

    Yes, like this:

    with date_group as (
    select
     min(trunc(month, 'MM')) mn
    ,max(trunc(month, 'MM')) mx
    ,cust_num
    from test
    group by
    cust_num
    )
    , dates as (
    select
     add_months(mn, level - 1) mn
    ,cust_num
    from date_group
    connect by
    add_months(mn, level - 1) <= mx
    and
    prior cust_num = cust_num
    and
    prior sys_guid() is not null
    )
    

    I can't get the file to trace such as suggested in the bug report, and I don't see rowid or case in terms of the explain command. If it's just guessing.
    But perhaps rowid is used internally in the recursive subquery.

  • Select numtodsinterval (150, 'DAY') twice;

    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod


    Select numtodsinterval (150, 'DAY') twice;

    + 00:00:00.000000 150

    I need like + 150 days 00:00:00.000000

    Published by: user9093689 on February 9, 2010 22:45
    SQL> select regexp_replace(numtodsinterval(+150, 'DAY'), '([+|-])0+(\d+)', '\1\2 days ') intval from dual
    /
    INTVAL
    -----------------------------
    +150 days  00:00:00.000000000
    1 row selected.
    
  • How to convert numtodsinterval in minutes?

    Thanks in advance.

    I have a question for which I check the time elapsed to run a batch job.

    Select numtodsinterval (avg (Last_DATE_UPDATE - STARTDATE), «minutes») avg_time
    of job_run where job_id = 'MMCD. "

    I get:
    AVG_TIME
    ----------------------------------------
    + 00:00:04.254901175 0000000000
    1 selected line.

    How to convert this to the Minutes that could 100 or 20 or more. I try to get a whole number. Thank you

    First of all, your statement is logically false (like syntax don't go too). Oracle date arithmetic uses the day as unit of measure. If date Last_DATE_UPDATE - STARTDATE differnce is expressed in days, while you say numtodsinterval to treat like minutes. Quick glance:

    SQL> select numtodsinterval(to_date('11/4/08','mm/dd/yy') - to_date('11/3/08','mm/dd/yy'),'minute') min,
      2         numtodsinterval(to_date('11/4/08','mm/dd/yy') - to_date('11/3/08','mm/dd/yy'),'day') day
      3    from dual
      4  /
    
    MIN
    ---------------------------------------------------------------------------
    DAY
    ---------------------------------------------------------------------------
    +000000000 00:01:00.000000000
    +000000001 00:00:00.000000000
    
    SQL> 
    

    As you can see, your code treats also 4 November andf November 3 as a minute difference, while it's a day. In any case, you could:

    SQL> with t as (
      2             select TO_DATE('1997-01-31 09:26:50','YYYY-MM-DD HH24:MI:SS') start_dt,
      3                    TO_DATE('1997-01-31 10:00:00','YYYY-MM-DD HH24:MI:SS') end_dt
      4               from dual
      5            )
      6  select TRUNC((end_dt - start_dt) * 1440)
      7    from t
      8  /
    
    TRUNC((END_DT-START_DT)*1440)
    -----------------------------
                               33
    
    SQL> 
    

    SY.
    P.S. Or you could round up using ROUND instead of TRUNC.

  • Three questions on partitioning

    RDBMS version: 11.2.0.4

    OS: RHEL 6.4

    Type of environment: OLTP

    ++++++++++++++++++++++++++

    We have a large non partitioned table with 4 billion documents and is 3 TB in size.

    We want to partition this table so that it can be easily maintained. We prefer partitioning on a daily basis.

    We are required by law to retain data only for 15 days. So, let's drop these scores after 15 days.

    The existing table using tablespaceA.

    We want to score range (with INTERVAL) by the CREATED_DATE column. We want to move the existing data to the great partition of base called PRE_2016 as shown below.

    About, it would look like

    create the table order_dtl

    (

    number of order_id,

    billable_flg not null char (1 car)

    complmntry_flg not null char (1 car)

    order_quantity_luom not null varchar2 (20)

    .

    .

    .

    CREATED_DATE timestamp (6)

    )

    partition by range (created_date)

    interval (numtodsinterval(1,'DAY'))

    (

    PRE_2016 PARTITION VALUES LOWER THAN (TO_DATE (DECEMBER 31, 2015 23:59:59 ',' HH24:MI:SS DD-MON-YYYY ',' NLS_CALENDAR = GREGORIAN '))

    )

    IN-STORE (tablespaceA, tablespaceB, tablespaceC);

    Question1. No idea how long it will take to make Exchange a partitiong using redefining online? Just a rough estimate would be.

    Question2. In the existing table, we have data for the years 2013, 2014 and 2015. When you create the partitioned table mentioned above, is there a way that we could divide the base for the years 2015 and 2013,2014 partition?

    Question3. After redefining online, I have to manually create the constraints and indexes. Right?

    None of the suggestions/recommendations are welcome

    For daily partitions, I understand that clues them are better.

    Better to do what? Consider CHOOSING. You expect to have 15 partitions. Search by index of a local index no prefixes will be so fifteen index partitions, which will have about 15 times so that the search for an overall index of research. Indeed, you may find that the optimizer favors the scans. Are you sure that you want to partition at all? Partitioning can make sense if you have hundreds or thousands of scores, but just fifteen years? Why bother?

  • difference of dates according to the model described

    Hello

    Need help...

    I have a table as below:

    create table select TEST_CASETBL (ID, CASE_NUM, CHANGED_ON_DATE, AUDIT_FIELD, OLD_VAL, NEW_VAL)

    111 1, 123-456', TO_DATE (January 9, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'status', 'Open', 'Farm' of the DUAL union all select

    110 1, 123-456', TO_DATE (August 30, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'sub-statut', 'close', "the DUAL Union all select them

    109 1, 123-456', TO_DATE (August 29, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'sub-statut', 'Customer of work', 'close' from DUAL union all select them

    108 1, 123-456', TO_DATE (August 26, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'Sub-etat', 'plane', ' work customer "DUAL Union select all

    107 1, 123-456', TO_DATE (24 August 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'sub-statut', 'work', 'air' Union DOUBLE select all the

    106 1, 123-456', TO_DATE (August 22, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'Sub-etat', 'review', 'work' Union DOUBLE select all the

    105 1, 123-456', TO_DATE (August 20, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'sub-statut', 'customer of work', 'revision' of union DOUBLE select all the

    104 1, 123-456', TO_DATE (August 18, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'sub-statut', 'work', ' client working "DUAL Union select all

    103 1, 123-456', TO_DATE (16 August 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'sub-statut', 'New', 'Work' Union DOUBLE select all the

    102 1, 123-456', TO_DATE (8 October 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'sub-statut', ", 'New' from DUAL union select all

    101 1, 123-456', TO_DATE (8 October 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'Account', ", 'TestingAcc' from DUAL union select all

    100 1, 123-456', TO_DATE (8 October 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'status', ", 'Open' from DUAL;

    I would like to calculate the duration total (days ideally) to AUDIT_FIELD = 'under status', thus have a set of lines like:

    New CASE_NUM review work customer close air it total by age

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    123-456 6 d 0 h 0 m 4 d 0 h 0 m 5 d 0 h 0 m 2d 0 h 0 m 2D 0 h 0 m 1 d 0 h 0 m 20 d 0 h 0 m

    Here is the explanation of the pattern:

    New:

    diff (value ID:103 CHANGED_ON_DATE - 1 - value ID:102 CHANGED_ON_DATE - 1)

    work:

    diff (value ID:104 CHANGED_ON_DATE - 1 - value ID:103 CHANGED_ON_DATE - 1) + diff (value ID:107 CHANGED_ON_DATE - 1 - value ID:106 CHANGED_ON_DATE - 1)

    customer work:

    diff (value ID:105 CHANGED_ON_DATE - 1 - value ID:104 CHANGED_ON_DATE - 1) + diff (value ID:109 CHANGED_ON_DATE - 1 - value ID:108 CHANGED_ON_DATE - 1)

    Review:

    diff (value ID:106 CHANGED_ON_DATE - 1 - value ID:105 CHANGED_ON_DATE - 1)

    air transport:

    diff (value ID:108 CHANGED_ON_DATE - 1 - value ID:107 CHANGED_ON_DATE - 1)

    close:

    diff (value ID:110 CHANGED_ON_DATE - 1 - value ID:109 CHANGED_ON_DATE - 1)

    Sum of the age

    sum (new + customer work + work + review + air + close + total age)

    Note:

    If lets say 2 rows below does not exist in table

    111 1, 123-456', TO_DATE (January 9, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'status', 'Open', 'Farm' of the DUAL union all select

    110 1, 123-456', TO_DATE (August 30, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'sub-statut', 'close', "the DUAL Union all select them

    then

    "close:" should be

    diff (current_date - value ID:109 CHANGED_ON_DATE - 1).

    That is because the status of CASE_NUM is still 'open' not yet closed and there is no subreport flip of 'close' another value

    I would appreciate any idea how to solve this, ideally as an SQL

    Thank you

    If the seconds and fractions of a second can be simply thrown away:


    with

    test_casetbl as

    (select id 111-1', 123-456' case_num, to_date (January 9, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss') changed_on_date, audit_field 'status', 'Open' old_val, 'Closed' new_val Union double all the)

    Select ' 110-1, 123-456', to_date (August 30, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'sub-statut', 'close', "Union double all the

    Select ' 109-1, 123-456', to_date (August 29, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'sub-statut', 'Customer of work', 'close' Union double all the

    Select ' 108-1, 123-456', to_date (August 26, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'sub-statut', 'air', 'Client working' double Union all

    Select ' 107-1, 123-456', to_date (24 August 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'Sub-etat', 'work', 'plane' from dual union all

    Select ' 106-1, 123-456', to_date (August 22, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'Sub-etat', 'review', 'work' of all the double union

    Select ' 105-1, 123-456', to_date (August 20, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'sub-statut', ' customer work ', 'review' Union double all the

    Select ' 104-1, 123-456', to_date (August 18, 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'sub-statut', 'work', ' client working ' double Union all

    Select ' 103-1, 123-456', to_date (16 August 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'registered void', 'New', 'Work' from dual union all

    Select ' 102-1, 123-456', to_date (8 October 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'sub-statut', ", 'New' dual union all

    Select ' 101-1, 123-456', to_date (8 October 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'Account', ", 'TestingAcc' from dual union all

    Select ' 100-1, 123-456', to_date (8 October 2015 10:00 ',' dd/mm/yyyy hh24:mi:ss'), 'status', ", 'Open' double

    )

    Select case_num,

    -regexp_replace (ltrim (regexp_replace (numtodsinterval (new, 'day'),'\s(\d{2}):(\d{2}):. *', had \1h \2m'),'+0'), '00 (.)', '0\1'))

    --     regexp_replace (ltrim (regexp_replace (numtodsinterval (work, 'day'),'\s(\d{2}):(\d{2}):. *', had \1h \2m'),'+0'), '00 (.)', '0\1') work, )

    -regexp_replace (ltrim (regexp_replace (numtodsinterval (customer_working, 'day'),'\s(\d{2}):(\d{2}):. *', had \1h \2m'),'+0'), '00 (.)', '0\1') customer_working,)

    - regexp_replace (ltrim (regexp_replace (numtodsinterval (review, 'day'),'\s(\d{2}):(\d{2}):. *', had \1h \2m'),'+0'), '00 (.)', '0\1') review,)

    - regexp_replace (ltrim (regexp_replace (numtodsinterval (air, 'day'),'\s(\d{2}):(\d{2}):. *', had \1h \2m'),'+0'), '00 (.)","0\1") air,)

    - regexp_replace (ltrim (regexp_replace (numtodsinterval (close_it, 'day'),'\s(\d{2}):(\d{2}):. *', had \1h \2m'),'+0'), '00 (.)', '0\1') close_it,)

    - regexp_replace (ltrim (regexp_replace (numtodsinterval (new + work + customer_working + review + air + close_it, 'day'),'\s(\d{2}):(\d{2}):. *', had \1h \2m'),'+0'), '00 (.)', '0\1') total_age)

          

    regexp_replace (ltrim (regexp_replace (numtodsinterval (work, 'day'),'\s(\d{2}):(\d{2}):. *', had \1h \2m'),'+0'), "0 (\d.)", "\1") work,)

    regexp_replace (ltrim (regexp_replace (numtodsinterval (customer_working, 'day'),'\s(\d{2}):(\d{2}):. *', had \1h \2m'),'+0'), "0 (\d.)", "\1") customer_working,)

    regexp_replace (ltrim (regexp_replace (numtodsinterval (review, 'day'),'\s(\d{2}):(\d{2}):. *', had \1h \2m'),'+0'), "0 (\d.)", "\1") review,)

    regexp_replace (ltrim (regexp_replace (numtodsinterval (air, 'day'),'\s(\d{2}):(\d{2}):. *', had \1h \2m'),'+0'), "0 (\d.)", "\1") air,)

    regexp_replace (ltrim (regexp_replace (numtodsinterval (close_it, 'day'),'\s(\d{2}):(\d{2}):. *', had \1h \2m'),'+0'), "0 (\d.)", "\1") close_it,)

    regexp_replace (ltrim (regexp_replace (numtodsinterval (new + work + customer_working + review + air + close_it, 'day'),'\s(\d{2}):(\d{2}):. *', had \1h \2m'),'+0'), "0 (\d.)", "\1") total_age)

    (select case_num, change_name, sum (duration) duration

    from (select case_num, changed_on_date, change_name, change_type,

    -case when change_type = 'start '.

    and lnnvl (lead (change_type) (case_num partition, change_name order of changed_on_date)! = 'stop')

    then nvl (lead (changed_on_date) (case_num partition, change_name order of changed_on_date), sysdate)-changed_on_date

    the end time

    from (select case_num, changed_on_date, lower (old_val) old_val, lower (new_val) new_val

    of test_casetbl

    where audit_field = 'under status.

    )

    UNPIVOT (change_name for change_type (old_val as 'stop', 'start' new_val))

    )

    Case_num group, change_name

    )

    Pivot (max (duration) for change_name in ('News' as new 'work' as work, "client works ' as customer_working, 'review' as review, 'air' under the air name, 'close' as close_it))

    CASE_NUM NEW WORKING CUSTOMER_WORKING REVIEW AIR CLOSE_IT TOTAL_AGE
    123-456 6 d 0 h 0 m 4 d 0 h 0 m 5 d 0 h 0 m 2D 0 h 0 m 2D 0 h 0 m 1 d 0 h 0 m 20 d 0 h 0 m

    Concerning

    Etbin

    changed to allow zero delete for h and m

  • ALL_PART_KEY_COLUMNS shows a wrong result in the presence of two indices the

    Applies to Oracle 11.2.0.3 64-bit running on Oracle Linux.

    See the example below, the partitioned table T1 is created using two indices, which is used as PK.

    CREATE TABLE T1

    (

    DATE DATETIME,

    ORDERID NUMBER (12)

    )

    PARTITION BY RANGE (DATETIME)

    INTERVAL (NUMTODSINTERVAL (1, 'DAY'))

    (

    PARTITION P1 VALUES LESS THAN (TO_DATE ('2015-01-01', 'YYYY-MM-DD'))

    );

    CREATE INDEXES ON T1 T1_IX1

    (ORDERID)

    LOCAL (PARTITION P1);

    CREATE A UNIQUE T1_PK ON T1 INDEX

    (DATETIME, ORDERID)

    LOCAL (PARTITION P1);

    ALTER TABLE T1 ADD)

    CONSTRAINT T1_PK

    KEY ELEMENTARY SCHOOL (DATETIME, ORDERID)

    WITH THE HELP OF INDEX LOCAL ENABLE);

    Now if ask us ALL_PART_KEY_COLUMNS to discover objects that use DATETIME as a partitioning column, both indexes appears:

    Select NAME, OBJECT_TYPE, COLUMN_NAME from ALL_PART_KEY_COLUMNS where COLUMN_NAME = 'DATETIME' AND NAME LIKE '% T1;

    NAMEOBJECT_TYPECOLUMN_NAME
    T1TABLEDATETIME
    T1_IX1INDEXDATETIME
    T1_PKINDEXDATETIME

    I think that T1_IX1 should not appear in a result of the above query. Is this a bug or feature?

    Applies to Oracle 11.2.0.3 64-bit running on Oracle Linux.

    See the example below, the partitioned table T1 is created using two indices, which is used as PK.

    CREATE INDEXES ON T1 T1_IX1

    (ORDERID)

    LOCAL (PARTITION P1);

    Now if ask us ALL_PART_KEY_COLUMNS to discover objects that use DATETIME as a partitioning column, both indexes appears:

    Select NAME, OBJECT_TYPE, COLUMN_NAME from ALL_PART_KEY_COLUMNS where COLUMN_NAME = 'DATETIME' AND NAME LIKE '% T1;

    NAME OBJECT_TYPE COLUMN_NAME
    T1 TABLE DATETIME
    T1_IX1 INDEX DATETIME
    T1_PK INDEX DATETIME

    I think that T1_IX1 should not appear in a result of the above query. Is this a bug or feature?

    It is a REQUIREMENT!

    You have specified a partitioned index ROOM (see code above). then the index will be partitioned on the same or the columns as the table.

    What is this column? DATETIME, of course.

    See the CREATE INDEX statement to local_partitioned_index API documentation

    http://docs.Oracle.com/CD/B28359_01/server.111/b28286/statements_5011.htm#i2135151

    local_partitioned_index

    The local_partitioned_index clauses allow you to specify that the index is partitioned on the same columns, with the same number of partitions and delimits the same partition as table . Oracle database automatically maintains local index partitioning the underlying table is repartitionnée.

    When you create a partitioned index, you must indicate to Oracle what columns you want to partition the index on.

    You have chosen to partition of the index on the same columns that the table is partitioned on.

    Which columns do you think index will be partitioned on? Post your answer.

  • SUBPARTITION to drop and add data give ora-14300

    11.2.0.4

    RHEL

    create a table partitioned by date, sous-partitionnée by the key 2 N, Y values

    Insert a record for sysdate, key_value = 'Y '.

    Insert a record for sysdate, key_value = ' don't


    2 subparts create ok.

    Drop the subparts to this date where value = N.

    Re-insert the record for sysdate, key_value = ' not and generates the error

    ORA-14300: partitioning key in a score cards outside the maximum number of partitions "" ""


    Manually add the subpartition (alter table add) high value N for the data to be inserted again for this partition.

    Is this expected behavior?  I can understand if the model was not there, but it is.  Probably a quirk to treat the scores of void

    
    SQL> drop table part_test;
    
    
    
    
    Table dropped.
    
    
    SQL> SQL> CREATE TABLE part_test
      2  (
      3    ID                  NUMBER(9)     NOT NULL,
      4    create_ts                       date default sysdate,
      5    keep_flag               varchar2(1) default 'Y'
      6  )
      7  COMPRESS BASIC 
      8      PARTITION BY range (create_ts)     INTERVAL (NUMTODSINTERVAL(1,'DAY'))
      9   SUBPARTITION BY list (keep_flag)
     10     subpartition template
     11         (
     12           subpartition sp_date1_list_y values ('Y'),
     13            subpartition sp_date1_list_n values ('N')
     14          )
     15       ( partition p1_date1 values less than (to_date('01-01-2015','DD-MM-YYYY'))
     16       );
    
    
    Table created.
    
    
    SQL>       
    SQL>     
    SQL> insert into part_test
      2  (id, create_ts, keep_flag)
      3  values
      4  (1, sysdate-1, 'Y');
    
    
    
    
    1 row created.
    
    
    SQL> SQL> insert into part_test
      2  (id, create_ts, keep_flag)
      3  values
      4  (2, sysdate-1, 'N');
    
    
    1 row created.
    
    
    SQL> 
    SQL> 
    SQL> insert into part_test
      2  (id, create_ts, keep_flag)
      3  values
      4  (3, sysdate, 'Y');
    
    
    1 row created.
    
    
    SQL> 
    SQL> insert into part_test
      2  (id, create_ts, keep_flag)
      3  values
      4  (4, sysdate, 'N');
    
    
    1 row created.
    
    
    SQL> 
    SQL> commit;
    
    
    Commit complete.
    
    
    SQL> 
    SQL> 
    SQL> set lines 180
    SQL> col high_value format a5
    SQL> 
    SQL> select partition_name, subpartition_name, high_value
      2   from dba_tab_subpartitions
      3  where table_name = 'PART_TEST';
    
    
    PARTITION_NAME                 SUBPARTITION_NAME              HIGH_
    ------------------------------ ------------------------------ -----
    P1_DATE1                       P1_DATE1_SP_DATE1_LIST_Y       'Y'
    P1_DATE1                       P1_DATE1_SP_DATE1_LIST_N       'N'
    SYS_P248743                    SYS_SUBP248741                 'Y'
    SYS_P248743                    SYS_SUBP248742                 'N'
    SYS_P248746                    SYS_SUBP248744                 'Y'
    SYS_P248746                    SYS_SUBP248745                 'N'
    
    
    6 rows selected.
    
    
    
    
    -- drop the last subpartition
    SQL> alter table part_test drop subpartition SYS_SUBP248745;
    
    
    Table altered.
    
    
    SQL> 
    SQL> insert into part_test
      2  (id, create_ts, keep_flag)
      3  values
      4  (4, sysdate, 'N');
    insert into part_test
                *
    ERROR at line 1:
    ORA-14300: partitioning key maps to a partition outside maximum permitted number of partitions
    
    
    
    
    -- manually add the subpartition
    
    
    SQL> 
    SQL> alter table part_test modify partition SYS_P248746 add subpartition sub_partN values('N');
    
    
    Table altered.
    
    
    SQL> 
    
    
    -- and now the data goes in and we can see the subpartition is created
    SQL> insert into part_test
      2  (id, create_ts, keep_flag)
      3  values
      4  (4, sysdate, 'N');
    
    
    1 row created.
    
    
    SQL> commit;
    
    
    Commit complete.
    
    
    SQL> 
    SQL> select partition_name, subpartition_name, high_value
      2   from dba_tab_subpartitions
      3  where table_name = 'PART_TEST';
    
    
    PARTITION_NAME                 SUBPARTITION_NAME              HIGH_
    ------------------------------ ------------------------------ -----
    P1_DATE1                       P1_DATE1_SP_DATE1_LIST_Y       'Y'
    P1_DATE1                       P1_DATE1_SP_DATE1_LIST_N       'N'
    SYS_P248743                    SYS_SUBP248741                 'Y'
    SYS_P248743                    SYS_SUBP248742                 'N'
    SYS_P248746                    SYS_SUBP248744                 'Y'
    SYS_P248746                    SUB_PARTN                      'N'
    
    
    6 rows selected.
    
    
    SQL> 
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    Perhaps more reasonable to expect ORA-14400: inserted partition key is not mapped with any partition?

    The subpartition template applies only to the subpartitions automatically created when the partition is created.

  • How to properly format the time

    Hi master,

    I tried to do a query involving two data: from_time and to_time. It's the query I used and its result:

    SQL > Select shift_num,.

    2 from_time,

    3 to_time

    4 of bom_shift_times

    5 where calendar_code = "GRUPO AZOR"

    6 and shift_num (2, 4, 11);

    SHIFT_NUM FROM_TIME TO_TIME

    ----------            ----------             ----------

    2 21600 50400

    4 50460 78000

    11 50460 70800

    I expect to get the result as follows:

    SHIFT_NUM FROM_TIME TO_TIME

    ----------           ----------              ----------

    2                  6:00                14:00

    4 14:00 21:40

    11 14:00 19:40

    Do you have any suggestions? Thanks in advance

    Roberto

    First suggestion: do not store time seconds. Use the built-in data INTERVAL type (as the time of day is just an interval, measured from midnight).

    Second suggestion: the following example converts second intervals:

    Select

    NUMTODSINTERVAL (21600, "second")

    Of

    Double

    Third suggestion: the following example converts seconds interval, formats such as hh: mi:

    Select

    TO_CHAR (extract (hour of numtodsinterval (21600, 'the other')), '09')

    || ':'

    || trim (to_char (extract (minute numtodsinterval (21600, 'the other')), '09'))

    Of

    Double

  • Denote absolute time and absolute time calculations

    We have Oracle database 11g in our production environment on RHEL 5.8 Virtual machine using VMware. The database version is 11.2.0.3.0.

    I have a certain scenario here, I want the code of the logic of a trouble ticket solution. The working hours for problems resolution ticket is 8 am-8 pm and resolution time is 4 hours. Now if a ticket will be logged at 18:30, his expected resolution time should be 10:30 the next day (1.30 hours of standby and 2,30 hrs the next day). I am not able to understand as below:

    1. How to write a subtraction of absolute time from 20:00 to 18:30 (18:30 can be a DB column so it is fine). The main concern here is how represent absolute time of 20:00.
    2. Subsequently, also how to add time of 08:00 the next day

    I hope that I was able to explain the application of absolute time representation and also calculations with it.


    Please get back with the answer to my query.


    Concerning

    with inp as

    (select sysdate log_time to double

    Union all select trunc (sysdate) + numtodsinterval (6.5, 'hour') of double

    Union all select trunc (sysdate) + numtodsinterval (18.5, 'hour') of double

    )

    log_time Select to_char (log_time, "dd-mm-yyyy hh24")

    to_char (case

    When log_time - trunc (log_time)< 8="" 24 ="" then="" trunc(="" log_time="" )="" +="" (="" 8="" 24="" +="" 4="" 24="">

    When log_time - trunc (log_time) > 20 / 24 then trunc (log_time) + (1 + 8 / 24 + 4 / 24)

    When log_time - trunc (log_time)< 20="" 24="" -="" 4="" 24="" then="" log_time="" +="" 4="">

    of another trunc (log_time) + (1 + 8 / 24 + 4 / 24 + (log_time - trunc (log_time) - 20 / 24))

    end, "dd-mm-yyyy hh24") expected_resolution_time

    the NPI

  • Select rownum 1

    Hi all

    I have table that represent the cam of the job, and a worker's 111222333

    other 111222888 are H start holiday (01/06/2015 to 07/06/2015 when workers return to work)

    W's when it works.

    Question is how calculate on 01/06/2015-07/06/2015 = 6 days holiday (start with H)?

    with mydata as

    (

    Select to_date (June 9, 2015 ',' DD/MM/YYYY ') dt, - 684002410 s, 'W', versus, 111222333 code of dual union all

    Select to_date (7 June 2015 ',' DD/MM/YYYY '), - 684050570, 'W', 111222333 of double union all

    Select to_date (7 June 2015 ',' DD/MM/YYYY '), - 684050570, 'W', 111222888 of double union all

    Select to_date (June 6, 2015 ',' DD/MM/YYYY '), - 684150570, 'W', 111222888 of double union all

    Select to_date (5 June 2015 ',' DD/MM/YYYY '), - 684190570, 'W', 111222888 of double union all

    Select to_date (June 4, 2015 ',' DD/MM/YYYY '), - 684220570, 'W', 111222888 of double union all

    Select to_date (3 June 2015 ',' DD/MM/YYYY '), - 684270570, 'W', 111222888 of double union all

    Select to_date (2 June 2015 ',' DD/MM/YYYY '), - 684310570, 'W', 111222888 of double union all

    Select to_date (1 June 2015 ',' DD/MM/YYYY '), - 684338692, 'H', 111222333 of double union all

    Select to_date (1 June 2015 ',' DD/MM/YYYY '), - 684348692, 'W', 111222333 of double union all

    Select to_date (1 June 2015 ',' DD/MM/YYYY '), - 684350570, 'W', 111222888 of double union all

    Select to_date (1 June 2015 ',' DD/MM/YYYY '), - 684350841, 'W', 111222333 of double union all

    Select to_date (1 June 2015 ',' DD/MM/YYYY '), - 684378694, 'W', 111222888 of double union all

    Select to_date (29 may 2015 ',' DD/MM/YYYY '), - 684611322, 'W', 111222333 of double union all

    Select to_date (29 may 2015 ',' DD/MM/YYYY '), - 684614272, 'W', 111222888 of double union all

    Select to_date (29 may 2015 ',' DD/MM/YYYY '), - 684615003, 'W', 111222333 of double union all

    Select to_date (29 may 2015 ',' DD/MM/YYYY '), - 684637550, 'W', 111222888 of double union all

    Select to_date (28 may 2015', ' MM/DD/YYYY ' "), - 684694292, 'W', 111222333 of the double

    )

    Select dt, dry

    , to_date (6 February 2037 08:28:17 ',' DD/MM/YYYY hh24:mi:ss') + numtodsinterval(sec,'SECOND') val

    , to_date (May 31, 2005 ',' DD/MM/YYYY ') + 0.2789 + numtodsinterval (s + 1000000000, 'SECOND') val2, versus, code

    of mydata;

    concerning

    Gordan

    Hello

    You can use the function of leader to access the values of the following line as follows

    with mydata as

    (

    Select to_date (June 9, 2015 ',' DD/MM/YYYY ') dt, - 684002410 s, 'W', versus, 111222333 code of dual union all

    Select to_date (7 June 2015 ',' DD/MM/YYYY '), - 684050570, 'W', 111222333 of double union all

    Select to_date (7 June 2015 ',' DD/MM/YYYY '), - 684050570, 'W', 111222888 of double union all

    Select to_date (June 6, 2015 ',' DD/MM/YYYY '), - 684150570, 'W', 111222888 of double union all

    Select to_date (5 June 2015 ',' DD/MM/YYYY '), - 684190570, 'W', 111222888 of double union all

    Select to_date (June 4, 2015 ',' DD/MM/YYYY '), - 684220570, 'W', 111222888 of double union all

    Select to_date (3 June 2015 ',' DD/MM/YYYY '), - 684270570, 'W', 111222888 of double union all

    Select to_date (2 June 2015 ',' DD/MM/YYYY '), - 684310570, 'W', 111222888 of double union all

    Select to_date (1 June 2015 ',' DD/MM/YYYY '), - 684338692, 'H', 111222333 of double union all

    Select to_date (1 June 2015 ',' DD/MM/YYYY '), - 684348692, 'W', 111222333 of double union all

    Select to_date (1 June 2015 ',' DD/MM/YYYY '), - 684350570, 'W', 111222888 of double union all

    Select to_date (1 June 2015 ',' DD/MM/YYYY '), - 684350841, 'W', 111222333 of double union all

    Select to_date (1 June 2015 ',' DD/MM/YYYY '), - 684378694, 'W', 111222888 of double union all

    Select to_date (29 may 2015 ',' DD/MM/YYYY '), - 684611322, 'W', 111222333 of double union all

    Select to_date (29 may 2015 ',' DD/MM/YYYY '), - 684614272, 'W', 111222888 of double union all

    Select to_date (29 may 2015 ',' DD/MM/YYYY '), - 684615003, 'W', 111222333 of double union all

    Select to_date (29 may 2015 ',' DD/MM/YYYY '), - 684637550, 'W', 111222888 of double union all

    Select to_date (28 may 2015', ' MM/DD/YYYY ' "), - 684694292, 'W', 111222333 of the double

    )

    Select dt, dry

    , to_date (6 February 2037 08:28:17 ',' DD/MM/YYYY hh24:mi:ss') + numtodsinterval(sec,'SECOND') val

    , to_date (May 31, 2005 ',' DD/MM/YYYY ') + 0.2789 + numtodsinterval (s + 1000000000, 'SECOND') val2, versus, code

    , DECODE (versus, 'H', LEAD(dt, 1) OVER (PARTITION BY code ORDER BY dt) - dt, null) holiday

    from mydata by code, dt;

    Concerning

    Salim

  • Dynamically partition a table based on different values of a specific column: possible?

    I'll start by explaining my problem, so that you can have a global vision of the problem and perhaps suggest another solution. Problem: I have 2 tables with millions of records. Records are added daily, and so each row in each table has a column of "insertion_date".

    C1 C2 ... C10 insertion_date (type date, ofc)
    

    lines are cleaned according to the insertion_date parameter. This can happen in two ways:

    1 - whenever an application error appears. In this case delete is based on a single day and would be like:

    delete from T1 where insertion_date=##;
    

    in other words remove us the lines added and then restart the program (business logic, can't change it)

    2. every two weeks the data associated with these two weeks are deleted because will be most used:

    delete from T1 where insertion_date between ## and ##; (a two weeks period here)   
    

    Delete is currently very slow: it takes abot 8 minutes just to remove approximately 5 M of records (with the same insertion_date), I can't even imagine the time required to delete records more.

    So, here's my idea!

    I would partition my DB according to the value of insertion_date.

    To remove case 1 I would simply delete the partion associated with this insertion date, to remove scores of cases 2 associates at that interval.

    For the needs of my application at most 15 were leaving are present each time (maybe 20 if I want to keep last at least 5 days of data), so the documented limit of 64000 partitions is not a problem.

    Real problem is that I do not know insertion_date values in advance, so my question: is it possible to automatically create a new partition every time presents itself a new value of insertion_date?

    And please correct me if I'm wrong, if I accomplish partitioning that I wouldn't need to edit above right queries? I know just the faster removal time am I correct?

    No - it isn't bog standard range partitioning partitioning interval

    But perhaps you're citing 9i documentation for a reason?

    It is a feature of 11g... then only about 10 years.

    create table t1
    (col1  date)
    partition by range (col1) interval (numtodsinterval(1,'DAY'))
    (partition po values less than (to_date('01-01-2015','DD-MM-YYYY')));
    
    table T1 created.
    
    select table_name, partition_name, high_value from user_tab_partitions where table_name = 'T1';
    
    TABLE_NAME                     PARTITION_NAME                 HIGH_VALUE
    ------------------------------ ------------------------------ --------------------------------------------------------------------------------
    T1                             PO                             TO_DATE(' 2015-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA...'
    
    insert into t1
    select trunc(sysdate,'MM')+rownum-1
    from   dual
    connect by  rownum <= 10;
    
    select table_name, partition_name, high_value from user_tab_partitions where table_name = 'T1';
    
    TABLE_NAME                     PARTITION_NAME                 HIGH_VALUE
    ------------------------------ ------------------------------ --------------------------------------------------------------------------------
    T1                             PO                             TO_DATE(' 2015-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA...'
    T1                             SYS_P450383                    TO_DATE(' 2015-07-02 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA...'
    T1                             SYS_P450384                    TO_DATE(' 2015-07-03 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA ...'
    T1                             SYS_P450385                    TO_DATE(' 2015-07-04 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA ...'
    T1                             SYS_P450386                    TO_DATE(' 2015-07-05 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA ...'
    T1                             SYS_P450387                    TO_DATE(' 2015-07-06 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA ...'
    T1                             SYS_P450388                    TO_DATE(' 2015-07-07 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA ...'
    T1                             SYS_P450389                    TO_DATE(' 2015-07-08 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA ...'
    T1                             SYS_P450390                    TO_DATE(' 2015-07-09 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA ...'
    T1                             SYS_P450391                    TO_DATE(' 2015-07-10 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA ...'
    T1                             SYS_P450392                    TO_DATE(' 2015-07-11 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA ...'
    
  • Counting in delays

    Hello

    I have a table with date-periods. Some are overlapping.


    StartDate enddate number

    2015-01-01 - 4

    2015-03-01 - 2015 - 04-04-6

    03-05-2015-2015-07-04-8

    31-05-2015-2015-08-01-10

    2015-10-04 - 15

    Within each period, I have a number.


    The query has created new periods with startdates en followed enddates of each other.

    The periods are not overlapping and within the specified time, the numbers are counted.

    Possible solution tabibitosan can help create the result set

    Thanks Wouter


    create table period_sum (startdate, enddate, num)

    as

    Select to_date ('2015-01-01', 'yyyy-mm-dd'), null, 4 Union double all the

    Select to_date ('01-03-2015', "yyyy-mm-dd"), to_date ('2015-04-04', "yyyy-mm-dd"), 6 Union double all the

    Select to_date ('2015-05-03', "yyyy-mm-dd"), to_date ('2015-07-04', 'yyyy-mm-dd'), 8 of all the double union

    Select to_date ('2015-05-31', "yyyy-mm-dd"), to_date ('01-08-2015', 'yyyy-mm-dd'), 10 of all double union

    Select to_date ('2015-10-04', 'yyyy-mm-dd'), null, double 15

    /

    StartDate enddate num

    2015-01-01 4 2015-02-28

    2015-03-01 10 2015-04-04

    2015-04-05 4 2015-05-02

    03-05-2015 2015-05-30 12

    2015-05-31 22 2015-07-04

    2015 05-07-2015-08-01 14

    08-02-2015 2015-10-03 4

    2015-10-04 19

    SQL > with all_days like

    2 (select mindate + numtodsinterval (level-1, 'day') dt

    3, cntall case when cntenddate then ' else n 'Y' end null_enddate_exists

    4 (maxdate, mindate, max (nvl (enddate, startdate)) select min (startdate), count (*) cntall, count (enddate) cntenddate of period_sum)

    5. connect by level<= maxdate="" -="" mindate="" +="">

    6)

    7, sums_per_day as

    8 (select ad.dt

    9, ad.null_enddate_exists

    10, sum (ps.num) sumnum

    11 of: ad all_days

    12 inner join period_sum ps on (ad.dt between ps.startdate and nvl (ps.enddate, date ' 9999-12-31'))

    Group 13 by ad.dt

    14, ad.null_enddate_exists

    15)

    16. Select min (dt)

    17, case when null_enddate_exists = 'Y' and grp = max (grp) () then null max (dt) to another end

    18, sumnum

    19 in (select dt

    20, sumnum

    21, null_enddate_exists

    22, max (rn) in grp (order of dt)

    23 of (select dt

    24, sumnum

    25, null_enddate_exists

    26, sumnum deal when lag (sumnum) (order dt layout) then another row_number() (any order by dt) null end rn

    27 of sums_per_day

    28                  )

    29         )

    30 per grp group

    31, sumnum

    32, null_enddate_exists

    33 arrested by min (dt)

    34.

    MIN (DT) CASEWHENNULL_ENDDAT SUMNUM

    ------------------- ------------------- --------------------------------------

    01/01/2015 00:00:00 28/02/2015 00:00:00 4

    03/01/2015 00:00:00 04/04/2015 00:00:00 10

    04/05/2015 00:00:00 05/02/2015 00:00:00 4

    05/03/2015 00:00:00 30/05/2015 00:00:00 12

    31/05/2015 00:00:00 07/04/2015 00:00:00 22

    07/05/2015 00:00:00 08/01/2015 00:00:00 14

    08/02/2015 00:00:00 03/10/2015 00:00:00 4

    10/04/2015 00:00:00 19

    8 rijen zijn geselecteerd.

  • Partition table with null column

    Friends,

    DB: 11 GR 2

    OS: Linux

    I'm conversion from table to table of partition and try to understand the to do.

    Table has a date column that can have null values and I am partitioning table to date.

    I creates interval partitioning and also want to use MAXVALUE so that all dates go null.

    Somehow below syntax does not work, tried to read the manual, but not able to set below.

    CREATE TABLE EMP

    (DATE_ENTERED DATE default sysdate,

    ID NUMBER (10) NULL NOT ACTIVATE.

    ACTIVATE THE FIRST NAME VARCHAR2 (200) NOT NULL,

    TURN ON LAS_NAME VARHCAR2 (200) NOT NULL

    CONSTRAINT PK_ID PRIMARY KEY (ID)

    )

    PARTITION BY RANGE (DATE_ENTERED)

    INTERVAL (NUMTODSINTERVAL(1,'day'))

    (

    partition values P_NOT_USE less (to_date ('2015-01-01', 'yyyy-mm-dd'));

    values p_max_value score less than (MAXVALUE)

    );

    Receive the error message:

    ORA-14761 maxvalue partition cannot be specified for interval partitioned objects.

    Advice to solve this problem?

    I think the problem is using the function of the interval but then how can we partition a day?

    Also is there any way/script available to find all the permissions/privileges table before a fall?

    Manual: maintenance of Partitions

    The error is pretty clear to me. You can't have a partition of maxvalue for objects partitioned interval, only beach.

    There is no logical sense to have a for range partitioning's maxvalue partition, because the whole point is to have the Oracle to create new partitions automatically when you insert something above the transition point.

    SQL> desc dba_tab_privs
    Name                                      Null?    Type
    ----------------------------------------- -------- --------------
    GRANTEE                                            VARCHAR2(128)
    OWNER                                              VARCHAR2(128)
    TABLE_NAME                                        VARCHAR2(128)
    GRANTOR                                            VARCHAR2(128)
    PRIVILEGE                                          VARCHAR2(40)
    GRANTABLE                                          VARCHAR2(3)
    HIERARCHY                                          VARCHAR2(3)
    COMMON                                            VARCHAR2(3)
    TYPE                                              VARCHAR2(24)
    
  • Time Dimension table

    Hello

    I have a requirement where I need to calculate the value of average purchase order based on the month. The problem I have here is that the custom time Dimension table that I have in my RPD has dates only until 2011 and not beyond. I downloaded this table via BI tutorials oracle schema EXAMPLE.

    I've looked everywhere on the internet for a time dimension table, but I'm unable to find it. Can someone please help me find a way to insert the time dimension table?

    Thank you

    Nicole Shepherd

    Hi Anthony,.

    You can change the SQL code to insert new rows into your table.

    Example:

    INSERT INTO your_table (your_field)

    SELECT TO_DATE('31/12/2010','DD/MM/YYYY') + NUMTODSINTERVAL (n, 'day') AS Full_Date

    FROM (SELECT level n FROM dual connect by level)<>

    The foregoing will insert lines starting at 01/01/2011 and until the 01/01/2011 + 4000 days (over 10 years).

    Of course, you must extend the code to calculate all the fields in your time dimension.

    Concerning

    Federico

Maybe you are looking for

  • Satellite A-80 131: cooling system

    Hi I would like to replace my cooling fan, I think that it Don t work properly, make noise when the machine is cold and starting. According to me, is a problem that came from a warmer. Could someone tell me where I could buy the replacement part or o

  • HP laptop - 15-r249tu: 15 HP r249tu Notebook wireless driver for 32-bit windows 8 x 64

    Please help me to get the drivers for my HP laptop laptop-15-r249tu (Free DOS)...I installed windows8 32 bit, x 64 based processor...Also please help me to get all the other drivers as well

  • HpSA will not update download

    HP 2000 379WM, HPSA says he connects to the server, but is unable to download/collection/analysis system and going on to prepare the list of actions.  I have the bios F32 and HPSA 6054.  Model of said registry also: hptcs "stopped working".

  • HP Pavilion series g, cd/dvd

    What blank cd (number) would be just for hp pavillion series g and also dvd,. Thank you.

  • Windows vista updates crashes reboot

    Hi, I've had my laptop windows vista for Christmas 2007 business and recently not installs the regular update of windows. The update appears on the home screen and I install, after the instalation it asks me to restart my computer when it restarts do