How to insert a timestamp in Oracle?

Mike Rifgin picture Mike Rifgin · Mar 24, 2011 · Viewed 410.9k times · Source

I have an Oracle DB with a timestamp field in it. What is the correct SQL code to insert a timestamp into this field?

Answer

reggie picture reggie · Mar 24, 2011
insert
into tablename (timestamp_value)
values (TO_TIMESTAMP(:ts_val, 'YYYY-MM-DD HH24:MI:SS'));

if you want the current time stamp to be inserted then:

insert
into tablename (timestamp_value)
values (CURRENT_TIMESTAMP);