Function that checks whether two geometries are identical

You can use the ST_Equals comparison function to check whether two geometries are identical.

ST_Equals

Use ST_Equals to determine if two geometries are identical.

ST_Equals returns a value of 1 (one) if two geometries are identical. The order of the points used to define the geometries is not relevant to the test of equality.
Figure 1. ST_Equals. The dark geometries represent geometry a; the gray geometries represent geometry b. In all cases, geometry a is equal to geometry b.

In the six examples (point, multipoint, linestring, multistring, polygon, and multipolygon) geometry a and geometry b are the same.

Begin figure description. All of the examples show that the first geometry is the same as the second geometry. End figure description.
Table 1. Matrix for equality. The DE-9IM pattern matrix for equality ensures that the interiors intersect and that no part interior or boundary of either geometry intersects the exterior of the other.
 

Geometry b Interior

Geometry b Boundary

Geometry b Exterior

Geometry a Boundary

*

*

F

Geometry a Interior

T

*

F

Geometry a Exterior

F

F

*