Importing data from csv file
I'm trying to import some data (using oracle sql developer) from a .csv
file b开发者_开发百科ut I'm getting an error as :-
Verifying if the Date columns have date formats FAILED Date columns
... column names
the date in my .csv
file is :
2008-01-09 15:59:23.187
I have tried giving this format but it doesn't work (in the data importing wizard)
yyyy-mm-dd HH24:mi:ss.ff3
I'm trying to figure out a solution expecting some help.
Thanks.
I can't test right now but I'm taking a guess: the format is not a DATE format but a TIMESTAMP format. Consider:
SQL> select to_date('2008-01-09 15:59:23.187',
2 'yyyy-mm-dd HH24:mi:ss.ff3') from dual;
ORA-01821: date format not recognized
SQL> select to_timestamp('2008-01-09 15:59:23.187',
2 'yyyy-mm-dd HH24:mi:ss.ff3') ts from dual;
TS
-------------------------------------------------
09/01/08 15:59:23,187000000
If this is the same error that SQL Dev encounters, you could import in a timestamp column.
Oracle Date's can only store to seconds, you will need to use the timestamp.
Using a timestamp works fine (date fails with error of "Fractional seconds format element not allowed in DATE formatting")
create table test2(cola number(1), colB varchar2(5), colD timestamp);
csv file:
colA, colB, colD
"1","a","2008-01-09 :15:59:23.187"
"2","b","2009-02-10 :16:48:32.188"
"3","c","2012-03-11 :17:37:41.189"
"Import Data" in SQL Developer 3.0.03 using colD format of yyyy-mm-dd HH24:mi:ss.ff3
select * from test2;
COLA COLB COLD
---------------------- ----- -------------------------
1 a 09-JAN-08 03.59.23.187000000 PM
2 b 10-FEB-09 04.48.32.188000000 PM
3 c 11-MAR-12 05.37.41.189000000 PM
精彩评论