您需要指定零小数秒。这是你的错误:
SQL> create table mytab (dt timestamp(0));
Table created.
SQL> Insert into mytab
(dt)
Values
(TO_TIMESTAMP('16/JUL/13 2:53:08. PM','DD/MON/YY fmHH12fm:MI:SS.FF AM')); 2 3 4
(TO_TIMESTAMP('16/JUL/13 2:53:08. PM','DD/MON/YY fmHH12fm:MI:SS.FF AM'))
*
ERROR at line 4:
ORA-01858: a non-numeric character was found where a numeric was expected
SQL>
让我们修复输入
SQL> ed
Wrote file afiedt.buf
1 Insert into mytab
2 (dt)
3 Values
4* (TO_TIMESTAMP('16/JUL/13 2:53:08.00 PM','DD/MON/YY fmHH12fm:MI:SS.FF AM'))
SQL> r
1 Insert into mytab
2 (dt)
3 Values
4* (TO_TIMESTAMP('16/JUL/13 2:53:08.00 PM','DD/MON/YY fmHH12fm:MI:SS.FF AM'))
1 row created.
SQL>
因此,即使您指定了一个精度为零的时间戳,您的输入仍然需要与掩码匹配。这意味着您需要.00
匹配.FF
.
或者,根本不要费心包括小数秒:
SQL> ed
Wrote file afiedt.buf
1 insert into mytab
2 (dt)
3 Values
4* (TO_TIMESTAMP('16/JUL/13 2:53:08 PM','DD/MON/YY fmHH12fm:MI:SS AM'))
SQL> r
1 insert into mytab
2 (dt)
3 Values
4* (TO_TIMESTAMP('16/JUL/13 2:53:08 PM','DD/MON/YY fmHH12fm:MI:SS AM'))
1 row created.
SQL>
顺便说一句,请注意 TIMESTAMP(0) 将四舍五入任何小数秒,在半秒处四舍五入。这是否重要取决于您将如何填充列以及时间需要有多准确。