SQL 将数据插入到Oracle 中的timestamp(6) 类型字段的语法是什么
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/204549/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the syntax for inserting data into a timestamp(6) type field in Oracle
提问by Scottm
I need to insert some data into a table in Oracle.
我需要将一些数据插入到 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.
唯一的问题是其中一个字段是时间戳(6)类型,并且它是必需的数据。我不关心这里实际发生了什么,我只需要为条目获取正确的语法,以便数据库接受它。
I'm using the gui web client to enter data however I don't mind using raw SQL if I have to.
我正在使用 gui Web 客户端输入数据,但是如果必须的话,我不介意使用原始 SQL。
Thanks.
谢谢。
回答by Mike Woodhouse
I dunno if this helps at all, but in SQL*Plus I did this:
我不知道这是否有帮助,但在 SQL*Plus 中我这样做了:
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:
如果您需要将先前已知的值放入列中,那么 TO_TIMESTAMP() 函数如何?像这样的东西:
select to_timestamp('27/02/2002 15:51.12.539880', 'dd/mm/yyyy hh24:mi.ss.ff')
from dual ;
回答by Benedikt Waldvogel
using to_timestamp()
is one option.
the other is doing this:
使用to_timestamp()
是一种选择。另一个正在这样做:
INSERT INTO table VALUES (timestamp'2009-09-09 09:30:25 CET');
回答by Cale Sweeney
Here are a couple of different TO_TIMESTAMP functions that worked for me...
这里有几个不同的 TO_TIMESTAMP 函数对我有用......
This TO_TIMESTAMP function worked on an INSERT against a column of type TIMESTAMP(6):
此 TO_TIMESTAMP 函数对 TIMESTAMP(6) 类型的列执行 INSERT:
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 函数对 DATE 类型的列执行 INSERT:
TO_TIMESTAMP('04/15/2015','mm/dd/yyyy')
回答by Piyush Sahay
insert into x values(to_timestamp('22:20:00','hh24:mi'));