1. 程式人生 > 其它 >8.17.2. Examples

8.17.2. Examples

技術標籤:PostgreSQL 13.0 Documentationpostgresql

8.17.2. Examples

8.17.2.示例

CREATE TABLE reservation (room int, during tsrange);

INSERT INTO reservation VALUES

(1108, '[2010-01-01 14:30, 2010-01-01 15:30)');

-- Containment

SELECT int4range(10, 20) @> 3;

-- Overlaps

SELECT numrange(11.1, 22.2) && numrange(20.0, 30.0);

-- Extract the upper bound

SELECT upper(int8range(15, 25));

-- Compute the intersection

SELECT int4range(10, 20) * int4range(15, 25);

-- Is the range empty?

SELECT isempty(numrange(1, 5));

See Table 9.50 and Table 9.51 for complete lists of operators and functions on range types.

範圍型別可用操作符和函式,請參見表9.53和9.54