Returns the geometry value that represents the point set difference of two geometries.
SELECT NEW ST_Polygon( 'Polygon( (-1 -0.25, 1 -0.25, 1 2.25, -1 2.25, -1 -0.25) )' ) AS A , NEW ST_CurvePolygon( 'CurvePolygon( CircularString( 0 1, 1 2, 2 1, 1 0, 0 1 ) )' ) AS B , A.ST_Difference( B ) AS C , B.ST_Difference( A ) AS D
The following picture shows the difference C=A-B and D=B-A as the shaded portion of the picture. Each difference is a single surface that contains all of the points that are in the geometry on the left hand side of the difference and not in the geometry on the right hand side. Union of a square and a circle
SQL/MM (ISO/IEC 13249-3: 2006) 5.1.20