column with the only format of loading time

My DB, 11 2 on OEL 5.5 GR
Hi all
I have a problem with the loading of the external table. I have a txt file with a format of columns HH24:MI:SS
START_TIME
00:10:20
01:15:11
02:11:10
And I don't know which data type use in external table because in the future, I'll have to do some calculations on this column, so I should load as a DATE, but miss me "mm/dd/yy" to the front. Any suggestion how to do properly?

You could use a data type CHAR or date for the outer table and do your math with this column correctly.

The key is that convert a time string to a date data type will add the current date to it. For example:

SQL> alter session set nls_date_format='dd/mm/yyyy hh24:mi:ss';

Session altered.

SQL> select to_date('00:10:20', 'hh24:mi:ss') from dual;

TO_DATE('00:10:20',
-------------------
01/02/2011 00:10:20

Some examples of code for both cases, by using the DATE and CHAR data type. I tested it on 11.2.0.1:

CREATE OR REPLACE DIRECTORY ext_tab_dir AS '/tmp';

-- /tmp/info.txt
1,00:10:20
2,01:15:11
3,02:11:10

alter session set nls_date_format='dd/mm/yyyy hh24:mi:ss';

(1) using the DATE data type

drop table tab_time_date;

CREATE TABLE tab_time_date (
  key VARCHAR2(5),
  start_time date)
  ORGANIZATION EXTERNAL (
     TYPE ORACLE_LOADER
     DEFAULT DIRECTORY ext_tab_dir
     ACCESS PARAMETERS
      (FIELDS TERMINATED BY ','
       (key char(5),
        start_time CHAR(8) DATE_FORMAT DATE MASK "HH24:MI:SS"
       )
      )
      LOCATION ('info.txt'));

select * from tab_time_date;

KEY   START_TIME
----- -------------------
1     01/02/2011 00:10:20
2     01/02/2011 01:15:11
3     01/02/2011 02:11:10

(2) using the CHAR data type

CREATE TABLE tab_time_char (
  key VARCHAR2(5),
  start_time char(8))
  ORGANIZATION EXTERNAL (
     TYPE ORACLE_LOADER
     DEFAULT DIRECTORY ext_tab_dir
     ACCESS PARAMETERS
      (FIELDS TERMINATED BY ','
      )
      LOCATION ('info.txt'));

select key, to_date(start_time, 'hh24:mi:ss') from tab_time_char;

KEY   TO_DATE(START_TIME,
----- -------------------
1     01/02/2011 00:10:20
2     01/02/2011 01:15:11
3     01/02/2011 02:11:10

Kind regards.

Tags: Database

Similar Questions

  • Different formats in the Excel column to the 1 format for loading into the table

    I have a situation. I have to do a SQL load into a temporary table to an Excel file but I noticed that the column that I am more interested about 4 different formats. My desired format must always be 7 characters and must only have numbers in them. This means, without hyphens or special characters or alphabets.

    I discovered that the column in Excel has about 4 or 5 different formats:

    Here's what they are supposed to be transformed into:
    42 = 0000042
    000-0257 = 0000257
    0090647 = 0090647 (format Corect)
    709782 = 0709782
    135566F1 = 0135566

    The latter case does not seem to have 2 or 3 lines here comes this Alphabet but then anything after what must be discarded. I could probably just delete the file manually (F1).

    Any ideas? Thanks in advance.

    Hello

    Raj404261 wrote:
    Sorry, not on 10g here.

    What a pity. It is so much easier using regular expressions!

    To return a copy of bad_txt with everything except the deleted numbers, and 0 concatenated to make the result 7 characters:

    ,     LPAD ( TRANSLATE ( bad_txt
                           , '0123456789' || TRANSLATE ( bad_txt
                                             , 'x0123456789'
                                       , 'x'
                                       )
                    , '0123456789'
                    )
              , 7
              , '0'
              )
    

    TRANSLATE inner removes all the numbers from bad_txt. What remains is a string that contains all the charcaters who have eliminated (as appropriate).
    TRANSLATE them externally only removes the characters of bad_txt, by translating the 10 digits to themselves and nothing else to NULL.
    LPAD provides enough information to make a 7 character string of 0.

  • help me create a column with the time format

    Hi all

    Please help me find the query to create a table with 3 columns and insert the following data

    ENTITYID | CHGDATE | CHGTIME

    ======= ==================== ========

    4214984 | 2 OCTOBER 06 12.00.00.000000 AM | 07:23:57

    4214985 | 12.00.00.000000 11-SEP-08 AM | 10:52:19

    and update of the first line of the above table as follows
    ---------------------
    4214984 | 2 OCTOBER 06 07.23.57.000000 AM | 07:23:57
    ------------------------
    you will need to update the CHGDATE column with the time of the CHGTIME column.

    Sorry, we need a new format around the to_date

    select to_date(to_char(chgdate, 'mm/dd/yyyy') || ' ' || to_char(chgtime, 'hh24:mi:ss'), 'mm/dd/yyyy hh24:mi:ss') from etime3;
    

    This should telll Oracle to the format of the generated string. If this isn't the case, run select with the to_char two as separate columns to see that get us the data that we expect.

  • Why people have suddenly begun to report their entire question in the place that is intended for a brief description of the problem.  Is there something inherently wrong with the new format of format?

    ... Only to repeat it once again here.

    Why people have suddenly begun to report their entire question in the place that is intended for a brief description of the problem.  Is there something inherently wrong with the new format of format?

    Ahhh, now I see.

    The man, who is just really, really bad design forum.

    I know that it will hurt, Adobe, but you will be away to Jive at a given time.  You're going to have to, as Jive moves further and further away from the ease of use.  So... Dick.22 now, or le.45 later.

  • Something wrong with the .png format!

    Hey everyone, anyone!

    All of you have noticed that there is a problem with the .png format? I've been on several maps now looking for an answer. Everyone does not have people like they are noobs to the whole process.

    I'm not a noob, far from it. But I can not save a transparent .png on any format.

    Here are a few facts.

    If I save it as a .png on my mac, it is not transparent, even if it shows as transparent in the document.

    I used 24 bit, I checked the Alpha channel and even made an alpha mask.

    If I drag it to my pc, it will be displayed as transparent.

    But... If I save a .png on the pc, there's always the white background on the mac.

    I have icons on folders and documents that are transparent, that I copied and pasted a few weeks previously, but these same exact files cannot be copied and pasted as transparent plus.

    I first noticed a question .png on an application that I use on a daily basis on my ipad. I thought it was just a problem of the timer with the new update system 8.

    I don't have the new Apple update system on my ipad, iMac or a Macbook Pro.

    All three of them are unable to see a transparent .png file.

    Boards are also full of people who are unable to write a transparent .png of fireworks, inkscape, gimp or photoshop!

    The forums all over the internet are full of windows pc that can't see a transparent .png file. What happened, what has changed? What is going on?

    Everyone on a track of insiders who can give an overview of this problem?

    In case anyone is wondering, I found the solution. I had a thought pop in my head (I learned to listen to those!) What happens if it's the Mac desktop, that's the question? So I put the folder in a finder window, pasted the icon and wallah! I have transparency! How wild is that? This seems like a bug of Mac for me! What do you think all?

    I thought I post a response here in case someone else has this problem! Case solved!

    See the image below...

  • [8i & 10g XE] How to compare a column with the text of a column with numbers

    This is probably a simple question, but I can't seem to find the answer. I tried variations on use to_number to_char and interpreters, all nothing will do.

    The real problem is that I have a table with a column of numbers in a database 8i (datatype = NUMBER (3)) and a column with the text (datatype = CHAR (3)), and I need to compare two values.

    This table has thousands of lines, but here's an example of the data in these two columns:
    TXT     CHR
    -----------
    001     1
    001     2
    002     2
    XXX     1
    003     3
    What I want to do is select the lines where the TXT and CHR VALUES do not match, then it would be (given my example):
    TXT     CHR
    -----------
    001     2
    XXX     1
    But, I'm having difficulties in comparing two columns, because they are not the same type of data.

    I tried to work on a simplified version of the problem in the 8i database both my 10g XE database:
    SELECT     *
    FROM     (
         SELECT     1.000               AS nbr
         ,     TO_CHAR(1.000,'000')     AS txt
         ,     CAST('001' AS CHAR(3))     AS chr
         FROM     dual
         )
    WHERE     txt = chr
    ;
    But this also returns any line, and it isn't even the "XXX" in the text column to treat in this example.

    Can someone help me understand what it is that I'm missing?

    Thank you!

    Hello

    user11033437 wrote:
    This is probably a simple question...

    Simple if you know the secret; maddening if you do not have.

    ... I tried to work on a simplified version of the problem in the 8i database both my 10g XE database:

    SELECT     *
    FROM     (
         SELECT     1.000               AS nbr
         ,     TO_CHAR(1.000,'000')     AS txt
         ,     CAST('001' AS CHAR(3))     AS chr
         FROM     dual
         )
    WHERE     txt = chr
    ;
    

    Try:

    TO_CHAR (1.000, 'FM000')
    

    By default, TO_CHAR leaves place the beginning of the string to a sign less, in which case he should ever one, TO_CHAR (1,000, '000') returns makes 4 characters, not 3. "FM" in the format said TO_CHAR do not add a space.

    If it does not, after the release of DUMP (txt) for the few lines that you can't match, so that we can see exactly what is in them.

  • An update on an index column with the same value generates an index to the top

    An update on an index column with the same value generates an update of the index?


    Thank you

    In addition to my previous answer, see also

    http://orainternals.WordPress.com/2010/11/04/does-an-update-statement-modify-the-row-if-the-update-modifies-the-column-to-same-value/

    Riyaj Shamsudeen has this to say:
    "+ We have an index on this column v1 and we update this column indexed too." Oracle was updating the indexed column? N ° if the values match the level of the indexed column, then the code of RDBMS isn't up-to-date index, a feature for optimization again. Only the row of table is updated, and the index is not updated. + "

    Hemant K Collette

  • Documentation about adding column with the DEFAULT value.

    Hello

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/statements_3001.htm#i2198241

    < quote >
    If you add a column, then the initial value of each row in the new column is NULL unless you specify the DEFAULT clause. In this case, Oracle database updates each row in the new column with the value specified for the DEFAULT value. This update operation, in turn, triggers AFTER UPDATE triggers defined on the table.
    < quote >

    I am not able to understand the emphasis on the part AFTER UPDATE while the column with DEFAULT values addition triggers both BEFORE and AFTER triggers defined on UPDATE.

    According to the documents of 11 g

    http://download.Oracle.com/docs/CD/B28359_01/server.111/b28286/statements_3001.htm#i2133105

    n.m. (u) r only changes with the NON NULL columns, but focus on AFTER UPDATE is still there. No trigger defined on the fire of the update in this case.

    This insistence is intended? If not, IMO, it should be changed.

    Kind regards

    Hi Sissi. After further discussion, we have added some information about a change in behavior. Here is what says the next version of the doc:

    When you add a column, the initial value of each row in the new column is null.

    * If you specify the DEFAULT clause for a column NOT NULL, then the default value is stored as metadata, but the column itself is not populated with data. However, the following queries that specify the new column are rewritten so that the default value is returned in the result set.

    This optimized behavior differs from earlier versions, when as part of operation ALTER TABLE Oracle database updated every line in the newly created with the default column and then fired defined update triggers on the table. In this release, no trigger is triggered because the default value is stored only in the form of metadata.

    * If you specify the DEFAULT for a nullable column clause, then the default value is added to existing lines under this ALTER TABLE statement, and any update triggers defined on the table are activated. This behavior also means if you change a NOT NULL column with a default value to be nullable.

    Hope that helps to clarify the matter further.

    Kind regards
    Diana

  • I have a column with two values, separated by a space, in each line. How to create 2 new columns with the first value in a column, and the second value in another column?

    I have a column with two values, separated by a space, in each line. How do I create 2 new columns with the first value in one column and the second value in another column?

    Add two new columns after than the original with space separated values column.

    Select cell B1 and type (or copy and paste it here) the formula:

    = IF (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')

    shortcut for this is:

    B1 = if (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')

    C1 = if (Len (a1) > 0, Member SUBSTITUTE (A1, B1 & "", ""), "")

    or

    the formula of the C1 could also be:

    = IF (Len (a1) > 0, RIGHT (A1, LEN (A1) −FIND ("", A1)), "")

    Select cells B1 and C1, copy

    Select cells B1 at the end of the C column, paste

  • How to take a column of duplicate names and fill a different column with the same names, excluding duplicates?

    How to take a column of duplicate names and fill a different column with the same names, excluding duplicates?

    I find easier to use this copy separate Automator Service (download Dropbox).

    To install in your numbers > Services, double-click menu just the package downloaded .workflow and if necessary give permissions in system preferences > security & privacy.

    To use, just:

    1. Select the cells in the column with duplicate names.
    2. Choose separate copy in numbers > Services menu.
    3. Click once in the upper cell where you want the deduplicated values appear.
    4. Command-v to paste.

    SG

  • Querying the oracle table that has a column with the name of "FILE".

    Hi all

    I need to have an oracle table that has the column with the name "FILE".

    I can query all columns with the query "select * from table".

    But I'm not able to use the query "select the table file.

    This table is converted from ms access to oracle and I need to have this column with the name "FILE".

    Any suggestions?

    Thank you

    Abdellaoui

    Hello

    FILE is a keyword from Oracle, so it's not a good name,

    Use FILEDATE, or DATE_FILED, or something else that is not in V$ RESERVED_WORDS. KEYWORD as the name column.

    If you need to use the FILE, then you must use quotation marks.

  • I want to convert my video files in FLV format as im eager to export the video in flash, this seems to be the only format that it will accept. Media Encoder is more to this format, how can I get around this?

    I want to convert my video files in FLV format as im eager to export the video in flash, this seems to be the only format that it will accept. Media Encoder is more to this format, how can I get around this?

    I could be wrong, but in my research for this issue, I learned that there is no solution from Adobe to convert an F4V or a FLV. I talked to Adobe support directly and they told me to buy a 3rd party conversion program. I find absolutely stupid that the only way to embed a video in Animate using a FLV or F4V, and there is no codec to convert video in this format.

  • I work in psd, I want to send an email to pdf, with the pixel format, how can I do?

    I work in psd, I want to send an email to pdf, with the pixel format, how can I do?

    I work in psd, I want to send an email to pdf, with the pixel format, how can I do?

  • java.sql.SQLException: problems with the native/lack of loading methods library

    Hi all

    Please let me know how to fix the exception "java.sql.SQLException: problems with the native/lack of loading methods library: no ttJdbc in java.library.path".

    Thank you
    Prabhu

    Published by: Nina Prabhu on November 20, 2012 02:12

    Hi Prabhu,

    Probably, you must specify the LD_LIBRARY_PATH variable. Like the following:

    export LD_LIBRARY_PATH=$TIMESTEN_HOME/ttoracle_home/instantclient_11_1
    

    Best regards
    Gennady

  • Columns with the same name but different data or precision length.

    DB version: 10 gr 2

    In a diagram, I need to find all of the columns with the same name but different or precision data length (if the column is of type number). I know I have to use the USER_TAB_COLS view for this. But I need to find a logic to compare the names of columns and its lengths.

    something like

    select t1.table_name
         , t1.column_name
         , t1.data_type
         , t1.data_length
         , t2.table_name
         , t2.column_name
         , t2.data_type
         , t2.data_length
      from user_tab_columns t1
         , user_tab_columns t2
     where t1.table_name != t2.table_name
       and t1.column_name = t2.column_name
       and t1.data_type = t2.data_type
       and t1.data_length != t2.data_length
    

    ... could be a starting point.

Maybe you are looking for