问题描述
在PostgreSQL范围类型中无穷大是什么意思?将 infinity
或 -infinity
作为界限,或 NULL
?即是 infinity
的显式形式,它指定范围界限是无限的,而 NULL
会隐式指定一个无限范围界限?
What is the meaning of 'infinity' in PostgreSQL range types? Is there any difference between specifying infinity
or -infinity
as a bound, or NULL
? I.e. is infinity
an explicit form of specifying that the range bound is infinite, whereas NULL
would implicit specify an infinite bound range?
请参见以下示例:
SELECT tstzrange('-infinity','infinity') && tstzrange(NULL, NULL);
?column?
----------
t
SELECT tstzrange('2013-01-01 00:00:00+01', '2013-02-01 00:00:00+01')
&& tstzrange(NULL, '2013-03-01 00:00:00+01');
?column?
----------
t
SELECT tstzrange('2013-01-01 00:00:00+01', '2013-02-01 00:00:00+01')
&& tstzrange('-infinity', '2013-03-01 00:00:00+01');
?column?
----------
t
推荐答案
NULL
对于为 -infinity
或 infinity
。我在此处引用:
NULL
does the same thing for the overlap operator &&
as -infinity
or infinity
, respectively. I quote the manual here:
但是作为 value , NULL
仍然不同于'infinity'
!
But as value, NULL
is still distinct from 'infinity'
!
SELECT tstzrange('-infinity','infinity') = tstzrange(NULL, NULL);
返回 FALSE
(不是 NULL
,请注意!)。
Returns FALSE
(not NULL
, mind you!).
此。
这篇关于PostgreSQL范围类型中的NULL与`infinity`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!