Number data type used on a date column

Hi Forum,

I have a table with one column defined as number type.

This column contains the date information and has an index defined on it.

When I issue a select statement on this table based on this column for over 5 years of data, the query takes a long time.

Select count (*) in x if date = 20070411

The query takes a long time.

such a situation is causing a problem when the where clause on a date, but the field filters is defined has a number type.

All the columns in this table are defined as non-unique, but the date column seems to be more selective.

Just curious to know if this type of data can have any impact IE do not provide the correct information to the optimizer etc.?

Thanks for any help or advice

Hello

user3206995 wrote:

Hi Forum,

I have a table with one column defined as number type.

This column contains the date information and has an index defined on it.

When I issue a select statement on this table based on this column for over 5 years of data, the query takes a long time.

Select count (*) in x if date = 20070411

The query takes a long time.

such a situation is causing a problem when the where clause on a date, but the field filters is defined has a number type.

Yes; You can count on having a lot of different problems, if you are storing information on dates in NUMBER of columns.  The columns DATE to the date information.

DATE is also a keyword from Oracle, so it's a very bad name of a column.  Use a column name as entry_date or date_column instead of just date.

All the columns in this table are defined as non-unique, but the date column seems to be more selective.

If

date_column = 20070411

is the only requirement, and it is slow, then it seems that you do not have an index on date_column, and you need to create a.

For all performance issues, see the FAQ forum:

Re: 3. how to improve the performance of my query? / My query is slow.

Just curious to know if this type of data can have any impact IE do not provide the correct information to the optimizer etc.?

It doesn't look like this problem is caused by using the wrong type of data.  Many others will, however.

Tags: Database

