The ST_WKTToSQL() function

The ST_WKTToSQL() function constructs an ST_Geometry given its well-known text representation. The SRID of the ST_Geometry is 0.

Syntax

ST_WKTToSQL (WKT lvarchar)

Return type

ST_Geometry

Example

The following CREATE TABLE statement creates the geometry_test table, which contains two columns: gid, of type INTEGER, which uniquely identifies each row, and the g1 column, which stores the geometry:
CREATE TABLE geometry_test (gid integer,
                            g1  ST_Geometry);
The following INSERT statements insert the data into the gid and g1 columns of the geometry_test table. The ST_WKTToSQL() function converts the text representation of each geometry into its corresponding instantiable subclass:
INSERT INTO geometry_test VALUES(
   1,
   ST_WKTToSQL('point (10.02 20.01)')
);

INSERT INTO geometry_test VALUES(
   2,
   ST_WKTToSQL('linestring (10.02 20.01,10.01 30.01,10.01 40.01)')
);

INSERT INTO geometry_test VALUES(
   3,
   ST_WKTToSQL('polygon ((10.02 20.01,11.92 35.64,25.02
34.15,19.15 33.94,10.02 20.01))')
);

INSERT INTO geometry_test VALUES(
   4,
   ST_WKTToSQL('multipoint (10.02 20.01,10.32 23.98,11.92 35.64)')
);

INSERT INTO geometry_test VALUES(
   5,
   ST_WKTToSQL('multilinestring ((10.02 20.01,10.32 23.98,11.92
25.64),(9.55 23.75,15.36 30.11))')
);

INSERT INTO geometry_test VALUES(
   6,
   ST_WKTToSQL('multipolygon (((10.02 20.01,11.92 35.64,25.02 
34.15,19.15 33.94,10.02 20.01)),((51.71 21.73,73.36 27.04,71.52
32.87,52.43 31.90,51.71 21.73)))')
);