OceanBase logo

OceanBase

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

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

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

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

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

About OceanBase

Partner

Trust Center

Contact Us

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

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

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

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

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

Practical guides for utilizing OceanBase more effectively and conveniently

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

About OceanBase

Partner

Trust Center

Contact Us

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

OceanBase Database

KV - V4.3.5

  • OBKV overview
  • Architecture
  • OBKV-Table
    • Introduction to OBKV-Table
      • Overview
      • OBKV-Table operation types
      • Core features of OBKV-Table
      • Differences between replace and insert_or_update
      • Supported value types
      • OBKV-Table data models
    • Use the OBKV-Table Java client
      • Java development guide for OBKV-Table
      • Prepare for development with OBKV-Table
      • Use the OBKV-Table Java client to connect to a cluster
      • Set client parameters
      • Supported client interfaces
      • Use the OBKV-Table Java client
    • Use the OBKV-Table GO client
      • Use the OBKV-Table Go client to connect to a cluster
      • Overview of the Go client
      • Individual API operations
      • Batch operations
      • About queries
      • Aggregation API
      • Filters
    • FAQ
  • OBKV-HBase
    • Overview
    • OBKV-HBase core features
    • Compatibility with HBase
    • Deployment
    • Application development with OBKV-HBase
      • Overview of OBKV-HBase application development
      • Data model
      • Data model design
      • Connect to a cluster using the OBKV-HBase client
      • Migrate HBase business code to OBKV-HBase
      • Data operation examples
      • Delete expired data
    • OBKV-HBase migration guide
    • OBKV-HBase management
      • Overview
      • High availability
      • Security and permissions
      • Monitoring metrics
    • Performance test
    • OBKV-HBase integrations
      • Flink
        • Synchronize data to OBKV-HBase by using Flink
    • Views
    • FAQ

Download PDF

OBKV overview Architecture Overview OBKV-Table operation types Core features of OBKV-Table Differences between replace and insert_or_update Supported value types OBKV-Table data models Java development guide for OBKV-Table Prepare for development with OBKV-Table Use the OBKV-Table Java client to connect to a cluster Set client parameters Supported client interfaces Use the OBKV-Table Java client Use the OBKV-Table Go client to connect to a cluster Overview of the Go client Individual API operations Batch operations About queries Aggregation API Filters FAQ Overview OBKV-HBase core features Compatibility with HBase Deployment Overview of OBKV-HBase application development Data model Data model design Connect to a cluster using the OBKV-HBase client Migrate HBase business code to OBKV-HBase Data operation examples Delete expired data OBKV-HBase migration guide Overview High availability Security and permissions Monitoring metrics Performance test Views FAQ
OceanBase logo

The Unified Distributed Database for the AI Era.

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

© OceanBase 2026. All rights reserved

Cloud Service AgreementPrivacy PolicySecurity
Contact Us
Document Feedback
  1. Documentation Center
  2. OceanBase Database
  3. KV
  4. V4.3.5
iconOceanBase Database
KV - V 4.3.5
SQL
KV
  • V 4.3.5

About queries

Last Updated:2025-09-08 11:41:13  Updated
share
What is on this page
Get a query iterator
ObQueryOption
QueryResultIterator
QueryResult
Example

folded

share

Get a query iterator

The syntax is as follows:

type Client interface {
    // Query records by rangePairs.
    Query(ctx context.Context, tableName string, rangePairs []*table.RangePair, opts ...option.ObQueryOption) (QueryResultIterator, error)
}

Input parameters:

  • ctx: the API timeout period.
  • tableName: the name of the table.
  • rangePairs: the primary key.
  • opts: the additional options. This parameter is optional.

Response parameters:

  • QueryResultIterator: the query iterator to obtain the result.
  • error: the error code and error message.

ObQueryOption

The syntax is as follows:

type ObQueryOptions struct {
    QueryFilter   filter.ObTableFilter
    HTableFilter  hfilter.ObHTableFilter
    SelectColumns []string
    IndexName     string
    BatchSize     int32
    MaxResultSize int64
    Limit         int32
    Offset        int32
    ScanOrder     table.ScanOrder
    IsHbaseQuery  bool
    KeyValueMode  table.ObKeyValueMode
}

Note

You can set most available parameters in the format of option.WithQuery+corresponding parameter(). You can set the Limit parameter in the format of option.WithQueryLimit().

Input parameters:

  • WithQueryFilter: the query filter.
  • WithQuerySelectColumns: the names of the columns whose values need to be returned. The names of the columns that use filters and the columns whose values need to be returned must be included.
  • WithQueryIndexName: the index name. The default value is the primary key.
  • WithQueryBatchSize: the maximum number of results carried in a packet during network communication.
  • WithQueryMaxResultSize: the maximum number of packets to be returned.
  • WithQueryLimit: the maximum number of results for a partition.
  • WithQueryOffset: the result sequence number starting from which results are returned.
  • WithQueryScanOrder: the scan order.

QueryResultIterator

The syntax is as follows:

type QueryResultIterator interface {
    IsClosed() bool
    Close()
    Next() (QueryResult, error)
    NextBatch() ([]QueryResult, error)
}

Input parameters:

  • IsClosed(): specifies whether to disable the iterator.
  • Close(): specifies to disable the iterator.
  • Next(): specifies to obtain the next output. The result is of the QueryResult type. This parameter cannot be used with NextBatch().
  • NextBatch(): specifies to obtain the next batch of output. The result type is a QueryResult array. This parameter cannot be used with Next().

QueryResult

The syntax is as follows:

type QueryResult interface {
    Value(columnName string) interface{}
    Values() []interface{}
}

Input parameters:

  • Value(columnName string): obtains the values of the column specified by columnName. If the column does not exist, nil is returned.
  • Values(): obtains the values of a row.

Example

func main() {
    const (
        configUrl    = "xxx"
        fullUserName = "user@tenant#cluster"
        passWord     = ""
        sysUserName  = "sysUser"
        sysPassWord  = ""
        tableName    = "test"
    )
    cfg := config.NewDefaultClientConfig()
    cli, err := client.NewClient(configUrl, fullUserName, passWord, sysUserName, sysPassWord, cfg)
    if err != nil {
        panic(err)
    }

    startRowKey := []*table.Column{table.NewColumn("c1", int64(0)), table.NewColumn("c2", table.Min)}
    endRowKey := []*table.Column{table.NewColumn("c1", int64(100)), table.NewColumn("c2", table.Max)}
    keyRanges := []*table.RangePair{table.NewRangePair(startRowKey, endRowKey)}

    lt30 := filter.CompareVal(filter.LessThan, "c2", int64(30))
    gt10 := filter.CompareVal(filter.GreaterThan, "c2", int64(10))
    filterList := filter.AndList(lt30, gt10)

    resSet, err := cli.Query(
        context.TODO(),
        tableName,
        keyRanges,
        option.WithQuerySelectColumns([]string{"c1", "c2", "c3"}),
        option.WithQueryBatchSize(batchSize),
        option.WithQueryFilter(filterList),
    )
    assert.Equal(t, nil, err)
    i := 0
    res, err := resSet.Next()
    for ; res != nil && err == nil; res, err = resSet.Next() {
        assert.EqualValues(t, res.Value("c1"), res.Value("c2"))
        assert.EqualValues(t, "hello", res.Value("c3"))
        i++
    }
    assert.Equal(t, nil, err)
    assert.EqualValues(t, 19, i)

Note

All rows whose c1 values are within the range of 0 to 100 are scanned, and then the values of the c1, c2, and c3 columns of the rows that meet the following conditions are returned: c2 > 10 and c2 < 30.

Previous topic

Batch operations
Last

Next topic

Aggregation API
Next
What is on this page
Get a query iterator
ObQueryOption
QueryResultIterator
QueryResult
Example