ST_GeometryType

ST_GeometryType takes a geometry as the input parameter and returns the fully qualified type name of the dynamic type of that geometry.

Syntax

Read syntax diagramSkip visual syntax diagramdb2gse.ST_GeometryType(geometry)

Parameter

geometry
A value of one of the seven distinct spatial data types for which the geometry type is to be returned.

Return type

CHAR(32)

Examples

The following code illustrates how to determine the type of a geometry.

SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse 

CREATE TABLE sample_geometries (id INTEGER, geometry ST_GEOMETRY)

INSERT INTO sample_geometries(id, geometry)
VALUES
    (7101, ST_Geometry('point(1 2)', 1) ),
    (7102, ST_Geometry('linestring(33 2, 34 3, 35 6)', 1) ),
    (7103, ST_Geometry('polygon((3 3, 4 6, 5 3, 3 3))', 1)),
    (7104, ST_Geometry('multipoint(1 2, 4 3)', 1) )

SELECT id, geometry..ST_GeometryType AS geometry_type
FROM   sample_geometries

Results:

ID          GEOMETRY_TYPE
----------- -------------------------------
       7101 DB2GSE.ST_POINT
       7102 DB2GSE.ST_LINESTRING
       7103 DB2GSE.ST_POLYGON
       7104 DB2GSE.ST_MULTIPOINT