OceanBase
English日本語简体中文
Docs Home
Products
Integrations
Release Notes

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Databases

OceanBase DatabaseOceanBase Cloud OceanBase Best Practices

Connectors and Middleware

OceanBase Database Proxy OceanBase Connector/C OceanBase Connector/J OceanBase Connector/ODBC OceanBase Connector/NETOceanBase Command-Line Client

Tools

OceanBase Cloud PlatformOceanBase Migration ServiceOceanBase Developer CenterOceanBase Migration AssessmentOceanBase Admin ToolOceanBase Loader and DumperOceanBase DeployerKubernetes operator for OceanBaseOceanBase Diagnostic Tool OceanBase Binlog Service
OceanBase DatabaseOceanBase Cloud ToolsConnectors and MiddlewareLifecycle Support Policy

OceanBase Cloud

  • Product Updates & Announcements
    • What's new
      • Release notes for 2026
      • Release notes for 2025
      • Release notes for 2024
      • Release history
    • Product announcements
      • Notice of underlying component upgrades for OceanBase Cloud database proxy clusters on Alibaba Cloud
      • AI Service Model Launch and Delisting Notice
      • Data development module deprecation notice
      • Optimization of Backup and Restore commercialization strategy
      • Database proxy billing update
      • AWS instance pricing adjustment
      • Billing notice for limited-time free OMS instances
      • Notice of cross-AZ data transfer billing adjustments (OceanBase Cloud on AWS)
  • Product Introduction
    • Overview
    • Management mode and scenarios
    • Core features
      • High availability with cross-cloud active-active architecture
      • High availability with cross-cloud primary-standby databases
      • Multi-layer online scaling and on-demand adjustment
    • Deployment modes
    • Product specifications
    • Product billing
      • Overview
      • Instance billing
        • Alibaba Cloud instance billing
        • Huawei Cloud instance billing
        • AWS instance billing
        • Google Cloud instance billing
        • Azure instance billing
      • Backup and restore billing
      • SQL audit billing
      • Migrations billing
      • Database proxy billing
      • Binlog service billing
      • Read-only replica billing
      • AI model billing
    • Supported database versions
  • Get Started
    • Quick start with Flagship Edition
    • Create a Flagship Edition cluster instance
    • Create a tenant
    • Use the database
  • Work with DBaaS Instances
    • Work with flagship edition instances
      • Overview
      • Create an instance
        • Overview
        • Create via OceanBase Cloud official website
        • Create via AWS Marketplace
        • Create via GCP Marketplace
        • Create via Huawei Cloud Marketplace
        • Create via Alibaba Cloud Marketplace
        • Create via Azure Marketplace
      • Connect to an instance
        • Configure network connection
          • Overview
          • Connect using a public IP address
          • Connect using Azure Private Link
          • Connect using Google Cloud Private Service Connect
          • Connect using Huawei Cloud VPC Endpoint
          • Connect using a Huawei Cloud peering connection
          • Connect using AWS PrivateLink
          • Connect using AWS VPC peering
          • Connect using Alibaba Cloud VPC
        • MySQL compatible mode
          • Connect with clients
            • Connect to OceanBase Cloud by using Client ODC
            • Connect to OceanBase Cloud by using a MySQL client
            • Connect to OceanBase Cloud by using OBClient
          • Connect with drivers
            • Java
              • Connect to OceanBase Cloud using SpringBoot
              • SpringBatch sample application for connecting to OceanBase Cloud
              • spring-jdbc
              • SpringDataJPA sample application for connecting to OceanBase Cloud
              • Hibernate application development with OceanBase Cloud
              • Sample program for connecting to OceanBase Cloud
              • connector-j
              • Use TestContainers to connect to and use OceanBase Cloud
            • Python
              • Connect to OceanBase Cloud using mysqlclient
              • Connect to OceanBase Cloud using PyMySQL
              • Use the MySQL-connector-python driver to connect to and use OceanBase Cloud
              • Use SQLAlchemy to connect to an OceanBase Cloud database
              • Connect to an OceanBase Cloud database using Django
              • Connect to an OceanBase Cloud database by using peewee
            • C
              • Use MySQL Connector/C to connect to OceanBase Cloud
            • Go
              • Connect to OceanBase Cloud using the Go-SQL-Driver/MySQL driver
              • Connect to OceanBase Cloud using GORM
            • PHP
              • Use the EXT driver to connect to OceanBase Cloud
              • Connect to OceanBase Cloud by using the MySQLi driver
              • Use the PDO driver to connect to OceanBase Cloud
            • Rust
              • Rust application example for connecting to OceanBase Cloud
              • SeaORM example for connecting to OceanBase Cloud
            • Ruby
              • ActiveRecord sample application for OceanBase Cloud
              • Connect to OceanBase Cloud by using mysql2
              • Connect to OceanBase Cloud by using Sequel
          • Use database connection pool
            • Database connection pool configuration
            • Connect to OceanBase Cloud by using a Tomcat connection pool
            • Connect to OceanBase Cloud by using a C3P0 connection pool
            • Connect to OceanBase Cloud by using a Proxool connection pool
            • Connect to OceanBase Cloud by using a HikariCP connection pool
            • Connect to OceanBase Cloud by using a DBCP connection pool
            • Connect to OceanBase Cloud by using Commons Pool
            • Connect to OceanBase Cloud by using a Druid connection pool
        • Oracle compatible mode
          • Connect with clients
            • Connect to OceanBase Cloud by using OBClient
            • Connect to OceanBase Cloud by using Client ODC
          • Connect with drivers
            • Java
              • Connect to OceanBase Cloud using OceanBase Connector/J
              • Connect to OceanBase Cloud by using Spring Boot
              • SpringBatch application example for connecting to OceanBase Cloud
              • Connect to OceanBase Cloud using Spring JDBC
              • Connect to OceanBase Cloud by using Spring Data JPA
              • Connect to OceanBase Cloud by using Hibernate
              • Use MyBatis to connect to OceanBase Cloud
              • Use JFinal to connect to OceanBase Cloud
            • Python
              • Python Driver for Oracle Mode
            • C/C++
              • Connect to OceanBase Cloud using OceanBase Connector/C
              • Connect to OceanBase Cloud using OceanBase Connector/ODBC
              • Use SqlSugar to connect to OceanBase Cloud
          • Use database connection pool
            • Database connection pool configuration
            • Sample program that uses a Tomcat connection pool to connect to OceanBase Cloud
            • C3P0 connection pool connects to OceanBase Cloud
            • Connect to OceanBase Cloud using Proxool connection pool
            • Sample program that uses HikariCP to connect to OceanBase Cloud
            • Use DBCP connection pool to connect to OceanBase Cloud
            • Connect to OceanBase Cloud by using Commons Pool
            • Connect to OceanBase Cloud by using a Druid connection pool
        • KV compatible mode
          • Connect to a cluster by using the OBKV-HBase client
      • Developer guide
        • MySQL compatible mode
          • Plan database objects
            • Create a database
            • Create a table group
            • Create a table
            • Create an index
            • Create an external table
          • Write data
            • Insert data
            • Update data
            • Delete data
            • Replace data
            • Generate test data in batches
          • Read data
            • Single-table queries
            • Join tables
              • INNER JOIN queries
              • FULL JOIN queries
              • LEFT JOIN queries
              • RIGHT JOIN queries
              • Subqueries
              • Lateral derived tables
            • Use operators and functions in queries
              • Use arithmetic operators in queries
              • Use numerical functions in queries
              • Use string concatenation operators in queries
              • Use string functions in queries
              • Use datetime functions in queries
              • Use aggregate functions in queries
              • Use NULL-related functions in queries
              • Use the CASE conditional operator in queries
              • Use the SELECT ... FOR UPDATE statement to lock query results
              • Use the SELECT ... LOCK IN SHARE MODE statement to lock query results
            • Use a DBLink in queries
            • Set operations
          • Manage transactions
            • Overview
            • Start a transaction
            • Savepoints
              • Mark a savepoint
              • Roll back a transaction to a savepoint
              • Release a savepoint
            • Commit a transaction
            • Roll back a transaction
        • Oracle compatible mode
          • Plan database objects
            • Create a table group
            • Create a table
            • Create an index
            • Create an external table
          • Write data
            • Insert data
            • Update data
            • Delete data
            • Replace data
            • Generate test data in batches
          • Read data
            • Single-table queries
            • Join tables
              • INNER JOIN queries
              • FULL JOIN queries
              • LEFT JOIN queries
              • RIGHT JOIN queries
              • Subqueries
              • Lateral derived tables
            • Use operators and functions in queries
              • Use arithmetic operators in queries
              • Use numerical functions in queries
              • Use string concatenation operators in queries
              • Use string functions in queries
              • Use datetime functions in queries
              • Use aggregate functions in queries
              • Use CASE functions in queries
            • Use a DBLink in queries
            • Set operations
          • Manage transactions
            • Overview
            • Start a transaction
            • Savepoints
              • Mark a savepoint
              • Roll back a transaction to a savepoint
            • Commit a transaction
            • Roll back a transaction
        • KV compatible mode
          • OBKV-Table Java development guide
          • Table data operation examples
            • Insert data with OBKV-Table
            • Query data with OBKV-Table
            • Update data with OBKV-Table
            • Delete data with OBKV-Table
          • Table Java development
            • Connect to an instance by using the OBKV-Table Java client
          • HBase data operation examples
            • OBKV-HBase application development overview
            • OBKV-HBase data operation examples
      • Manage instances
        • Manage instances
          • View the instance list
          • Instance workbench overview
          • Stop and start instances
          • Unit migration
        • Manage tenants
          • Tenant overview
          • Create a tenant
          • Modify tenant specifications
          • Modify tenant names
          • Add an endpoint
          • Resource isolation
            • Overview
            • Manage resource groups
              • Create a resource group
              • View a resource group
              • Edit a resource group
              • Delete a resource group
            • Manage isolation rules
              • Create an isolation rule
              • View isolation rules
              • Edit an isolation rule
              • Delete a quarantine rule
          • Modify primary zone
          • Modify the maximum number of connections for a tenant proxy
          • Enable the AI function built-in AI models
          • Monitor tenant performance
            • Overview
            • View performance and SQL monitoring details
            • View transaction monitoring details
            • View storage and cache monitoring details
            • View Binlog service monitoring
            • Customize a monitoring dashboard for a tenant
          • Diagnostics
            • View performance monitoring data
            • Real-time diagnostics
              • SQL diagnostics
                • Top SQL
                • Slow SQL
                • Suspicious SQL
                • High-risk SQL
                • SQL details
              • Session management
                • Session management
              • Optimization management
                • Manage active outlines
                • View optimization history
              • SQL audit
          • Manage tenant parameters
            • Manage tenant parameters
            • Parameters for tenants
            • Parameter template overview
          • Delete a tenant
          • Manage databases and accounts
            • Create accounts
            • Manage accounts
            • Create a database (MySQL compatible mode)
            • Manage databases (MySQL compatible mode)
        • Monitor instance performance
          • Overview
          • Monitor the performance of databases in an instance
          • Monitor multidimensional metrics of an instance
          • Monitor the performance of hosts in an instance
          • Monitor database proxy
          • Monitor database proxy hosts
          • Monitor cross-cloud network performance
          • Customize a monitoring dashboard for an instance
        • Manage major compactions
          • Initiate a major compaction
          • View compaction records
          • Update time for compactions
        • Manage instance parameters
          • Manage parameters
          • Parameters for cluster instances
        • Change instance configurations
          • Set compute auto-scaling
          • Set storage auto-scaling
          • View history of configuration changes
          • Change configuration
          • Switch the deployment mode
        • Manage standby instances
          • Overview
          • Create a standby instance
          • Create a cross-cloud standby instance
          • Primary-standby instance workspace
          • Configure a primary-standby synchronization strategy
          • Configure global endpoint
          • Enable automatic forwarding of standby write requests
          • Primary-standby instance switchover
          • Initiate failover
          • Detach a standby instance
          • Release a standby instance
        • Release an instance
        • Database proxy
          • Overview
          • Manage database proxy
          • Direct load
        • Manage alerts
          • Overview
          • Manage alert rules
            • Create an alert rule
            • View an alert rule
            • Edit an alert rule
            • Delete an alert rule
          • View alert history
          • Manage alert templates
            • Create an alert template
            • View an alert template
            • Edit an alert template
            • Copy an alert rule template
            • Delete an alert template
          • Manage muting rules
            • Create an alert muting rule
            • View an alert muting rule
            • Edit an alert muting rule
            • Delete an alert muting rule
          • Manage alert notification templates
            • Create an alert notification template
            • View an alert notification template
            • Edit an alert notification template
            • Copy an alert notification template
            • Delete an alert notification template
          • Manage alert contacts
            • Add an alert contact
            • Add an alert contact group
            • View an alert contact
            • Edit an alert contact
            • Delete an alert contact
            • Obtain a webhook URL
          • Monitoring metrics for alerts
        • Backup and restore
          • Overview
          • Backup strategy
          • Initiate a backup immediately
          • Data backup
          • Initiate a restore
          • Data restore
          • Restore data from the instance recycle bin
        • Diagnostics
          • View performance monitoring data
          • Capacity diagnostics
          • One-click diagnostics
            • Initiate one-click diagnostics
            • View one-click diagnostic report
              • Exceptions
              • Real-time diagnostics
              • Optimization suggestions
              • Capacity management
              • Security management
          • Real-time diagnostics
            • SQL diagnostics
              • Top SQL
              • Slow SQL
              • Suspicious SQL
              • High-risk SQL
              • SQL details
              • SQL monitoring metrics list
            • Session management
              • Session management
            • Request analysis
              • Request analysis
          • Root cause diagnostics
            • Exception handling
            • Enable system autonomy
          • SQL audit
          • Materialized view analysis
          • Optimization center
            • Optimization suggestions
            • Manage active outlines
            • SQL review
            • View the optimization history
        • Manage read-only replicas
          • Overview
          • Instance read-only replicas
            • Add a read-only replica to an instance
            • View read-only replicas of an instance
            • Manage read-only replicas of an instance
            • Delete a read-only replica of an instance
          • Tenant read-only replicas
            • Add a read-only replica to a tenant
            • View read-only replicas of a tenant
            • Manage read-only replicas of a tenant
            • Delete a read-only replica of a tenant
        • Manage tags
        • Manage JVM-dependent services
      • Data source management
        • Overview of data source management
        • Manage data sources
        • User privileges
          • User privileges for compatibility assessment
          • User privileges for data migration
          • User privileges for performance assessment
          • User privileges for data archiving
          • User privileges for data cleanup
        • Connect via private network
          • AWS
          • Huawei Cloud
          • Alibaba Cloud
          • Azure
          • Private IP address segments
        • Connect via public network
          • AWS
          • Huawei Cloud
          • Alibaba Cloud
          • Azure
      • Data lifecycle management
        • Archive data
        • Clean up data
      • Manage recycle bin
        • Instance recycle bin
        • Manage databases and tables in recycle bin
          • Overview
          • Instance-level recycle bin
          • Tenant-level recycle bin
    • Work with transactional instances
      • Overview
      • Create an instance
        • Overview
        • Create via OceanBase Cloud official website
        • Create via AWS Marketplace
        • Create via GCP Marketplace
        • Create via Huawei Cloud Marketplace
        • Create via Alibaba Cloud Marketplace
        • Create via Azure Marketplace
      • Connect to an instance
        • MySQL compatible mode
          • Overview
          • Get connection string
            • Overview
            • Connect to a database by using AWS PrivateLink
            • Access the database by using an Azure private network connection
            • Connect using AWS VPC peering
            • Connect using Google Cloud Private Service Connect
            • Connect using Huawei Cloud VPC Endpoint
            • Connect using Alibaba Cloud VPC
            • Connect using a public IP address
            • Connect using a Huawei Cloud peering connection
          • Connect with clients
            • Connect to OceanBase Cloud by using Client ODC
            • Connect to OceanBase Cloud by using a MySQL client
            • Connect to OceanBase Cloud by using OBClient
          • Connect with drivers
            • Java
              • Connect to OceanBase Cloud using SpringBoot
              • SpringBatch sample application for connecting to OceanBase Cloud
              • spring-jdbc
              • SpringDataJPA sample application for connecting to OceanBase Cloud
              • Hibernate application development with OceanBase Cloud
              • Sample program for connecting to OceanBase Cloud
              • connector-j
              • Use TestContainers to connect to and use OceanBase Cloud
            • Python
              • Connect to OceanBase Cloud using mysqlclient
              • Connect to OceanBase Cloud using PyMySQL
              • Use the MySQL-connector-python driver to connect to and use OceanBase Cloud
              • Use SQLAlchemy to connect to an OceanBase Cloud database
              • Connect to an OceanBase Cloud database using Django
              • Connect to an OceanBase Cloud database by using peewee
            • C
              • Use MySQL Connector/C to connect to OceanBase Cloud
            • Go
              • Connect to OceanBase Cloud using the Go-SQL-Driver/MySQL driver
              • Connect to OceanBase Cloud using GORM
            • PHP
              • Use the EXT driver to connect to OceanBase Cloud
              • Connect to OceanBase Cloud by using the MySQLi driver
              • Use the PDO driver to connect to OceanBase Cloud
            • Rust
              • Rust application example for connecting to OceanBase Cloud
              • SeaORM example for connecting to OceanBase Cloud
            • ruby
              • ActiveRecord sample application for OceanBase Cloud
              • Connect to OceanBase Cloud by using mysql2
              • Connect to OceanBase Cloud by using Sequel
          • Use database connection pool
            • Database connection pool configuration
            • Connect to OceanBase Cloud by using a Tomcat connection pool
            • Connect to OceanBase Cloud by using a C3P0 connection pool
            • Connect to OceanBase Cloud by using a Proxool connection pool
            • Connect to OceanBase Cloud by using a HikariCP connection pool
            • Connect to OceanBase Cloud by using a DBCP connection pool
            • Connect to OceanBase Cloud by using Commons Pool
            • Connect to OceanBase Cloud by using a Druid connection pool
        • Oracle compatible mode
          • Overview
          • Get connection string
            • Overview
            • Connect to a database by using AWS PrivateLink
            • Access a database by using an Azure private network connection
            • Connect using AWS VPC peering
            • Connect using Google Cloud Private Service Connect
            • Connect using Huawei Cloud VPC Endpoint
            • Connect using a public IP address
          • Connect with clients
            • Connect to OceanBase Cloud by using OBClient
            • Connect to OceanBase Cloud by using Client ODC
          • Connect with drivers
            • Java
              • Connect to OceanBase Cloud using OceanBase Connector/J
              • Connect to OceanBase Cloud by using Spring Boot
              • SpringBatch application example for connecting to OceanBase Cloud
              • Connect to OceanBase Cloud using Spring JDBC
              • Connect to OceanBase Cloud by using Spring Data JPA
              • Connect to OceanBase Cloud by using Hibernate
              • Use MyBatis to connect to OceanBase Cloud
              • Use JFinal to connect to OceanBase Cloud
            • Python
              • Python Driver for Oracle Mode
            • C
              • Connect to OceanBase Cloud using OceanBase Connector/C
              • Connect to OceanBase Cloud using OceanBase Connector/ODBC
              • Use SqlSugar to connect to OceanBase Cloud
          • Use database connection pool
            • Database connection pool configuration
            • Sample program that uses a Tomcat connection pool to connect to OceanBase Cloud
            • C3P0 connection pool connects to OceanBase Cloud
            • Connect to OceanBase Cloud using Proxool connection pool
            • Sample program that uses HikariCP to connect to OceanBase Cloud
            • Use DBCP connection pool to connect to OceanBase Cloud
            • Connect to OceanBase Cloud by using Commons Pool
            • Connect to OceanBase Cloud by using a Druid connection pool
      • Developer guide
        • MySQL compatible mode
          • Plan database objects
            • Create a database
            • Create a table group
            • Create a table
            • Create an index
            • Create an external table
          • Write data
            • Insert data
            • Update data
            • Delete data
            • Replace data
            • Generate test data in batches
          • Read data
            • Single-table queries
            • Join tables
              • INNER JOIN queries
              • FULL JOIN queries
              • LEFT JOIN queries
              • RIGHT JOIN queries
              • Subqueries
              • Lateral derived tables
            • Use operators and functions in queries
              • Use arithmetic operators in queries
              • Use numerical functions in queries
              • Use string concatenation operators in queries
              • Use string functions in queries
              • Use datetime functions in queries
              • Use type conversion functions in queries
              • Use aggregate functions in queries
              • Use NULL-related functions in queries
              • Use the CASE conditional operator in queries
              • Use the SELECT ... FOR UPDATE statement to lock query results
              • Use the SELECT ... LOCK IN SHARE MODE statement to lock query results
            • Use a DBLink in queries
            • Set operations
          • Manage transactions
            • Overview
            • Start a transaction
            • Savepoints
              • Mark a savepoint
              • Roll back a transaction to a savepoint
              • Release a savepoint
            • Commit a transaction
            • Roll back a transaction
        • Oracle compatible mode
          • Plan database objects
            • Create a table group
            • Create a table
            • Create an index
            • Create an external table
          • Write data
            • Insert data
            • Update data
            • Delete data
            • Replace data
            • Generate test data in batches
          • Read data
            • Single-table queries
            • Join tables
              • INNER JOIN queries
              • FULL JOIN queries
              • LEFT JOIN queries
              • RIGHT JOIN queries
              • Subqueries
              • Lateral derived tables
            • Use operators and functions in queries
              • Use arithmetic operators in queries
              • Use numerical functions in queries
              • Use string concatenation operators in queries
              • Use string functions in queries
              • Use datetime functions in queries
              • Use type conversion functions in queries
              • Use aggregate functions in queries
              • Use NULL-related functions in queries
              • Use CASE functions in queries
              • Use the SELECT ... FOR UPDATE statement to lock query results
            • Use a DBLink in queries
            • Set operations
          • Manage transactions
            • Overview
            • Start a transaction
            • Savepoints
              • Mark a savepoint
              • Roll back a transaction to a savepoint
            • Commit a transaction
            • Roll back a transaction
      • Manage instances
        • Manage instances
          • View the instance list
          • Instance overview
          • Stop and restart instances
          • Unit migration
        • Manage tenants
          • Tenant overview
          • Create a tenant
          • Modify tenant specifications
          • Modify tenant names
          • Add an endpoint
          • Resource isolation
            • Overview
            • Manage resource groups
              • Create a resource group
              • View a resource group
              • Edit a resource group
              • Delete a resource group
            • Manage isolation rules
              • Create an isolation rule
              • View isolation rules
              • Edit an isolation rule
              • Delete a quarantine rule
          • Modify primary zone
          • Modify the maximum number of connections for a tenant proxy
          • Enable the AI function built-in AI models
          • Monitor tenant performance
            • Overview
            • View performance and SQL monitoring details
            • View transaction monitoring details
            • View storage and cache monitoring details
            • View Binlog service monitoring
            • Customize a monitoring dashboard for a tenant
          • Diagnostics
            • Real-time diagnostics
              • SQL diagnostics
                • Top SQL
                • Slow SQL
                • Suspicious SQL
                • High-risk SQL
              • SQL audit
          • Manage tenant parameters
            • Manage tenant parameters
            • Parameters for tenants
            • Parameter template overview
          • Delete a tenant
          • Manage databases and accounts
            • Create accounts
            • Manage accounts
            • Create a database (MySQL compatible mode)
            • Manage databases (MySQL compatible mode)
        • Monitor instance performance
          • Overview
          • Monitor the performance of databases in an instance
          • Monitor multidimensional metrics of an instance
          • Monitor the performance of hosts in an instance
          • Monitor database proxy
          • Monitor database proxy hosts
          • Monitor cross-cloud network performance
          • Customize a monitoring dashboard for an instance
        • Manage major compactions
          • Initiate a major compaction
          • View compaction records
          • Update time for compactions
        • Manage instance parameters
          • Manage parameters
          • Parameters for cluster instances
        • Change instance configurations
          • Set storage auto-scaling
          • View history of configuration changes
          • Change configuration
          • Switch the deployment mode
        • Manage standby instances
          • Overview
          • Create a standby instance
          • Create a cross-cloud standby instance
          • View details of primary and standby instances
          • Configure global endpoint
          • Enable automatic forwarding for write requests of standby databases
          • Primary-standby instance switchover
          • Initiate failover
          • Detach a standby instance
          • Release a standby instance
        • Release an instance
        • Database proxy
          • Overview
          • Manage database proxy
          • Direct load
        • Manage alerts
          • Overview
          • Manage alert rules
            • Create an alert rule
            • View an alert rule
            • Edit an alert rule
            • Delete an alert rule
          • View alert history
          • Manage alert templates
            • Create a trigger condition template
            • View an alert template
            • Edit an alert template
            • Copy an alert rule template
            • Delete an alert template
          • Manage muting rules
            • Create an alert muting rule
            • View an alert muting rule
            • Edit an alert muting rule
            • Delete an alert muting rule
          • Manage alert notification templates
            • Create an alert notification template
            • View an alert notification template
            • Edit an alert notification template
            • Copy an alert notification template
            • Delete an alert notification template
          • Manage alert contacts
            • Add an alert contact
            • Add an alert contact group
            • View an alert contact
            • Edit an alert contact
            • Delete an alert contact
            • Obtain a webhook URL
          • Monitoring metrics for alerts
        • Backup and restore
          • Overview
          • Backup strategy
          • Initiate a backup immediately
          • Data backup
          • Initiate a restore
          • Data restore
          • Restore data from the instance recycle bin
        • Diagnostics
          • View performance monitoring data
          • Capacity diagnostics
          • One-click diagnostics
            • Initiate one-click diagnostics
            • View one-click diagnostic report
              • Exceptions
              • Real-time diagnostics
              • Optimization suggestions
              • Capacity management
              • Security management
          • Real-time diagnostics
            • SQL diagnostics
              • Top SQL
              • Slow SQL
              • Suspicious SQL
              • High-risk SQL
              • SQL details
              • SQL monitoring metrics list
            • Session management
              • Session management
            • Request analysis
              • Request analysis
          • Root cause diagnostics
            • Exception handling
            • Enable system autonomy
          • SQL audit
          • Materialized view analysis
          • Optimization center
            • Optimization suggestions
            • Manage active outlines
            • SQL review
            • View the optimization history
        • Manage read-only replicas
          • Overview
          • Instance read-only replicas
            • Add a read-only replica to an instance
            • View read-only replicas of an instance
            • Manage read-only replicas of an instance
            • Delete a read-only replica of an instance
          • Tenant read-only replicas
            • Add a read-only replica to a tenant
            • View read-only replicas of a tenant
            • Manage read-only replicas of a tenant
            • Delete a read-only replica of a tenant
        • Manage tags
        • Manage JVM-dependent services
      • Data source management
        • Connect via private network
          • Google Cloud
        • Connect via public network
          • Google Cloud
      • Overview of data source management
      • Data lifecycle management
        • Overview
        • Archive data
        • Clean up data
        • Data archiving configurations
      • Manage recycle Bin
        • Instance recycle bin
        • Manage databases and tables in recycle bin
          • Overview
          • Instance-level recycle bin
          • Tenant-level recycle bin
    • Work with analytical instances
      • Overview
      • Core features
      • Connect to an instance
        • Overview
        • Get connection string
          • Overview
          • Connect using AWS PrivateLink
          • Connect using Huawei Cloud VPC Endpoint
          • Connect using a public IP address
        • Connect with clients
          • Connect to OceanBase Cloud by using Client ODC
          • Connect to OceanBase Cloud by using a MySQL client
          • Connect to OceanBase Cloud by using OBClient
        • Connect with drivers
          • Java
            • Connect to OceanBase Cloud by using Spring Boot
            • Connect to OceanBase Cloud by using Spring Batch
            • Connect to OceanBase Cloud by using Spring Data JDBC
            • Connect to OceanBase Cloud by using Spring Data JPA
            • Connect to OceanBase Cloud by using Hibernate
            • Connect to OceanBase Cloud by using MyBatis
            • Connect to OceanBase Cloud using MySQL Connector/J
          • Python
            • Connect to OceanBase Cloud by using mysqlclient
            • Connect to OceanBase Cloud by using PyMySQL
            • Connect to OceanBase Cloud using MySQL Connector/Python
          • C
            • Connect to OceanBase Cloud using MySQL Connector/C
          • Go
            • Connect to OceanBase Cloud using Go-SQL-Driver/MySQL
          • PHP
            • Connect to OceanBase Cloud using PHP
        • Use database connection pool
          • Database connection pool configuration
          • Connect to OceanBase Cloud by using a Tomcat connection pool
          • Connect to OceanBase Cloud by using a C3P0 connection pool
          • Connect to OceanBase Cloud by using a Proxool connection pool
          • Connect to OceanBase Cloud by using a HikariCP connection pool
          • Connect to OceanBase Cloud by using a DBCP connection pool
          • Connect to OceanBase Cloud by using Commons Pool
          • Connect to OceanBase Cloud by using a Druid connection pool
      • Create an instance
      • Data table design
        • Table overview
        • Best practices
          • Unit 1: Best practices for optimizing storage structures and query performance
          • Unit 2: Best practices for creating special indexes
      • Export data
      • OceanBase data processing
      • Query acceleration
        • Statistics
        • Materialized views for query acceleration
        • Select a query parallelism level
      • Manage instances
        • Instance overview
        • Change configuration
        • Set storage auto-scaling
        • Modify primary zone
        • Manage parameters
        • Backup and restore
          • Backup overview
          • Backup strategies
          • Immediate backup
          • Data Backup
          • Initiate restore
          • Data restore
        • Monitor instance performance
          • Overview
          • Monitor the performance of databases in an instance
          • Monitor the performance of hosts in an instance
        • Manage major compactions
          • Initiate a major compaction
          • View compaction records
          • Update time for compactions
        • Database proxy
          • Overview
          • Manage database proxy
          • Direct load
        • Manage alerts
          • Overview
          • Manage alert rules
            • Create an alert rule
            • View an alert rule
            • Edit an alert rule
            • Delete an alert rule
          • View alert history
          • Manage alert templates
            • Create a trigger condition template
            • View an alert template
            • Edit an alert template
            • Copy an alert template
            • Delete an alert template
          • Manage muting rules
            • Create an alert muting rule
            • View an alert muting rule
            • Edit an alert muting rule
            • Delete an alert muting rule
          • Manage alert notification templates
            • Create an alert notification template
            • View an alert notification template
            • Edit an alert notification template
            • Copy an alert notification template
            • Delete an alert notification template
          • Manage alert contacts
            • Add an alert contact
            • Add an alert contact group
            • View an alert contact
            • Edit an alert contact
            • Delete an alert contact
            • Obtain a webhook URL
          • Monitoring metrics for alerts
        • Diagnostics
          • View performance monitoring data
          • Capacity diagnostics
          • Real-time diagnostics
            • SQL diagnostics
              • Top SQL
              • Slow SQL
              • Suspicious SQL
              • High-risk SQL
              • SQL details
              • SQL monitoring metrics list
            • Session management
              • Session management
            • Optimization management
              • Manage active outlines
              • View the optimization history
            • Request analysis
              • Request analysis
        • Stop and restart instances
        • Release instances
        • Manage databases and accounts
          • Create and manage accounts
          • Create a database
          • Manage databases
        • Manage tags
      • Overview of data source management
      • Data lifecycle management
        • Archive data
        • Clean up data
      • Performance diagnosis and tuning
        • Use the DBMS_XPLAN package for performance diagnostics
        • Use the GV$SQL_PLAN_MONITOR view for performance analysis
        • Views related to AP performance analysis
      • Performance testing
      • Product integration
      • Manage recycle Bin
        • View instance recycle bin
        • Manage databases and tables in recycle bin
          • Overview
          • Instance recycle bin
    • Work with Key-Value instances
      • Try out Key-Value instances
        • Create an instance
        • Create a tenant
        • Create an account for a database user
        • OBKV HBase data operation examples
      • Use Table model
        • Create an instance
        • Manage instances
          • Manage instances
            • View the instance list
            • Instance overview
            • Stop and restart instances
            • Release an instance
          • Manage tenants
            • Create a tenant
            • Modify tenant specifications
            • Modify tenant names
            • Delete a tenant
            • Tenant overview
            • Resource isolation
              • Overview
              • Manage resource groups
                • Create a resource group
                • View a resource group
                • Edit a resource group
                • Delete a resource group
              • Manage isolation rules
                • Create an isolation rule
                • View isolation rules
                • Edit an isolation rule
                • Delete a quarantine rule
            • Monitor tenant performance
              • Overview
              • View performance and SQL monitoring details
              • View transaction monitoring details
              • View storage and cache monitoring details
              • OBKV-Table
              • Customize a monitoring dashboard for a tenant
            • Diagnostics
              • Top SQL
            • Manage tenant parameters
              • Manage tenant parameters
              • Parameters for tenants
            • Manage databases and accounts
              • Create and manage accounts
              • Create a database
              • Manage databases
            • Modify primary zone
          • Monitor instance performance
            • Overview
            • Monitor the performance of databases in an instance
            • Monitor multi-dimensional metrics of an instance
            • Monitor the performance of hosts in a cluster
            • Customize monitoring dashboards for an instance
          • Manage major compactions
            • Initiate major compactions
            • View compaction records
            • Update time for compactions
          • Manage instance parameters
            • Parameter management overview
            • Parameters for cluster instances
          • Change instance configurations
            • Set storage auto-scaling
            • View history of configuration changes
            • Change configuration
            • Switch the deployment mode
          • Database proxy
            • Overview
            • Manage database proxy
          • Manage alerts
            • Overview
            • Manage alert rules
              • Create an alert rule
              • View an alert rule
              • Edit an alert rule
              • Delete an alert rule
            • View alert history
            • Manage alert templates
              • Trigger condition template management
              • Create an alert template
              • View an alert template
              • Edit an alert template
              • Copy an alert template
              • Delete an alert template
            • Manage muting rules
              • Create an alert muting rule
              • View an alert muting rule
              • Edit an alert muting rule
              • Delete an alert muting rule
            • Manage alert contacts
              • Add an alert contact
              • Add an alert contact group
              • View an alert contact
              • Edit an alert contact
              • Delete an alert contact
              • Obtain a webhook URL
            • Monitoring metrics for alerts
          • Backup and restore
            • Backup overview
            • Backup strategies
            • Immediate backup
            • Data backup
            • Initiate restore
            • Data restore
          • Diagnostics
            • View performance monitoring data
            • Top SQL
            • Capacity diagnostics
            • Request analysis
          • Manage recycle Bin
            • View instance recycle bin
            • Manage databases and tables in recycle bin
              • Overview
              • Instance-level recycle bin
              • Tenant-level recycle bin
          • Manage tags
      • Use HBase model
        • OBKV-HBase Overview
        • Create an instance
        • Develop in HBase model
          • Connect to an instance by using the OBKV-HBase client
        • Manage instances
          • Manage instances
            • View the instance list
            • Instance overview
            • Stop and restart instances
            • Release an instance
          • Manage tenants
            • Create a tenant
            • Modify tenant specifications
            • Modify tenant names
            • Delete a tenant
            • Tenant overview
            • Resource isolation
              • Overview
              • Manage resource groups
                • Create a resource group
                • View a resource group
                • Edit a resource group
                • Delete a resource group
              • Manage isolation rules
                • Create an isolation rule
                • View isolation rules
                • Edit an isolation rule
                • Delete a quarantine rule
            • Monitor tenant performance
              • Overview
              • View performance and SQL monitoring details
              • View transaction monitoring details
              • View storage and cache monitoring details
              • OBKV-HBase
              • Customize a monitoring dashboard for a tenant
            • Diagnostics
              • Top SQL
            • Manage tenant parameters
              • Manage tenant parameters
              • Parameters for tenants
            • Manage databases and accounts
              • Create and manage accounts
              • Create a database
              • Manage databases
            • Modify primary zone
          • Monitor instance performance
            • Overview
            • Monitor the performance of databases in an instance
            • Monitor multi-dimensional metrics of an instance
            • Monitor the performance of hosts in a cluster
            • Customize monitoring dashboards for an instance
          • Manage major compactions
            • Initiate major compactions
            • View compaction records
            • Update time for compactions
          • Manage instance parameters
            • Parameter management overview
            • Parameters for cluster instances
          • Change instance configurations
            • Set storage auto-scaling
            • View history of configuration changes
            • Change configuration
            • Switch the deployment mode
          • Database proxy
            • Overview
            • Manage database proxy
          • Manage alerts
            • Overview
            • Manage alert rules
              • Create an alert rule
              • View an alert rule
              • Edit an alert rule
              • Delete an alert rule
            • View alert history
            • Manage alert templates
              • Trigger condition template management
              • Create an alert template
              • View an alert template
              • Edit an alert template
              • Copy an alert template
              • Delete an alert template
            • Manage muting rules
              • Create an alert muting rule
              • View an alert muting rule
              • Edit an alert muting rule
              • Delete an alert muting rule
            • Manage alert contacts
              • Add an alert contact
              • Add an alert contact group
              • View an alert contact
              • Edit an alert contact
              • Delete an alert contact
              • Obtain a webhook URL
            • Monitoring metrics for alerts
          • Backup and restore
            • Backup overview
            • Backup strategies
            • Immediate backup
            • Data backup
            • Initiate restore
            • Data restore
          • Diagnostics
            • View performance monitoring data
            • Top SQL
            • Capacity diagnostics
            • Request analysis
          • Manage recycle Bin
            • View instance recycle bin
            • Manage databases and tables in recycle bin
              • Overview
              • Instance-level recycle bin
              • Tenant-level recycle bin
          • Manage tags
        • Overview of data source management
        • Performance test
      • Connect Key-Value instances
        • Overview
        • Connect using Huawei Cloud VPC Endpoint
        • Connect using a public IP address
  • AI Features
    • AI services
      • Overview of AI service
      • Quick start
      • Manage AI API keys
      • Use AI models
      • Use Claude Code with OceanBase MaaS
      • Use Codex CLI and Codex App with OceanBase MaaS
      • Use the memory feature
      • AI APIs
        • Access guide
        • AI service APIs
          • AI API list
          • Anthropic compatible APIs
            • List Anthropic models
            • Create a message
            • Create a message (default base URL)
          • OpenAI compatible APIs
            • List models
            • Create chat completion
            • Create embedding
            • Rerank
            • Reranks
            • Create response
          • Vertex AI compatible APIs
            • Generate content
            • Stream generate content
          • Image and video generation APIs
            • Create an image generation task
            • Create a video generation task
            • Retrieve task status
          • Image model APIs
            • gpt-image-2 text-to-image
            • gpt-image-2 image editing
            • gemini-3-pro-image text-to-image
            • gemini-3-pro-image image-to-image / image editing
          • OpenAI compatible batches and files APIs
            • Upload file
            • List files
            • Retrieve file
            • Delete file
            • Get file content
            • Get file content (POST)
            • Create batch
            • List batches
            • openai-compatible-apis
            • Retrieve batch (POST)
            • Cancel batch
          • Memory APIs
            • listSpaces - Paginated list of memory spaces
            • createSpace - Create a memory space
            • getSpace - Get details of a specified memory space
            • updateSpace - Update the name and description of a space
            • deleteSpace - Delete a space
            • extractMemories - Extract memories from dialogue messages
            • listMemories - List memories in a space
            • addMemory - Add a memory directly
            • getMemory - Retrieve a single memory
            • updateMemory - Update a single memory
            • deleteMemory - Delete a single memory
            • distillMemory - Distill experiences from conversations
            • searchExperiences - Search for experiences
            • getExperience - Retrieve a single experience
            • deleteExperience - Delete a single experience
            • feedbackExperiences - Submit feedback on experiences
            • setExperienceObsolescence - Set the obsolete status of an experience
            • combinedSearch - Combined search for memories and experiences
      • Built-in models
    • OceanBase OAgent
      • What is OceanBase OAgent?
      • Quick start with OceanBase OAgent
      • Configure a channel
      • Set skills
      • View OceanBase OAgent token usage
  • Migrations
    • Data migration and import solutions
    • Data assessment and migration quick start
    • Assess compatibility
      • Overview
      • Perform online assessment
      • Perform offline assessment
      • Manage compatibility assessment tasks
        • View a compatibility assessment task
        • View and download a compatibility assessment report
        • Stop a compatibility assessment task
        • Delete a compatibility assessment task
      • Obtain files for upload
      • Configure PrivateLink
      • Add an IP address to an allowlist
    • Data source management
      • Create a data source
      • Manage data sources
      • User privileges
        • User privileges for compatibility assessment
        • User privileges for data migration
        • User privileges for performance assessment
        • User privileges for data archiving
        • User privileges for data cleanup
      • Connect via private network
        • AWS
        • Huawei Cloud
        • Alibaba Cloud
        • Azure
        • Private IP address range
      • Connect via public network
        • AWS
        • Huawei Cloud
        • Alibaba Cloud
        • Azure
      • Connect via VPC peering
        • Configure an AWS data service peering connection
        • Configure a Huawei Cloud data service peering connection
        • Configure an Alibaba Cloud data service peering connection
        • Configure a Google Cloud data service peering connection
    • Migrate data
      • Overview
      • Migrations specification
      • Purchase a data migration instance
      • Migrate data from a MySQL database to the MySQL-compatible mode of OceanBase Database
      • Migrate data from OceanBase Database in MySQL-compatible mode to a MySQL database
      • Data migration between tenants of OceanBase Database in the same compatibility mode
      • Migrate data between OceanBase database tenants of different compatibility modes
      • Migrate data from an Oracle database to an Oracle-compatible tenant of OceanBase Database
      • Migrate data from an Oracle-compatible tenant of OceanBase Database to an Oracle database
      • Configure a two-way synchronization task
      • Migrate data from OceanBase Database to Kafka
      • Migrate data from a TiDB database to the MySQL-compatible mode of OceanBase Database
      • Migrate incremental data from OceanBase Database in MySQL-compatible mode to TiDB Database
      • Migrate data from a PostgreSQL database to OceanBase Database
      • Migrate incremental data from OceanBase Database to PostgreSQL Database
      • Migrate data from a Lindorm/HBase database to the HBase API compatible mode of OceanBase Database
      • Migrate incremental data from OceanBase Database in HBase API compatibility mode to a Lindorm/HBase database
      • Migrate data from OceanBase Database to RocketMQ
      • Migrate data from OceanBase Database to DataHub
      • Migrate data from OceanBase Database in MySQL mode to ADB
      • Migrate data from PolarDB-X 2.0 to OceanBase Database in MySQL mode
      • Manage data migration tasks
        • View details of a data migration task
        • Rename a data migration task
        • View and modify migration objects
        • View and modify migration parameters
        • Configure alert monitoring
        • Manage data migration tasks by using tags
        • Intelligent diagnosis
        • Start, stop, and resume a data migration task
        • Clone a data migration task
        • Terminate and release a data migration task
      • Features
        • Custom DML/DDL configurations
        • DDL synchronization scope
        • Use SQL conditions to filter data
        • Rename a migration object
        • Set an incremental synchronization timestamp
        • Instructions on schema migration
        • Configure and modify matching rules
        • Wildcard rules
        • Import migration objects
        • Download conflict data
        • Change a topic
        • Column filtering
        • Data formats
        • Partition settings
      • Authorize an Alibaba Cloud account
      • SQL statements for querying table objects
      • Online DDL tools
      • Create a trigger
      • Modify the log level of a self-managed PostgreSQL instance
      • Supported DDL statements for synchronization and their limitations
        • DDL synchronization from Aurora MySQL DB clusters to MySQL-compatible tenants of OceanBase Database
        • DDL synchronization from MySQL-compatible tenants of OceanBase Database to Aurora MySQL DB clusters
        • DDL synchronization between MySQL-compatible tenants of OceanBase Database
        • DDL synchronization from Oracle databases to Oracle-compatible tenants of OceanBase Database
        • DDL synchronization from Oracle-compatible tenants of OceanBase Database to Oracle databases
        • DDL synchronization between Oracle-compatible tenants of OceanBase Database
        • DDL synchronization from OceanBase databases to Kafka instances
    • Data subscription
      • Create a data subscription task
      • Manage data subscription tasks
        • View details of a data subscription task
        • Configure subscription information
        • Modify the name of a data subscription task
        • View and modify subscription objects
        • View data subscription parameters
        • Set up data subscription alerts
        • Start, stop, and resume data subscription tasks
        • Clone a data subscription task
        • Release a data subscription task
      • Manage private connections for data subscriptions
      • Configure consumer subscription
      • Message formats
    • Data validation
      • Overview
      • Create a data validation task
      • Manage data validation tasks
        • View details of a data validation task
        • View and modify validation objects
        • View and modify validation parameters
        • Manage data validation tasks with tags
        • Start, pause, and resume data validation tasks
        • Clone a data validation task
        • Release a data validation task
      • Features
        • Import validation objects
        • Rename the validation object
        • Filter objects by using SQL conditions
        • Configure the matching rules for the validation object
    • Assess performance
      • Overview
      • Obtain traffic files from a database instance
      • Create a full performance assessment task
      • Create an SQL file parsing task
      • Create an SQL file replay task
      • Manage performance assessment tasks
        • View the details of a performance assessment task
        • View a performance assessment report
        • Retry and stop a performance assessment task
        • Delete a performance assessment task
      • Obtain a database instance
      • Create an access key
    • Import data
      • Import data
      • Direct load
      • Supported file formats and encoding formats for Data Import
      • Sample data introduction
    • Binlog service
      • Overview
      • Purchase the Binlog service
      • Manage Binlog service
        • View details of the Binlog service
        • Change configuration
        • Modify the auto-scaling strategy for storage space
        • Modify the elasticity strategy for compute units
        • Disable the Binlog service
    • Upgrade assistant
  • Security
    • OceanBase Cloud account settings
      • Manage personal account information
      • Multi-factor authentication
      • Organization authentication
        • Enable organization authentication
        • Configure IdP
      • Manage AccessKeys
      • Time zone settings
      • Manage cloud marketplace accounts
      • Account audit
    • Organizations and projects
      • Overview
      • Manage organization information
      • Project management
        • Manage projects
        • Cross-project bidirectional authorization
        • AI settings
        • Manage object storage configurations
        • Subscribe to project messages
      • Manage members
      • Permissions for roles
      • Cost management
        • Overview
        • Cost details
        • Manage cost units
      • Operation audit
    • Database accounts and privileges
      • Account privileges
      • Authorize cloud vendor accounts
      • AWS KMS key management
      • Support access control
    • Security and encryption
      • Set allowlist groups
      • SSL encryption
      • Transparent Data Encryption (TDE)
    • Monitoring dashboard
    • Events
    • Support plans
      • Overview of OceanBase Cloud support plans
      • Subscribe to and manage support plans
  • SQL Console
    • Overview
    • Access SQL Console
    • SQL editing and execution
    • PL compilation
    • Result set editing
    • Execution analysis
    • Database object management
      • Create a table
      • Create a view
      • Create a function
      • Create a stored procedure
      • Create a program package
      • Create a trigger
      • Create a type
      • Create a sequence
      • Create a synonym
    • Session variable management
    • Functional keys in SQL Console
    • Intelligent SQL development
  • Integrations
    • Overview
    • Schema evolution
      • Liquibase
      • Flyway
    • Data ingestion
      • Canal
      • dbt
      • Debezium
      • Flink
      • Glue
      • Informatica Cloud
      • Kafka
      • Maxwell
      • SeaTunnel
      • DataWorks
      • NiFi
    • SQL development
      • DataGrip
      • DBeaver
      • Navicat
      • TablePlus
    • Orchestration
      • DolphinScheduler
      • Linkis
      • Airflow
    • Visualization
      • Grafana
      • Power BI
      • Quick BI
      • Superset
      • Tableau
    • Observability
      • Datadog
      • Prometheus
    • Database management
      • Bytebase
    • AI
      • LlamaIndex
      • Dify
      • LangChain
      • Tongyi Qianwen
      • OpenAI
      • n8n
      • Trae
      • SpringAI
      • Cline
      • Cursor
      • Continue
      • Toolbox
      • CamelAI
      • Firecrawl
      • Hugging Face
      • Ollama
      • Google Gemini
      • Cloudflare Workers AI
      • Qoder
      • OpenCode
      • Claude Code
      • GitHub Copilot
      • Codex
      • Jina AI
      • Augment Code
      • Claude Code
      • Kiro
    • Development tools
      • Cloudflare Workers
      • Vercel
  • Best practices
    • Best practices for achieving high availability through cross-cloud active-active deployment
    • High availability through cross-cloud primary-standby databases (1:1)
    • High availability through cross-cloud primary-standby databases (1:n)
    • High host CPU usage
    • Best practices for read/write splitting in OceanBase Cloud
    • Best practices for migrating data from AWS RDS to OceanBase Cloud
  • References
    • System architecture
    • System management
    • Database object management
    • Database design and specification constraints
    • SQL reference
    • System views
    • Parameters and system variables
    • Error codes
    • Performance tuning
    • Open API References
      • Overview of Open APIs
      • Service endpoints
      • Using API
      • Open APIs
        • Cluster management
          • DescribeInstances
          • DescribeInstance
          • CreateInstance
          • DeleteInstance
          • ModifyInstanceName
          • describe-node-options
          • StopCluster
          • StartCluster
          • ModifyInstanceSpec
          • DescribeInstanceTopology
          • DescribeReadonlyInstances
          • CreateReadonlyInstance
          • ModifyReadonlyInstanceSpec
          • ModifyReadonlyInstanceDiskSize
          • ModifyReadonlyInstanceNodeNum
          • DeleteReadonlyInstance
          • DescribeInstanceAvailableRoZones
          • DescribeInstanceParameters
          • UpdateInstanceParameters
          • DescribeInstanceParametersHistory
          • ModifyInstanceTagList
          • ModifyInstanceNodeNum
          • DescribeInstanceAnomalyEvents
          • DescribeOasClusterAnomalySqlList
          • DescribeOasClusterSlowSQLList
          • DescribeInstanceSqlAuditServiceInfo - Query SQL Audit Service Information
          • DescribeProxyClusterForInstance - Query ODP clusters associated with an instance
          • SwitchoverInstance - Perform a primary/standby switchover
        • Tenant management
          • DescribeTenants
          • DescribeTenant - Query Information of a Specified Tenant in a Specified Cluster
          • CreateTenants
          • DeleteTenants
          • ModifyTenantName
          • ModifyTenant
          • ModifyTenantUserDescription
          • ModifyTenantUserStatus
          • GetTenantCreateConstraints
          • ModifyTenantPrimaryZone
          • GetTenantCreateCpuConstraints
          • GetTenantCreateMemConstraints
          • GetTenantModifyCpuConstraints
          • GetTenantModifyMemConstraints
          • CreateTenantSecurityIpGroup
          • DescribeTenantSecurityIpGroups
          • ModifyTenantSecurityIpGroup
          • DeleteTenantSecurityIpGroup
          • DescribeTenantPrivateLink
          • DeletePrivatelinkConnection
          • CreatePrivatelinkService
          • ConnectPrivatelinkService
          • AddPrivatelinkServiceUser
          • BatchKillProcessList
          • DescribeProcessStatsComposition
          • DescribeTenantAddressInfo - Query Tenant Address Information
          • DescribeTenantAvailableRoZones
          • ModifyTenantReadonlyReplica
          • DescribeTenantParameters
          • UpdateTenantParameters
          • DescribeTenantParametersHistory
          • ModifyTenantTagList
          • CreateReadonlyPrivatelink
          • CreateReadwritePrivatelink
          • DescribeTenantPublicAddress - Query Tenant Public IP Address
          • DescribeTenantSqlAuditServiceInfo - Query SQL Audit Service Information for a Tenant
        • Tenant user management
          • CreateTenantUser
          • DescribeTenantUsers
          • DeleteTenantUsers
          • ModifyTenantUserPassword
          • ModifyTenantUserRoles
        • Database management
          • CreateDatabase
          • DescribeDatabases
          • DeleteDatabases
          • ModifyDatabaseUserRoles
          • DescribeTableSchema
        • Backup and restore
          • DescribeDataBackupSet
          • DescribeRestorableTenants
          • ModifyBackupStrategy
          • CreateTenantRestoreTask
          • CreateDataBackupTask
          • DescribeOneDataBackupSet
          • CreateBackupSetDownloadLink - Create a backup set download link
          • DeleteBackupSetDownloadTask - Delete a backup set download task
          • DescribeBackupSetDownloadLink - Query a backup set download link
          • DescribeBackupStrategy - Query backup strategy
        • Database proxy management
          • CreateTenantAddress
          • CreateTenantSingleTunnelSLBAddress
          • DeleteTenantAddress
          • DescribeTenantAddress
          • ModifyOdpClusterSpec
          • ModifyTenantAddressPort
          • ModifyTenantAddressDomainPrefix
          • ConfirmPrivatelinkConnection
          • DescribeTenantAddressInfo
        • Data source management
          • ListDataSources - List data sources
          • CreateDataSource - Create a data source
          • DeleteDataSource - Delete a data source
        • OMS project management
          • DescribeProject - Query project details
          • CreateProject - Create a project
          • DeleteProject - Delete a project
          • DescribeProjectSteps - Query project steps
          • StartProject - Start a project
          • StopProject - Stop a project
          • ResumeProject - Resume a project
          • ReleaseProject - Release project resources
          • UpdateProjectConfig - Update project configuration
          • ListProjectModifyRecords - List project modification records
          • CreateProjectModifyRecords - Create modification records (add or remove tables)
          • CancelProjectModifyRecord - Cancel a modification record
          • RetryProjectModifyRecords - Retry a modification
          • StopProjectModifyRecords - Terminate a modification
          • GetModifyRecord - Query modification record details
          • DescribeTransferMapping - Query transfer object mappings
        • Monitoring management
          • DescribeTenantMetrics
          • DescribeMetricsData
          • CreatePrometheusIntegration - Create a Prometheus Monitoring Integration
          • DeletePrometheusIntegration - Delete Prometheus Monitoring Integration
          • ListPrometheusIntegration - Query Prometheus Monitoring Integration List
          • DescribeNodeMetrics
        • Diagnostic management
          • DescribeOasTopSQLList
          • DescribeOasAnomalySQLList
          • DescribeOasSlowSQLList
          • DescribeOasSQLText
          • DescribeSqlAudits
          • DescribeOutlineBinding
          • DescribeSampleSqlRawTexts
          • DescribeSQLTuningAdvices
          • DescribeOasSlowSQLSamples
          • DescribeOasSQLTrends
          • DescribeOasSQLPlanGroup
          • DescribeRcaRecord
          • DescribeTopSQLComparision
          • DescribeSessionStatsGroupBySqlId
          • DescribeIndexes
          • DescribeOasHighRiskSQL
        • Security management
          • CreateSecurityIpGroup
          • DescribeInstanceSSL
          • ModifyInstanceSSL
          • DescribeTenantEncryption
          • ModifyTenantEncryption
          • ModifySecurityIps
          • DeleteSecurityIpGroup
          • DescribeTenantSecurityConfigs
          • DescribeInstanceSecurityConfigs
        • Tag management
          • DescribeTags
          • CreateTags
          • UpdateTag
          • DeleteTag
        • Historical event management
          • DescribeOperationEvents
        • AI service management
          • CreateAIServiceAPIKey
          • DeleteAIServiceAPIKey
          • ListAIServiceAPIKeys
      • Open API FAQ
      • Differences between ApsaraDB for OceanBase APIs and OceanBase Cloud APIs
    • Download OBClient
      • Download OBClient
      • Download OceanBase Connector/J
      • Download client ODC
      • Download OceanBase Connector/ODBC
      • Download OBClient Libs
    • Performance Tests
      • OLTP performance test: Sysbench benchmark
      • OLAP performance test: TPC-H benchmark
      • OLTP performance test: TPC-C benchmark
    • Metrics References
      • Cluster database
      • Cluster hosts
      • Binlog service
      • Cross-cloud network channel connection
      • Performance and SQL
      • Transactions
      • Storage and caching
      • Proxy database
      • Proxy host
    • ODC User Guide
      • What is ODC?
        • What is ODC?
        • Limitations
      • Quick start
        • Client ODC
          • Overview
          • Install Client ODC
          • Use Client ODC
        • Web ODC
          • Overview
          • Use Web ODC
      • Data source management
        • Create a data source
        • Data sources and project collaboration
        • Database O&M
          • Session management
          • Global variable management
          • Recycle bin management
      • SQL development
        • Edit and execute SQL statements
        • Perform PL compilation and debugging
        • Edit and export the result set of an SQL statement
        • Execution analysis
        • Generate test data
        • System settings
        • Database objects
          • Table objects
            • Overview
            • Create a table
          • View objects
            • Overview
            • Create a view
            • Manage views
          • Materialized view objects
            • Overview
            • Create a materialized view
            • Manage materialized views
          • Function objects
            • Overview
            • Create a function
            • Manage functions
          • Stored procedure objects
            • Overview
            • Create a stored procedure
            • Manage stored procedures
          • Sequence objects
            • Overview
            • Create a sequence
            • Manage sequences
          • Package objects
            • Overview
            • Create a program package
            • Manage program packages
          • Trigger objects
            • Overview
            • Create a trigger
            • Manage triggers
          • Type objects
            • Overview
            • Create a type
            • Manage types
          • Synonym objects
            • Overview
            • Create a synonym
            • Manage synonyms
      • Import and export
        • Import schemas and data
        • Export schemas and data
      • Database change management
        • User permission management
          • Users and roles
          • Automatic authorization
          • User permission management
        • Project collaboration management
        • Risk levels, risk identification rules, and approval processes
        • SQL check specifications
        • SQL window specification
        • Database change management
        • Batch database change management
        • Online schema changes
        • Synchronize shadow tables
        • Schema comparison
      • Data lifecycle management
        • Partitioning plan management
          • Manage partitioning plans
          • Set partitioning strategies
          • Examples
        • SQL plan task
      • Data desensitization and auditing
        • Desensitize data
        • Operation records
      • Notification management
        • Overview
        • View notification records
        • Manage notification channel
          • Create a notification channel
          • View, edit, and delete a notification channel
          • Configure a custom channel
        • Manage notification rules
      • Best practices
        • Tips for SQL development
        • Explore ODC team workspaces
        • Understanding real-time SQL diagnostics for OceanBase AP
        • OceanBase historical database solutions
        • ODC SQL check for automatic identification of high-risk operations
        • Manage and modify sharded databases and tables via ODC
        • Data masking and control practices
        • Enterprise-level control and collaboration: Safeguard every database change
    • Data development
      • Overview
      • Workspace management
      • Worksheet management
      • Compute node pool management
      • Workflow management
      • Dashboard management
      • Manage Git repositories
      • SQL development
        • SQL editing and execution
        • Result set editing
        • Execution analysis
        • Database object management
          • Create a table
          • Create a view
          • Create a function
          • Create a stored procedure
        • Session variable management
        • Git integration
      • Sample datasets
      • Data development terms
  • Manage Billing
    • Access billing
    • View bills
      • View orders
    • View monthly bills
    • View payment details
    • Manage AI service billing
      • Usage monitoring
      • View API key records
      • Rate limits & quotas
    • Payment method
      • Use vouchers for payment
    • View invoices
  • Legal Agreements
    • OceanBase Cloud Services Agreement
    • AI Service Addendum
    • Service Level Agreement
    • OceanBase Data Processing Addendum
    • Service Level Agreement for OceanBase Cloud Migration Service
    • Historical agreements
      • Service Level Agreement for OceanBase Cloud Migration Service (Released March 20, 2026)

