简体   繁体   English

TIMESTAMP(0)WITH TIME ZONE数据类型的Oracle示例值

[英]Oracle example value for TIMESTAMP(0) WITH TIME ZONE datatype

Hi how will be example value for the column with datatype of TIMESTAMP ? 嗨,数据类型为TIMESTAMP的列的示例值将如何?

Need some insert operation for it. 需要一些插入操作。 createdTime is datatype of TIMESTAMP(0) WITH TIME ZONE createdTimeTIMESTAMP(0) WITH TIME ZONE数据类型

INSERT INTO table1 values(<id>, <firstName>, <createdTime>);

When I try like the following 当我尝试如下

INSERT INTO table1 values(1, "John", TIMESTAMP '06-APR-14 06.00.42.000000000 PM ASIA/SINGAPORE');

gives the SQL error; 给出SQL错误;

SQL Error: ORA-01843: not a valid month
01843. 00000 -  "not a valid month"

If you're using a timestamp literal you have to use a specific format: 如果使用时间戳文字 ,则必须使用特定格式:

INSERT INTO table1 values(1, 'John',
  TIMESTAMP '2014-04-06 18:00:42.0 ASIA/SINGAPORE');

You can be more flexible with a to_timestamp_tz function call: 使用to_timestamp_tz函数调用可以更加灵活:

INSERT INTO table1 values(2, 'John',
  TO_TIMESTAMP_TZ ('06-APR-14 06.00.42 PM ASIA/SINGAPORE', 
    'DD-MON-RR HH:MI:SS AM TZR'));

SQL Fiddle demo . SQL Fiddle演示

I've omitted the FF format element since you don't want fractional seconds. 我已经省略了FF格式元素,因为您不需要小数秒。

I've also changed the double quotes around John to single quotes, to stop it being interpreted as an identifier. 我还将John周围的双引号更改为单引号,以防止将其解释为标识符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM