OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.2.1

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & CertificationTicket
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.2.1
    iconOceanBase Database
    SQL - V 4.2.1
    Databases
    • OceanBase Database
    • OceanBase Cloud
    • OceanBase Tugraph
    • Interactive Tutorials
    • OceanBase Best Practices
    Tools
    • OceanBase Cloud Platform
    • OceanBase Migration Service
    • OceanBase Developer Center
    • OceanBase Migration Assessment
    • OceanBase Admin Tool
    • OceanBase Loader and Dumper
    • OceanBase Deployer
    • Kubernetes operator for OceanBase
    • OceanBase Diagnostic Tool
    • OceanBase Binlog Service
    Connectors and Middleware
    • OceanBase Database Proxy
    • Embedded SQL in C for OceanBase
    • OceanBase Call Interface
    • OceanBase Connector/C
    • OceanBase Connector/J
    • OceanBase Connector/ODBC
    • OceanBase Connector/NET
    SQL
    KV
    • V 4.6.0
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    Functions that create geometry values

    Last Updated:2026-04-28 09:23:26  Updated
    Share
    What is on this page
    ST_GeomFromText and ST_GeometryFromText
    ST_GeomFromWKB and ST_GeometryFromWKB
    Considerations for parameters

    folded

    Share

    You can use functions in this topic to create a geometry object from a well-known text (WKT) representation or a well-known binary (WKB) representation of an input geometry. OceanBase Database supports the following functions that create geometry values in the current version: ST_GeomFromText(), ST_GeometryFromText(), ST_GeomFromWKB(), and ST_GeometryFromWKB().

    ST_GeomFromText and ST_GeometryFromText

    The ST_GeomFromText() and ST_GeometryFromText() functions take the WKT representation and optional spatial reference system identifiers (SRIDs) as arguments and return the corresponding geometry objects. For more information about the WKT format, see Spatial data formats.

    The ST_GeomFromText() function accepts a WKT value of any geometry type as its first argument. Other functions provide type-specific constructors for constructing geometry values for each geometry type. The syntaxes of the functions are as follows:

    ST_GeomFromText(wkt [, srid [, options]]), ST_GeometryFromText(wkt [, srid [, options]])
    

    Here is an example:

    obclient [test]> SET @geo = "MULTILINESTRING((10 10, 11 11), (9 9, 10 10))";
    Query OK, 0 rows affected
    
    obclient [test]> SELECT ST_AsText(ST_GeomFromText(@geo));
    +--------------------------------------------+
    | ST_AsText(ST_GeomFromText(@geo))           |
    +--------------------------------------------+
    | MULTILINESTRING((10 10,11 11),(9 9,10 10)) |
    +--------------------------------------------+
    1 row in set
    

    ST_GeomFromWKB and ST_GeometryFromWKB

    The ST_GeomFromWKB() and ST_GeometryFromWKB() take, as arguments, BLOBs that contain WKB representations and optional SRIDs, and return the corresponding geometry objects. For more information about the WKB format, see Spatial data formats.

    The syntaxes of the functions are as follows:

    ST_GeomFromWKB(wkb [, srid [, options]]), ST_GeometryFromWKB(wkb [, srid [, options]])
    

    Considerations for parameters

    The return value for a geometry argument in a function that creates geometry values is not NULL, except in the following cases:

    • If any geometry argument is NULL or is in an incorrect syntactic format, the return value is NULL.

    • The optional options argument enables the latitude and longitude of the geographic coordinates to be resolved in the order specified by the spatial reference system (SRS) of the geometry argument. options consists of a comma-separated list of key=value pairs. key can only be set to axis-order, and value can be lat-long, long-lat, or srid-defined (default). If options is NULL, the return value is NULL. If the options argument is invalid, an error is reported.

    • If the SRID argument references an undefined SRS, the ER_SRS_NOT_FOUND error occurs.

    • For geographic SRS geometry arguments, if the longitude or latitude of any argument exceeds the valid range in degrees or in other units used by the SRS, an error is reported.

      • If the longitude value is not within the range of (-180, 180], the ER_LONGITUDE_OUT_OF_RANGE error occurs.

      • If the latitude value is not within the range of [−90, 90], the ER_LATITUDE_OUT_OF_RANGE error occurs.

    Previous topic

    JSON_OBJECTAGG
    Last

    Next topic

    Spatial operation functions
    Next
    What is on this page
    ST_GeomFromText and ST_GeometryFromText
    ST_GeomFromWKB and ST_GeometryFromWKB
    Considerations for parameters