Download PDF

Document Feedback
  1. Documentation Center
  2. OceanBase Cloud

Single-table queries

Last Updated:2026-09-22 03:22:12

Prerequisites
Syntax
Execution order of keywords in the SELECT statement
Create test tables and add test data to the tables
Basic queries
Query all columns
Query specified columns
Query calculated values and specify column aliases
Data filtering
Queries with comparison conditions
Queries with logical conditions
Fuzzy queries
Range queries
Queries with a specified set
NULL value queries
Data grouping
GROUP BY query based on a single field
GROUP BY query based on multiple fields
Filtering before grouping
Filtering after grouping
Sorting after grouping
Aggregate queries
Data sorting
Sorting by a single field
Sorting by multiple fields
Sorting by functions
Sorting after data filtering
LIMIT clause
Limit the number of rows in the result set
Pagination queries

This topic describes how to use SQL statements to perform single-table queries in OceanBase Cloud.

Prerequisites

  • You have connected to a MySQL-compatible tenant of OceanBase Cloud.
  • You have the SELECT privilege. If you do not have the required privileges, contact the administrator to obtain the privileges. For more information, see Manage tenant accounts.

Syntax

Use the SELECT statement to query data.

The general syntax of a single-table query using the SELECT statement is as follows:

SELECT [ALL | DISTINCT | UNIQUE | SQL_CALC_FOUND_ROWS] select_list
FROM table_name
[ WHERE query_condition ]
[ GROUP BY group_by_condition ]
[ HAVING group_condition ]
[ ORDER BY column_list ][ASC | DESC]
[ LIMIT limit_clause ]

column_list:
 column_name[,column_name...]

Parameters

Parameter
Description
select_list The list of columns to retrieve, which can be column names, expressions, or aggregate functions. Separate multiple columns with commas (,).
table_name The name of the table from which data is to be retrieved.
WHERE query_condition Optional. The query condition. Only rows that meet the condition will be returned.
GROUP BY group_by_condition Optional. Specifies to group the results by the specified column. This parameter is typically used with aggregate functions.
HAVING group_condition Optional. Specifies to filter the grouped result set. Only groups that meet the condition will be returned.
ORDER BY column_list Optional. Specifies to sort the result set. You can specify to sort one or more columns.
ASC | DESC Optional. The order of sorting. ASC indicates the ascending order, and DESC indicates the descending order. The default value is ASC.
LIMIT limit_clause Optional. Specifies to limit the number of rows returned in the result set.
column_list The list of columns to retrieve. You can specify one or more columns. Separate multiple columns with commas (,).
column_name The name of the column to retrieve.

Execution order of keywords in the SELECT statement

If you use the WHERE, GROUP BY, HAVING, ORDER BY, and LIMIT clauses in a query, these clauses are executed in strict accordance with the following sequence:

  1. The FROM clause is executed to find the required table.

  2. The WHERE clause is executed to specify conditions.

  3. The GROUP BY clause is executed to group or aggregate records. If GROUP BY is not executed, all records are considered a group.

  4. The HAVING clause is executed to filter the grouped results.

  5. The SELECT clause is executed.

  6. The DISTINCT clause is executed to remove duplicate rows.

  7. The ORDER BY clause is executed to sort the results in ascending or descending order.

  8. The LIMIT clause is executed to limit the number of records.

Notice

The difference between WHERE and HAVING is that WHERE filters data before grouping, while HAVING filters data after grouping and returns the entire SQL query result.

Create test tables and add test data to the tables

  1. Create a table named student.

    CREATE TABLE student (
      id INT PRIMARY KEY AUTO_INCREMENT,
      name VARCHAR(20) NOT NULL,
      gender TINYINT NOT NULL,
      age INT NOT NULL,
      score FLOAT NOT NULL,
      enrollment_date DATE NOT NULL,
      notes VARCHAR(50)
    );
    
  2. Insert 10 records into the student table.

    INSERT INTO student (name, gender, age, score, enrollment_date, notes)
      VALUES ('Emma', 0, 20, 85.0, '2021-09-01',NULL),
      ('William', 1, 21, 90.5, '2021-09-02','B'),
      ('Olivia', 0, 19, 95.5, '2021-09-03','A'),
      ('James', 1, 20, 87.5, '2021-09-03',NULL),
      ('Sophia', 0, 20, 91.5, '2021-09-05','B'),
      ('Benjamin', 1, 21, 96.5, '2021-09-01','A'),
      ('Ava', 0, 22, 89.5, '2021-09-06',NULL),
      ('Michael', 1, 18, 93.5, '2021-09-08','B'),
      ('Charlotte', 1, 19, 88.0, '2021-09-06',NULL),
      ('Ethan', 1, 20, 92.0, '2021-09-01','B');
    
  3. Create a table named fruit_order.

    CREATE TABLE fruit_order(
      order_id INT PRIMARY KEY AUTO_INCREMENT COMMENT 'Order ID',
      user_id BIGINT NOT NULL COMMENT 'Customer ID',
      user_name VARCHAR(16) NOT NULL DEFAULT '' COMMENT 'Customer name',
      fruit_price DECIMAL(10,2) NOT NULL DEFAULT 0 COMMENT 'Order amount',
      order_year SMALLINT NOT NULL COMMENT 'Year of order placement'
    ) COMMENT 'Order table';
    
  4. Insert 10 records into the fruit_order table.

    INSERT INTO fruit_order(user_id, user_name,fruit_price,order_year)
      VALUES (1011,'A1',13.11,'2019'),
      (1011,'A1',22.21,'2020'),
      (1011,'A1',58.83,'2020'),
      (1022,'B2',23.34,'2019'),
      (1022,'B2',12.22,'2019'),
      (1022,'B2',14.66,'2021'),
      (1022,'B2',34.44,'2021'),
      (1033,'C3',51.55,'2020'),
      (1033,'C3',63.66,'2021'),
      (1034,'D4',53.62,'2021');
    

Basic queries

When you use SELECT, we recommend that you use meaningful column aliases and properly organize the columns to improve the readability and organization of the result set, making it easier to understand the query results.

Query all columns

  • You can execute the SELECT * FROM student; statement to query all student information.

  • You can also execute the SELECT id,name,gender,age,score,enrollment_date FROM student; statement to query all student information.

Note

Although you can use an asterisk (*) to quickly list all fields, manually listing all fields in the statement improves query performance and code readability and maintainability.

Example 1: Query the data of all rows in the student table.

SELECT id, name, gender, age, score, enrollment_date, notes
FROM student;

or

SELECT * FROM student;

The return result is as follows:

+----+-----------+--------+-----+-------+-----------------+-------+
| id | name      | gender | age | score | enrollment_date | notes |
+----+-----------+--------+-----+-------+-----------------+-------+
|  1 | Emma      |      0 |  20 |    85 | 2021-09-01      | NULL  |
|  2 | William   |      1 |  21 |  90.5 | 2021-09-02      | B     |
|  3 | Olivia    |      0 |  19 |  95.5 | 2021-09-03      | A     |
|  4 | James     |      1 |  20 |  87.5 | 2021-09-03      | NULL  |
|  5 | Sophia    |      0 |  20 |  91.5 | 2021-09-05      | B     |
|  6 | Benjamin  |      1 |  21 |  96.5 | 2021-09-01      | A     |
|  7 | Ava       |      0 |  22 |  89.5 | 2021-09-06      | NULL  |
|  8 | Michael   |      1 |  18 |  93.5 | 2021-09-08      | B     |
|  9 | Charlotte |      1 |  19 |    88 | 2021-09-06      | NULL  |
| 10 | Ethan     |      1 |  20 |    92 | 2021-09-01      | B     |
+----+-----------+--------+-----+-------+-----------------+-------+
10 rows in set

