PostgreSQL box(point,point) Function
The PostgreSQL box(point,point)
function converts any two points into a box and returns it.
A rectangle box
is represented by a point in the upper right corner and a point in the lower left corner, for example: (1,1),(0,0)
.
box(point,point)
Syntax
This is the syntax of the PostgreSQL box(point,point)
function:
box(point1,point2) -> box
Parameters
point1
-
Required. A point. For example:
point '(1,1)'
. point2
-
Required. Another point. For example:
point '(2,2)'
.
Return value
The PostgreSQL box(point,point)
function returns a rectangle represented by any two specified points.
box(point,point)
Examples
The following statement shows how to use the PostgreSQL box(point,point)
function to return a rectangle represented by any two specified points.
SELECT box(point '(1,1)', point '(2,2)');
box
-------------
(2,2),(1,1)
You can also change to any other two points, such as:
SELECT box(point '(1,0)', point '(0,1)');
box
-------------
(1,1),(0,0)
This function is equivalent to the box(point)
function if the two points are the same, for example:
SELECT
box(point '(1,1)', point '(1,1)'),
box(point '(1,1)');
box | box
-------------+-------------
(1,1),(1,1) | (1,1),(1,1)