MySQL supports the functions listed in this section for converting geometry values from internal geometry format to WKT or WKB format.
There are also functions to convert a string from WKT or WKB format to internal geometry format. See Section 12.17.3, “Functions That Create Geometry Values from WKT Values”, and Section 12.17.4, “Functions That Create Geometry Values from WKB Values”.
ST_AsBinary()
,ST_AsWKB()
,AsBinary()
, andAsWKB()
are synonyms. For more information, see the description ofST_AsBinary()
.ST_AsText()
,ST_AsWKT()
,AsText()
, andAsWKT()
are synonyms. For more information, see the description ofST_AsText()
.Converts a value in internal geometry format to its WKB representation and returns the binary result.
The result is
NULL
if the geometry argument isNULL
or not a syntactically well-formed geometry.SELECT ST_AsBinary(g) FROM geom;
ST_AsBinary()
,ST_AsWKB()
,AsBinary()
, andAsWKB()
are synonyms.Converts a value in internal geometry format to its WKT representation and returns the string result.
The result is
NULL
if the geometry argument isNULL
or not a syntactically well-formed geometry.mysql> SET @g = 'LineString(1 1,2 2,3 3)'; mysql> SELECT ST_AsText(ST_GeomFromText(@g)); +--------------------------------+ | ST_AsText(ST_GeomFromText(@g)) | +--------------------------------+ | LINESTRING(1 1,2 2,3 3) | +--------------------------------+
ST_AsText()
,ST_AsWKT()
,AsText()
, andAsWKT()
are synonyms.