openharmony 鸿蒙 arkts-apis-data-relationalStore

2026-08-25 浏览 (1)

Module Description

The relational database (RDB) manages data based on relational models. The relationalStore module provides a complete mechanism for managing local databases based on the underlying SQLite. You can use the APIs to perform operations such as adding, deleting, modifying, and querying data, and directly run SQL statements. In addition, you can obtain sendable data using ResultSet.getSendableRow and transfer the data across threads.

To ensure successful data access, limit the size of a data record to 2 MB. If a data record exceeds 2 MB, it can be inserted successfully but cannot be read.

Querying data from a large amount of data may take time or even cause application suspension. In this case, you can perform batch operations. For details, see Batch Database Operations. Moreover, observe the following:

  • The number of data records to be queried at a time should not exceed 5000.
  • Use TaskPool if there is a large amount of data needs to be queried.
  • Keep concatenated SQL statements as concise as possible.
  • Query data in batches.

The relationalStore module provides the following functionalities:

  • RdbPredicates: provides predicates indicating the nature, feature, or relationship of a data entity in an RDB store. It is used to define the operation conditions for an RDB store.
  • RdbStore: provides APIs for managing data in an RDB store.
  • ResultSet: provides APIs for accessing the result set obtained from the RDB store.
  • LiteResultSet: provides APIs for accessing the result set obtained from the RDB store, such as queryWithoutRowCount and querySqlWithoutRowCount. Unlike ResultSet, LiteResultSet does not include the total number of rows in the query result.
  • Transaction: provides APIs for managing transaction objects.

NOTE

The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Module to Import

import { relationalStore } from '@kit.ArkData';

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 js-apis-distributedKVStore-sys

openharmony 鸿蒙 capi-oh-preferences-h

openharmony 鸿蒙 capi-udmf-oh-udshyperlink

openharmony 鸿蒙 js-apis-data-dataSharePredicates

openharmony 鸿蒙 capi-udmf-oh-udsappitem

openharmony 鸿蒙 capi-rdb-oh-data-vbuckets

openharmony 鸿蒙 capi-rdb-oh-predicates

openharmony 鸿蒙 capi-rdb-oh-data-value

openharmony 鸿蒙 capi-preferences-oh-preferencespair

openharmony 鸿蒙 errorcode-datashare

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/o1uAhBeM