Query specified columns

You can query data in specified columns based on column names.

Example 2: Query the data of all rows in the student table and return the data of the id and name columns in each row.

SELECT id, name
FROM student;

The return result is as follows:

+----+-----------+
| id | name      |
+----+-----------+
|  1 | Emma      |
|  2 | William   |
|  3 | Olivia    |
|  4 | James     |
|  5 | Sophia    |
|  6 | Benjamin  |
|  7 | Ava       |
|  8 | Michael   |
|  9 | Charlotte |
| 10 | Ethan     |
+----+-----------+
10 rows in set

Query calculated values and specify column aliases

You can calculate the data of specified columns in a query.

Example 3: Select data from the id, name, age, and age+5 columns of the student table, and specify the alias age_plus_5 for the age+5 column that stores the calculation result.

SELECT id, name, age, age+5 AS age_plus_5
FROM student;

The return result is as follows:

+----+-----------+-----+------------+
| id | name      | age | age_plus_5 |
+----+-----------+-----+------------+
|  1 | Emma      |  20 |         25 |
|  2 | William   |  21 |         26 |
|  3 | Olivia    |  19 |         24 |
|  4 | James     |  20 |         25 |
|  5 | Sophia    |  20 |         25 |
|  6 | Benjamin  |  21 |         26 |
|  7 | Ava       |  22 |         27 |
|  8 | Michael   |  18 |         23 |
|  9 | Charlotte |  19 |         24 |
| 10 | Ethan     |  20 |         25 |
+----+-----------+-----+------------+
10 rows in set

