Search code examples
sqloracledateoracle-sqldevelopersql-insert

Inserting a TIMESTAMP value in SQL Developer


Hello I'm having a trouble inserting this value in Oracle SQL Developer Version 19.4.0.354.

'2013-01-01 00:00:00.0000'

Here is the value that I want to insert in one of my tables.

I tried DATE and TIMESTAMP data types but they don't work. I also tried altering the sessions and other possible solutions all over the internet.


Solution

  • Column datatype should be TIMESTAMP. Use appropriate format mask in TO_TIMESTAMP function.

    SQL> create table test (col timestamp);
    
    Table created.
    
    SQL> insert into test (col) values (to_timestamp('2013-01-01 00:00:00.0000', 'yyyy-mm-dd hh24:mi:ss:ff6'));
    
    1 row created.
    

    What's in there? (alter session is here just to display the result in desired format; it doesn't affect the value stored in that column):

    SQL> alter session set nls_timestamp_format = 'dd.mm.yyyy hh24:mi:ss.ff6';
    
    Session altered.
    
    SQL> select * From test;
    
    COL
    ---------------------------------------------------------------------------
    01.01.2013 00:00:00.000000
    
    SQL>