Similar Questions

  • [nQSError: 43119]:-the data type: 25 is not supported columns error for data type "uniqueidentifier".

    Hi all


    I am facing a problem while creating a BI reports to the SQL Server 2008 Database.

    Access to columns of data type "uniqueidentifier" I get error [nQSError: 43119]:-the data type: 25 is not supported.

    • OBIEE 11.1.1.6.11 on Linux x86_64 servers is hosted by the Services of Oracle Cloud.
    • Using last "ODBC driver for SQL server 11" for connection (also tried driver "DataDirect SQL Server 6.0 native Wire Protocol").
    • No "Uniqueidentifier" data type columns display correctly in reports.
    • I tried to change the columns of data type "Uniqueidentifier" to char (36), VARCHAR (36), VARCHAR (40), types of binary data (16) in the physical layer on various suggestions but error still there.

    Same columns questioned the SQL Developer (using third-party jTDS JDBC driver "jtds - 1.2.7 - dist") I am able to see these "uniqueidentifier" data columns. record sample:-"CB350576-FCD8-DE11-B111-002219598619".


    Please advice if this is a bug or I'm missing some property of SQL server database settings.


    Thanks in advance.

    Yes Srini,

    This type of column becomes UNKNOWN when they are imported into SPR but its strange after changing to VARCHAR (36), we can use it for joining tables without any problem.

    Only issue I'm facing now is the limitation to use in queries like calculate the total number of incidents (in my case incidentid is the primary key).

    But I've found a workaround. I am formulating a measure in MDB layer to get the number of total incidents as {CASE WHEN is NULL then 0 otherwise 1 END}.  the aggregation is defined on the sum and I get incident count works correctly.

    Thanks for your help.

  • Largest number of digits for the NUMBER data type?

    What length more of a NUMBER that Oracle will "support"?

    The documentation says the following:

    Limitations of the data type says:

    «Can be represented in a comprehensive precision 38 digits»

    NUMBER of Data Types says:

    "Oracle guarantees portability of numbers with precision of up to 20 digits of base-100, which equals 39 or 40 decimal digits according to the position of the decimal point."

    I realize account that if I define a column as simply NUMBER, I can insert numbers with a size up to 126 characters.  However, Oracle seems to maintain only the first 40 digits in MOST cases.  The largest number of digits, it seems to allow is 40 before it begins to be replaced by 0.

    With numbers that have more than 40 figures, Oracle will sometimes replace all numbers according to the 38th numbers with a 0 and sometimes replace 0 after the digit 39th or 40th.

    Therefore, what is the largest number of digits, can be trusted to safely store Oracle?

    This is the code I used for this testing process.

    create the table max_num (num number);

    declare

    number of l_x;

    Start

    for x in 1.200

    loop

    l_x: = x;

    insert into max_num values (rpad (1, x, 1));

    end loop;

    exception

    while others then

    dbms_output.put_line ('STOP: ' | l_x);

    dbms_output.put_line (SQLERRM);

    end;

    /

    Select num, length (replace (num, 0)) of max_num;

    What length more of a NUMBER that Oracle will "support"?

    You have already given your own answer. If 'length': the maximum number of digits is written the doc gives you the answer:

    999... (38 9's) x 10 value maximum125

    The 38/39/40, hereinafter referred to as the doc means "significant digits". This is why rounding or truncation occurs if you provide more significant digits of 38/39/40.

    Oracle stores the numbers internally in a binary format 21 bytes using a documented structure in the doc of the OIC in the section 'NUMBER'.

    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e10646/oci03typ.htm#i423684

    Oracle database stores the values of the NUMBER data type in a variable length format. The first byte is the exponent and is followed by 1 to 20 mantissa bytes. The high bit of the exponent byte is the sign bit; It is defined for positive numbers, and it is cleared for negative numbers. The lower 7 bits represent the exponent, which is a number of base-100 with an offset of 65.

    This article from doc continues to show you how to convert the internal format to the real value.

    An additional byte of 1 is used for all types of data to store the length; That's why you often see docs saying numbers can take 22 bytes.

  • Number and types of digital data

    Hello



    My table contains data, it is a very large table, data type of the columns little is just number (no precession or scale not reported). When this table get imported OWB and used in maps, then the display of the size of the column number in the Numeric form with zero as the precision and scale. The source in the mapping table contains the same type of data columns but with precision and scale declared. When I validate the mapping I get ' precision of the column is greater then the column target ' error. "



    I tried to edit the table with the same precision and scale as a source but as data are already existing, throws to oracle cannot reduce the size. I don't want to create another table and generate data and reload as this is a large table.



    Is there a solution for this problem, please help.



    Thank you

    HESH

    Ignore this warning.

  • Convert or map Typedonnees decimal Transact-SQL for Oracle Number data type?

    MSSQL 2005
    Oracle 10.2 g

    In a MSSQL table, I have a column with the data type set on (decimal (1.0), null) with the values of line-1. (695 lines in total)

    In the Oracle table, the proposed mapped column is a number data type. When I import data, I received 695 errors with the message "invalid value for the field. How to properly convert or map Decimal (MSSQL) Transact-SQL for Oracle Number data type for a negative value?

    Thank you.

    How do you load data into Oracle? What tool or programming language you are using? Can you post something cause what you stated in your post should work, but there may be some ODBC, or other type of conversion factors to be taken into account.

     > create table t1 (field1  number(1,0));
    
    Table created.
    
     > insert into t1 values (-1);
    
    1 row created.
    
    UT1 > select * from t1;
    
        FIELD1
    ----------
            -1
    

    HTH - Mark D Powell.

  • need to get only one line when you use between (date columns)

    Hi all

    create the table SAMPLE_ITEMS

    (ITEM_NO, varchar2 (10))

    Date DELIVERY_DATE,

    Number of QTY_SUM1

    Number of QTY_SUM2

    Number ITEM_QTY,

    Number ORDER_QTY,

    Number ITEM_AMOUNT,

    Number of SALES_AMOUNT

    );

    insert into SAMPLE_ITEMS values ('AAA', ' 28 / 04/2014 ',-88, 0,475,262,-123.45,-1188);

    insert into SAMPLE_ITEMS values ('AAA', ' 28 / 05/2014 ', 0, - 122, 475, 262, - 10.234,-1647);

    insert into SAMPLE_ITEMS values ('AAA', ' 16 / 06/2014. ', 0, 0,475,262,-80.59,-135);

    insert into SAMPLE_ITEMS values ('AAA', 19 December 2014 ', 0, 0,475,262,-42.29,-67.5);

    Setting out with my own query,

    ITEM_NOTRUNC (DELIVERY_DATE)QTY_SUM1QTY_SUM2ITEM_QTYORDER_QTYITEM_AMOUNTSALES_AMOUNT
    AAA28/04/2014-880475262-123.45-1188
    AAA28/05/20140-122475262-10.234-1647
    AAA16/06/201400475262-80.59-135
    AAA19/12/201400475262-42.29-67.5

    Every time I question as code

    Select * from SAMPLE_ITEMS

    where DELIVERY_DATE between April 28, 2014 ' and 19 December 2014 '-> they must pass as a parameter

    I need to get only one line

    AAA-88-122475262-256.564-3037.5

    Database 11.2.0.1.0

    Note; Please do not use MAX for Date and do not want to display Date columns in the result

    Note 1: I want to choose DELIVERY_DATE in select it also and only get a line like above the expected result

    SELECT item_no

    SUM (qty_sum1),

    SUM (qty_sum2),

    SUM (DISTINCT item_qty),

    SUM (DISTINCT order_qty),

    SUM (item_amount),

    SUM (sales_amount)

    OF SAMPLE_ITEMS

    WHERE the DELIVERY_DATE BETWEEN TO_DATE (28 April 2014 ', "dd/mm/yyyy")

    AND TO_DATE (19 December 2014 ', "dd/mm/yyyy")

    GROUP BY item_no;

    I will get

    ITEM_NO Trunc (DELIVERY_DATE) QTY_SUM1 QTY_SUM2 ITEM_QTY    ORDER_QTY TTEM_AMOUNT SALES_AMOUNT        

    AAA             12/19/2014                         -88                 -122                475                262                       -256.564              -3037.5

    OK fine, I want to choose DELIVERY_DATE as if so I'll have all the lines, but I want to only show one as shown above

    Because I do report discoverer in Oracle Apps, without taking the DELIVERY_DATE of the select query, it is not possible to move the date as a parameter

    Can you please help me how to do this?

    Thank you

    Post edited by: Rajesh123 NOTE added in the body of the Message

    Post edited by: added test Rajesh123 messages

    Maybe you want a single line in all cases

    Select si.item_no,

    start_date min (d.start_date),

    min (d.end_date) end_date,

    min (si.qty_sum1) qty_sum1,

    min (si.qty_sum2) qty_sum2,

    min (si.item_qty) item_qty,

    min (si.order_qty) order_qty,

    Sum (si.item_amount) item_amount,

    Sum (if. Sales_Amount) sales_amount

    of (start_date select to_date(:date_from,'dd-MON-yyyy'))

    to_date(:date_to,'dd-mon-yyyy') end_date

    of the double

    ) d

    left outer join

    TR sample_items

    on the si.delivery_date between d.start_date and d.end_date

    Group of item_no

    ITEM_NO START_DATE END_DATE QTY_SUM1 QTY_SUM2 ITEM_QTY ORDER_QTY ITEM_AMOUNT SALES_AMOUNT
    - 01/01/1900 31/12/2000 - - - - - -

    Concerning

    Etbin

  • OBIEE 10 g, Using sysdate as a variable of presentation on a date column

    Hello guys,.

    I use Obiee 10 g. I have a date in my report column, and what I'm doing, that's if the date is less than the current date, then I want to add a condition (blush the bottom of the column in the report) for this column. I looked in a few forums and found that system.currentTime is a variable of default presentation and I tried to use it, but it does not work.

    What I've done, in the responses, I went to the properties of the date column, colum went to add selected condition then add a variable presentation and then the phrase I used was system.currentTime and then chose the red background color, but that does not reflect when I click on the results.

    Please let me know how to solve this problem. Thank you.

    796078 wrote:
    Hello guys,.

    I use Obiee 10 g. I have a date in my report column, and what I'm doing, that's if the date is less than the current date, then I want to add a condition (blush the bottom of the column in the report) for this column. I looked in a few forums and found that system.currentTime is a variable of default presentation and I tried to use it, but it does not work.

    What I've done, in the responses, I went to the properties of the date column, colum went to add selected condition then add a variable presentation and then the phrase I used was system.currentTime and then chose the red background color, but that does not reflect when I click on the results.

    Please let me know how to solve this problem. Thank you.

    Follow these steps:

    (1) take an additional column, call the 'DIFF' and in the fx, enter this:

    TIMESTAMPDIFF (SQL_TSI_DAY, VALUEOF ("CURRENT_DATE"), your_date_column)

    This will be negative, each time your date column value is less than the current date.

    (2) on your date_column, click the Format button and add that the conditional formatting based on the DIFF column blush the background when DIFF is "less than 0."

    This will achieve what you want. Hide the DIFF column.

  • HO to Comapre with Number data Type

    Hello

    My need is to perform validation in the ValidateEntity method.

    How to compare the data type number:

    For ex: number = gatAbc();

    If(a>10)
    {
    throw new oaExcption...
    }

    But while comapring got compiler error

    Error (218,17): not found >(oracle.jbo.domain.Number, int) method in the abc.oracle.apps.per.irc.pqr.schema.server.XxabcEOImpl class

    So please tell me how to compare integer value with the Number data type

    Thanx

    Check with the float. It will certainly work.

    float number = Float.parseFloat(HrsPerDay); //HrsPerDay is a String and I am converting it to float 
    
    if(( number <= 0) || (number >= 21))
                       {
                            throw new OAAttrValException(OAAttrValException.TYP_VIEW_OBJECT,
                                              "xxCopyResourceVO1",
                                              rowi.getKey(),
                                              "NoOfCopies",
                                              rowi.getAttribute("NoOfCopies"),
                                              "PA",
                                              "xx_xx_COPY_POSITIVE_NUM");
                       }
    

    Here in this code I also check the hours cannot be less then 0 and 20 above.

    Thank you
    -Anil

  • Starting from two data tables, how do you get the values in two columns using values in a column (values get col. If col. A is not null values and get the pass. B if col. A is null)?

    Two tables provided, how you retrieve the values in two columns using values in a column (the pass get values. If col. A is not null values and get the pass. B if col. A is null)?

    Guessing

    Select nvl (x.col_a, y.col_b) the_column

    from table_1 x,.

    table_2 y

    where x.pk = y.pk

    Concerning

    Etbin

  • Compare a column varchar2 with a date column segment


    Dear all,

    I have a column with the data type varchar2 with the sample of data such as segment ' 2013/06/09 00:00:00 ', I want to compare this column by date column

    I tried many ways to conversion but does not like

    Select to_date (TO_NCHAR (substr (' 2013/06/09 00:00:00 ',1 11),' DD-MM-YY '))DATE_C of double-> giving invalid number

    Select TO_TIMESTAMP (TO_NCHAR (substr (' 2013/06/09 00:00:00 ',1 11),' DD-MM-YY '))DATE_C of double-> giving invalid number

    Can I have any suggestion for this please

    Thank you and best regards

    Hello

    Use something like this:

    Select to_date (' ' 2013/06/09 00:00:00 ', ' DD/MM/RRRR HH24:MI:SS') twice;

    Thank you &

    Best regards

  • column of username in dba_users PLS-00306: wrong number or types of arguments

    Can someone please help me understand what is happening here? I need to insert items in schemas a little, but I can't get the column username to work for some reason any.

    SQL > start
    2 for v_username looping (select username from dba_users)
    3 dbms_output.put_line (v_username);
    4 end of loop;
    5 end;
    6.
    dbms_output.put_line (v_username);
    *
    ERROR at line 3:
    ORA-06550: line 3, column 1:
    PLS-00306: wrong number or types of arguments in the call to "PUT_LINE '.
    ORA-06550: line 3, column 1:
    PL/SQL: Statement ignored


    SQL > dba_users desc;
    Name Null? Type
    ----------------------------------------- -------- ----------------------------
    USER NAME NOT NULL VARCHAR2 (30)
    USER_ID NOT NULL NUMBER
    PASSWORD VARCHAR2 (30)
    ACCOUNT_STATUS NOT NULL VARCHAR2 (32)
    DATE OF LOCK_DATE
    EXPIRY_DATE DATE
    USER_USERS NOT NULL VARCHAR2 (30)
    TEMPORARY_TABLESPACE NOT NULL VARCHAR2 (30)
    CREATION DATE NOT NULL
    PROFILE NON-NULL VARCHAR2 (30)
    INITIAL_RSRC_CONSUMER_GROUP VARCHAR2 (30)
    EXTERNAL_NAME VARCHAR2 (4000)

    SQL >

    >
    for v_username in a loop (select username from dba_users)
    >
    v_username in the loop is a CURSOR that represents the WHOLE folder.

    If you need to access the columns in the record using the dot notation. It works for me.

     declare
     v_username varchar2(30);
     begin
     for v_username in (select username from dba_users) loop
     dbms_output.put_line(v_username.username);
     end loop;
     end;
    
    SCOTT
    . . .
    
  • Index on the date column

    Hello

    I have a behavior when running a table with an indexed column date that seems a bit away from me.

    I have a table with many columns and rows 4.8 million (Oracle 11 g 2). One of his columns is of data type Date. This column is indexed using a b-three index.

    Consider the select statement. It returns only 32 thousand rows (less than 1% of the number of rows in the table). Oracle did a full scan to run the query.

    Field2 can be any column of the table that is not part of the index (for example, a column which is varchar2 (14)).

    As the used filter has a high selectivity, I expect Oracle to use the index on the date_field when executing the query. Have no idea about it? Is there a rule on the date columns indexing?

    Select Field2
    TABLE
    WHERE date_field > = TO_DATE('13/09/2010','DD/MM/YYYY')
    and date_field < TO_DATE('14/09/2010','DD/MM/YYYY')

    user492400 wrote:
    The clustering_factor is not too high?

    OBJECT_TYPE-> INDEX
    BLEVEL-> 2
    LEAF_BLOCKS-> 14796
    DISTINCT_KEYS-> 3249780
    AVG_LEAF_BLOCKS_PER_KEY-> 1
    AVG_DATA_BLOCKS_PER_KEY-> 1
    CLUSTERING_FACTOR-> 3620372
    NUM_ROWS-> 4823298

    If you look at your plan, it has a cost of 11156.

    The CBO estimated 29446 lines will be returned. It's a selectivity of 29446/4823298, which represents 0.61%.

    Therefore, the cost of using the index is approximately:

    2 (blevel) + 0.61% of the 14796 (pads of sheets) + 0.61% 3620372 (clustering factor) which is about 22195 (assuming that CBO based default settings).

    22195 is superior (so much) than 11156 so Full Table Scan WINS.

    See you soon

    Richard Foote
    http://richardfoote.WordPress.com/

  • PCT_GRAPH in the number/date format

    The version of the APEX, we're currently on is 4.1.1.00.23. I'm trying to get a progress bar to display in a report. I use the PCT_GRAPH:330099:CC0000:100 in the number/date of the bar column format. It does not work. I will attach what it looks like. Is there anything else I need to do?

    Thanks for your help!

    PAM

    PAM wrote:

    The version of the APEX, we're currently on is 4.1.1.00.23. I'm trying to get a progress bar to display in a report. I use the PCT_GRAPH:330099:CC0000:100 in the number/date of the bar column format. It does not work. I will attach what it looks like. Is there anything else I need to do?

    Set the column attribute display as Standard report column and not display text (escape special characters, does not save the State).

  • Concatenate the date and time that are stored in two different date columns

    Hello

    I have to select date two columns from two different tables a date and another over time.

    I want to concatenate these two columns and format the result form dd/mm/yyyy hh24

    But I get error invalid number

    For example

    create table as datetime

    (select to_date (' 21/01/2014 ',' dd/mm/yyyy') as dt, to_date('08:00','hh24:mi') like double MC

    )

    Select to_char(dt||) TM, "dd/mm/yyyy hh24") of datetime

    I use oracle 10 g

    Help, please.

    Hello

    Roger wrote:

    ... If you need to take the party date to a date column and the time of anonther part, then you must first convert them to a string, concatenate them and convert them to date.

    You don't need to do this.  What you have described is a way to do it, but this isn't the only way.

    If d1 and d2 are the two DATEs, you can get year, month and day of d1 combined with hours, minutes, and seconds from d2 liike this:

    TRUNC (d1) and (d2 - TRUNC (d2))

    Nesting TO_DATE and TO_CHAR in Oracle, is almost never the best way to do anything.  Oracle provides many functions (for example, TRUNC) to manipulate dates, but also of DATE arithmetic.

  • Data external to appear as the date column

    Hello

    I have an external table that gets a column called time_stamp in the external table as varchar (I know, bad), is there a way to turn in date with the time when the external table definition? or can I have a query with the to_date function to overcome the problem?

    column

    14/01/2014 11:20:43

    Thank you very much.

    the foregoing transforms col3 in date format, but displays the following value in the external table: 14 January 14, it should be mm-dd-yyyy

    Do you mean when you query the external table?

    Dates (stored as DATE data type) have no "format".

    If you want the string to a date column representation in a specific format, and then set your NLS settings (setting NLS_DATE_FORMAT) accordingly.

    Edit:

    Don't forget to change the data type in the column as well list, otherwise you will get an implicit conversion that could also explain the issue:

    create table my_ext_table)

    col1 number (8)

    , col2 VARCHAR2 (3)

    col3 date

    )

    (external) Organization

    ...

Maybe you are looking for

  • How update software

    Hello I have a 2007 Macbook, it is not a Pro. I have been informed that the lion is compatible with this computer, but I'm stumped on how to update the latest software, this device is compatible with the witch is not el capitan (obviously). could som

  • Cannot connect to all websites

    Other browsers may connect to the sites.When I open my browser, all the sites say connection but never connect.When I try to restart Firefox, I get a recording error "Firefox is already running, but is unresponsive. To open a new windos, you must fir

  • Response on Email

    Since the update to El Captain version 10.11.2 I have the following problem with emails On eilther by clicking on the button 'reply to sender' e-mail or choosing it from the menu button, I receive a blank email windowin which I can't do anything with

  • Do not result

    Search Help and reference manual but can't find where to put "Do not not Record result." Thank you JVH

  • Unable to connect to the internet (using a wired connection or wireless) after a power failure, error "the cable network is disconnected"

    After a power outage, I can not connect wireless (cannot connect even with the wired ethernet cable); get message "network cable is unplugged", which is not.  The cable modem work properly in wireless mode with two other computers.  System to an earl