Note

For more information about how to use operators and functions to process data of specified columns in a query, see Use operators and functions in queries.

Data filtering

You can add a WHERE clause to the SELECT statement to query data that meets the specified conditions. The WHERE clause can contain one or more conditions for filtering data. Only data that meets the WHERE conditions will be returned. You can flexibly use query conditions based on specific requirements to filter and retrieve target data.

When you use the WHERE clause, make sure that the conditions are correct and appropriate operators are used.

The following table lists general query conditions specified by the WHERE clause.

Condition type
Predicate
Comparison condition =, >, <, >=, <=, !=, and <>
Logical condition (multiple conditions supported in a query) AND, OR, and NOT
Fuzzy condition (matching by characters) LIKE and NOT LIKE
Interval condition (with a specified range) BETWEEN AND and NOT BETWEEN AND
Condition with a specified set IN and NOT IN
Condition related to NULL values IS NULL and IS NOT NULL

Queries with comparison conditions

Equal to

The equal to operator (=) returns data equal to the target value in the specified column. If the value is a string, it needs to be enclosed in single quotation marks (' ') or double quotation marks (" ").

Example 4: Query all rows where gender values are equal to 1 in the student table, and return the data of the id, name, and gender columns in the rows.

SELECT id, name, gender
FROM student
WHERE gender = 1;    

The return result is as follows:

+----+-----------+--------+
| id | name      | gender |
+----+-----------+--------+
|  2 | William   |      1 |
|  4 | James     |      1 |
|  6 | Benjamin  |      1 |
|  8 | Michael   |      1 |
|  9 | Charlotte |      1 |
| 10 | Ethan     |      1 |
+----+-----------+--------+
6 rows in set

Not equal to

The not equal to operator includes two expressions: <> and !=.

Example 5: Query all rows where gender values are not equal to 1 in the student table, and return the data of the id, name, and gender columns in the rows.

SELECT id, name, gender
FROM student
WHERE gender <> 1;

The return result is as follows:

+----+--------+--------+
| id | name   | gender |
+----+--------+--------+
|  1 | Emma   |      0 |
|  3 | Olivia |      0 |
|  5 | Sophia |      0 |
|  7 | Ava    |      0 |
+----+--------+--------+
4 rows in set

Greater than and less than

The greater than operator (>) and the less than operator (<) compare numbers based on their values. If characters are compared, they are converted into their respective ASCII codes, and then the ASCII codes are compared from left to right.

Note

The greater than or equal to (>=) and less than or equal to (<=) operators operate in a similar manner.

Example 6: Query all rows where score values are less than 90 in the student table, and return the data of the id, name, and score columns in the rows.

SELECT id, name, score
FROM student
WHERE score < 90;

The return result is as follows:

+----+-----------+-------+
| id | name      | score |
+----+-----------+-------+
|  1 | Emma      |    85 |
|  4 | James     |  87.5 |
|  7 | Ava       |  89.5 |
|  9 | Charlotte |    88 |
+----+-----------+-------+
4 rows in set

Queries with logical conditions

Logical query operators AND and OR support queries with multiple conditions.

AND

You can use the AND keyword to combine multiple conditions. Only data that meets all the conditions will be returned.

Example 7: Query all rows where gender values are equal to 1 and score values are less than or equal to 90 in the student table, and return the data of the id, name, gender, and score columns in the rows.

SELECT id, name, gender, score
FROM student
WHERE gender = 1 AND score <= 90;

The return result is as follows:

+----+-----------+--------+-------+
| id | name      | gender | score |
+----+-----------+--------+-------+
|  4 | James     |      1 |  87.5 |
|  9 | Charlotte |      1 |    88 |
+----+-----------+--------+-------+
2 rows in set

OR

You can use the OR keyword to concatenate multiple conditions. Data that meets any one of the conditions will be returned.

Example 8: Query all rows where gender values are equal to 1 or score values are less than 90 in the student table, and return the data of the id, name, gender, and score columns in the rows.

SELECT id, name, gender, score
FROM student
WHERE gender = 1 OR score < 90;

The return result is as follows:

+----+-----------+--------+-------+
| id | name      | gender | score |
+----+-----------+--------+-------+
|  1 | Emma      |      0 |    85 |
|  2 | William   |      1 |  90.5 |
|  4 | James     |      1 |  87.5 |
|  6 | Benjamin  |      1 |  96.5 |
|  7 | Ava       |      0 |  89.5 |
|  8 | Michael   |      1 |  93.5 |
|  9 | Charlotte |      1 |    88 |
| 10 | Ethan     |      1 |    92 |
+----+-----------+--------+-------+
8 rows in set

Fuzzy queries

You can use the LIKE predicate for fuzzy matching of strings.

The syntax means finding data that matches the corresponding column value with the pattern. The pattern can be a complete string or contain wildcards % and _, where:

  • The underscore (_) exactly matches any character in the value.

  • The percent sign (%) matches zero or multiple characters in the value, but cannot match NULL.

Notice

If the database character set is ASCII, one Chinese character needs two underscores (_); if the database character set is GBK, one Chinese character needs only one underscore (_).

Example 9: Query all rows where name values contain am in the student table, and return the data of the id and name columns in the rows.

SELECT id, name
FROM student
WHERE name LIKE '%am%';

The return result is as follows:

+----+----------+
| id | name     |
+----+----------+
|  2 | William  |
|  4 | James    |
|  6 | Benjamin |
+----+----------+
3 rows in set

Range queries

The BETWEEN AND operator selects data between two values. These values can be numerals, literals, or dates.

Notice

The boundary values of a range query cannot be exchanged, as the values within the range must be greater than or equal to the left boundary and less than or equal to the right boundary.

Example 10: Query all rows where score values range from 85 to 90 in the student table, and return the data of the id, name, and score columns in the rows.

SELECT id, name, score
FROM student
WHERE score BETWEEN 85 AND 90;

The return result is as follows:

+----+-----------+-------+
| id | name      | score |
+----+-----------+-------+
|  1 | Emma      |    85 |
|  4 | James     |  87.5 |
|  7 | Ava       |  89.5 |
|  9 | Charlotte |    88 |
+----+-----------+-------+
4 rows in set

Queries with a specified set

The IN operator specifies multiple values in a WHERE clause. The values can be treated as a set. The IN operator returns data, in the specified column, that matches any value in the set. The NOT IN operator returns data, in the specified column, that does not match any value in the set.

Notice

  • The values in the [NOT] IN set must be of the same type or compatible types.
  • The values in the [NOT] IN set do not support wildcards.

Example 11: Query all rows where id values belong to the set of (1, 3, 5, 7) in the student table, and return the data of the id and name columns in the rows.

SELECT id, name
FROM student
WHERE id IN (1,3,5,7);

The return result is as follows:

+----+--------+
| id | name   |
+----+--------+
|  1 | Emma   |
|  3 | Olivia |
|  5 | Sophia |
|  7 | Ava    |
+----+--------+
4 rows in set

NULL value queries

Since you cannot obtain accurate results when you use comparison operators, LIKE, BETWEEN AND, IN, and NOT IN to query NULL values, we recommend that you use the dedicated query conditions IS NULL and IS NOT NULL for NULL value queries. You can also use the NULL-safe equal to operator (<=>) to compare both NULL values and normal numerals.

IS NULL

You can use the IS NULL condition to query the data where the value of the specified column is NULL.

Example 12: Query all rows whose notes values are NULL in the student table, and return the data of the id, name, score, and notes columns in the rows.

SELECT id, name, score, notes
FROM student
WHERE notes IS NULL;

The return result is as follows:

+----+-----------+-------+-------+
| id | name      | score | notes |
+----+-----------+-------+-------+
|  1 | Emma      |    85 | NULL  |
|  4 | James     |  87.5 | NULL  |
|  7 | Ava       |  89.5 | NULL  |
|  9 | Charlotte |    88 | NULL  |
+----+-----------+-------+-------+
4 rows in set

IS NOT NULL

You can use the IS NOT NULL condition to query the data where the value of the specified column is not NULL.

Example 13: Query all rows whose notes values are not NULL in the student table, and return the data of the id, name, score, and notes columns in the rows.

SELECT id, name, score, notes
FROM student
WHERE notes IS NOT NULL;

The return result is as follows:

+----+----------+-------+-------+
| id | name     | score | notes |
+----+----------+-------+-------+
|  2 | William  |  90.5 | B     |
|  3 | Olivia   |  95.5 | A     |
|  5 | Sophia   |  91.5 | B     |
|  6 | Benjamin |  96.5 | A     |
|  8 | Michael  |  93.5 | B     |
| 10 | Ethan    |    92 | B     |
+----+----------+-------+-------+
6 rows in set

Data grouping

You can use the GROUP BY clause to group the query results in SQL queries. GROUP BY supports grouping by a single field or multiple fields. You can also use the WHERE clause to filter data before grouping, use the HAVING clause to filter data after grouping, and use the ORDER BY clause to sort data after grouping.

Considerations

  • When you use the GROUP BY clause, make sure that the columns in the SELECT statement are either included in the GROUP BY clause or used as aggregate functions.
  • When you use the HAVING clause, make sure that the conditions are applied to the grouped results, not the original data.

GROUP BY query based on a single field

Example 14: Query the number of orders placed by each customer in the fruit_order table, and return the data of the user_id and COUNT(order_id) columns.

SELECT user_id, COUNT(order_id)
FROM fruit_order
GROUP BY user_id;

The return result is as follows:

+---------+-----------------+
| user_id | COUNT(order_id) |
+---------+-----------------+
|    1011 |               3 |
|    1022 |               4 |
|    1033 |               2 |
|    1034 |               1 |
+---------+-----------------+
4 rows in set

GROUP BY query based on multiple fields

Example 15: Query the number of orders placed by each customer each year in the fruit_order table, and return the data of the user_id, order_year, and COUNT(order_id) columns.

SELECT user_id, order_year, COUNT(order_id)
FROM fruit_order
GROUP BY user_id,order_year;

The return result is as follows:

+---------+------------+-----------------+
| user_id | order_year | COUNT(order_id) |
+---------+------------+-----------------+
|    1011 |       2019 |               1 |
|    1011 |       2020 |               2 |
|    1022 |       2019 |               2 |
|    1022 |       2021 |               2 |
|    1033 |       2020 |               1 |
|    1033 |       2021 |               1 |
|    1034 |       2021 |               1 |
+---------+------------+-----------------+
7 rows in set

Filtering before grouping

Example 16: Query the number of orders placed by each customer in 2020, and return the data of the user_id and COUNT(order_id) columns.

SELECT user_id, COUNT(order_id)
FROM fruit_order t
WHERE t.order_year = 2020
GROUP BY user_id;

The return result is as follows:

+---------+-----------------+
| user_id | COUNT(order_id) |
+---------+-----------------+
|    1011 |               2 |
|    1033 |               1 |
+---------+-----------------+
2 rows in set

