简体   繁体   English

在Oracle时间戳列中插入时间戳

[英]Inserting timestamp in oracle timestamp column

I am trying to insert the timestamp(6) data type value into the table by using following code: 我试图通过使用以下代码将timestamp(6)数据类型值插入表中:

INSERT INTO TOY_STORE (TOY_STORE_ID,TOY_STORE_NAME,CITY,PHONENUMBER,STORE_OPENING_TIME,STORE_CLOSING_TIME)
    VALUES(1,'Kid''s Cave','Delhi',9912312312,'2014-04-01 09:10:12','2014-04-01 21:42:05');

But it is giving be error SQL Error: ORA-01843: not a valid month 01843. 00000 - "not a valid month" *Cause: 但是它给出了错误SQL错误:ORA-01843:无效的月份01843。00000-“无效的月份” *原因:
*Action: Can someone rectify my code *操作:有人可以纠正我的代码吗

Oracle has a non-standard format for date. Oracle具有非标准的日期格式。 You can use that format (DD/MMM/YYYY), use the to_date() function, or the DATE / TIMESTAMP operator. 您可以使用该格式(DD / MMM / YYYY),使用to_date()函数或DATE / TIMESTAMP运算符。 I think this will work: 我认为这会起作用:

INSERT INTO TOY_STORE (TOY_STORE_ID,T OY_STORE_NAME, CITY,PHONENUMBER, 
                       STORE_OPENING_TIME, STORE_CLOSING_TIME)
    VALUES(1, 'Kid''s Cave',' Delhi', 9912312312,
           TIMESTAMP '2014-04-01 09:10:12', TIMESTAMP '2014-04-01 21:42:05');

您也可以在插入之前执行以下命令:

ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'yyyy-mm-dd hh24:mi:ss';

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

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