PostgreSQL isempty() Function

The PostgreSQL isempty() function checks if a given range or multirange value is empty.

PostgreSQL isempty() Syntax

Here is the syntax of the PostgreSQL isempty() function:

isempty(anyrange) -> boolean
isempty(anymultirange) -> boolean

Parameters

anyrange

Required. A range value.

anymultirange

Required. A multirange value.

Return value

The PostgreSQL isempty() function returns a boolean value true or false indicating if the given range or multirange value is empty.

PostgreSQL isempty() Examples

Here are some examples of the PostgreSQL isempty() function.

To check if the range (1, 1) is empty, use the following statement:

SELECT isempty('(1, 1)'::int4range);
 isempty
---------
 t

Since the range (1, 1) does not contain any values, the function calling isempty('(1, 1)'::int4range) returned t, indicating that (1, 1) is an empty range.

To check if the range (1, 2] is empty, use the following statement:

SELECT isempty('(1, 2]'::int4range);
 isempty
---------
 f

The function calling isempty('(1, 1)'::int4range) returned because f the range (1, 2] is not empty .