Filtering after grouping

Note

When a query includes the HAVING clause, it first obtains the SQL query results without the HAVING clause, then uses the HAVING clause to filter the data based on these results, and finally returns the filtered data. Therefore, after HAVING, you can use aggregate functions, and these aggregate functions do not have to be the same as those following SELECT.

Example 17: Query customers who placed two or more orders in 2019, and return the data of the user_id and COUNT(order_id) columns.

SELECT user_id, COUNT(order_id)
FROM fruit_order t
WHERE t.order_year = 2019
GROUP BY user_id
HAVING COUNT(order_id) >= 2;

The return result is as follows:

+---------+-----------------+
| user_id | COUNT(order_id) |
+---------+-----------------+
|    1022 |               2 |
+---------+-----------------+
1 row in set

Sorting after grouping

Example 18: Query the maximum order amount of each customer, and return the data of the user_id and MAX(fruit_price) columns sorted by the maximum order amount in descending order.

SELECT user_id, MAX(fruit_price)
FROM fruit_order t
GROUP BY user_id
ORDER BY MAX(fruit_price) DESC;

The return result is as follows:

+---------+------------------+
| user_id | MAX(fruit_price) |
+---------+------------------+
|    1033 |            63.66 |
|    1011 |            58.83 |
|    1034 |            53.62 |
|    1022 |            34.44 |
+---------+------------------+
4 rows in set

Aggregate queries

An aggregate query aggregates data and returns a summary of results. It can collect statistics on, count, or calculate the sum, average value, maximum value, or minimum value of a set of data. An aggregate query is usually used with the GROUP BY clause to group data and aggregate each group of data. The GROUP BY clause groups data based on specified columns. Then an aggregate function is applied to each group to generate a result set.

The following table lists frequently-used aggregate functions in GROUP BY queries.

Aggregate function
Description
MAX() Queries the maximum value of the specified column.
MIN() Queries the minimum value of the specified column.
COUNT() Returns the number of rows in the query result.
SUM() Returns the sum of the specified column.
AVG() Returns the average value of the data in the specified column.

Data sorting

Data sorting is an operation that arranges the query results based on specified columns or expressions, allowing data to be rearranged in either ascending (ASC) or descending (DESC) order. You can use the ORDER BY clause to specify the sorting method in SQL queries. ORDER BY supports sorting by a single field, multiple fields, an alias, or a function. Separate multiple fields with commas (,). If the ASC or DESC keyword is not added in the ORDER BY clause, the query results are sorted in ascending order by default.

The ORDER BY clause consumes a large amount of resources, especially when you use it to sort large datasets. We recommend that you use indexes to optimize the sorting operation when necessary. Make sure that the correct columns and sorting order are specified.

Sorting by a single field

Example 19: Query student information in the student table, and return the information sorted by score in ascending order.

SELECT id, name, score
FROM student
ORDER BY score;

The return result is as follows:

+----+-----------+-------+
| id | name      | score |
+----+-----------+-------+
|  1 | Emma      |    85 |
|  4 | James     |  87.5 |
|  9 | Charlotte |    88 |
|  7 | Ava       |  89.5 |
|  2 | William   |  90.5 |
|  5 | Sophia    |  91.5 |
| 10 | Ethan     |    92 |
|  8 | Michael   |  93.5 |
|  3 | Olivia    |  95.5 |
|  6 | Benjamin  |  96.5 |
+----+-----------+-------+
10 rows in set

Example 20: Query student information in the student table, and return the information sorted by score in descending order.

SELECT id, name, score
FROM student
ORDER BY score DESC;

The return result is as follows:

+----+-----------+-------+
| id | name      | score |
+----+-----------+-------+
|  6 | Benjamin  |  96.5 |
|  3 | Olivia    |  95.5 |
|  8 | Michael   |  93.5 |
| 10 | Ethan     |    92 |
|  5 | Sophia    |  91.5 |
|  2 | William   |  90.5 |
|  7 | Ava       |  89.5 |
|  9 | Charlotte |    88 |
|  4 | James     |  87.5 |
|  1 | Emma      |    85 |
+----+-----------+-------+
10 rows in set

Sorting by multiple fields

Example 21: Query student information in the student table, and return the information sorted by enrollment_date in descending order and by score in ascending order.

SELECT id, name, score, enrollment_date
FROM student
ORDER BY enrollment_date DESC,score ASC;

The return result is as follows:

+----+-----------+-------+-----------------+
| id | name      | score | enrollment_date |
+----+-----------+-------+-----------------+
|  8 | Michael   |  93.5 | 2021-09-08      |
|  9 | Charlotte |    88 | 2021-09-06      |
|  7 | Ava       |  89.5 | 2021-09-06      |
|  5 | Sophia    |  91.5 | 2021-09-05      |
|  4 | James     |  87.5 | 2021-09-03      |
|  3 | Olivia    |  95.5 | 2021-09-03      |
|  2 | William   |  90.5 | 2021-09-02      |
|  1 | Emma      |    85 | 2021-09-01      |
| 10 | Ethan     |    92 | 2021-09-01      |
|  6 | Benjamin  |  96.5 | 2021-09-01      |
+----+-----------+-------+-----------------+
10 rows in set

Sorting by functions

You can use functions in the ORDER BY clause to sort query results. The functions can be applied to specified columns or expressions to support complex data sorting.

Example 22: Query student information in the student table, and return the information sorted by DAY(enrollment_date) in descending order and by score in ascending order.

SELECT id, name, score, enrollment_date
FROM student
ORDER BY DAY(enrollment_date) DESC,score ASC;

The return result is as follows:

+----+-----------+-------+-----------------+
| id | name      | score | enrollment_date |
+----+-----------+-------+-----------------+
|  8 | Michael   |  93.5 | 2021-09-08      |
|  9 | Charlotte |    88 | 2021-09-06      |
|  7 | Ava       |  89.5 | 2021-09-06      |
|  5 | Sophia    |  91.5 | 2021-09-05      |
|  4 | James     |  87.5 | 2021-09-03      |
|  3 | Olivia    |  95.5 | 2021-09-03      |
|  2 | William   |  90.5 | 2021-09-02      |
|  1 | Emma      |    85 | 2021-09-01      |
| 10 | Ethan     |    92 | 2021-09-01      |
|  6 | Benjamin  |  96.5 | 2021-09-01      |
+----+-----------+-------+-----------------+
10 rows in set

Sorting after data filtering

You can use the WHERE clause to filter data before sorting.

Example 23: Query information about students whose score values are greater than 85 in the student table, and return the information sorted by DAY(enrollment_date) in ascending order.

SELECT id, name, score, DAY(enrollment_date)
FROM student
WHERE score > 85
ORDER BY DAY(enrollment_date) ASC;

The return result is as follows:

+----+-----------+-------+----------------------+
| id | name      | score | DAY(enrollment_date) |
+----+-----------+-------+----------------------+
|  6 | Benjamin  |  96.5 |                    1 |
| 10 | Ethan     |    92 |                    1 |
|  2 | William   |  90.5 |                    2 |
|  3 | Olivia    |  95.5 |                    3 |
|  4 | James     |  87.5 |                    3 |
|  5 | Sophia    |  91.5 |                    5 |
|  7 | Ava       |  89.5 |                    6 |
|  9 | Charlotte |    88 |                    6 |
|  8 | Michael   |  93.5 |                    8 |
+----+-----------+-------+----------------------+
9 rows in set

LIMIT clause

Limit the number of rows in the result set

You can use the LIMIT clause to limit the number of rows returned in the result set for an SQL query.

The format of the LIMIT clause to limit the number of rows is as follows:

LIMIT [offset,] row_count

or

LIMIT row_count OFFSET offset

where

  • offset specifies the number of rows to skip. In the first format, offset is optional, and its default value is 0, indicating that zero rows are to be skipped. The value range is [0, +∞).

  • row_count specifies the number of rows to be returned. In the first format, if offset is not specified, data is returned starting from the first row by default. The value range is [0, +∞).

Notice

Take note of the following limitations on the values of offset and row_count:

  • Expressions are not supported.
  • Only explicit numerical values are allowed, and they cannot be negative.

Retrieve the first m rows of records

Example 24: Retrieve the first five rows of the student table, and return the data of the id and name columns.

SELECT id, name
FROM student
LIMIT 5;

The return result is as follows:

+----+---------+
| id | name    |
+----+---------+
|  1 | Emma    |
|  2 | William |
|  3 | Olivia  |
|  4 | James   |
|  5 | Sophia  |
+----+---------+
5 rows in set

Retrieve the record with the maximum value

Example 25: Sort data in the student table by score in descending order, and retrieve the first row to obtain the record with the maximum score value.

SELECT id, name, score
FROM student
ORDER BY score DESC
LIMIT 1;

The return result is as follows:

+----+----------+-------+
| id | name     | score |
+----+----------+-------+
|  6 | Benjamin |  96.5 |
+----+----------+-------+
1 row in set

Obtain the m rows of records following the n skipped rows of records

Note

When less than m rows remain after you skip n rows, all the remaining data is returned in the query result.

Example 26: Retrieve the three rows following the fifth row in the student table, and return the data of the id and name columns.

SELECT id, name
FROM student
LIMIT 3 OFFSET 5;

The return result is as follows:

+----+----------+
| id | name     |
+----+----------+
|  6 | Benjamin |
|  7 | Ava      |
|  8 | Michael  |
+----+----------+
3 rows in set

Pagination queries

You can use the LIMIT clause to implement pagination queries.

The format of the LIMIT clause for pagination is as follows:

LIMIT (page_no - 1) * page_size, page_size;

where

  • page_no specifies the page number. The value range is [1, +∞).

  • page_size specifies the number of records per page. The value range is [1, +∞). For example, if page_no is set to 5 and page_size is set to 10, the 10 records on page 5 are retrieved.

Example 27: For the student table, set page_size to 2 to retrieve data of page 1, page 2, and page 3.

Page 1:

SELECT id, name
FROM student
ORDER BY id
LIMIT 0,2;

The return result is as follows:

+----+---------+
| id | name    |
+----+---------+
|  1 | Emma    |
|  2 | William |
+----+---------+
2 rows in set

Page 2:

SELECT id, name
FROM student
ORDER BY id
LIMIT 2,2;

The return result is as follows:

+----+--------+
| id | name   |
+----+--------+
|  3 | Olivia |
|  4 | James  |
+----+--------+
2 rows in set

Page 3:

SELECT id, name
FROM student
ORDER BY id
LIMIT 4,2;

The return result is as follows:

+----+----------+
| id | name     |
+----+----------+
|  5 | Sophia   |
|  6 | Benjamin |
+----+----------+
2 rows in set

Previous topic

Generate test data in batches
Last

Next topic

INNER JOIN queries
Next
on this page
Prerequisites
Syntax
Execution order of keywords in the SELECT statement
Create test tables and add test data to the tables
Basic queries
Query all columns
Query specified columns
Query calculated values and specify column aliases
Data filtering
Queries with comparison conditions
Queries with logical conditions
Fuzzy queries
Range queries
Queries with a specified set
NULL value queries
Data grouping
GROUP BY query based on a single field
GROUP BY query based on multiple fields
Filtering before grouping
Filtering after grouping
Sorting after grouping
Aggregate queries
Data sorting
Sorting by a single field
Sorting by multiple fields
Sorting by functions
Sorting after data filtering
LIMIT clause
Limit the number of rows in the result set
Pagination queries