[20261106]ANSI DATE and TIMESTAMP SQL syntax.txt
--//更正自己以前的一些错误认知,以为timestamp不支持秒后面的数字,实际上支持的,看如下例子:
--//补充说明:date仅仅支持年月日,timestamp不能没有时分秒。
--//以前链接:[20230207]ANSI DATE and TIMESTAMP SQL syntax.txt
SCOTT@book01p> select count(*) from dba_objects where created > timestamp'2012-01-01 08:12:34.00001';
COUNT(*)
----------
75211
SCOTT@book01p> select count(*) from dba_objects where created > timestamp'2012-01-01 08:12:34';
COUNT(*)
----------
75211
SCOTT@book01p> select count(*) from dba_objects where created > timestamp'2012-01-01';
select count(*) from dba_objects where created > timestamp'2012-01-01'
*
ERROR at line 1:
ORA-01861: literal does not match format string
--//反倒不支持date格式。
SCOTT@book01p> select count(*) from dba_objects where created > timestamp'2012-01-01 08:12:34.1234567891';
select count(*) from dba_objects where created > timestamp'2012-01-01 08:12:34.1234567891'
*
ERROR at line 1:
ORA-01873: the leading precision of the interval is too small
SCOTT@book01p> select count(*) from dba_objects where created > timestamp'2012-01-01 08:12:34.123456789';
COUNT(*)
----------
75211
--//最多9位小数。
SCOTT@book01p> select count(*) from dba_objects where created > timestamp'2012/01/01 08:12:34.123456789';
select count(*) from dba_objects where created > timestamp'2012/01/01 08:12:34.123456789'
*
ERROR at line 1:
ORA-01861: literal does not match format string
--//不支持/分割。
SCOTT@book01p> select count(*) from dba_objects where created > timestamp'2012 - 01 -01 08 : 12 : 34.123456789';
COUNT(*)
----------
75211
--//中间存在空格没问题。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-3188150/ ,如需转载,请注明出处,否则将追究法律责任。