MySQL supports the following functions for converting geometry values between internal format and either WKT or WKB format:

Converts a value in internal geometry format to its WKB representation and returns the binary result.

SELECT AsBinary(g) FROM geom;

Converts a value in internal geometry format to its WKT representation and returns the string result.

mysql>

mysql>`SET @g = 'LineString(1 1,2 2,3 3)';`

+--------------------------+ | AsText(GeomFromText(@g)) | +--------------------------+ | LINESTRING(1 1,2 2,3 3) | +--------------------------+`SELECT AsText(GeomFromText(@g));`

Converts a string value from its WKT representation to internal geometry format and returns the result. A number of type-specific functions are also supported, such as

`PointFromText()`

and`LineFromText()`

. See Section 12.14.3, “Functions That Create Geometry Values from WKT Values”.Converts a binary value from its WKB representation to internal geometry format and returns the result. A number of type-specific functions are also supported, such as

`PointFromWKB()`

and`LineFromWKB()`

. See Section 12.14.4, “Functions That Create Geometry Values from WKB Values”.