I need to insert some data into a table in Oracle.
The only problem is one of the fields is a timestamp(6) type and it is required data. I don't care about what actually goes in here I just need to get the right syntax for an entry so that the database will accept it.
I'm using the gui web client to enter data however I don't mind using raw SQL if I have to.
Thanks.
I dunno if this helps at all, but in SQL*Plus I did this:
create table x ( a timestamp(6));
insert into x values ( current_timestamp );
select * from x;
getting me this:
T
---------------------------------------------------------------------------
15-OCT-08 02.01.25.604309 PM
So it looks like that works.
If you need to put a previously-known value into the column, how about the TO_TIMESTAMP() function? Something like this:
select to_timestamp('27/02/2002 15:51.12.539880', 'dd/mm/yyyy hh24:mi.ss.ff')
from dual ;
using to_timestamp()
is one option. the other is doing this:
INSERT INTO table VALUES (timestamp'2009-09-09 09:30:25 CET');
Here are a couple of different TO_TIMESTAMP functions that worked for me...
This TO_TIMESTAMP function worked on an INSERT against a column of type TIMESTAMP(6):
TO_TIMESTAMP('04/14/2015 2:25:55','mm/dd/yyyy hh24:mi.ss.ff')
This TO_TIMESTAMP function worked on an INSERT against a column of type DATE:
TO_TIMESTAMP('04/15/2015','mm/dd/yyyy')
insert into x values(to_timestamp('22:20:00','hh24:mi'));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.