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.4.2

    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.4.2
    iconOceanBase Database
    SQL - V 4.4.2
    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

    Geometry property functions

    Last Updated:2026-04-02 06:23:57  Updated
    Share
    What is on this page
    ST_Area
    ST_SRID
    ST_Latitude
    ST_Longitude
    ST_X
    ST_Y
    Considerations

    folded

    Share

    A geometry property function is used to access qualitative or quantitative properties of a geometry object. OceanBase Database supports the following geometry property functions in the current version: ST_Area(), ST_SRID(), ST_Latitude(), ST_Longitude(), ST_X(), and ST_Y().

    You can use the ST_X() and ST_Y() functions to get the X and Y coordinates of a point, respectively. For Point objects that have a geographic spatial reference system (SRS), you can use the ST_Longitude() and ST_Latitude() functions to get the longitude and latitude, respectively.

    ST_Area

    ST_Area() returns the area of a Polygon or MultiPolygon object in a spatial coordinate system. This function does not support other types of spatial objects. The syntax is as follows:

    ST_Area({poly|mpoly})
    

    Here is an example:

    obclient> SELECT ST_Area(ST_GEOMFROMTEXT('POLYGON((0 0, 0 1, 1 1, 0 0))'));
    +-----------------------------------------------------------+
    | ST_Area(ST_GEOMFROMTEXT('POLYGON((0 0, 0 1, 1 1, 0 0))')) |
    +-----------------------------------------------------------+
    |                                                       0.5 |
    +-----------------------------------------------------------+
    1 row in set
    

    The ST_Area() function cannot return the area of a 0-dimensional spatial object (point) or a 1-dimensional spatial object (line).

    obclient> SELECT ST_Area(ST_GEOMFROMTEXT('LINESTRING(0 0, 0 1)'));
    ERROR 3516 (22S01): POLYGON/MULTIPOLYGON value is a geometry of unexpected type LINESTRING in st_area.
    

    For a MultiPolygon object, the ST_Area() function returns the sum of the areas of the polygons in the collection.

    obclient> SELECT ST_Area(ST_GEOMFROMTEXT('MultiPolygon(((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1)))'));
    +-----------------------------------------------------------------------------------------+
    | st_area(ST_GEOMFROMTEXT('MultiPolygon(((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1)))')) |
    +-----------------------------------------------------------------------------------------+
    |                                                                                       8 |
    +-----------------------------------------------------------------------------------------+
    1 row in set
    

    ST_SRID

    ST_SRID() returns an integer to indicate the ID of the SRS associated with g. The syntax is as follows:

    ST_SRID(g [, srid])
    

    The optional srid argument represents a valid SRID value. The ST_SRID() function returns a value that is of the same type as its first argument and with the SRID value specified in the second argument. This function only sets the SRID value of the object and does not convert coordinate values. For a single argument, the ST_SRID() function returns the geometry SRID. Even if the function references an undefined SRS, the ER_SRS_NOT_FOUND error will not occur.

    The differences between ST_SRID(g, target_srid) and ST_Transform(g, target_srid) are as follows:

    • ST_SRID() changes the geometry SRID value without transforming its coordinates.

    • ST_Transform() not only changes the SRID value, but also transforms its geometry coordinates.

    obclient [test]> SET @geo = ST_GeomFromText('LineString(1 1,2 2)', 0);
    Query OK, 0 rows affected
    
    obclient [test]> SELECT ST_SRID(@geo);
    +---------------+
    | ST_SRID(@geo) |
    +---------------+
    |             0 |
    +---------------+
    1 row in set
    
    obclient [test]> SET @geo = ST_SRID(@geo, 4230);
    Query OK, 0 rows affected
    
    obclient [test]> SELECT ST_SRID(@geo);
    +---------------+
    | ST_SRID(@geo) |
    +---------------+
    |          4230 |
    +---------------+
    1 row in set
    

    ST_Latitude

    ST_Latitude() returns a double-precision number of the latitude value of a valid Point object p with a geographic SRS. The syntax is as follows:

    ST_Latitude(p [, new_latitude_val])
    

    The argument new_latitude_val is optional and indicates a valid latitude value. If this argument is used, the ST_Latitude() function returns a Point object whose latitude is equal to the value of the second argument.

    If the Point object is valid but does not have a geographic SRS, the ER_SRS_NOT_GEOGRAPHIC error is returned.

    obclient [test]> SET @pit = ST_GeomFromText('POINT(45 90)', 4326);
    Query OK, 0 rows affected
    
    obclient [test]> SELECT ST_Latitude(@pit);
    +-------------------+
    | ST_Latitude(@pit) |
    +-------------------+
    |                45 |
    +-------------------+
    1 row in set
    
    obclient [test]> SELECT ST_AsText(ST_Latitude(@pit, 30));
    +----------------------------------+
    | ST_AsText(ST_Latitude(@pit, 30)) |
    +----------------------------------+
    | POINT(30 90)                     |
    +----------------------------------+
    1 row in set
    

    ST_Longitude

    ST_Longitude() returns a double-precision number of the longitude value of a valid Point object p with a geographic SRS. The syntax is as follows:

    ST_Longitude(p [, new_longitude_val])
    

    The argument new_longitude_val is optional and indicates a valid longitude value. If this argument is used, the ST_Longitude() function returns a Point object whose longitude is equal to the value of the second argument. If the Point object is valid but does not have a geographic SRS, the ER_SRS_NOT_GEOGRAPHIC error is returned.

    obclient [test]> SET @pit = ST_GeomFromText('POINT(45 90)', 4326);
    Query OK, 0 rows affected
    
    obclient [test]> SELECT ST_Longitude(@pit);
    +--------------------+
    | ST_Longitude(@pit) |
    +--------------------+
    |                 90 |
    +--------------------+
    1 row in set
    
    obclient [test]> SELECT ST_AsText(ST_Longitude(@pit, 30));
    +-----------------------------------+
    | ST_AsText(ST_Longitude(@pit, 30)) |
    +-----------------------------------+
    | POINT(45 30)                      |
    +-----------------------------------+
    1 row in set
    

    ST_X

    ST_X() returns the double-precision number of the X coordinate value for a valid point project p. The X coordinate is considered the first axis defined in a point SRS. The syntax is as follows:

    ST_X(p [, new_x_val])
    

    The argument new_x_val is optional. If this argument is used, the ST_X() function returns a Point object whose X coordinate is equal to the value of the second argument. If the Point object has a geographic SRS, the second argument must be within the valid range of longitude or latitude values.

    obclient [test]> SELECT ST_X(Point(53.7, 56.34));
    +--------------------------+
    | ST_X(Point(53.7, 56.34)) |
    +--------------------------+
    |                     53.7 |
    +--------------------------+
    1 row in set
    
    obclient [test]> SELECT ST_AsText(ST_X(Point(53.7, 56.34), 15.5));
    +-------------------------------------------+
    | ST_AsText(ST_X(Point(53.7, 56.34), 15.5)) |
    +-------------------------------------------+
    | POINT(15.5 56.34)                         |
    +-------------------------------------------+
    1 row in set
    

    ST_Y

    ST_Y() returns the double-precision number of the Y coordinate value for a valid Point project p. The Y coordinate is considered the second axis defined in a point SRS. The syntax is as follows:

    ST_Y(p [, new_y_val])
    

    The argument new_y_val is optional. If this argument is used, the ST_Y() function returns a Point object whose Y coordinate is equal to the value of the second argument. If the Point object has a geographic SRS, the second argument must be within the valid range of longitude or latitude values.

    obclient [test]> SELECT ST_Y(Point(53.7, 56.34));
    +--------------------------+
    | ST_Y(Point(53.7, 56.34)) |
    +--------------------------+
    |                    56.34 |
    +--------------------------+
    1 row in set
    
    obclient [test]> SELECT ST_AsText(ST_Y(Point(53.7, 56.34), 15.5));
    +-------------------------------------------+
    | ST_AsText(ST_Y(Point(53.7, 56.34), 15.5)) |
    +-------------------------------------------+
    | POINT(53.7 15.5)                          |
    +-------------------------------------------+
    1 row in set
    

    Considerations

    The return value for a geometry argument in a geometry property function is non-NULL, except in the following cases:

    • If any argument is NULL or any geometry argument is an empty geometry object, the return value is NULL.
    • If any geometry argument is in an incorrect syntax format, the ER_GIS_INVALID_DATA error is returned.
    • If any geometry argument belongs to an undefined SRS, the ER_SRS_NOT_FOUND error is returned.
    • If any SRID argument is not in the range of 32-bit unsigned integers, the ER_DATA_OUT_OF_RANGE error is returned.
    • If any SRID argument references an undefined SRS, the ER_SRS_NOT_FOUND error is returned.

    Take note of the following limitations on the ST_Latitude(), ST_Longitude(), ST_X(), and ST_Y() functions:

    • If any geometry argument is a valid geometry object but not a Point object, the ER_UNEXPECTED_GEOMETRY_TYPE error is returned.
    • If an X or Y coordinate argument is provided and its value is -inf, +inf, or NaN, the ER_DATA_OUT_OF_RANGE error is returned.
    • If the longitude or latitude value exceeds the valid range in degrees or in other units used by the SRS, an error is returned.
      • If the longitude value is not within the range of (-180, 180], the ER_LONGITUDE_OUT_OF_RANGE error is returned.
      • If the latitude value is not within the range of [−90, 90], the ER_LATITUDE_OUT_OF_RANGE error is returned.

    Previous topic

    Spatial relation functions
    Last

    Next topic

    Geometry format conversion functions
    Next
    What is on this page
    ST_Area
    ST_SRID
    ST_Latitude
    ST_Longitude
    ST_X
    ST_Y
    Considerations