1e41f4b71Sopenharmony_ci# @ohos.data.relationalStore (RDB Store)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe relational database (RDB) store manages data based on relational models. It provides a complete mechanism for managing local databases based on the underlying SQLite. To satisfy different needs in complicated scenarios, the RDB store offers APIs for performing operations such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. It also allows sendable data to be obtained by using [ResultSet.getSendableRow](#getsendablerow12) and transferred across threads.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ciThe maximum size of a data record is 2 MB. If a data record exceeds 2 MB, it can be inserted successfully but cannot be read.
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciThe application may be suspended if a large amount of data is queried. To prevent this problem, observe the following:
8e41f4b71Sopenharmony_ci- The number of data records to be queried at a time should not exceed 5000.
9e41f4b71Sopenharmony_ci- Use [TaskPool](../apis-arkts/js-apis-taskpool.md) if there is a large amount of data needs to be queried.
10e41f4b71Sopenharmony_ci- Keep concatenated SQL statements as concise as possible.
11e41f4b71Sopenharmony_ci- Query data in batches.
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ciThe **relationalStore** module provides the following functionalities:
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci- [RdbPredicates](#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.
16e41f4b71Sopenharmony_ci- [RdbStore](#rdbstore): provides APIs for managing data in an RDB store.
17e41f4b71Sopenharmony_ci- [Resultset](#resultset): provides APIs for accessing the result set obtained from the RDB store. 
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci> **NOTE**
20e41f4b71Sopenharmony_ci> 
21e41f4b71Sopenharmony_ci> 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.
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci## Modules to Import
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci```ts
26e41f4b71Sopenharmony_ciimport { relationalStore } from '@kit.ArkData';
27e41f4b71Sopenharmony_ci```
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci## relationalStore.getRdbStore
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_cigetRdbStore(context: Context, config: StoreConfig, callback: AsyncCallback<RdbStore>): void
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ciObtains an RDB store. This API uses an asynchronous callback to return the result. You can set parameters for the RDB store based on service requirements and call APIs to perform data operations.
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ciIf error code 14800011 is returned when this API is used to obtain an encrypted RDB store, check the value of **encrypt** in **StoreConfig**. The encrypted RDB store can be obtained successfully when **encrypt** is **true**.
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ciCurrently, **getRdbStore()** does not support multi-thread concurrent operations.
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci**Parameters**
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci| Name  | Type                                          | Mandatory| Description                                                        |
44e41f4b71Sopenharmony_ci| -------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ |
45e41f4b71Sopenharmony_ci| context  | Context                                        | Yes  | Application context.<br>For details about the application context of the FA model, see [Context](../apis-ability-kit/js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-uiAbilityContext.md).|
46e41f4b71Sopenharmony_ci| config   | [StoreConfig](#storeconfig)               | Yes  | Configuration of the RDB store.                               |
47e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;[RdbStore](#rdbstore)&gt; | Yes  | Callback used to return the RDB store obtained.                  |
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci**Error codes**
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci| **ID**| **Error Message**  |
54e41f4b71Sopenharmony_ci|-----------|---------|
55e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
56e41f4b71Sopenharmony_ci| 14800000  | Inner error.     |
57e41f4b71Sopenharmony_ci| 14800010  | Invalid database path.   |
58e41f4b71Sopenharmony_ci| 14800011  | Database corrupted.    |
59e41f4b71Sopenharmony_ci| 14801001  | Only supported in stage mode.    |
60e41f4b71Sopenharmony_ci| 14801002  | The data group id is not valid.     |
61e41f4b71Sopenharmony_ci| 14800017  | Config changed.   |
62e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error.    |
63e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort.   |
64e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied.    |
65e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database.   |
66e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred.     |
67e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full.  |
68e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file.   |
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci**Example**
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ciFA model:
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
75e41f4b71Sopenharmony_ci```js
76e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
77e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_cilet store: relationalStore.RdbStore | undefined = undefined;
80e41f4b71Sopenharmony_cilet context = featureAbility.getContext(); 
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ciconst STORE_CONFIG: relationalStore.StoreConfig = {
83e41f4b71Sopenharmony_ci  name: "RdbTest.db",
84e41f4b71Sopenharmony_ci  securityLevel: relationalStore.SecurityLevel.S3
85e41f4b71Sopenharmony_ci};
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_cirelationalStore.getRdbStore(context, STORE_CONFIG, (err: BusinessError, rdbStore: relationalStore.RdbStore) => {
88e41f4b71Sopenharmony_ci  store = rdbStore;
89e41f4b71Sopenharmony_ci  if (err) {
90e41f4b71Sopenharmony_ci    console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
91e41f4b71Sopenharmony_ci    return;
92e41f4b71Sopenharmony_ci  }
93e41f4b71Sopenharmony_ci  console.info('Get RdbStore successfully.');
94e41f4b71Sopenharmony_ci})
95e41f4b71Sopenharmony_ci```
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ciStage model:
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci```ts
100e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
101e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
102e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
103e41f4b71Sopenharmony_ci
104e41f4b71Sopenharmony_cilet store: relationalStore.RdbStore | undefined = undefined;
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ciclass EntryAbility extends UIAbility {
107e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage) {
108e41f4b71Sopenharmony_ci    const STORE_CONFIG: relationalStore.StoreConfig = {
109e41f4b71Sopenharmony_ci      name: "RdbTest.db",
110e41f4b71Sopenharmony_ci      securityLevel: relationalStore.SecurityLevel.S3
111e41f4b71Sopenharmony_ci    };
112e41f4b71Sopenharmony_ci        
113e41f4b71Sopenharmony_ci    relationalStore.getRdbStore(this.context, STORE_CONFIG, (err: BusinessError, rdbStore: relationalStore.RdbStore) => {
114e41f4b71Sopenharmony_ci      store = rdbStore;
115e41f4b71Sopenharmony_ci      if (err) {
116e41f4b71Sopenharmony_ci        console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
117e41f4b71Sopenharmony_ci        return;
118e41f4b71Sopenharmony_ci      }
119e41f4b71Sopenharmony_ci      console.info('Get RdbStore successfully.');
120e41f4b71Sopenharmony_ci    })
121e41f4b71Sopenharmony_ci  }
122e41f4b71Sopenharmony_ci}
123e41f4b71Sopenharmony_ci```
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ci## relationalStore.getRdbStore
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_cigetRdbStore(context: Context, config: StoreConfig): Promise&lt;RdbStore&gt;
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ciObtains an RDB store. This API uses a promise to return the result. You can set parameters for the RDB store based on service requirements and call APIs to perform data operations.
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ciIf error code 14800011 is returned when this API is used to obtain an encrypted RDB store, check the value of **encrypt** in **StoreConfig**. The encrypted RDB store can be obtained successfully when **encrypt** is **true**.
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ciCurrently, **getRdbStore()** does not support multi-thread concurrent operations.
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ci**Parameters**
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ci| Name | Type                            | Mandatory| Description                                                        |
140e41f4b71Sopenharmony_ci| ------- | -------------------------------- | ---- | ------------------------------------------------------------ |
141e41f4b71Sopenharmony_ci| context | Context                          | Yes  | Application context.<br>For details about the application context of the FA model, see [Context](../apis-ability-kit/js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-uiAbilityContext.md).|
142e41f4b71Sopenharmony_ci| config  | [StoreConfig](#storeconfig) | Yes  | Configuration of the RDB store.                               |
143e41f4b71Sopenharmony_ci
144e41f4b71Sopenharmony_ci**Return value**
145e41f4b71Sopenharmony_ci
146e41f4b71Sopenharmony_ci| Type                                     | Description                             |
147e41f4b71Sopenharmony_ci| ----------------------------------------- | --------------------------------- |
148e41f4b71Sopenharmony_ci| Promise&lt;[RdbStore](#rdbstore)&gt; | Promise used to return the **RdbStore** object obtained.|
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ci**Error codes**
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
155e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
156e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
157e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
158e41f4b71Sopenharmony_ci| 14800010  | Invalid database path. |
159e41f4b71Sopenharmony_ci| 14800011  | Database corrupted.  |
160e41f4b71Sopenharmony_ci| 14801001  | Only supported in stage mode.                               |
161e41f4b71Sopenharmony_ci| 14801002  | The data group id is not valid.                             |
162e41f4b71Sopenharmony_ci| 14800017  | Config changed. |
163e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
164e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
165e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
166e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
167e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ci**Example**
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ciFA model:
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
174e41f4b71Sopenharmony_ci```js
175e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
176e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_cilet store: relationalStore.RdbStore | undefined = undefined;
179e41f4b71Sopenharmony_cilet context = featureAbility.getContext(); 
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ciconst STORE_CONFIG: relationalStore.StoreConfig = {
182e41f4b71Sopenharmony_ci  name: "RdbTest.db",
183e41f4b71Sopenharmony_ci  securityLevel: relationalStore.SecurityLevel.S3
184e41f4b71Sopenharmony_ci};
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_cirelationalStore.getRdbStore(context, STORE_CONFIG).then(async (rdbStore: relationalStore.RdbStore) => {
187e41f4b71Sopenharmony_ci  store = rdbStore;
188e41f4b71Sopenharmony_ci  console.info('Get RdbStore successfully.')
189e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
190e41f4b71Sopenharmony_ci  console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
191e41f4b71Sopenharmony_ci})
192e41f4b71Sopenharmony_ci```
193e41f4b71Sopenharmony_ci
194e41f4b71Sopenharmony_ciStage model:
195e41f4b71Sopenharmony_ci
196e41f4b71Sopenharmony_ci```ts
197e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
198e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
199e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
200e41f4b71Sopenharmony_ci
201e41f4b71Sopenharmony_cilet store: relationalStore.RdbStore | undefined = undefined;
202e41f4b71Sopenharmony_ci
203e41f4b71Sopenharmony_ciclass EntryAbility extends UIAbility {
204e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage) {
205e41f4b71Sopenharmony_ci    const STORE_CONFIG: relationalStore.StoreConfig = {
206e41f4b71Sopenharmony_ci      name: "RdbTest.db",
207e41f4b71Sopenharmony_ci      securityLevel: relationalStore.SecurityLevel.S3
208e41f4b71Sopenharmony_ci    };
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_ci    relationalStore.getRdbStore(this.context, STORE_CONFIG).then(async (rdbStore: relationalStore.RdbStore) => {
211e41f4b71Sopenharmony_ci      store = rdbStore;
212e41f4b71Sopenharmony_ci      console.info('Get RdbStore successfully.')
213e41f4b71Sopenharmony_ci    }).catch((err: BusinessError) => {
214e41f4b71Sopenharmony_ci      console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
215e41f4b71Sopenharmony_ci    })
216e41f4b71Sopenharmony_ci  }
217e41f4b71Sopenharmony_ci}
218e41f4b71Sopenharmony_ci```
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ci## relationalStore.deleteRdbStore
221e41f4b71Sopenharmony_ci
222e41f4b71Sopenharmony_cideleteRdbStore(context: Context, name: string, callback: AsyncCallback&lt;void&gt;): void
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ciDeletes an RDB store. This API uses an asynchronous callback to return the result.
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ciAfter the deletion, you are advised to set the database object to null. If a customized path is set in [StoreConfig](#storeconfig) when an RDB store is created, using this API cannot delete the RDB store. Use [deleteRdbStore<sup>10+</sup>](#relationalstoredeleterdbstore10) instead.
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ci**Parameters**
231e41f4b71Sopenharmony_ci
232e41f4b71Sopenharmony_ci| Name  | Type                     | Mandatory| Description                                                        |
233e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
234e41f4b71Sopenharmony_ci| context  | Context                   | Yes  | Application context.<br>For details about the application context of the FA model, see [Context](../apis-ability-kit/js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-uiAbilityContext.md).|
235e41f4b71Sopenharmony_ci| name     | string                    | Yes  | Name of the RDB store to delete.                                                |
236e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                      |
237e41f4b71Sopenharmony_ci
238e41f4b71Sopenharmony_ci**Error codes**
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ci| **ID**| **Error Message**                       |
243e41f4b71Sopenharmony_ci|-----------|---------------------------------------|
244e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
245e41f4b71Sopenharmony_ci| 14800000  | Inner error.     |
246e41f4b71Sopenharmony_ci| 14800010  | Failed to open or delete database by invalid database path. |
247e41f4b71Sopenharmony_ci
248e41f4b71Sopenharmony_ci**Example**
249e41f4b71Sopenharmony_ci
250e41f4b71Sopenharmony_ciFA model:
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
253e41f4b71Sopenharmony_ci```js
254e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
255e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
256e41f4b71Sopenharmony_ci
257e41f4b71Sopenharmony_cilet store: relationalStore.RdbStore | undefined = undefined;
258e41f4b71Sopenharmony_cilet context = featureAbility.getContext(); 
259e41f4b71Sopenharmony_ci
260e41f4b71Sopenharmony_cirelationalStore.deleteRdbStore(context, "RdbTest.db", (err: BusinessError) => {
261e41f4b71Sopenharmony_ci  if (err) {
262e41f4b71Sopenharmony_ci    console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
263e41f4b71Sopenharmony_ci    return;
264e41f4b71Sopenharmony_ci  }
265e41f4b71Sopenharmony_ci  store = undefined;
266e41f4b71Sopenharmony_ci  console.info('Delete RdbStore successfully.');
267e41f4b71Sopenharmony_ci})
268e41f4b71Sopenharmony_ci```
269e41f4b71Sopenharmony_ci
270e41f4b71Sopenharmony_ciStage model:
271e41f4b71Sopenharmony_ci
272e41f4b71Sopenharmony_ci```ts
273e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
274e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
275e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
276e41f4b71Sopenharmony_ci
277e41f4b71Sopenharmony_cilet store: relationalStore.RdbStore | undefined = undefined;
278e41f4b71Sopenharmony_ci
279e41f4b71Sopenharmony_ciclass EntryAbility extends UIAbility {
280e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage){
281e41f4b71Sopenharmony_ci    relationalStore.deleteRdbStore(this.context, "RdbTest.db", (err: BusinessError) => {
282e41f4b71Sopenharmony_ci      if (err) {
283e41f4b71Sopenharmony_ci        console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
284e41f4b71Sopenharmony_ci        return;
285e41f4b71Sopenharmony_ci      }
286e41f4b71Sopenharmony_ci      store = undefined;
287e41f4b71Sopenharmony_ci      console.info('Delete RdbStore successfully.');
288e41f4b71Sopenharmony_ci    })
289e41f4b71Sopenharmony_ci  }
290e41f4b71Sopenharmony_ci}
291e41f4b71Sopenharmony_ci```
292e41f4b71Sopenharmony_ci
293e41f4b71Sopenharmony_ci## relationalStore.deleteRdbStore
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_cideleteRdbStore(context: Context, name: string): Promise&lt;void&gt;
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ciDeletes an RDB store. This API uses a promise to return the result.
298e41f4b71Sopenharmony_ci
299e41f4b71Sopenharmony_ciAfter the deletion, you are advised to set the database object to null. If a customized path is set in [StoreConfig](#storeconfig) when an RDB store is created, using this API cannot delete the RDB store. Use [deleteRdbStore<sup>10+</sup>](#relationalstoredeleterdbstore10-1) instead.
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
302e41f4b71Sopenharmony_ci
303e41f4b71Sopenharmony_ci**Parameters**
304e41f4b71Sopenharmony_ci
305e41f4b71Sopenharmony_ci| Name | Type   | Mandatory| Description                                                        |
306e41f4b71Sopenharmony_ci| ------- | ------- | ---- | ------------------------------------------------------------ |
307e41f4b71Sopenharmony_ci| context | Context | Yes  | Application context.<br>For details about the application context of the FA model, see [Context](../apis-ability-kit/js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-uiAbilityContext.md).|
308e41f4b71Sopenharmony_ci| name    | string  | Yes  | Name of the RDB store to delete.                                                |
309e41f4b71Sopenharmony_ci
310e41f4b71Sopenharmony_ci**Return value**
311e41f4b71Sopenharmony_ci
312e41f4b71Sopenharmony_ci| Type               | Description                     |
313e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
314e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
315e41f4b71Sopenharmony_ci
316e41f4b71Sopenharmony_ci**Error codes**
317e41f4b71Sopenharmony_ci
318e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
319e41f4b71Sopenharmony_ci
320e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                        |
321e41f4b71Sopenharmony_ci|-----------|----------------------------------------------------------------------------------|
322e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
323e41f4b71Sopenharmony_ci| 14800000  | Inner error.                                                                     |
324e41f4b71Sopenharmony_ci| 14800010  | Invalid database path.                      |
325e41f4b71Sopenharmony_ci
326e41f4b71Sopenharmony_ci**Example**
327e41f4b71Sopenharmony_ci
328e41f4b71Sopenharmony_ciFA model:
329e41f4b71Sopenharmony_ci
330e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
331e41f4b71Sopenharmony_ci```js
332e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
333e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
334e41f4b71Sopenharmony_ci
335e41f4b71Sopenharmony_cilet store: relationalStore.RdbStore | undefined = undefined;
336e41f4b71Sopenharmony_cilet context = featureAbility.getContext(); 
337e41f4b71Sopenharmony_ci
338e41f4b71Sopenharmony_cirelationalStore.deleteRdbStore(context, "RdbTest.db").then(()=>{
339e41f4b71Sopenharmony_ci  store = undefined;
340e41f4b71Sopenharmony_ci  console.info('Delete RdbStore successfully.');
341e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
342e41f4b71Sopenharmony_ci  console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
343e41f4b71Sopenharmony_ci})
344e41f4b71Sopenharmony_ci```
345e41f4b71Sopenharmony_ci
346e41f4b71Sopenharmony_ciStage model:
347e41f4b71Sopenharmony_ci
348e41f4b71Sopenharmony_ci```ts
349e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
350e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
351e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
352e41f4b71Sopenharmony_ci
353e41f4b71Sopenharmony_cilet store: relationalStore.RdbStore | undefined = undefined;
354e41f4b71Sopenharmony_ci
355e41f4b71Sopenharmony_ciclass EntryAbility extends UIAbility {
356e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage){
357e41f4b71Sopenharmony_ci    relationalStore.deleteRdbStore(this.context, "RdbTest.db").then(()=>{
358e41f4b71Sopenharmony_ci      store = undefined;
359e41f4b71Sopenharmony_ci      console.info('Delete RdbStore successfully.');
360e41f4b71Sopenharmony_ci    }).catch((err: BusinessError) => {
361e41f4b71Sopenharmony_ci      console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
362e41f4b71Sopenharmony_ci    })
363e41f4b71Sopenharmony_ci  }
364e41f4b71Sopenharmony_ci}
365e41f4b71Sopenharmony_ci```
366e41f4b71Sopenharmony_ci
367e41f4b71Sopenharmony_ci## relationalStore.deleteRdbStore<sup>10+</sup>
368e41f4b71Sopenharmony_ci
369e41f4b71Sopenharmony_cideleteRdbStore(context: Context, config: StoreConfig, callback: AsyncCallback\<void>): void
370e41f4b71Sopenharmony_ci
371e41f4b71Sopenharmony_ciDeletes an RDB store. This API uses an asynchronous callback to return the result.
372e41f4b71Sopenharmony_ci
373e41f4b71Sopenharmony_ciAfter the deletion, you are advised to set the database object to null. If the database file is in the public sandbox directory, you must use this API to delete the database. If the database is accessed by multiple processes at the same time, you are advised to send a database deletion notification to other processes. Use this API to delete the RDB store that has a customized path set in [StoreConfig](#storeconfig).
374e41f4b71Sopenharmony_ci
375e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
376e41f4b71Sopenharmony_ci
377e41f4b71Sopenharmony_ci**Parameters**
378e41f4b71Sopenharmony_ci
379e41f4b71Sopenharmony_ci| Name  | Type                       | Mandatory| Description                                                        |
380e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
381e41f4b71Sopenharmony_ci| context  | Context                     | Yes  | Application context.<br>For details about the application context of the FA model, see [Context](../apis-ability-kit/js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-uiAbilityContext.md).|
382e41f4b71Sopenharmony_ci| config   | [StoreConfig](#storeconfig) | Yes  | Configuration of the RDB store.                               |
383e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt;   | Yes  | Callback used to return the result.                                      |
384e41f4b71Sopenharmony_ci
385e41f4b71Sopenharmony_ci**Error codes**
386e41f4b71Sopenharmony_ci
387e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
388e41f4b71Sopenharmony_ci
389e41f4b71Sopenharmony_ci| **ID**| **Error Message**         |
390e41f4b71Sopenharmony_ci|-----------|----------|
391e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
392e41f4b71Sopenharmony_ci| 14800000  | Inner error.        |
393e41f4b71Sopenharmony_ci| 14800010  | Failed to open or delete database by invalid database path.        |
394e41f4b71Sopenharmony_ci| 14801001  | Only supported in stage mode.         |
395e41f4b71Sopenharmony_ci| 14801002  | The data group id is not valid.        |
396e41f4b71Sopenharmony_ci
397e41f4b71Sopenharmony_ci**Example**
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_ciFA model:
400e41f4b71Sopenharmony_ci
401e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
402e41f4b71Sopenharmony_ci```js
403e41f4b71Sopenharmony_ciimport { featureAbility } from '@kit.AbilityKit';
404e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
405e41f4b71Sopenharmony_ci
406e41f4b71Sopenharmony_cilet store: relationalStore.RdbStore | undefined = undefined;
407e41f4b71Sopenharmony_cilet context = featureAbility.getContext(); 
408e41f4b71Sopenharmony_ci
409e41f4b71Sopenharmony_ciconst STORE_CONFIG: relationalStore.StoreConfig = {
410e41f4b71Sopenharmony_ci  name: "RdbTest.db",
411e41f4b71Sopenharmony_ci  securityLevel: relationalStore.SecurityLevel.S3
412e41f4b71Sopenharmony_ci};
413e41f4b71Sopenharmony_ci
414e41f4b71Sopenharmony_cirelationalStore.deleteRdbStore(context, STORE_CONFIG, (err: BusinessError) => {
415e41f4b71Sopenharmony_ci  if (err) {
416e41f4b71Sopenharmony_ci    console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
417e41f4b71Sopenharmony_ci    return;
418e41f4b71Sopenharmony_ci  }
419e41f4b71Sopenharmony_ci  store = undefined;
420e41f4b71Sopenharmony_ci  console.info('Delete RdbStore successfully.');
421e41f4b71Sopenharmony_ci})
422e41f4b71Sopenharmony_ci```
423e41f4b71Sopenharmony_ci
424e41f4b71Sopenharmony_ciStage model:
425e41f4b71Sopenharmony_ci
426e41f4b71Sopenharmony_ci```ts
427e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
428e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
429e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
430e41f4b71Sopenharmony_ci
431e41f4b71Sopenharmony_cilet store: relationalStore.RdbStore | undefined = undefined;
432e41f4b71Sopenharmony_ci
433e41f4b71Sopenharmony_ciclass EntryAbility extends UIAbility {
434e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage){
435e41f4b71Sopenharmony_ci    const STORE_CONFIG: relationalStore.StoreConfig = {
436e41f4b71Sopenharmony_ci      name: "RdbTest.db",
437e41f4b71Sopenharmony_ci      securityLevel: relationalStore.SecurityLevel.S3
438e41f4b71Sopenharmony_ci    };
439e41f4b71Sopenharmony_ci    relationalStore.deleteRdbStore(this.context, STORE_CONFIG, (err: BusinessError) => {
440e41f4b71Sopenharmony_ci      if (err) {
441e41f4b71Sopenharmony_ci        console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
442e41f4b71Sopenharmony_ci        return;
443e41f4b71Sopenharmony_ci      }
444e41f4b71Sopenharmony_ci      store = undefined;
445e41f4b71Sopenharmony_ci      console.info('Delete RdbStore successfully.');
446e41f4b71Sopenharmony_ci    })
447e41f4b71Sopenharmony_ci  }
448e41f4b71Sopenharmony_ci}
449e41f4b71Sopenharmony_ci```
450e41f4b71Sopenharmony_ci
451e41f4b71Sopenharmony_ci## relationalStore.deleteRdbStore<sup>10+</sup>
452e41f4b71Sopenharmony_ci
453e41f4b71Sopenharmony_cideleteRdbStore(context: Context, config: StoreConfig): Promise\<void>
454e41f4b71Sopenharmony_ci
455e41f4b71Sopenharmony_ciDeletes an RDB store. This API uses a promise to return the result.
456e41f4b71Sopenharmony_ci
457e41f4b71Sopenharmony_ciAfter the deletion, you are advised to set the database object to null. If the database file is in the public sandbox directory, you must use this API to delete the database. If the database is accessed by multiple processes at the same time, you are advised to send a database deletion notification to other processes. Use this API to delete the RDB store that has a customized path set in [StoreConfig](#storeconfig).
458e41f4b71Sopenharmony_ci
459e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
460e41f4b71Sopenharmony_ci
461e41f4b71Sopenharmony_ci**Parameters**
462e41f4b71Sopenharmony_ci
463e41f4b71Sopenharmony_ci| Name | Type                       | Mandatory| Description                                                        |
464e41f4b71Sopenharmony_ci| ------- | --------------------------- | ---- | ------------------------------------------------------------ |
465e41f4b71Sopenharmony_ci| context | Context                     | Yes  | Application context.<br>For details about the application context of the FA model, see [Context](../apis-ability-kit/js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-uiAbilityContext.md).|
466e41f4b71Sopenharmony_ci| config  | [StoreConfig](#storeconfig) | Yes  | Configuration of the RDB store.                               |
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_ci**Return value**
469e41f4b71Sopenharmony_ci
470e41f4b71Sopenharmony_ci| Type               | Description                     |
471e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
472e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
473e41f4b71Sopenharmony_ci
474e41f4b71Sopenharmony_ci**Error codes**
475e41f4b71Sopenharmony_ci
476e41f4b71Sopenharmony_ciFor details about the error codes, see [RDB Error Codes](errorcode-data-rdb.md).
477e41f4b71Sopenharmony_ci
478e41f4b71Sopenharmony_ci| **ID**| **Error Message**            |
479e41f4b71Sopenharmony_ci|-----------|---------------------|
480e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
481e41f4b71Sopenharmony_ci| 801       | Capability not supported.      |
482e41f4b71Sopenharmony_ci| 14800000  | Inner error.      |
483e41f4b71Sopenharmony_ci| 14800010  | Invalid database path.   |
484e41f4b71Sopenharmony_ci| 14801001  | Only supported in stage mode.   |
485e41f4b71Sopenharmony_ci| 14801002  | The data group id is not valid.   |
486e41f4b71Sopenharmony_ci
487e41f4b71Sopenharmony_ci
488e41f4b71Sopenharmony_ci**Example**
489e41f4b71Sopenharmony_ci
490e41f4b71Sopenharmony_ciFA model:
491e41f4b71Sopenharmony_ci
492e41f4b71Sopenharmony_ci<!--code_no_check_fa-->
493e41f4b71Sopenharmony_ci```js
494e41f4b71Sopenharmony_ciimport { featureAbility } from "@kit.AbilityKit";
495e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
496e41f4b71Sopenharmony_ci
497e41f4b71Sopenharmony_cilet store: relationalStore.RdbStore | undefined = undefined;
498e41f4b71Sopenharmony_cilet context = featureAbility.getContext(); 
499e41f4b71Sopenharmony_ci
500e41f4b71Sopenharmony_ciconst STORE_CONFIG: relationalStore.StoreConfig = {
501e41f4b71Sopenharmony_ci  name: "RdbTest.db",
502e41f4b71Sopenharmony_ci  securityLevel: relationalStore.SecurityLevel.S3
503e41f4b71Sopenharmony_ci};
504e41f4b71Sopenharmony_ci
505e41f4b71Sopenharmony_cirelationalStore.deleteRdbStore(context, STORE_CONFIG).then(()=>{
506e41f4b71Sopenharmony_ci  store = undefined;
507e41f4b71Sopenharmony_ci  console.info('Delete RdbStore successfully.');
508e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
509e41f4b71Sopenharmony_ci  console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
510e41f4b71Sopenharmony_ci})
511e41f4b71Sopenharmony_ci```
512e41f4b71Sopenharmony_ci
513e41f4b71Sopenharmony_ciStage model:
514e41f4b71Sopenharmony_ci
515e41f4b71Sopenharmony_ci```ts
516e41f4b71Sopenharmony_ciimport { UIAbility } from '@kit.AbilityKit';
517e41f4b71Sopenharmony_ciimport { window } from '@kit.ArkUI';
518e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
519e41f4b71Sopenharmony_ci
520e41f4b71Sopenharmony_cilet store: relationalStore.RdbStore | undefined = undefined;
521e41f4b71Sopenharmony_ci
522e41f4b71Sopenharmony_ciclass EntryAbility extends UIAbility {
523e41f4b71Sopenharmony_ci  onWindowStageCreate(windowStage: window.WindowStage){
524e41f4b71Sopenharmony_ci    const STORE_CONFIG: relationalStore.StoreConfig = {
525e41f4b71Sopenharmony_ci      name: "RdbTest.db",
526e41f4b71Sopenharmony_ci      securityLevel: relationalStore.SecurityLevel.S3
527e41f4b71Sopenharmony_ci    };
528e41f4b71Sopenharmony_ci    relationalStore.deleteRdbStore(this.context, STORE_CONFIG).then(()=>{
529e41f4b71Sopenharmony_ci      store = undefined;
530e41f4b71Sopenharmony_ci      console.info('Delete RdbStore successfully.');
531e41f4b71Sopenharmony_ci    }).catch((err: BusinessError) => {
532e41f4b71Sopenharmony_ci      console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
533e41f4b71Sopenharmony_ci    })
534e41f4b71Sopenharmony_ci  }
535e41f4b71Sopenharmony_ci}
536e41f4b71Sopenharmony_ci```
537e41f4b71Sopenharmony_ci
538e41f4b71Sopenharmony_ci## StoreConfig
539e41f4b71Sopenharmony_ci
540e41f4b71Sopenharmony_ciDefines the RDB store configuration.
541e41f4b71Sopenharmony_ci
542e41f4b71Sopenharmony_ci| Name       | Type         | Mandatory| Description                                                     |
543e41f4b71Sopenharmony_ci| ------------- | ------------- | ---- | --------------------------------------------------------- |
544e41f4b71Sopenharmony_ci| name          | string        | Yes  | Database file name, which is the unique identifier of the database.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core  |
545e41f4b71Sopenharmony_ci| securityLevel | [SecurityLevel](#securitylevel) | Yes  | Security level of the RDB store.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
546e41f4b71Sopenharmony_ci| encrypt       | boolean       | No  | Whether to encrypt the RDB store.<br> The value **true** means to encrypt the RDB store; the value **false** (default) means the opposite.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
547e41f4b71Sopenharmony_ci| dataGroupId<sup>10+</sup> | string | No| Application group ID, which needs to be obtained from AppGallery. This parameter is not supported currently.<br>**Model restriction**: This attribute can be used only in the stage model.<br>This parameter is supported since API version 10. The **RdbStore** instance is created in the sandbox directory corresponding to the specified **dataGroupId**. If this parameter is not specified, the **RdbStore** instance is created in the sandbox directory of the application.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
548e41f4b71Sopenharmony_ci| customDir<sup>11+</sup> | string | No| Customized path of the RDB store.<br>**Constraints**: The value cannot exceed 128 bytes.<br>This parameter is supported since API version 11. The RDB store directory is in the **context.databaseDir**/**rdb**/**customDir** format. **context.databaseDir** specifies the application sandbox path. **rdb** is a fixed field that indicates an RDB store. **customDir** specifies the customized path. If this parameter is not specified, the **RdbStore** instance is created in the sandbox directory of the application.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
549e41f4b71Sopenharmony_ci| autoCleanDirtyData<sup>11+</sup> | boolean | No| Whether to automatically clear the dirty data (data that has been deleted from the cloud) from the local device. The value **true** means to clear the dirty data automatically. The value **false** means to clear the data manually. The default value is **true**.<br>This parameter applies to the RDB stores with device-cloud synergy. To manually clear the dirty data, use [cleanDirtyData<sup>11+</sup>](#cleandirtydata11).<br>This parameter is supported since API version 11.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
550e41f4b71Sopenharmony_ci| allowRebuild<sup>12+</sup> | boolean | No| Whether auto rebuild is allowed when the RDB store is corrupted. The default value is **false**.<br>The value **true** means auto rebuild is allowed.<br>The value **false** means the opposite.<br>This parameter is supported since API version 12.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
551e41f4b71Sopenharmony_ci| isReadOnly<sup>12+</sup> | boolean | No| Whether the RDB store is read-only. The default value is **false**, which means the RDB store is readable and writeable.<br>If the value is **true** (read-only), writing data to the RDB store will throw error code 801.<br>The value **false** means the RDB store is readable and writeable.<br>This parameter is supported since API version 12.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
552e41f4b71Sopenharmony_ci| pluginLibs<sup>12+</sup> | Array\<string> | No| Dynamic libraries with capabilities such as Full-Text Search (FTS).<br>**Constraints**: The maximum number of dynamic libraries is 16. If the number of dynamic library names exceeds 16, the RDB store fails to be opened and an error is returned. The dynamic library must be in the sandbox directory or system directory of the application. If the dynamic library cannot be loaded, the RDB store fails to be opened and an error is returned.<br>The dynamic library name must be a complete path. For example, **[context.bundleCodeDir+ "/libs/arm64/" + libtokenizer.so]**, where **context.bundleCodeDir** is the application sandbox path, **/libs/arm64/** indicates the subdirectory, and **libtokenizer.so** is the dynamic library name. If this parameter is left blank, dynamic libraries are not loaded by default.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
553e41f4b71Sopenharmony_ci
554e41f4b71Sopenharmony_ci## SecurityLevel
555e41f4b71Sopenharmony_ci
556e41f4b71Sopenharmony_ciEnumerates the RDB store security levels. Use the enum name rather than the enum value.
557e41f4b71Sopenharmony_ci
558e41f4b71Sopenharmony_ci> **NOTE**
559e41f4b71Sopenharmony_ci>
560e41f4b71Sopenharmony_ci> To perform data sync operations, the RDB store security level must be lower than or equal to that of the peer device. For details, see the [Cross-Device Data Sync Mechanism](../../database/access-control-by-device-and-data-level.md#access-control-mechanism-in-cross-device-sync).
561e41f4b71Sopenharmony_ci
562e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
563e41f4b71Sopenharmony_ci
564e41f4b71Sopenharmony_ci| Name| Value  | Description                                                        |
565e41f4b71Sopenharmony_ci| ---- | ---- | ------------------------------------------------------------ |
566e41f4b71Sopenharmony_ci| S1   | 1    | The RDB store security level is low. If data leakage occurs, minor impact will be caused on the database. For example, an RDB store that contains system data such as wallpapers.|
567e41f4b71Sopenharmony_ci| S2   | 2    | The RDB store security level is medium. If data leakage occurs, moderate impact will be caused on the database. For example, an RDB store that contains information created by users or call records, such as audio or video clips.|
568e41f4b71Sopenharmony_ci| S3   | 3    | The RDB store security level is high. If data leakage occurs, major impact will be caused on the database. For example, an RDB store that contains information such as user fitness, health, and location data.|
569e41f4b71Sopenharmony_ci| S4   | 4    | The RDB store security level is critical. If data leakage occurs, severe impact will be caused on the database. For example, an RDB store that contains information such as authentication credentials and financial data.|
570e41f4b71Sopenharmony_ci
571e41f4b71Sopenharmony_ci## AssetStatus<sup>10+</sup>
572e41f4b71Sopenharmony_ci
573e41f4b71Sopenharmony_ciEnumerates the asset statuses. Use the enum name rather than the enum value.
574e41f4b71Sopenharmony_ci
575e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
576e41f4b71Sopenharmony_ci
577e41f4b71Sopenharmony_ci| Name                             | Value  | Description            |
578e41f4b71Sopenharmony_ci| ------------------------------- | --- | -------------- |
579e41f4b71Sopenharmony_ci| ASSET_NORMAL     | 1  | The asset is in normal status.     |
580e41f4b71Sopenharmony_ci| ASSET_INSERT | 2 | The asset is to be inserted to the cloud.|
581e41f4b71Sopenharmony_ci| ASSET_UPDATE | 3 | The asset is to be updated to the cloud.|
582e41f4b71Sopenharmony_ci| ASSET_DELETE | 4 | The asset is to be deleted from the cloud.|
583e41f4b71Sopenharmony_ci| ASSET_ABNORMAL    | 5   | The asset is in abnormal status.     |
584e41f4b71Sopenharmony_ci| ASSET_DOWNLOADING | 6   | The asset is being downloaded to a local device.|
585e41f4b71Sopenharmony_ci
586e41f4b71Sopenharmony_ci## Asset<sup>10+</sup>
587e41f4b71Sopenharmony_ci
588e41f4b71Sopenharmony_ciDefines information about an asset (such as a document, image, and video).
589e41f4b71Sopenharmony_ci
590e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
591e41f4b71Sopenharmony_ci
592e41f4b71Sopenharmony_ci| Name         | Type                         | Mandatory | Description          |
593e41f4b71Sopenharmony_ci| ----------- | --------------------------- | --- | ------------ |
594e41f4b71Sopenharmony_ci| name        | string                      | Yes  | Asset name.      |
595e41f4b71Sopenharmony_ci| uri         | string                      | Yes  | Asset URI, which is an absolute path in the system.      |
596e41f4b71Sopenharmony_ci| path        | string                      | Yes  | Application sandbox path of the asset.      |
597e41f4b71Sopenharmony_ci| createTime  | string                      | Yes  | Time when the asset was created.  |
598e41f4b71Sopenharmony_ci| modifyTime  | string                      | Yes  | Time when the asset was last modified.|
599e41f4b71Sopenharmony_ci| size        | string                      | Yes  | Size of the asset.   |
600e41f4b71Sopenharmony_ci| status      | [AssetStatus](#assetstatus10) | No  | Asset status. The default value is **ASSET_NORMAL**.       |
601e41f4b71Sopenharmony_ci
602e41f4b71Sopenharmony_ci## Assets<sup>10+</sup>
603e41f4b71Sopenharmony_ci
604e41f4b71Sopenharmony_citype Assets = Asset[]
605e41f4b71Sopenharmony_ci
606e41f4b71Sopenharmony_ciDefines an array of the [Asset](#asset10) type.
607e41f4b71Sopenharmony_ci
608e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
609e41f4b71Sopenharmony_ci
610e41f4b71Sopenharmony_ci| Type   | Description                |
611e41f4b71Sopenharmony_ci| ------- | -------------------- |
612e41f4b71Sopenharmony_ci| [Asset](#asset10)[] | Array of assets.  |
613e41f4b71Sopenharmony_ci
614e41f4b71Sopenharmony_ci## ValueType
615e41f4b71Sopenharmony_ci
616e41f4b71Sopenharmony_citype ValueType = null | number | string | boolean | Uint8Array | Asset | Assets | Float32Array | bigint
617e41f4b71Sopenharmony_ci
618e41f4b71Sopenharmony_ciEnumerates the types of the value in a KV pair. The type varies with the parameter function.
619e41f4b71Sopenharmony_ci
620e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
621e41f4b71Sopenharmony_ci
622e41f4b71Sopenharmony_ci| Type   | Description                |
623e41f4b71Sopenharmony_ci| ------- | -------------------- |
624e41f4b71Sopenharmony_ci| null<sup>10+</sup>    | Null.  |
625e41f4b71Sopenharmony_ci| number  | Number.  |
626e41f4b71Sopenharmony_ci| string  | String. |
627e41f4b71Sopenharmony_ci| boolean | Boolean.|
628e41f4b71Sopenharmony_ci| Uint8Array<sup>10+</sup>           | Uint8 array.           |
629e41f4b71Sopenharmony_ci| Asset<sup>10+</sup>  | [Asset](#asset10).<br>If the field type is **Asset**, the type in the SQL statement for creating a table must be **ASSET**.|
630e41f4b71Sopenharmony_ci| Assets<sup>10+</sup> | [Assets](#assets10).<br>If the field type is **Assets**, the type in the SQL statement for creating a table must be **ASSETS**.|
631e41f4b71Sopenharmony_ci| Float32Array<sup>12+</sup> | Array of 32-bit floating-point numbers.<br>If the field type is **Float32Array**, the type in the SQL statement for creating a table must be **floatvector(128)**.|
632e41f4b71Sopenharmony_ci| bigint<sup>12+</sup> | Integer of any length.<br>If the value type is **bigint**, the type in the SQL statement for creating a table must be **UNLIMITED INT**. For details, see [Persisting RDB Store Data](../../database/data-persistence-by-rdb-store.md).<br>**NOTE**<br>The bigint type does not support value comparison and cannot be used with the following predicates: **between**, **notBetween**, **greaterThanlessThan**, **greaterThanOrEqualTo**, **lessThanOrEqualTo**, **orderByAsc**, and **orderByDesc**<br>To write a value of bigint type, use **BigInt()** or add **n** to the end of the value, for example,'let data = BigInt(1234)' or 'let data = 1234n'.<br>If data of the number type is written to a bigint field, the type of the return value obtained (queried) is number but not bigint.|
633e41f4b71Sopenharmony_ci
634e41f4b71Sopenharmony_ci## ValuesBucket
635e41f4b71Sopenharmony_ci
636e41f4b71Sopenharmony_citype ValuesBucket = Record<string, ValueType>
637e41f4b71Sopenharmony_ci
638e41f4b71Sopenharmony_ciDefines the data in the form of a KV pair, which cannot be transferred across threads.
639e41f4b71Sopenharmony_ci
640e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
641e41f4b71Sopenharmony_ci
642e41f4b71Sopenharmony_ci| Type             | Description                          |
643e41f4b71Sopenharmony_ci| ---------------- | ---------------------------- |
644e41f4b71Sopenharmony_ci| Record<string, [ValueType](#valuetype)> | Types of the key and value in a KV pair. The key type is string, and the value type is [ValueType](#valuetype).|
645e41f4b71Sopenharmony_ci
646e41f4b71Sopenharmony_ci## PRIKeyType<sup>10+</sup> 
647e41f4b71Sopenharmony_ci
648e41f4b71Sopenharmony_citype PRIKeyType = number | string
649e41f4b71Sopenharmony_ci
650e41f4b71Sopenharmony_ciEnumerates the types of the primary key in a row of a database table.
651e41f4b71Sopenharmony_ci
652e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
653e41f4b71Sopenharmony_ci
654e41f4b71Sopenharmony_ci| Type            | Description                              |
655e41f4b71Sopenharmony_ci| ---------------- | ---------------------------------- |
656e41f4b71Sopenharmony_ci| number | The primary key is a number.|
657e41f4b71Sopenharmony_ci| string | The primary key is a string.|
658e41f4b71Sopenharmony_ci
659e41f4b71Sopenharmony_ci## UTCTime<sup>10+</sup>
660e41f4b71Sopenharmony_ci
661e41f4b71Sopenharmony_citype UTCTime = Date
662e41f4b71Sopenharmony_ci
663e41f4b71Sopenharmony_ciRepresents the data type of the UTC time.
664e41f4b71Sopenharmony_ci
665e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
666e41f4b71Sopenharmony_ci
667e41f4b71Sopenharmony_ci| Type| Description           |
668e41f4b71Sopenharmony_ci| ---- | --------------- |
669e41f4b71Sopenharmony_ci| Date | UTC time.|
670e41f4b71Sopenharmony_ci
671e41f4b71Sopenharmony_ci## ModifyTime<sup>10+</sup> 
672e41f4b71Sopenharmony_ci
673e41f4b71Sopenharmony_citype ModifyTime = Map<PRIKeyType, UTCTime>
674e41f4b71Sopenharmony_ci
675e41f4b71Sopenharmony_ciRepresents the data type of the primary key and modification time of a database table.
676e41f4b71Sopenharmony_ci
677e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
678e41f4b71Sopenharmony_ci
679e41f4b71Sopenharmony_ci| Type                                                   | Description                                                        |
680e41f4b71Sopenharmony_ci| ------------------------------------------------------- | ------------------------------------------------------------ |
681e41f4b71Sopenharmony_ci| Map<[PRIKeyType](#prikeytype10), [UTCTime](#utctime10)> | The key is the primary key of a row in the database table, and the value is the last modification time of the row in UTC format.|
682e41f4b71Sopenharmony_ci
683e41f4b71Sopenharmony_ci## SyncMode
684e41f4b71Sopenharmony_ci
685e41f4b71Sopenharmony_ciEnumerates the database sync modes. Use the enum name rather than the enum value.
686e41f4b71Sopenharmony_ci
687e41f4b71Sopenharmony_ci| Name          | Value  | Description                              |
688e41f4b71Sopenharmony_ci| -------------- | ---- | ---------------------------------- |
689e41f4b71Sopenharmony_ci| SYNC_MODE_PUSH                       | 0   | Push data from a local device to a remote device.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
690e41f4b71Sopenharmony_ci| SYNC_MODE_PULL                       | 1   | Pull data from a remote device to a local device.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
691e41f4b71Sopenharmony_ci| SYNC_MODE_TIME_FIRST<sup>10+</sup>   | 4   | Synchronize with the data with the latest modification time.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
692e41f4b71Sopenharmony_ci| SYNC_MODE_NATIVE_FIRST<sup>10+</sup> | 5   | Synchronize data from a local device to the cloud.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
693e41f4b71Sopenharmony_ci| SYNC_MODE_CLOUD_FIRST<sup>10+</sup>  | 6   | Synchronize data from the cloud to a local device.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
694e41f4b71Sopenharmony_ci
695e41f4b71Sopenharmony_ci## Origin<sup>11+</sup>
696e41f4b71Sopenharmony_ci
697e41f4b71Sopenharmony_ciEnumerates the data sources. Use the enum name rather than the enum value.
698e41f4b71Sopenharmony_ci
699e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
700e41f4b71Sopenharmony_ci
701e41f4b71Sopenharmony_ci| Name          | Value  | Description                              |
702e41f4b71Sopenharmony_ci| -------------- | ---- | ---------------------------------- |
703e41f4b71Sopenharmony_ci| LOCAL       | 0   | Local data.     |
704e41f4b71Sopenharmony_ci| CLOUD       | 1   | Cloud data.    |
705e41f4b71Sopenharmony_ci| REMOTE      | 2   | Remote device data.|
706e41f4b71Sopenharmony_ci
707e41f4b71Sopenharmony_ci## Field<sup>11+</sup>
708e41f4b71Sopenharmony_ci
709e41f4b71Sopenharmony_ciEnumerates the special fields used in predicates. Use the enum name rather than the enum value.
710e41f4b71Sopenharmony_ci
711e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
712e41f4b71Sopenharmony_ci
713e41f4b71Sopenharmony_ci| Name          | Value  | Description                              |
714e41f4b71Sopenharmony_ci| -------------- | ---- | ---------------------------------- |
715e41f4b71Sopenharmony_ci| CURSOR_FIELD        | '#_cursor'     | Field name to be searched based on the cursor.|
716e41f4b71Sopenharmony_ci| ORIGIN_FIELD        | '#_origin'     | Data source to be searched based on the cursor.   |
717e41f4b71Sopenharmony_ci| DELETED_FLAG_FIELD  | '#_deleted_flag' | Whether the dirty data (data deleted from the cloud) is cleared from the local device. It fills in the result set returned upon the cursor-based search.<br>The value **true** means the dirty data is cleared; the value **false** means the opposite.|
718e41f4b71Sopenharmony_ci| DATA_STATUS_FIELD<sup>12+</sup>   | '#_data_status' | Data status in the cursor-based search result set. The value **0** indicates normal data status; **1** indicates that data is retained after the account is logged out; **2** indicates that data is deleted from the cloud; **3** indicates that data is deleted after the account is logged out.|
719e41f4b71Sopenharmony_ci| OWNER_FIELD  | '#_cloud_owner' | Party who shares the data. It fills in the result set returned when the owner of the shared data is searched.|
720e41f4b71Sopenharmony_ci| PRIVILEGE_FIELD  | '#_cloud_privilege' | Operation permission on the shared data. It fills in the result set returned when the permission on the shared data is searched.|
721e41f4b71Sopenharmony_ci| SHARING_RESOURCE_FIELD   | '#_sharing_resource_field' | Resource shared. It fills in the result set returned when the shared resource is searched.|
722e41f4b71Sopenharmony_ci
723e41f4b71Sopenharmony_ci## SubscribeType
724e41f4b71Sopenharmony_ci
725e41f4b71Sopenharmony_ciEnumerates the subscription types. Use the enum name rather than the enum value.
726e41f4b71Sopenharmony_ci
727e41f4b71Sopenharmony_ci| Name                 | Value  | Description              |
728e41f4b71Sopenharmony_ci| --------------------- | ---- | ------------------ |
729e41f4b71Sopenharmony_ci| SUBSCRIBE_TYPE_REMOTE | 0    | Subscribe to remote data changes.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
730e41f4b71Sopenharmony_ci| SUBSCRIBE_TYPE_CLOUD<sup>10+</sup> | 1  | Subscribe to cloud data changes.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
731e41f4b71Sopenharmony_ci| SUBSCRIBE_TYPE_CLOUD_DETAILS<sup>10+</sup> | 2  | Subscribe to cloud data change details.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
732e41f4b71Sopenharmony_ci| SUBSCRIBE_TYPE_LOCAL_DETAILS<sup>12+</sup> | 3  | Subscribe to details of the local data change.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
733e41f4b71Sopenharmony_ci
734e41f4b71Sopenharmony_ci## RebuildType<sup>12+</sup>
735e41f4b71Sopenharmony_ci
736e41f4b71Sopenharmony_ciEnumerates the RDB store rebuild types. Use the enum name rather than the enum value.
737e41f4b71Sopenharmony_ci
738e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
739e41f4b71Sopenharmony_ci
740e41f4b71Sopenharmony_ci| Name   | Value  | Description                                    |
741e41f4b71Sopenharmony_ci| ------- | ---- | ---------------------------------------- |
742e41f4b71Sopenharmony_ci| NONE    | 0    | The RDB store is not rebuilt.                  |
743e41f4b71Sopenharmony_ci| REBUILT | 1    | An empty RDB store is built.|
744e41f4b71Sopenharmony_ci| REPAIRED | 2    | The RDB store is repaired, with undamaged data restored. <!--RP2-->Currently, this value is available only to a [vector database](js-apis-data-relationalStore-sys.md#storeconfig).<!--RP2End-->|
745e41f4b71Sopenharmony_ci
746e41f4b71Sopenharmony_ci## ChangeType<sup>10+</sup>
747e41f4b71Sopenharmony_ci
748e41f4b71Sopenharmony_ciEnumerates data change types. Use the enum name rather than the enum value.
749e41f4b71Sopenharmony_ci
750e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
751e41f4b71Sopenharmony_ci
752e41f4b71Sopenharmony_ci| Name                        | Value  | Description                        |
753e41f4b71Sopenharmony_ci| -------------------------- | --- | -------------------------- |
754e41f4b71Sopenharmony_ci| DATA_CHANGE  | 0   | Data change.  |
755e41f4b71Sopenharmony_ci| ASSET_CHANGE | 1   | Asset change.|
756e41f4b71Sopenharmony_ci
757e41f4b71Sopenharmony_ci## ChangeInfo<sup>10+</sup>
758e41f4b71Sopenharmony_ci
759e41f4b71Sopenharmony_ciRepresents the detail information about the device-cloud sync process.
760e41f4b71Sopenharmony_ci
761e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
762e41f4b71Sopenharmony_ci
763e41f4b71Sopenharmony_ci| Name    | Type                              | Mandatory| Description                                                        |
764e41f4b71Sopenharmony_ci| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ |
765e41f4b71Sopenharmony_ci| table    | string                             | Yes  | Name of the table with data changes.                                    |
766e41f4b71Sopenharmony_ci| type     | [ChangeType](#changetype10)        | Yes  | Type of the data changed, which can be data or asset.        |
767e41f4b71Sopenharmony_ci| inserted | Array\<string\> \| Array\<number\> | Yes  | Location where data is inserted. If the primary key of the table is of the string type, the value is the value of the primary key. Otherwise, the value is the row number of the inserted data.|
768e41f4b71Sopenharmony_ci| updated  | Array\<string\> \| Array\<number\> | Yes  | Location where data is updated. If the primary key of the table is of the string type, the value is the value of the primary key. Otherwise, the value is the row number of the updated data.|
769e41f4b71Sopenharmony_ci| deleted  | Array\<string\> \| Array\<number\> | Yes  | Location where data is deleted. If the primary key of the table is of the string type, the value is the value of the primary key. Otherwise, the value is the row number of the deleted data.|
770e41f4b71Sopenharmony_ci
771e41f4b71Sopenharmony_ci## DistributedType<sup>10+</sup>
772e41f4b71Sopenharmony_ci
773e41f4b71Sopenharmony_ciEnumerates the distributed table types. Use the enum name rather than the enum value.
774e41f4b71Sopenharmony_ci
775e41f4b71Sopenharmony_ci| Name               | Value  | Description                                                                                                |
776e41f4b71Sopenharmony_ci| ------------------ | --- | -------------------------------------------------------------------------------------------------- |
777e41f4b71Sopenharmony_ci| DISTRIBUTED_DEVICE | 0  | Distributed database table between devices.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core              |
778e41f4b71Sopenharmony_ci| DISTRIBUTED_CLOUD  | 1   | Distributed database table between the device and the cloud.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
779e41f4b71Sopenharmony_ci
780e41f4b71Sopenharmony_ci## DistributedConfig<sup>10+</sup>
781e41f4b71Sopenharmony_ci
782e41f4b71Sopenharmony_ciDefines the configuration of the distributed mode of tables.
783e41f4b71Sopenharmony_ci
784e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
785e41f4b71Sopenharmony_ci
786e41f4b71Sopenharmony_ci| Name    | Type   | Mandatory| Description                                                        |
787e41f4b71Sopenharmony_ci| -------- | ------- | ---- | ------------------------------------------------------------ |
788e41f4b71Sopenharmony_ci| autoSync   | boolean | Yes  | The value **true** means both auto sync and manual sync are supported for the table. The value **false** means only manual sync is supported for the table.|
789e41f4b71Sopenharmony_ci
790e41f4b71Sopenharmony_ci## ConflictResolution<sup>10+</sup>
791e41f4b71Sopenharmony_ci
792e41f4b71Sopenharmony_ciDefines the resolution to use when a conflict occurs during data insertion or modification. Use the enum name rather than the enum value.
793e41f4b71Sopenharmony_ci
794e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
795e41f4b71Sopenharmony_ci
796e41f4b71Sopenharmony_ci| Name                | Value  | Description                                                        |
797e41f4b71Sopenharmony_ci| -------------------- | ---- | ------------------------------------------------------------ |
798e41f4b71Sopenharmony_ci| ON_CONFLICT_NONE | 0 | No operation is performed.|
799e41f4b71Sopenharmony_ci| ON_CONFLICT_ROLLBACK | 1    | Abort the SQL statement and roll back the current transaction.               |
800e41f4b71Sopenharmony_ci| ON_CONFLICT_ABORT    | 2    | Abort the current SQL statement and revert any changes made by the current SQL statement. However, the changes made by the previous SQL statement in the same transaction are retained and the transaction remains active.|
801e41f4b71Sopenharmony_ci| ON_CONFLICT_FAIL     | 3    | Abort the current SQL statement. The **FAIL** resolution does not revert previous changes made by the failed SQL statement or end the transaction.|
802e41f4b71Sopenharmony_ci| ON_CONFLICT_IGNORE   | 4    | Skip the rows that contain constraint violations and continue to process the subsequent rows of the SQL statement.|
803e41f4b71Sopenharmony_ci| ON_CONFLICT_REPLACE  | 5    | Delete pre-existing rows that cause the constraint violation before inserting or updating the current row, and continue to execute the command normally.|
804e41f4b71Sopenharmony_ci
805e41f4b71Sopenharmony_ci## Progress<sup>10+</sup>
806e41f4b71Sopenharmony_ci
807e41f4b71Sopenharmony_ciEnumerates the stages in the device-cloud sync progress. Use the enum name rather than the enum value.
808e41f4b71Sopenharmony_ci
809e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
810e41f4b71Sopenharmony_ci
811e41f4b71Sopenharmony_ci| Name            | Value  | Description                    |
812e41f4b71Sopenharmony_ci| ---------------- | ---- | ------------------------ |
813e41f4b71Sopenharmony_ci| SYNC_BEGIN       | 0    | The device-cloud sync starts.  |
814e41f4b71Sopenharmony_ci| SYNC_IN_PROGRESS | 1    | The device-cloud sync is in progress.|
815e41f4b71Sopenharmony_ci| SYNC_FINISH      | 2    | The device-cloud sync is complete.|
816e41f4b71Sopenharmony_ci
817e41f4b71Sopenharmony_ci## Statistic<sup>10+</sup>
818e41f4b71Sopenharmony_ci
819e41f4b71Sopenharmony_ciRepresents the device-cloud sync statistics information.
820e41f4b71Sopenharmony_ci
821e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
822e41f4b71Sopenharmony_ci
823e41f4b71Sopenharmony_ci| Name      | Type  | Mandatory| Description                                    |
824e41f4b71Sopenharmony_ci| ---------- | ------ | ---- | ---------------------------------------- |
825e41f4b71Sopenharmony_ci| total      | number | Yes  | Total number of rows to be synchronized between the device and cloud in the database table.    |
826e41f4b71Sopenharmony_ci| successful | number | Yes  | Number of rows that are successfully synchronized between the device and cloud in the database table.      |
827e41f4b71Sopenharmony_ci| failed     | number | Yes  | Number of rows that failed to be synchronized between the device and cloud in the database table.      |
828e41f4b71Sopenharmony_ci| remained   | number | Yes  | Number of rows that are not executed for device-cloud sync in the database table.|
829e41f4b71Sopenharmony_ci
830e41f4b71Sopenharmony_ci## TableDetails<sup>10+</sup>
831e41f4b71Sopenharmony_ci
832e41f4b71Sopenharmony_ciRepresents the upload and download statistics of device-cloud sync tasks.
833e41f4b71Sopenharmony_ci
834e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
835e41f4b71Sopenharmony_ci
836e41f4b71Sopenharmony_ci| Name    | Type                     | Mandatory| Description                                      |
837e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ------------------------------------------ |
838e41f4b71Sopenharmony_ci| upload   | [Statistic](#statistic10) | Yes  | Statistics of the device-cloud upload tasks.|
839e41f4b71Sopenharmony_ci| download | [Statistic](#statistic10) | Yes  | Statistics of the device-cloud download tasks.|
840e41f4b71Sopenharmony_ci
841e41f4b71Sopenharmony_ci## ProgressCode<sup>10+</sup>
842e41f4b71Sopenharmony_ci
843e41f4b71Sopenharmony_ciEnumerates the device-cloud sync states. Use the enum name rather than the enum value.
844e41f4b71Sopenharmony_ci
845e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
846e41f4b71Sopenharmony_ci
847e41f4b71Sopenharmony_ci| Name                 | Value  | Description                                                        |
848e41f4b71Sopenharmony_ci| --------------------- | ---- | ------------------------------------------------------------ |
849e41f4b71Sopenharmony_ci| SUCCESS               | 0    | The device-cloud sync is successful.                                      |
850e41f4b71Sopenharmony_ci| UNKNOWN_ERROR         | 1    | An unknown error occurs during device-cloud sync.                              |
851e41f4b71Sopenharmony_ci| NETWORK_ERROR         | 2    | A network error occurs during device-cloud sync.                              |
852e41f4b71Sopenharmony_ci| CLOUD_DISABLED        | 3    | The cloud is unavailable.                                            |
853e41f4b71Sopenharmony_ci| LOCKED_BY_OTHERS      | 4    | The device-cloud sync of another device is being performed.<br>Start device-cloud sync after checking that cloud resources are not occupied by other devices.|
854e41f4b71Sopenharmony_ci| RECORD_LIMIT_EXCEEDED | 5    | The number of records or size of the data to be synchronized exceeds the maximum. The maximum value is configured on the cloud.|
855e41f4b71Sopenharmony_ci| NO_SPACE_FOR_ASSET    | 6    | The remaining cloud space is less than the size of the data to be synchronized.                    |
856e41f4b71Sopenharmony_ci| BLOCKED_BY_NETWORK_STRATEGY<sup>12+</sup>    | 7    | The device-cloud sync is blocked due to the network strategy.                    |
857e41f4b71Sopenharmony_ci
858e41f4b71Sopenharmony_ci## ProgressDetails<sup>10+</sup>
859e41f4b71Sopenharmony_ci
860e41f4b71Sopenharmony_ciRepresents the statistics of the overall device-cloud sync (upload and download) tasks.
861e41f4b71Sopenharmony_ci
862e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
863e41f4b71Sopenharmony_ci
864e41f4b71Sopenharmony_ci| Name    | Type                                             | Mandatory| Description                                                        |
865e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
866e41f4b71Sopenharmony_ci| schedule | [Progress](#progress10)                           | Yes  | Device-cloud sync progress.                                          |
867e41f4b71Sopenharmony_ci| code     | [ProgressCode](#progresscode10)                   | Yes  | Device-cloud sync state.                                    |
868e41f4b71Sopenharmony_ci| details  | Record<string, [TableDetails](#tabledetails10)> | Yes  | Statistics of each table.<br>The key indicates the table name, and the value indicates the device-cloud sync statistics of the table.|
869e41f4b71Sopenharmony_ci
870e41f4b71Sopenharmony_ci## SqlExecutionInfo<sup>12+</sup>
871e41f4b71Sopenharmony_ci
872e41f4b71Sopenharmony_ciRepresents statistics about SQL statements executed by the database.
873e41f4b71Sopenharmony_ci
874e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
875e41f4b71Sopenharmony_ci
876e41f4b71Sopenharmony_ci| Name    | Type                                              | Read-Only| Optional |Description                                                        |
877e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- | ---- | ---- | -------------------------------------------------------- |
878e41f4b71Sopenharmony_ci| sql<sup>12+</sup>           | Array&lt;string&gt;            | Yes  |   No  | SQL statements executed. If the value of [batchInsert](#batchinsert) is too large, there may be multiple SQL statements.     |
879e41f4b71Sopenharmony_ci| totalTime<sup>12+</sup>      | number                        | Yes  |   No  | Total time used to execute the SQL statements, in μs.                                   |
880e41f4b71Sopenharmony_ci| waitTime<sup>12+</sup>       | number                        | Yes  |   No  | Time used to obtain the handle, in μs.                                        |
881e41f4b71Sopenharmony_ci| prepareTime<sup>12+</sup>    | number                        | Yes  |   No  | Time used to get the SQL statements ready and bind parameters, in μs.                                |
882e41f4b71Sopenharmony_ci| executeTime<sup>12+</sup>    | number                        | Yes  |   No  | Total time used to execute the SQL statements, in μs.|
883e41f4b71Sopenharmony_ci
884e41f4b71Sopenharmony_ci## RdbPredicates
885e41f4b71Sopenharmony_ci
886e41f4b71Sopenharmony_ciDefines the predicates for an RDB store. This class determines whether the conditional expression for the RDB store is true or false. Multiple predicates statements can be concatenated by using **and()** by default. Data of the Sendable type cannot be passed across threads.
887e41f4b71Sopenharmony_ci
888e41f4b71Sopenharmony_ci### constructor
889e41f4b71Sopenharmony_ci
890e41f4b71Sopenharmony_ciconstructor(name: string)
891e41f4b71Sopenharmony_ci
892e41f4b71Sopenharmony_ciA constructor used to create an **RdbPredicates** object.
893e41f4b71Sopenharmony_ci
894e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
895e41f4b71Sopenharmony_ci
896e41f4b71Sopenharmony_ci**Parameters**
897e41f4b71Sopenharmony_ci
898e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description        |
899e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------ |
900e41f4b71Sopenharmony_ci| name   | string | Yes  | Database table name.|
901e41f4b71Sopenharmony_ci
902e41f4b71Sopenharmony_ci**Error codes**
903e41f4b71Sopenharmony_ci
904e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
905e41f4b71Sopenharmony_ci
906e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
907e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
908e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
909e41f4b71Sopenharmony_ci
910e41f4b71Sopenharmony_ci**Example**
911e41f4b71Sopenharmony_ci
912e41f4b71Sopenharmony_ci```ts
913e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
914e41f4b71Sopenharmony_ci```
915e41f4b71Sopenharmony_ci
916e41f4b71Sopenharmony_ci### inDevices
917e41f4b71Sopenharmony_ci
918e41f4b71Sopenharmony_ciinDevices(devices: Array&lt;string&gt;): RdbPredicates
919e41f4b71Sopenharmony_ci
920e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to specify the remote devices to connect during the distributed database sync.
921e41f4b71Sopenharmony_ci
922e41f4b71Sopenharmony_ci> **NOTE**
923e41f4b71Sopenharmony_ci>
924e41f4b71Sopenharmony_ci> **devices** can be obtained by [deviceManager.getAvailableDeviceListSync](../apis-distributedservice-kit/js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
925e41f4b71Sopenharmony_ciIf **inDevices** is specified in **predicates** when **sync()** is called, data is synchronized with the specified device. If **inDevices** is not specified, data is synchronized with all devices on the network by default.
926e41f4b71Sopenharmony_ci
927e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
928e41f4b71Sopenharmony_ci
929e41f4b71Sopenharmony_ci**Parameters**
930e41f4b71Sopenharmony_ci
931e41f4b71Sopenharmony_ci| Name | Type               | Mandatory| Description                      |
932e41f4b71Sopenharmony_ci| ------- | ------------------- | ---- | -------------------------- |
933e41f4b71Sopenharmony_ci| devices | Array&lt;string&gt; | Yes  | IDs of the remote devices in the same network.|
934e41f4b71Sopenharmony_ci
935e41f4b71Sopenharmony_ci**Return value**
936e41f4b71Sopenharmony_ci
937e41f4b71Sopenharmony_ci| Type                                | Description                      |
938e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
939e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
940e41f4b71Sopenharmony_ci
941e41f4b71Sopenharmony_ci**Error codes**
942e41f4b71Sopenharmony_ci
943e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
944e41f4b71Sopenharmony_ci
945e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
946e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
947e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
948e41f4b71Sopenharmony_ci
949e41f4b71Sopenharmony_ci**Example**
950e41f4b71Sopenharmony_ci
951e41f4b71Sopenharmony_ci```ts
952e41f4b71Sopenharmony_ciimport { distributedDeviceManager } from '@kit.DistributedServiceKit';
953e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
954e41f4b71Sopenharmony_ci
955e41f4b71Sopenharmony_cilet dmInstance: distributedDeviceManager.DeviceManager;
956e41f4b71Sopenharmony_cilet deviceIds: Array<string> = [];
957e41f4b71Sopenharmony_ci
958e41f4b71Sopenharmony_citry {
959e41f4b71Sopenharmony_ci  dmInstance = distributedDeviceManager.createDeviceManager("com.example.appdatamgrverify");
960e41f4b71Sopenharmony_ci  let devices: Array<distributedDeviceManager.DeviceBasicInfo> = dmInstance.getAvailableDeviceListSync();
961e41f4b71Sopenharmony_ci  for (let i = 0; i < devices.length; i++) {
962e41f4b71Sopenharmony_ci    deviceIds[i] = devices[i].networkId!;
963e41f4b71Sopenharmony_ci  }
964e41f4b71Sopenharmony_ci} catch (err) {
965e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
966e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message
967e41f4b71Sopenharmony_ci  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
968e41f4b71Sopenharmony_ci}
969e41f4b71Sopenharmony_ci
970e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
971e41f4b71Sopenharmony_cipredicates.inDevices(deviceIds);
972e41f4b71Sopenharmony_ci```
973e41f4b71Sopenharmony_ci
974e41f4b71Sopenharmony_ci### inAllDevices
975e41f4b71Sopenharmony_ci
976e41f4b71Sopenharmony_ciinAllDevices(): RdbPredicates
977e41f4b71Sopenharmony_ci
978e41f4b71Sopenharmony_ciSets an **RdbPredicates** instance to specify all remote devices to connect during the distributed database sync.
979e41f4b71Sopenharmony_ci
980e41f4b71Sopenharmony_ci
981e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
982e41f4b71Sopenharmony_ci
983e41f4b71Sopenharmony_ci**Return value**
984e41f4b71Sopenharmony_ci
985e41f4b71Sopenharmony_ci| Type                                | Description                      |
986e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
987e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
988e41f4b71Sopenharmony_ci
989e41f4b71Sopenharmony_ci**Example**
990e41f4b71Sopenharmony_ci
991e41f4b71Sopenharmony_ci```ts
992e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
993e41f4b71Sopenharmony_cipredicates.inAllDevices();
994e41f4b71Sopenharmony_ci```
995e41f4b71Sopenharmony_ci
996e41f4b71Sopenharmony_ci### equalTo
997e41f4b71Sopenharmony_ci
998e41f4b71Sopenharmony_ciequalTo(field: string, value: ValueType): RdbPredicates
999e41f4b71Sopenharmony_ci
1000e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to match the fields in the specified column that are equal to the given value.
1001e41f4b71Sopenharmony_ci
1002e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1003e41f4b71Sopenharmony_ci
1004e41f4b71Sopenharmony_ci**Parameters**
1005e41f4b71Sopenharmony_ci
1006e41f4b71Sopenharmony_ci| Name| Type                   | Mandatory| Description                  |
1007e41f4b71Sopenharmony_ci| ------ | ----------------------- | ---- | ---------------------- |
1008e41f4b71Sopenharmony_ci| field  | string                  | Yes  | Column name in the database table.    |
1009e41f4b71Sopenharmony_ci| value  | [ValueType](#valuetype) | Yes  | Value to match the **RdbPredicates**.|
1010e41f4b71Sopenharmony_ci
1011e41f4b71Sopenharmony_ci**Return value**
1012e41f4b71Sopenharmony_ci
1013e41f4b71Sopenharmony_ci| Type                                | Description                      |
1014e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1015e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1016e41f4b71Sopenharmony_ci
1017e41f4b71Sopenharmony_ci**Error codes**
1018e41f4b71Sopenharmony_ci
1019e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1020e41f4b71Sopenharmony_ci
1021e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1022e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1023e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1024e41f4b71Sopenharmony_ci
1025e41f4b71Sopenharmony_ci**Example**
1026e41f4b71Sopenharmony_ci
1027e41f4b71Sopenharmony_ci```ts
1028e41f4b71Sopenharmony_ci// Locate data of Lisa in the EMPLOYEE table.
1029e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1030e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Lisa");
1031e41f4b71Sopenharmony_ci```
1032e41f4b71Sopenharmony_ci
1033e41f4b71Sopenharmony_ci
1034e41f4b71Sopenharmony_ci### notEqualTo
1035e41f4b71Sopenharmony_ci
1036e41f4b71Sopenharmony_cinotEqualTo(field: string, value: ValueType): RdbPredicates
1037e41f4b71Sopenharmony_ci
1038e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to match the fields in the specified column that are not equal to the given value.
1039e41f4b71Sopenharmony_ci
1040e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1041e41f4b71Sopenharmony_ci
1042e41f4b71Sopenharmony_ci**Parameters**
1043e41f4b71Sopenharmony_ci
1044e41f4b71Sopenharmony_ci| Name| Type                   | Mandatory| Description                  |
1045e41f4b71Sopenharmony_ci| ------ | ----------------------- | ---- | ---------------------- |
1046e41f4b71Sopenharmony_ci| field  | string                  | Yes  | Column name in the database table.    |
1047e41f4b71Sopenharmony_ci| value  | [ValueType](#valuetype) | Yes  | Value to match the **RdbPredicates**.|
1048e41f4b71Sopenharmony_ci
1049e41f4b71Sopenharmony_ci**Return value**
1050e41f4b71Sopenharmony_ci
1051e41f4b71Sopenharmony_ci| Type                                | Description                      |
1052e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1053e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1054e41f4b71Sopenharmony_ci
1055e41f4b71Sopenharmony_ci**Error codes**
1056e41f4b71Sopenharmony_ci
1057e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1058e41f4b71Sopenharmony_ci
1059e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1060e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1061e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1062e41f4b71Sopenharmony_ci
1063e41f4b71Sopenharmony_ci**Example**
1064e41f4b71Sopenharmony_ci
1065e41f4b71Sopenharmony_ci```ts
1066e41f4b71Sopenharmony_ci// Locate data of the employees whose name is not Lisa in the table.
1067e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1068e41f4b71Sopenharmony_cipredicates.notEqualTo("NAME", "Lisa");
1069e41f4b71Sopenharmony_ci```
1070e41f4b71Sopenharmony_ci
1071e41f4b71Sopenharmony_ci
1072e41f4b71Sopenharmony_ci### beginWrap
1073e41f4b71Sopenharmony_ci
1074e41f4b71Sopenharmony_cibeginWrap(): RdbPredicates
1075e41f4b71Sopenharmony_ci
1076e41f4b71Sopenharmony_ciAdds a left parenthesis to the **RdbPredicates**.
1077e41f4b71Sopenharmony_ci
1078e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1079e41f4b71Sopenharmony_ci
1080e41f4b71Sopenharmony_ci**Return value**
1081e41f4b71Sopenharmony_ci
1082e41f4b71Sopenharmony_ci| Type                                | Description                     |
1083e41f4b71Sopenharmony_ci| ------------------------------------ | ------------------------- |
1084e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** with a left parenthesis.|
1085e41f4b71Sopenharmony_ci
1086e41f4b71Sopenharmony_ci**Example**
1087e41f4b71Sopenharmony_ci
1088e41f4b71Sopenharmony_ci```ts
1089e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1090e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Lisa")
1091e41f4b71Sopenharmony_ci    .beginWrap()
1092e41f4b71Sopenharmony_ci    .equalTo("AGE", 18)
1093e41f4b71Sopenharmony_ci    .or()
1094e41f4b71Sopenharmony_ci    .equalTo("SALARY", 200.5)
1095e41f4b71Sopenharmony_ci    .endWrap()
1096e41f4b71Sopenharmony_ci```
1097e41f4b71Sopenharmony_ci
1098e41f4b71Sopenharmony_ci### endWrap
1099e41f4b71Sopenharmony_ci
1100e41f4b71Sopenharmony_ciendWrap(): RdbPredicates
1101e41f4b71Sopenharmony_ci
1102e41f4b71Sopenharmony_ciAdds a right parenthesis to the **RdbPredicates**.
1103e41f4b71Sopenharmony_ci
1104e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1105e41f4b71Sopenharmony_ci
1106e41f4b71Sopenharmony_ci**Return value**
1107e41f4b71Sopenharmony_ci
1108e41f4b71Sopenharmony_ci| Type                                | Description                     |
1109e41f4b71Sopenharmony_ci| ------------------------------------ | ------------------------- |
1110e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** with a right parenthesis.|
1111e41f4b71Sopenharmony_ci
1112e41f4b71Sopenharmony_ci**Example**
1113e41f4b71Sopenharmony_ci
1114e41f4b71Sopenharmony_ci```ts
1115e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1116e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Lisa")
1117e41f4b71Sopenharmony_ci    .beginWrap()
1118e41f4b71Sopenharmony_ci    .equalTo("AGE", 18)
1119e41f4b71Sopenharmony_ci    .or()
1120e41f4b71Sopenharmony_ci    .equalTo("SALARY", 200.5)
1121e41f4b71Sopenharmony_ci    .endWrap()
1122e41f4b71Sopenharmony_ci```
1123e41f4b71Sopenharmony_ci
1124e41f4b71Sopenharmony_ci### or
1125e41f4b71Sopenharmony_ci
1126e41f4b71Sopenharmony_cior(): RdbPredicates
1127e41f4b71Sopenharmony_ci
1128e41f4b71Sopenharmony_ciAdds the OR condition to the **RdbPredicates**.
1129e41f4b71Sopenharmony_ci
1130e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1131e41f4b71Sopenharmony_ci
1132e41f4b71Sopenharmony_ci**Return value**
1133e41f4b71Sopenharmony_ci
1134e41f4b71Sopenharmony_ci| Type                                | Description                     |
1135e41f4b71Sopenharmony_ci| ------------------------------------ | ------------------------- |
1136e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** with the OR condition.|
1137e41f4b71Sopenharmony_ci
1138e41f4b71Sopenharmony_ci**Example**
1139e41f4b71Sopenharmony_ci
1140e41f4b71Sopenharmony_ci```ts
1141e41f4b71Sopenharmony_ci// Locate the employees named Lisa or Rose in the table.
1142e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1143e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Lisa")
1144e41f4b71Sopenharmony_ci    .or()
1145e41f4b71Sopenharmony_ci    .equalTo("NAME", "Rose")
1146e41f4b71Sopenharmony_ci```
1147e41f4b71Sopenharmony_ci
1148e41f4b71Sopenharmony_ci### and
1149e41f4b71Sopenharmony_ci
1150e41f4b71Sopenharmony_ciand(): RdbPredicates
1151e41f4b71Sopenharmony_ci
1152e41f4b71Sopenharmony_ciAdds the AND condition to the **RdbPredicates**.
1153e41f4b71Sopenharmony_ci
1154e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1155e41f4b71Sopenharmony_ci
1156e41f4b71Sopenharmony_ci**Return value**
1157e41f4b71Sopenharmony_ci
1158e41f4b71Sopenharmony_ci| Type                                | Description                     |
1159e41f4b71Sopenharmony_ci| ------------------------------------ | ------------------------- |
1160e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** with the AND condition.|
1161e41f4b71Sopenharmony_ci
1162e41f4b71Sopenharmony_ci**Example**
1163e41f4b71Sopenharmony_ci
1164e41f4b71Sopenharmony_ci```ts
1165e41f4b71Sopenharmony_ci// Locate the field with name of Lisa and salary of 200.5 in the table.
1166e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1167e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Lisa")
1168e41f4b71Sopenharmony_ci    .and()
1169e41f4b71Sopenharmony_ci    .equalTo("SALARY", 200.5)
1170e41f4b71Sopenharmony_ci```
1171e41f4b71Sopenharmony_ci
1172e41f4b71Sopenharmony_ci### contains
1173e41f4b71Sopenharmony_ci
1174e41f4b71Sopenharmony_cicontains(field: string, value: string): RdbPredicates
1175e41f4b71Sopenharmony_ci
1176e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to match the fields in the specified column that contain the given value.
1177e41f4b71Sopenharmony_ci
1178e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1179e41f4b71Sopenharmony_ci
1180e41f4b71Sopenharmony_ci**Parameters**
1181e41f4b71Sopenharmony_ci
1182e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                  |
1183e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------- |
1184e41f4b71Sopenharmony_ci| field  | string | Yes  | Column name in the database table.    |
1185e41f4b71Sopenharmony_ci| value  | string | Yes  | Value to match the **RdbPredicates**.|
1186e41f4b71Sopenharmony_ci
1187e41f4b71Sopenharmony_ci**Return value**
1188e41f4b71Sopenharmony_ci
1189e41f4b71Sopenharmony_ci| Type                                | Description                      |
1190e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1191e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1192e41f4b71Sopenharmony_ci
1193e41f4b71Sopenharmony_ci**Error codes**
1194e41f4b71Sopenharmony_ci
1195e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1196e41f4b71Sopenharmony_ci
1197e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1198e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1199e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1200e41f4b71Sopenharmony_ci
1201e41f4b71Sopenharmony_ci**Example**
1202e41f4b71Sopenharmony_ci
1203e41f4b71Sopenharmony_ci```ts
1204e41f4b71Sopenharmony_ci// Locate data of the employees whose name contains os, for example, Rose, in the table.
1205e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1206e41f4b71Sopenharmony_cipredicates.contains("NAME", "os");
1207e41f4b71Sopenharmony_ci```
1208e41f4b71Sopenharmony_ci
1209e41f4b71Sopenharmony_ci### beginsWith
1210e41f4b71Sopenharmony_ci
1211e41f4b71Sopenharmony_cibeginsWith(field: string, value: string): RdbPredicates
1212e41f4b71Sopenharmony_ci
1213e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to match the fields in the specified column that begin with the given value.
1214e41f4b71Sopenharmony_ci
1215e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1216e41f4b71Sopenharmony_ci
1217e41f4b71Sopenharmony_ci**Parameters**
1218e41f4b71Sopenharmony_ci
1219e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                  |
1220e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------- |
1221e41f4b71Sopenharmony_ci| field  | string | Yes  | Column name in the database table.    |
1222e41f4b71Sopenharmony_ci| value  | string | Yes  | Value to match the **RdbPredicates**.|
1223e41f4b71Sopenharmony_ci
1224e41f4b71Sopenharmony_ci**Return value**
1225e41f4b71Sopenharmony_ci
1226e41f4b71Sopenharmony_ci| Type                                | Description                      |
1227e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1228e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1229e41f4b71Sopenharmony_ci
1230e41f4b71Sopenharmony_ci**Error codes**
1231e41f4b71Sopenharmony_ci
1232e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1233e41f4b71Sopenharmony_ci
1234e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1235e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1236e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1237e41f4b71Sopenharmony_ci
1238e41f4b71Sopenharmony_ci**Example**
1239e41f4b71Sopenharmony_ci
1240e41f4b71Sopenharmony_ci```ts
1241e41f4b71Sopenharmony_ci// Locate data of the employees whose name begins with Li, for example, Lisa, in the table.
1242e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1243e41f4b71Sopenharmony_cipredicates.beginsWith("NAME", "Li");
1244e41f4b71Sopenharmony_ci```
1245e41f4b71Sopenharmony_ci
1246e41f4b71Sopenharmony_ci### endsWith
1247e41f4b71Sopenharmony_ci
1248e41f4b71Sopenharmony_ciendsWith(field: string, value: string): RdbPredicates
1249e41f4b71Sopenharmony_ci
1250e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to match the fields in the specified column that end with the given value.
1251e41f4b71Sopenharmony_ci
1252e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1253e41f4b71Sopenharmony_ci
1254e41f4b71Sopenharmony_ci**Parameters**
1255e41f4b71Sopenharmony_ci
1256e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                  |
1257e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------- |
1258e41f4b71Sopenharmony_ci| field  | string | Yes  | Column name in the database table.    |
1259e41f4b71Sopenharmony_ci| value  | string | Yes  | Value to match the **RdbPredicates**.|
1260e41f4b71Sopenharmony_ci
1261e41f4b71Sopenharmony_ci**Return value**
1262e41f4b71Sopenharmony_ci
1263e41f4b71Sopenharmony_ci| Type                                | Description                      |
1264e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1265e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1266e41f4b71Sopenharmony_ci
1267e41f4b71Sopenharmony_ci**Error codes**
1268e41f4b71Sopenharmony_ci
1269e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1270e41f4b71Sopenharmony_ci
1271e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1272e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1273e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1274e41f4b71Sopenharmony_ci
1275e41f4b71Sopenharmony_ci**Example**
1276e41f4b71Sopenharmony_ci
1277e41f4b71Sopenharmony_ci```ts
1278e41f4b71Sopenharmony_ci// Locate data of the employees whose name ends with se, for example, Rose, in the table.
1279e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1280e41f4b71Sopenharmony_cipredicates.endsWith("NAME", "se");
1281e41f4b71Sopenharmony_ci```
1282e41f4b71Sopenharmony_ci
1283e41f4b71Sopenharmony_ci### isNull
1284e41f4b71Sopenharmony_ci
1285e41f4b71Sopenharmony_ciisNull(field: string): RdbPredicates
1286e41f4b71Sopenharmony_ci
1287e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to match the fields in the specified column that are **null**.
1288e41f4b71Sopenharmony_ci
1289e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1290e41f4b71Sopenharmony_ci
1291e41f4b71Sopenharmony_ci**Parameters**
1292e41f4b71Sopenharmony_ci
1293e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description              |
1294e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------ |
1295e41f4b71Sopenharmony_ci| field  | string | Yes  | Column name in the database table.|
1296e41f4b71Sopenharmony_ci
1297e41f4b71Sopenharmony_ci**Return value**
1298e41f4b71Sopenharmony_ci
1299e41f4b71Sopenharmony_ci| Type                                | Description                      |
1300e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1301e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1302e41f4b71Sopenharmony_ci
1303e41f4b71Sopenharmony_ci**Error codes**
1304e41f4b71Sopenharmony_ci
1305e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1306e41f4b71Sopenharmony_ci
1307e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1308e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1309e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1310e41f4b71Sopenharmony_ci
1311e41f4b71Sopenharmony_ci**Example**
1312e41f4b71Sopenharmony_ci
1313e41f4b71Sopenharmony_ci```ts
1314e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1315e41f4b71Sopenharmony_cipredicates.isNull("NAME");
1316e41f4b71Sopenharmony_ci```
1317e41f4b71Sopenharmony_ci
1318e41f4b71Sopenharmony_ci### isNotNull
1319e41f4b71Sopenharmony_ci
1320e41f4b71Sopenharmony_ciisNotNull(field: string): RdbPredicates
1321e41f4b71Sopenharmony_ci
1322e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to match the fields in the specified column that are not **null**.
1323e41f4b71Sopenharmony_ci
1324e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1325e41f4b71Sopenharmony_ci
1326e41f4b71Sopenharmony_ci**Parameters**
1327e41f4b71Sopenharmony_ci
1328e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description              |
1329e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------ |
1330e41f4b71Sopenharmony_ci| field  | string | Yes  | Column name in the database table.|
1331e41f4b71Sopenharmony_ci
1332e41f4b71Sopenharmony_ci**Return value**
1333e41f4b71Sopenharmony_ci
1334e41f4b71Sopenharmony_ci| Type                                | Description                      |
1335e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1336e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1337e41f4b71Sopenharmony_ci
1338e41f4b71Sopenharmony_ci**Error codes**
1339e41f4b71Sopenharmony_ci
1340e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1341e41f4b71Sopenharmony_ci
1342e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1343e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1344e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1345e41f4b71Sopenharmony_ci
1346e41f4b71Sopenharmony_ci**Example**
1347e41f4b71Sopenharmony_ci
1348e41f4b71Sopenharmony_ci```ts
1349e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1350e41f4b71Sopenharmony_cipredicates.isNotNull("NAME");
1351e41f4b71Sopenharmony_ci```
1352e41f4b71Sopenharmony_ci
1353e41f4b71Sopenharmony_ci### like
1354e41f4b71Sopenharmony_ci
1355e41f4b71Sopenharmony_cilike(field: string, value: string): RdbPredicates
1356e41f4b71Sopenharmony_ci
1357e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to match the fields in the specified column that are similar to the given value.
1358e41f4b71Sopenharmony_ci
1359e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1360e41f4b71Sopenharmony_ci
1361e41f4b71Sopenharmony_ci**Parameters**
1362e41f4b71Sopenharmony_ci
1363e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                  |
1364e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------- |
1365e41f4b71Sopenharmony_ci| field  | string | Yes  | Column name in the database table.    |
1366e41f4b71Sopenharmony_ci| value  | string | Yes  | Value to match the **RdbPredicates**.|
1367e41f4b71Sopenharmony_ci
1368e41f4b71Sopenharmony_ci**Return value**
1369e41f4b71Sopenharmony_ci
1370e41f4b71Sopenharmony_ci| Type                                | Description                      |
1371e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1372e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1373e41f4b71Sopenharmony_ci
1374e41f4b71Sopenharmony_ci**Error codes**
1375e41f4b71Sopenharmony_ci
1376e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1377e41f4b71Sopenharmony_ci
1378e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1379e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1380e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1381e41f4b71Sopenharmony_ci
1382e41f4b71Sopenharmony_ci**Example**
1383e41f4b71Sopenharmony_ci
1384e41f4b71Sopenharmony_ci```ts
1385e41f4b71Sopenharmony_ci// Locate data of the employees whose name is similar to os in the table, for example, Rose.
1386e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1387e41f4b71Sopenharmony_cipredicates.like("NAME", "%os%");
1388e41f4b71Sopenharmony_ci```
1389e41f4b71Sopenharmony_ci
1390e41f4b71Sopenharmony_ci### glob
1391e41f4b71Sopenharmony_ci
1392e41f4b71Sopenharmony_ciglob(field: string, value: string): RdbPredicates
1393e41f4b71Sopenharmony_ci
1394e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to locate the fields in the specified column that match the given string.
1395e41f4b71Sopenharmony_ci
1396e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1397e41f4b71Sopenharmony_ci
1398e41f4b71Sopenharmony_ci**Parameters**
1399e41f4b71Sopenharmony_ci
1400e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                                                        |
1401e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------------------------------------------------ |
1402e41f4b71Sopenharmony_ci| field  | string | Yes  | Column name in the database table.                                          |
1403e41f4b71Sopenharmony_ci| value  | string | Yes  | Value to match the **RdbPredicates**.<br><br>Wildcards are supported. * indicates zero, one, or multiple digits or characters. **?** indicates a single digit or character.|
1404e41f4b71Sopenharmony_ci
1405e41f4b71Sopenharmony_ci**Return value**
1406e41f4b71Sopenharmony_ci
1407e41f4b71Sopenharmony_ci| Type                                | Description                      |
1408e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1409e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1410e41f4b71Sopenharmony_ci
1411e41f4b71Sopenharmony_ci**Error codes**
1412e41f4b71Sopenharmony_ci
1413e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1414e41f4b71Sopenharmony_ci
1415e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1416e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1417e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1418e41f4b71Sopenharmony_ci
1419e41f4b71Sopenharmony_ci**Example**
1420e41f4b71Sopenharmony_ci
1421e41f4b71Sopenharmony_ci```ts
1422e41f4b71Sopenharmony_ci// Locate data of the employees whose name matches the "?h*g" string in the table.
1423e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1424e41f4b71Sopenharmony_cipredicates.glob("NAME", "?h*g");
1425e41f4b71Sopenharmony_ci```
1426e41f4b71Sopenharmony_ci
1427e41f4b71Sopenharmony_ci### between
1428e41f4b71Sopenharmony_ci
1429e41f4b71Sopenharmony_cibetween(field: string, low: ValueType, high: ValueType): RdbPredicates
1430e41f4b71Sopenharmony_ci
1431e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to match the fields in the specified column that are within the given range (including the min. and max. values).
1432e41f4b71Sopenharmony_ci
1433e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1434e41f4b71Sopenharmony_ci
1435e41f4b71Sopenharmony_ci**Parameters**
1436e41f4b71Sopenharmony_ci
1437e41f4b71Sopenharmony_ci| Name| Type                   | Mandatory| Description                      |
1438e41f4b71Sopenharmony_ci| ------ | ----------------------- | ---- | -------------------------- |
1439e41f4b71Sopenharmony_ci| field  | string                  | Yes  | Column name in the database table.        |
1440e41f4b71Sopenharmony_ci| low    | [ValueType](#valuetype) | Yes  | Minimum value to match.  |
1441e41f4b71Sopenharmony_ci| high   | [ValueType](#valuetype) | Yes  | Maximum value to match.|
1442e41f4b71Sopenharmony_ci
1443e41f4b71Sopenharmony_ci**Return value**
1444e41f4b71Sopenharmony_ci
1445e41f4b71Sopenharmony_ci| Type                                | Description                      |
1446e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1447e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1448e41f4b71Sopenharmony_ci
1449e41f4b71Sopenharmony_ci**Error codes**
1450e41f4b71Sopenharmony_ci
1451e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1452e41f4b71Sopenharmony_ci
1453e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1454e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1455e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1456e41f4b71Sopenharmony_ci
1457e41f4b71Sopenharmony_ci**Example**
1458e41f4b71Sopenharmony_ci
1459e41f4b71Sopenharmony_ci```ts
1460e41f4b71Sopenharmony_ci// Locate data of the employees with age between 10 and 50 (including 10 and 50) in the table.
1461e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1462e41f4b71Sopenharmony_cipredicates.between("AGE", 10, 50);
1463e41f4b71Sopenharmony_ci```
1464e41f4b71Sopenharmony_ci
1465e41f4b71Sopenharmony_ci### notBetween
1466e41f4b71Sopenharmony_ci
1467e41f4b71Sopenharmony_cinotBetween(field: string, low: ValueType, high: ValueType): RdbPredicates
1468e41f4b71Sopenharmony_ci
1469e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to match the fields in the specified column that are out of the given range (excluding the min. and max. values).
1470e41f4b71Sopenharmony_ci
1471e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1472e41f4b71Sopenharmony_ci
1473e41f4b71Sopenharmony_ci**Parameters**
1474e41f4b71Sopenharmony_ci
1475e41f4b71Sopenharmony_ci| Name| Type                   | Mandatory| Description                      |
1476e41f4b71Sopenharmony_ci| ------ | ----------------------- | ---- | -------------------------- |
1477e41f4b71Sopenharmony_ci| field  | string                  | Yes  | Column name in the database table.        |
1478e41f4b71Sopenharmony_ci| low    | [ValueType](#valuetype) | Yes  | Minimum value to match.  |
1479e41f4b71Sopenharmony_ci| high   | [ValueType](#valuetype) | Yes  | Maximum value to match.|
1480e41f4b71Sopenharmony_ci
1481e41f4b71Sopenharmony_ci**Return value**
1482e41f4b71Sopenharmony_ci
1483e41f4b71Sopenharmony_ci| Type                                | Description                      |
1484e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1485e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1486e41f4b71Sopenharmony_ci
1487e41f4b71Sopenharmony_ci**Error codes**
1488e41f4b71Sopenharmony_ci
1489e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1490e41f4b71Sopenharmony_ci
1491e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1492e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1493e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1494e41f4b71Sopenharmony_ci
1495e41f4b71Sopenharmony_ci**Example**
1496e41f4b71Sopenharmony_ci
1497e41f4b71Sopenharmony_ci```ts
1498e41f4b71Sopenharmony_ci// Locate data of the employees who are younger than 10 or older than 50 in the table.
1499e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1500e41f4b71Sopenharmony_cipredicates.notBetween("AGE", 10, 50);
1501e41f4b71Sopenharmony_ci```
1502e41f4b71Sopenharmony_ci
1503e41f4b71Sopenharmony_ci### greaterThan
1504e41f4b71Sopenharmony_ci
1505e41f4b71Sopenharmony_cigreaterThan(field: string, value: ValueType): RdbPredicates
1506e41f4b71Sopenharmony_ci
1507e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to match the fields in the specified column that are greater than the given value.
1508e41f4b71Sopenharmony_ci
1509e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1510e41f4b71Sopenharmony_ci
1511e41f4b71Sopenharmony_ci**Parameters**
1512e41f4b71Sopenharmony_ci
1513e41f4b71Sopenharmony_ci| Name| Type                   | Mandatory| Description                  |
1514e41f4b71Sopenharmony_ci| ------ | ----------------------- | ---- | ---------------------- |
1515e41f4b71Sopenharmony_ci| field  | string                  | Yes  | Column name in the database table.    |
1516e41f4b71Sopenharmony_ci| value  | [ValueType](#valuetype) | Yes  | Value to match the **RdbPredicates**.|
1517e41f4b71Sopenharmony_ci
1518e41f4b71Sopenharmony_ci**Return value**
1519e41f4b71Sopenharmony_ci
1520e41f4b71Sopenharmony_ci| Type                                | Description                      |
1521e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1522e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1523e41f4b71Sopenharmony_ci
1524e41f4b71Sopenharmony_ci**Error codes**
1525e41f4b71Sopenharmony_ci
1526e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1527e41f4b71Sopenharmony_ci
1528e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1529e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1530e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1531e41f4b71Sopenharmony_ci
1532e41f4b71Sopenharmony_ci**Example**
1533e41f4b71Sopenharmony_ci
1534e41f4b71Sopenharmony_ci```ts
1535e41f4b71Sopenharmony_ci// Locate data of the employees who are older than 18 in the table.
1536e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1537e41f4b71Sopenharmony_cipredicates.greaterThan("AGE", 18);
1538e41f4b71Sopenharmony_ci```
1539e41f4b71Sopenharmony_ci
1540e41f4b71Sopenharmony_ci### lessThan
1541e41f4b71Sopenharmony_ci
1542e41f4b71Sopenharmony_cilessThan(field: string, value: ValueType): RdbPredicates
1543e41f4b71Sopenharmony_ci
1544e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to match the fields in the specified column that are less than the given value.
1545e41f4b71Sopenharmony_ci
1546e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1547e41f4b71Sopenharmony_ci
1548e41f4b71Sopenharmony_ci**Parameters**
1549e41f4b71Sopenharmony_ci
1550e41f4b71Sopenharmony_ci| Name| Type                   | Mandatory| Description                  |
1551e41f4b71Sopenharmony_ci| ------ | ----------------------- | ---- | ---------------------- |
1552e41f4b71Sopenharmony_ci| field  | string                  | Yes  | Column name in the database table.    |
1553e41f4b71Sopenharmony_ci| value  | [ValueType](#valuetype) | Yes  | Value to match the **RdbPredicates**.|
1554e41f4b71Sopenharmony_ci
1555e41f4b71Sopenharmony_ci**Return value**
1556e41f4b71Sopenharmony_ci
1557e41f4b71Sopenharmony_ci| Type                                | Description                      |
1558e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1559e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1560e41f4b71Sopenharmony_ci
1561e41f4b71Sopenharmony_ci**Error codes**
1562e41f4b71Sopenharmony_ci
1563e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1564e41f4b71Sopenharmony_ci
1565e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1566e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1567e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1568e41f4b71Sopenharmony_ci
1569e41f4b71Sopenharmony_ci**Example**
1570e41f4b71Sopenharmony_ci
1571e41f4b71Sopenharmony_ci```ts
1572e41f4b71Sopenharmony_ci// Locate data of the employees who are younger than 20 in the table.
1573e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1574e41f4b71Sopenharmony_cipredicates.lessThan("AGE", 20);
1575e41f4b71Sopenharmony_ci```
1576e41f4b71Sopenharmony_ci
1577e41f4b71Sopenharmony_ci### greaterThanOrEqualTo
1578e41f4b71Sopenharmony_ci
1579e41f4b71Sopenharmony_cigreaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates
1580e41f4b71Sopenharmony_ci
1581e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to match the fields in the specified column that are greater than or equal to the given value.
1582e41f4b71Sopenharmony_ci
1583e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1584e41f4b71Sopenharmony_ci
1585e41f4b71Sopenharmony_ci**Parameters**
1586e41f4b71Sopenharmony_ci
1587e41f4b71Sopenharmony_ci| Name| Type                   | Mandatory| Description                  |
1588e41f4b71Sopenharmony_ci| ------ | ----------------------- | ---- | ---------------------- |
1589e41f4b71Sopenharmony_ci| field  | string                  | Yes  | Column name in the database table.    |
1590e41f4b71Sopenharmony_ci| value  | [ValueType](#valuetype) | Yes  | Value to match the **RdbPredicates**.|
1591e41f4b71Sopenharmony_ci
1592e41f4b71Sopenharmony_ci**Return value**
1593e41f4b71Sopenharmony_ci
1594e41f4b71Sopenharmony_ci| Type                                | Description                      |
1595e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1596e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1597e41f4b71Sopenharmony_ci
1598e41f4b71Sopenharmony_ci**Error codes**
1599e41f4b71Sopenharmony_ci
1600e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1601e41f4b71Sopenharmony_ci
1602e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1603e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1604e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1605e41f4b71Sopenharmony_ci
1606e41f4b71Sopenharmony_ci**Example**
1607e41f4b71Sopenharmony_ci
1608e41f4b71Sopenharmony_ci```ts
1609e41f4b71Sopenharmony_ci// Locate data of the employees who are 18 or older in the table.
1610e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1611e41f4b71Sopenharmony_cipredicates.greaterThanOrEqualTo("AGE", 18);
1612e41f4b71Sopenharmony_ci```
1613e41f4b71Sopenharmony_ci
1614e41f4b71Sopenharmony_ci### lessThanOrEqualTo
1615e41f4b71Sopenharmony_ci
1616e41f4b71Sopenharmony_cilessThanOrEqualTo(field: string, value: ValueType): RdbPredicates
1617e41f4b71Sopenharmony_ci
1618e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to match the fields in the specified column that are less than or equal to the given value.
1619e41f4b71Sopenharmony_ci
1620e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1621e41f4b71Sopenharmony_ci
1622e41f4b71Sopenharmony_ci**Parameters**
1623e41f4b71Sopenharmony_ci
1624e41f4b71Sopenharmony_ci| Name| Type                   | Mandatory| Description                  |
1625e41f4b71Sopenharmony_ci| ------ | ----------------------- | ---- | ---------------------- |
1626e41f4b71Sopenharmony_ci| field  | string                  | Yes  | Column name in the database table.    |
1627e41f4b71Sopenharmony_ci| value  | [ValueType](#valuetype) | Yes  | Value to match the **RdbPredicates**.|
1628e41f4b71Sopenharmony_ci
1629e41f4b71Sopenharmony_ci**Return value**
1630e41f4b71Sopenharmony_ci
1631e41f4b71Sopenharmony_ci| Type                                | Description                      |
1632e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1633e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1634e41f4b71Sopenharmony_ci
1635e41f4b71Sopenharmony_ci**Error codes**
1636e41f4b71Sopenharmony_ci
1637e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1638e41f4b71Sopenharmony_ci
1639e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1640e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1641e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1642e41f4b71Sopenharmony_ci
1643e41f4b71Sopenharmony_ci**Example**
1644e41f4b71Sopenharmony_ci
1645e41f4b71Sopenharmony_ci```ts
1646e41f4b71Sopenharmony_ci// Locate data of the employees who are 20 or younger in the table.
1647e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1648e41f4b71Sopenharmony_cipredicates.lessThanOrEqualTo("AGE", 20);
1649e41f4b71Sopenharmony_ci```
1650e41f4b71Sopenharmony_ci
1651e41f4b71Sopenharmony_ci### orderByAsc
1652e41f4b71Sopenharmony_ci
1653e41f4b71Sopenharmony_ciorderByAsc(field: string): RdbPredicates
1654e41f4b71Sopenharmony_ci
1655e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to sort the fields in the specified column in ascending order.
1656e41f4b71Sopenharmony_ci
1657e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1658e41f4b71Sopenharmony_ci
1659e41f4b71Sopenharmony_ci**Parameters**
1660e41f4b71Sopenharmony_ci
1661e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description              |
1662e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------ |
1663e41f4b71Sopenharmony_ci| field  | string | Yes  | Column name in the database table.|
1664e41f4b71Sopenharmony_ci
1665e41f4b71Sopenharmony_ci**Return value**
1666e41f4b71Sopenharmony_ci
1667e41f4b71Sopenharmony_ci| Type                                | Description                      |
1668e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1669e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1670e41f4b71Sopenharmony_ci
1671e41f4b71Sopenharmony_ci**Error codes**
1672e41f4b71Sopenharmony_ci
1673e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1674e41f4b71Sopenharmony_ci
1675e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1676e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1677e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1678e41f4b71Sopenharmony_ci
1679e41f4b71Sopenharmony_ci**Example**
1680e41f4b71Sopenharmony_ci
1681e41f4b71Sopenharmony_ci```ts
1682e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1683e41f4b71Sopenharmony_cipredicates.orderByAsc("NAME");
1684e41f4b71Sopenharmony_ci```
1685e41f4b71Sopenharmony_ci
1686e41f4b71Sopenharmony_ci### orderByDesc
1687e41f4b71Sopenharmony_ci
1688e41f4b71Sopenharmony_ciorderByDesc(field: string): RdbPredicates
1689e41f4b71Sopenharmony_ci
1690e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to sort the fields in the specified column in descending order.
1691e41f4b71Sopenharmony_ci
1692e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1693e41f4b71Sopenharmony_ci
1694e41f4b71Sopenharmony_ci**Parameters**
1695e41f4b71Sopenharmony_ci
1696e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description              |
1697e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ------------------ |
1698e41f4b71Sopenharmony_ci| field  | string | Yes  | Column name in the database table.|
1699e41f4b71Sopenharmony_ci
1700e41f4b71Sopenharmony_ci**Return value**
1701e41f4b71Sopenharmony_ci
1702e41f4b71Sopenharmony_ci| Type                                | Description                      |
1703e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1704e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1705e41f4b71Sopenharmony_ci
1706e41f4b71Sopenharmony_ci**Error codes**
1707e41f4b71Sopenharmony_ci
1708e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1709e41f4b71Sopenharmony_ci
1710e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1711e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1712e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1713e41f4b71Sopenharmony_ci
1714e41f4b71Sopenharmony_ci**Example**
1715e41f4b71Sopenharmony_ci
1716e41f4b71Sopenharmony_ci```ts
1717e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1718e41f4b71Sopenharmony_cipredicates.orderByDesc("AGE");
1719e41f4b71Sopenharmony_ci```
1720e41f4b71Sopenharmony_ci
1721e41f4b71Sopenharmony_ci### distinct
1722e41f4b71Sopenharmony_ci
1723e41f4b71Sopenharmony_cidistinct(): RdbPredicates
1724e41f4b71Sopenharmony_ci
1725e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to filter out duplicate records.
1726e41f4b71Sopenharmony_ci
1727e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1728e41f4b71Sopenharmony_ci
1729e41f4b71Sopenharmony_ci**Return value**
1730e41f4b71Sopenharmony_ci
1731e41f4b71Sopenharmony_ci| Type                                | Description                          |
1732e41f4b71Sopenharmony_ci| ------------------------------------ | ------------------------------ |
1733e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that can filter out duplicate records.|
1734e41f4b71Sopenharmony_ci
1735e41f4b71Sopenharmony_ci**Example**
1736e41f4b71Sopenharmony_ci
1737e41f4b71Sopenharmony_ci```ts
1738e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1739e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Rose").distinct();
1740e41f4b71Sopenharmony_ci```
1741e41f4b71Sopenharmony_ci
1742e41f4b71Sopenharmony_ci### limitAs
1743e41f4b71Sopenharmony_ci
1744e41f4b71Sopenharmony_cilimitAs(value: number): RdbPredicates
1745e41f4b71Sopenharmony_ci
1746e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to specify the maximum number of records.
1747e41f4b71Sopenharmony_ci
1748e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1749e41f4b71Sopenharmony_ci
1750e41f4b71Sopenharmony_ci**Parameters**
1751e41f4b71Sopenharmony_ci
1752e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description            |
1753e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------- |
1754e41f4b71Sopenharmony_ci| value  | number | Yes  | Maximum number of records.|
1755e41f4b71Sopenharmony_ci
1756e41f4b71Sopenharmony_ci**Return value**
1757e41f4b71Sopenharmony_ci
1758e41f4b71Sopenharmony_ci| Type                                | Description                                |
1759e41f4b71Sopenharmony_ci| ------------------------------------ | ------------------------------------ |
1760e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the maximum number of records.|
1761e41f4b71Sopenharmony_ci
1762e41f4b71Sopenharmony_ci**Error codes**
1763e41f4b71Sopenharmony_ci
1764e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1765e41f4b71Sopenharmony_ci
1766e41f4b71Sopenharmony_ci| **ID**| **Error Message**              |
1767e41f4b71Sopenharmony_ci| --------- |--------------------------|
1768e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1769e41f4b71Sopenharmony_ci
1770e41f4b71Sopenharmony_ci**Example**
1771e41f4b71Sopenharmony_ci
1772e41f4b71Sopenharmony_ci```ts
1773e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1774e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Rose").limitAs(3);
1775e41f4b71Sopenharmony_ci```
1776e41f4b71Sopenharmony_ci
1777e41f4b71Sopenharmony_ci### offsetAs
1778e41f4b71Sopenharmony_ci
1779e41f4b71Sopenharmony_cioffsetAs(rowOffset: number): RdbPredicates
1780e41f4b71Sopenharmony_ci
1781e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to specify the start position of the returned result.
1782e41f4b71Sopenharmony_ci
1783e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1784e41f4b71Sopenharmony_ci
1785e41f4b71Sopenharmony_ci**Parameters**
1786e41f4b71Sopenharmony_ci
1787e41f4b71Sopenharmony_ci| Name   | Type  | Mandatory| Description                              |
1788e41f4b71Sopenharmony_ci| --------- | ------ | ---- | ---------------------------------- |
1789e41f4b71Sopenharmony_ci| rowOffset | number | Yes  | Number of rows to offset from the beginning. The value is a positive integer.|
1790e41f4b71Sopenharmony_ci
1791e41f4b71Sopenharmony_ci**Return value**
1792e41f4b71Sopenharmony_ci
1793e41f4b71Sopenharmony_ci| Type                                | Description                                |
1794e41f4b71Sopenharmony_ci| ------------------------------------ | ------------------------------------ |
1795e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the start position of the returned result.|
1796e41f4b71Sopenharmony_ci
1797e41f4b71Sopenharmony_ci**Error codes**
1798e41f4b71Sopenharmony_ci
1799e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1800e41f4b71Sopenharmony_ci
1801e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1802e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1803e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1804e41f4b71Sopenharmony_ci
1805e41f4b71Sopenharmony_ci**Example**
1806e41f4b71Sopenharmony_ci
1807e41f4b71Sopenharmony_ci```ts
1808e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1809e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Rose").offsetAs(3);
1810e41f4b71Sopenharmony_ci```
1811e41f4b71Sopenharmony_ci
1812e41f4b71Sopenharmony_ci### groupBy
1813e41f4b71Sopenharmony_ci
1814e41f4b71Sopenharmony_cigroupBy(fields: Array&lt;string&gt;): RdbPredicates
1815e41f4b71Sopenharmony_ci
1816e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to group rows that have the same value into summary rows.
1817e41f4b71Sopenharmony_ci
1818e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1819e41f4b71Sopenharmony_ci
1820e41f4b71Sopenharmony_ci**Parameters**
1821e41f4b71Sopenharmony_ci
1822e41f4b71Sopenharmony_ci| Name| Type               | Mandatory| Description                |
1823e41f4b71Sopenharmony_ci| ------ | ------------------- | ---- | -------------------- |
1824e41f4b71Sopenharmony_ci| fields | Array&lt;string&gt; | Yes  | Names of columns to group.|
1825e41f4b71Sopenharmony_ci
1826e41f4b71Sopenharmony_ci**Return value**
1827e41f4b71Sopenharmony_ci
1828e41f4b71Sopenharmony_ci| Type                                | Description                  |
1829e41f4b71Sopenharmony_ci| ------------------------------------ | ---------------------- |
1830e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that groups rows with the same value.|
1831e41f4b71Sopenharmony_ci
1832e41f4b71Sopenharmony_ci**Error codes**
1833e41f4b71Sopenharmony_ci
1834e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1835e41f4b71Sopenharmony_ci
1836e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1837e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1838e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1839e41f4b71Sopenharmony_ci
1840e41f4b71Sopenharmony_ci**Example**
1841e41f4b71Sopenharmony_ci
1842e41f4b71Sopenharmony_ci```ts
1843e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1844e41f4b71Sopenharmony_cipredicates.groupBy(["AGE", "NAME"]);
1845e41f4b71Sopenharmony_ci```
1846e41f4b71Sopenharmony_ci
1847e41f4b71Sopenharmony_ci### indexedBy
1848e41f4b71Sopenharmony_ci
1849e41f4b71Sopenharmony_ciindexedBy(field: string): RdbPredicates
1850e41f4b71Sopenharmony_ci
1851e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to specify the index column.
1852e41f4b71Sopenharmony_ci
1853e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1854e41f4b71Sopenharmony_ci
1855e41f4b71Sopenharmony_ci**Parameters**
1856e41f4b71Sopenharmony_ci
1857e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description          |
1858e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------- |
1859e41f4b71Sopenharmony_ci| field  | string | Yes  | Name of the index column.|
1860e41f4b71Sopenharmony_ci
1861e41f4b71Sopenharmony_ci**Return value**
1862e41f4b71Sopenharmony_ci
1863e41f4b71Sopenharmony_ci
1864e41f4b71Sopenharmony_ci| Type                                | Description                                 |
1865e41f4b71Sopenharmony_ci| ------------------------------------ | ------------------------------------- |
1866e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the index column.|
1867e41f4b71Sopenharmony_ci
1868e41f4b71Sopenharmony_ci**Error codes**
1869e41f4b71Sopenharmony_ci
1870e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1871e41f4b71Sopenharmony_ci
1872e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1873e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1874e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1875e41f4b71Sopenharmony_ci
1876e41f4b71Sopenharmony_ci**Example**
1877e41f4b71Sopenharmony_ci
1878e41f4b71Sopenharmony_ci```ts
1879e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1880e41f4b71Sopenharmony_cipredicates.indexedBy("SALARY");
1881e41f4b71Sopenharmony_ci```
1882e41f4b71Sopenharmony_ci
1883e41f4b71Sopenharmony_ci### in
1884e41f4b71Sopenharmony_ci
1885e41f4b71Sopenharmony_ciin(field: string, value: Array&lt;ValueType&gt;): RdbPredicates
1886e41f4b71Sopenharmony_ci
1887e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to match the fields in the specified column that are in the given range.
1888e41f4b71Sopenharmony_ci
1889e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1890e41f4b71Sopenharmony_ci
1891e41f4b71Sopenharmony_ci**Parameters**
1892e41f4b71Sopenharmony_ci
1893e41f4b71Sopenharmony_ci| Name| Type                                | Mandatory| Description                                   |
1894e41f4b71Sopenharmony_ci| ------ | ------------------------------------ | ---- | --------------------------------------- |
1895e41f4b71Sopenharmony_ci| field  | string                               | Yes  | Column name in the database table.                     |
1896e41f4b71Sopenharmony_ci| value  | Array&lt;[ValueType](#valuetype)&gt; | Yes  | Array of **ValueType**s to match.|
1897e41f4b71Sopenharmony_ci
1898e41f4b71Sopenharmony_ci**Return value**
1899e41f4b71Sopenharmony_ci
1900e41f4b71Sopenharmony_ci| Type                                | Description                      |
1901e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1902e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1903e41f4b71Sopenharmony_ci
1904e41f4b71Sopenharmony_ci**Error codes**
1905e41f4b71Sopenharmony_ci
1906e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1907e41f4b71Sopenharmony_ci
1908e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1909e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1910e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1911e41f4b71Sopenharmony_ci
1912e41f4b71Sopenharmony_ci**Example**
1913e41f4b71Sopenharmony_ci
1914e41f4b71Sopenharmony_ci```ts
1915e41f4b71Sopenharmony_ci// Locate data of the employees with age of [18, 20] in the table.
1916e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1917e41f4b71Sopenharmony_cipredicates.in("AGE", [18, 20]);
1918e41f4b71Sopenharmony_ci```
1919e41f4b71Sopenharmony_ci
1920e41f4b71Sopenharmony_ci### notIn
1921e41f4b71Sopenharmony_ci
1922e41f4b71Sopenharmony_cinotIn(field: string, value: Array&lt;ValueType&gt;): RdbPredicates
1923e41f4b71Sopenharmony_ci
1924e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to match the fields in the specified column that are out of the given range.
1925e41f4b71Sopenharmony_ci
1926e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1927e41f4b71Sopenharmony_ci
1928e41f4b71Sopenharmony_ci**Parameters**
1929e41f4b71Sopenharmony_ci
1930e41f4b71Sopenharmony_ci| Name| Type                                | Mandatory| Description                                 |
1931e41f4b71Sopenharmony_ci| ------ | ------------------------------------ | ---- | ------------------------------------- |
1932e41f4b71Sopenharmony_ci| field  | string                               | Yes  | Column name in the database table.                   |
1933e41f4b71Sopenharmony_ci| value  | Array&lt;[ValueType](#valuetype)&gt; | Yes  | Array of **ValueType**s to match.|
1934e41f4b71Sopenharmony_ci
1935e41f4b71Sopenharmony_ci**Return value**
1936e41f4b71Sopenharmony_ci
1937e41f4b71Sopenharmony_ci| Type                                | Description                      |
1938e41f4b71Sopenharmony_ci| ------------------------------------ | -------------------------- |
1939e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1940e41f4b71Sopenharmony_ci
1941e41f4b71Sopenharmony_ci**Error codes**
1942e41f4b71Sopenharmony_ci
1943e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1944e41f4b71Sopenharmony_ci
1945e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1946e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1947e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1948e41f4b71Sopenharmony_ci
1949e41f4b71Sopenharmony_ci**Example**
1950e41f4b71Sopenharmony_ci
1951e41f4b71Sopenharmony_ci```ts
1952e41f4b71Sopenharmony_ci// Locate data of all the employees except Lisa and Rose in the table.
1953e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1954e41f4b71Sopenharmony_cipredicates.notIn("NAME", ["Lisa", "Rose"]);
1955e41f4b71Sopenharmony_ci```
1956e41f4b71Sopenharmony_ci
1957e41f4b71Sopenharmony_ci### notContains<sup>12+</sup>
1958e41f4b71Sopenharmony_ci
1959e41f4b71Sopenharmony_cinotContains(field: string, value: string): RdbPredicates
1960e41f4b71Sopenharmony_ci
1961e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to match the fields in the specified column that do not contain the given value.
1962e41f4b71Sopenharmony_ci
1963e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1964e41f4b71Sopenharmony_ci
1965e41f4b71Sopenharmony_ci**Parameters**
1966e41f4b71Sopenharmony_ci
1967e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                  |
1968e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------- |
1969e41f4b71Sopenharmony_ci| field  | string | Yes  | Column name in the database table.    |
1970e41f4b71Sopenharmony_ci| value  | string | Yes  | Value to match the **RdbPredicates**.|
1971e41f4b71Sopenharmony_ci
1972e41f4b71Sopenharmony_ci**Return value**
1973e41f4b71Sopenharmony_ci
1974e41f4b71Sopenharmony_ci| Type                           | Description                      |
1975e41f4b71Sopenharmony_ci| ------------------------------- | -------------------------- |
1976e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1977e41f4b71Sopenharmony_ci
1978e41f4b71Sopenharmony_ci**Error codes**
1979e41f4b71Sopenharmony_ci
1980e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1981e41f4b71Sopenharmony_ci
1982e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
1983e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
1984e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1985e41f4b71Sopenharmony_ci
1986e41f4b71Sopenharmony_ci**Example**
1987e41f4b71Sopenharmony_ci
1988e41f4b71Sopenharmony_ci```ts
1989e41f4b71Sopenharmony_ci// Match the fields that do not contain "os" in the NAME column of the data table, for example, Lisa in the list.
1990e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1991e41f4b71Sopenharmony_cipredicates.notContains("NAME", "os");
1992e41f4b71Sopenharmony_ci```
1993e41f4b71Sopenharmony_ci
1994e41f4b71Sopenharmony_ci### notLike<sup>12+</sup>
1995e41f4b71Sopenharmony_ci
1996e41f4b71Sopenharmony_cinotLike(field: string, value: string): RdbPredicates
1997e41f4b71Sopenharmony_ci
1998e41f4b71Sopenharmony_ciSets an **RdbPredicates** object to match the fields in the specified column that are not similar to the given value.
1999e41f4b71Sopenharmony_ci
2000e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2001e41f4b71Sopenharmony_ci
2002e41f4b71Sopenharmony_ci**Parameters**
2003e41f4b71Sopenharmony_ci
2004e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                  |
2005e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------- |
2006e41f4b71Sopenharmony_ci| field  | string | Yes  | Column name in the database table.    |
2007e41f4b71Sopenharmony_ci| value  | string | Yes  | Value to match the **RdbPredicates**.|
2008e41f4b71Sopenharmony_ci
2009e41f4b71Sopenharmony_ci**Return value**
2010e41f4b71Sopenharmony_ci
2011e41f4b71Sopenharmony_ci| Type                           | Description                      |
2012e41f4b71Sopenharmony_ci| ------------------------------- | -------------------------- |
2013e41f4b71Sopenharmony_ci| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
2014e41f4b71Sopenharmony_ci
2015e41f4b71Sopenharmony_ci**Error codes**
2016e41f4b71Sopenharmony_ci
2017e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
2018e41f4b71Sopenharmony_ci
2019e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                      |
2020e41f4b71Sopenharmony_ci| --------- |----------------------------------------------------------------------------------------------------------------|
2021e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
2022e41f4b71Sopenharmony_ci
2023e41f4b71Sopenharmony_ci**Example**
2024e41f4b71Sopenharmony_ci
2025e41f4b71Sopenharmony_ci```ts
2026e41f4b71Sopenharmony_ci// Match the fields that are not "os" in the NAME column of the data table, for example, Rose in the list.
2027e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
2028e41f4b71Sopenharmony_cipredicates.notLike("NAME", "os");
2029e41f4b71Sopenharmony_ci```
2030e41f4b71Sopenharmony_ci
2031e41f4b71Sopenharmony_ci
2032e41f4b71Sopenharmony_ci
2033e41f4b71Sopenharmony_ci## RdbStore
2034e41f4b71Sopenharmony_ci
2035e41f4b71Sopenharmony_ciProvides APIs to manage an RDB store.
2036e41f4b71Sopenharmony_ci
2037e41f4b71Sopenharmony_ciBefore using the APIs of this class, use [executeSql](#executesql) to initialize the database table structure and related data.
2038e41f4b71Sopenharmony_ci
2039e41f4b71Sopenharmony_ci### Properties
2040e41f4b71Sopenharmony_ci
2041e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2042e41f4b71Sopenharmony_ci
2043e41f4b71Sopenharmony_ci| Name        | Type           | Read-Only      | Optional | Description                            |
2044e41f4b71Sopenharmony_ci| ------------ | ----------- | ---- | -------------------------------- | -------------------------------- |
2045e41f4b71Sopenharmony_ci| version<sup>10+</sup>  | number | No| No  | RDB store version, which is an integer greater than 0.      |
2046e41f4b71Sopenharmony_ci| rebuilt<sup>12+</sup> | [RebuildType](#rebuildtype12) | Yes| No| Whether the RDB store has been rebuilt or repaired.|
2047e41f4b71Sopenharmony_ci
2048e41f4b71Sopenharmony_ci**Error codes**
2049e41f4b71Sopenharmony_ci
2050e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
2051e41f4b71Sopenharmony_ci
2052e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
2053e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
2054e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2055e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
2056e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
2057e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
2058e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
2059e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
2060e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
2061e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
2062e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
2063e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
2064e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
2065e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
2066e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
2067e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
2068e41f4b71Sopenharmony_ci
2069e41f4b71Sopenharmony_ci**Example**
2070e41f4b71Sopenharmony_ci
2071e41f4b71Sopenharmony_ci```ts
2072e41f4b71Sopenharmony_ci// Set the RDB store version.
2073e41f4b71Sopenharmony_ciif(store != undefined) {
2074e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).version = 3;
2075e41f4b71Sopenharmony_ci  // Obtain the RDB store version.
2076e41f4b71Sopenharmony_ci  console.info(`RdbStore version is ${store.version}`);
2077e41f4b71Sopenharmony_ci  // Whether the RDB store has been rebuilt.
2078e41f4b71Sopenharmony_ci  console.info(`RdbStore rebuilt is ${store.rebuilt}`);
2079e41f4b71Sopenharmony_ci}
2080e41f4b71Sopenharmony_ci```
2081e41f4b71Sopenharmony_ci
2082e41f4b71Sopenharmony_ci### insert
2083e41f4b71Sopenharmony_ci
2084e41f4b71Sopenharmony_ciinsert(table: string, values: ValuesBucket, callback: AsyncCallback&lt;number&gt;):void
2085e41f4b71Sopenharmony_ci
2086e41f4b71Sopenharmony_ciInserts a row of data into a table. This API uses an asynchronous callback to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
2087e41f4b71Sopenharmony_ci
2088e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2089e41f4b71Sopenharmony_ci
2090e41f4b71Sopenharmony_ci**Parameters**
2091e41f4b71Sopenharmony_ci
2092e41f4b71Sopenharmony_ci| Name  | Type                         | Mandatory| Description                                                      |
2093e41f4b71Sopenharmony_ci| -------- | ----------------------------- | ---- | ---------------------------------------------------------- |
2094e41f4b71Sopenharmony_ci| table    | string                        | Yes  | Name of the target table.                                          |
2095e41f4b71Sopenharmony_ci| values   | [ValuesBucket](#valuesbucket) | Yes  | Row of data to insert.                                |
2096e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;number&gt;   | Yes  | Callback used to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
2097e41f4b71Sopenharmony_ci
2098e41f4b71Sopenharmony_ci**Error codes**
2099e41f4b71Sopenharmony_ci
2100e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
2101e41f4b71Sopenharmony_ci
2102e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
2103e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
2104e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2105e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
2106e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
2107e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
2108e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
2109e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
2110e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
2111e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
2112e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
2113e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
2114e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
2115e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
2116e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
2117e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
2118e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
2119e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
2120e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
2121e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
2122e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
2123e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
2124e41f4b71Sopenharmony_ci
2125e41f4b71Sopenharmony_ci**Example**
2126e41f4b71Sopenharmony_ci
2127e41f4b71Sopenharmony_ci```ts
2128e41f4b71Sopenharmony_cilet value1 = "Lisa";
2129e41f4b71Sopenharmony_cilet value2 = 18;
2130e41f4b71Sopenharmony_cilet value3 = 100.5;
2131e41f4b71Sopenharmony_cilet value4 = new Uint8Array([1, 2, 3, 4, 5]);
2132e41f4b71Sopenharmony_ci
2133e41f4b71Sopenharmony_ci// You can use either of the following:
2134e41f4b71Sopenharmony_ciconst valueBucket1: relationalStore.ValuesBucket = {
2135e41f4b71Sopenharmony_ci  'NAME': value1,
2136e41f4b71Sopenharmony_ci  'AGE': value2,
2137e41f4b71Sopenharmony_ci  'SALARY': value3,
2138e41f4b71Sopenharmony_ci  'CODES': value4,
2139e41f4b71Sopenharmony_ci};
2140e41f4b71Sopenharmony_ciconst valueBucket2: relationalStore.ValuesBucket = {
2141e41f4b71Sopenharmony_ci  NAME: value1,
2142e41f4b71Sopenharmony_ci  AGE: value2,
2143e41f4b71Sopenharmony_ci  SALARY: value3,
2144e41f4b71Sopenharmony_ci  CODES: value4,
2145e41f4b71Sopenharmony_ci};
2146e41f4b71Sopenharmony_ciconst valueBucket3: relationalStore.ValuesBucket = {
2147e41f4b71Sopenharmony_ci  "NAME": value1,
2148e41f4b71Sopenharmony_ci  "AGE": value2,
2149e41f4b71Sopenharmony_ci  "SALARY": value3,
2150e41f4b71Sopenharmony_ci  "CODES": value4,
2151e41f4b71Sopenharmony_ci};
2152e41f4b71Sopenharmony_ci
2153e41f4b71Sopenharmony_ciif(store != undefined) {
2154e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).insert("EMPLOYEE", valueBucket1, (err: BusinessError, rowId: number) => {
2155e41f4b71Sopenharmony_ci    if (err) {
2156e41f4b71Sopenharmony_ci      console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
2157e41f4b71Sopenharmony_ci      return;
2158e41f4b71Sopenharmony_ci    }
2159e41f4b71Sopenharmony_ci    console.info(`Insert is successful, rowId = ${rowId}`);
2160e41f4b71Sopenharmony_ci  })
2161e41f4b71Sopenharmony_ci}
2162e41f4b71Sopenharmony_ci```
2163e41f4b71Sopenharmony_ci
2164e41f4b71Sopenharmony_ci### insert<sup>10+</sup>
2165e41f4b71Sopenharmony_ci
2166e41f4b71Sopenharmony_ciinsert(table: string, values: ValuesBucket,  conflict: ConflictResolution, callback: AsyncCallback&lt;number&gt;):void
2167e41f4b71Sopenharmony_ci
2168e41f4b71Sopenharmony_ciInserts a row of data into a table. This API uses an asynchronous callback to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
2169e41f4b71Sopenharmony_ci
2170e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2171e41f4b71Sopenharmony_ci
2172e41f4b71Sopenharmony_ci**Parameters**
2173e41f4b71Sopenharmony_ci
2174e41f4b71Sopenharmony_ci| Name  | Type                                       | Mandatory| Description                                                      |
2175e41f4b71Sopenharmony_ci| -------- | ------------------------------------------- | ---- | ---------------------------------------------------------- |
2176e41f4b71Sopenharmony_ci| table    | string                                      | Yes  | Name of the target table.                                          |
2177e41f4b71Sopenharmony_ci| values   | [ValuesBucket](#valuesbucket)               | Yes  | Row of data to insert.                                |
2178e41f4b71Sopenharmony_ci| conflict | [ConflictResolution](#conflictresolution10) | Yes  | Resolution used to resolve the conflict.                                        |
2179e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;number&gt;                 | Yes  | Callback used to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
2180e41f4b71Sopenharmony_ci
2181e41f4b71Sopenharmony_ci**Error codes**
2182e41f4b71Sopenharmony_ci
2183e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
2184e41f4b71Sopenharmony_ci
2185e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
2186e41f4b71Sopenharmony_ci|-----------| ---------------------------------------------------- |
2187e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2188e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
2189e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
2190e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
2191e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
2192e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
2193e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
2194e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
2195e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
2196e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
2197e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
2198e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
2199e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
2200e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
2201e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
2202e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
2203e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
2204e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
2205e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
2206e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
2207e41f4b71Sopenharmony_ci
2208e41f4b71Sopenharmony_ci**Example**
2209e41f4b71Sopenharmony_ci
2210e41f4b71Sopenharmony_ci```ts
2211e41f4b71Sopenharmony_cilet value1 = "Lisa";
2212e41f4b71Sopenharmony_cilet value2 = 18;
2213e41f4b71Sopenharmony_cilet value3 = 100.5;
2214e41f4b71Sopenharmony_cilet value4 = new Uint8Array([1, 2, 3, 4, 5]);
2215e41f4b71Sopenharmony_ci
2216e41f4b71Sopenharmony_ci// You can use either of the following:
2217e41f4b71Sopenharmony_ciconst valueBucket1: relationalStore.ValuesBucket = {
2218e41f4b71Sopenharmony_ci  'NAME': value1,
2219e41f4b71Sopenharmony_ci  'AGE': value2,
2220e41f4b71Sopenharmony_ci  'SALARY': value3,
2221e41f4b71Sopenharmony_ci  'CODES': value4,
2222e41f4b71Sopenharmony_ci};
2223e41f4b71Sopenharmony_ciconst valueBucket2: relationalStore.ValuesBucket = {
2224e41f4b71Sopenharmony_ci  NAME: value1,
2225e41f4b71Sopenharmony_ci  AGE: value2,
2226e41f4b71Sopenharmony_ci  SALARY: value3,
2227e41f4b71Sopenharmony_ci  CODES: value4,
2228e41f4b71Sopenharmony_ci};
2229e41f4b71Sopenharmony_ciconst valueBucket3: relationalStore.ValuesBucket = {
2230e41f4b71Sopenharmony_ci  "NAME": value1,
2231e41f4b71Sopenharmony_ci  "AGE": value2,
2232e41f4b71Sopenharmony_ci  "SALARY": value3,
2233e41f4b71Sopenharmony_ci  "CODES": value4,
2234e41f4b71Sopenharmony_ci};
2235e41f4b71Sopenharmony_ci
2236e41f4b71Sopenharmony_ciif(store != undefined) {
2237e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).insert("EMPLOYEE", valueBucket1, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE,
2238e41f4b71Sopenharmony_ci    (err: BusinessError, rowId: number) => {
2239e41f4b71Sopenharmony_ci      if (err) {
2240e41f4b71Sopenharmony_ci        console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
2241e41f4b71Sopenharmony_ci        return;
2242e41f4b71Sopenharmony_ci      }
2243e41f4b71Sopenharmony_ci      console.info(`Insert is successful, rowId = ${rowId}`);
2244e41f4b71Sopenharmony_ci  })
2245e41f4b71Sopenharmony_ci}
2246e41f4b71Sopenharmony_ci```
2247e41f4b71Sopenharmony_ci
2248e41f4b71Sopenharmony_ci### insert
2249e41f4b71Sopenharmony_ci
2250e41f4b71Sopenharmony_ciinsert(table: string, values: ValuesBucket):Promise&lt;number&gt;
2251e41f4b71Sopenharmony_ci
2252e41f4b71Sopenharmony_ciInserts a row of data into a table. This API uses a promise to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
2253e41f4b71Sopenharmony_ci
2254e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2255e41f4b71Sopenharmony_ci
2256e41f4b71Sopenharmony_ci**Parameters**
2257e41f4b71Sopenharmony_ci
2258e41f4b71Sopenharmony_ci| Name| Type                         | Mandatory| Description                      |
2259e41f4b71Sopenharmony_ci| ------ | ----------------------------- | ---- | -------------------------- |
2260e41f4b71Sopenharmony_ci| table  | string                        | Yes  | Name of the target table.          |
2261e41f4b71Sopenharmony_ci| values | [ValuesBucket](#valuesbucket) | Yes  | Row of data to insert.|
2262e41f4b71Sopenharmony_ci
2263e41f4b71Sopenharmony_ci**Return value**
2264e41f4b71Sopenharmony_ci
2265e41f4b71Sopenharmony_ci| Type                 | Description                                             |
2266e41f4b71Sopenharmony_ci| --------------------- | ------------------------------------------------- |
2267e41f4b71Sopenharmony_ci| Promise&lt;number&gt; | Promise used to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
2268e41f4b71Sopenharmony_ci
2269e41f4b71Sopenharmony_ci**Error codes**
2270e41f4b71Sopenharmony_ci
2271e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
2272e41f4b71Sopenharmony_ci
2273e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
2274e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
2275e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2276e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
2277e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
2278e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
2279e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
2280e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
2281e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
2282e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
2283e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
2284e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
2285e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
2286e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
2287e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
2288e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
2289e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
2290e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
2291e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
2292e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
2293e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
2294e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
2295e41f4b71Sopenharmony_ci
2296e41f4b71Sopenharmony_ci**Example**
2297e41f4b71Sopenharmony_ci
2298e41f4b71Sopenharmony_ci```ts
2299e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2300e41f4b71Sopenharmony_ci
2301e41f4b71Sopenharmony_cilet value1 = "Lisa";
2302e41f4b71Sopenharmony_cilet value2 = 18;
2303e41f4b71Sopenharmony_cilet value3 = 100.5;
2304e41f4b71Sopenharmony_cilet value4 = new Uint8Array([1, 2, 3, 4, 5]);
2305e41f4b71Sopenharmony_ci
2306e41f4b71Sopenharmony_ci// You can use either of the following:
2307e41f4b71Sopenharmony_ciconst valueBucket1: relationalStore.ValuesBucket = {
2308e41f4b71Sopenharmony_ci  'NAME': value1,
2309e41f4b71Sopenharmony_ci  'AGE': value2,
2310e41f4b71Sopenharmony_ci  'SALARY': value3,
2311e41f4b71Sopenharmony_ci  'CODES': value4,
2312e41f4b71Sopenharmony_ci};
2313e41f4b71Sopenharmony_ciconst valueBucket2: relationalStore.ValuesBucket = {
2314e41f4b71Sopenharmony_ci  NAME: value1,
2315e41f4b71Sopenharmony_ci  AGE: value2,
2316e41f4b71Sopenharmony_ci  SALARY: value3,
2317e41f4b71Sopenharmony_ci  CODES: value4,
2318e41f4b71Sopenharmony_ci};
2319e41f4b71Sopenharmony_ciconst valueBucket3: relationalStore.ValuesBucket = {
2320e41f4b71Sopenharmony_ci  "NAME": value1,
2321e41f4b71Sopenharmony_ci  "AGE": value2,
2322e41f4b71Sopenharmony_ci  "SALARY": value3,
2323e41f4b71Sopenharmony_ci  "CODES": value4,
2324e41f4b71Sopenharmony_ci};
2325e41f4b71Sopenharmony_ci
2326e41f4b71Sopenharmony_ciif(store != undefined) {
2327e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).insert("EMPLOYEE", valueBucket1).then((rowId: number) => {
2328e41f4b71Sopenharmony_ci    console.info(`Insert is successful, rowId = ${rowId}`);
2329e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
2330e41f4b71Sopenharmony_ci    console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
2331e41f4b71Sopenharmony_ci  })
2332e41f4b71Sopenharmony_ci}
2333e41f4b71Sopenharmony_ci```
2334e41f4b71Sopenharmony_ci
2335e41f4b71Sopenharmony_ci### insert<sup>10+</sup>
2336e41f4b71Sopenharmony_ci
2337e41f4b71Sopenharmony_ciinsert(table: string, values: ValuesBucket,  conflict: ConflictResolution):Promise&lt;number&gt;
2338e41f4b71Sopenharmony_ci
2339e41f4b71Sopenharmony_ciInserts a row of data into a table. This API uses a promise to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
2340e41f4b71Sopenharmony_ci
2341e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2342e41f4b71Sopenharmony_ci
2343e41f4b71Sopenharmony_ci**Parameters**
2344e41f4b71Sopenharmony_ci
2345e41f4b71Sopenharmony_ci| Name  | Type                                       | Mandatory| Description                      |
2346e41f4b71Sopenharmony_ci| -------- | ------------------------------------------- | ---- | -------------------------- |
2347e41f4b71Sopenharmony_ci| table    | string                                      | Yes  | Name of the target table.          |
2348e41f4b71Sopenharmony_ci| values   | [ValuesBucket](#valuesbucket)               | Yes  | Row of data to insert.|
2349e41f4b71Sopenharmony_ci| conflict | [ConflictResolution](#conflictresolution10) | Yes  | Resolution used to resolve the conflict.        |
2350e41f4b71Sopenharmony_ci
2351e41f4b71Sopenharmony_ci**Return value**
2352e41f4b71Sopenharmony_ci
2353e41f4b71Sopenharmony_ci| Type                 | Description                                             |
2354e41f4b71Sopenharmony_ci| --------------------- | ------------------------------------------------- |
2355e41f4b71Sopenharmony_ci| Promise&lt;number&gt; | Promise used to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
2356e41f4b71Sopenharmony_ci
2357e41f4b71Sopenharmony_ci**Error codes**
2358e41f4b71Sopenharmony_ci
2359e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
2360e41f4b71Sopenharmony_ci
2361e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
2362e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
2363e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2364e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
2365e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
2366e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
2367e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
2368e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
2369e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
2370e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
2371e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
2372e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
2373e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
2374e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
2375e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
2376e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
2377e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
2378e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
2379e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
2380e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
2381e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
2382e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
2383e41f4b71Sopenharmony_ci
2384e41f4b71Sopenharmony_ci**Example**
2385e41f4b71Sopenharmony_ci
2386e41f4b71Sopenharmony_ci```ts
2387e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2388e41f4b71Sopenharmony_ci
2389e41f4b71Sopenharmony_cilet value1 = "Lisa";
2390e41f4b71Sopenharmony_cilet value2 = 18;
2391e41f4b71Sopenharmony_cilet value3 = 100.5;
2392e41f4b71Sopenharmony_cilet value4 = new Uint8Array([1, 2, 3, 4, 5]);
2393e41f4b71Sopenharmony_ci
2394e41f4b71Sopenharmony_ci// You can use either of the following:
2395e41f4b71Sopenharmony_ciconst valueBucket1: relationalStore.ValuesBucket = {
2396e41f4b71Sopenharmony_ci  'NAME': value1,
2397e41f4b71Sopenharmony_ci  'AGE': value2,
2398e41f4b71Sopenharmony_ci  'SALARY': value3,
2399e41f4b71Sopenharmony_ci  'CODES': value4,
2400e41f4b71Sopenharmony_ci};
2401e41f4b71Sopenharmony_ciconst valueBucket2: relationalStore.ValuesBucket = {
2402e41f4b71Sopenharmony_ci  NAME: value1,
2403e41f4b71Sopenharmony_ci  AGE: value2,
2404e41f4b71Sopenharmony_ci  SALARY: value3,
2405e41f4b71Sopenharmony_ci  CODES: value4,
2406e41f4b71Sopenharmony_ci};
2407e41f4b71Sopenharmony_ciconst valueBucket3: relationalStore.ValuesBucket = {
2408e41f4b71Sopenharmony_ci  "NAME": value1,
2409e41f4b71Sopenharmony_ci  "AGE": value2,
2410e41f4b71Sopenharmony_ci  "SALARY": value3,
2411e41f4b71Sopenharmony_ci  "CODES": value4,
2412e41f4b71Sopenharmony_ci};
2413e41f4b71Sopenharmony_ci
2414e41f4b71Sopenharmony_ciif(store != undefined) {
2415e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).insert("EMPLOYEE", valueBucket1, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE).then((rowId: number) => {
2416e41f4b71Sopenharmony_ci    console.info(`Insert is successful, rowId = ${rowId}`);
2417e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
2418e41f4b71Sopenharmony_ci    console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
2419e41f4b71Sopenharmony_ci  })
2420e41f4b71Sopenharmony_ci}
2421e41f4b71Sopenharmony_ci```
2422e41f4b71Sopenharmony_ci
2423e41f4b71Sopenharmony_ci### insertSync<sup>12+</sup>
2424e41f4b71Sopenharmony_ci
2425e41f4b71Sopenharmony_ciinsertSync(table: string, values: ValuesBucket,  conflict?: ConflictResolution):number
2426e41f4b71Sopenharmony_ci
2427e41f4b71Sopenharmony_ciInserts a row of data into a table. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
2428e41f4b71Sopenharmony_ci
2429e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2430e41f4b71Sopenharmony_ci
2431e41f4b71Sopenharmony_ci**Parameters**
2432e41f4b71Sopenharmony_ci
2433e41f4b71Sopenharmony_ci| Name  | Type                                       | Mandatory| Description                                                        |
2434e41f4b71Sopenharmony_ci| -------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
2435e41f4b71Sopenharmony_ci| table    | string                                      | Yes  | Name of the target table.                                            |
2436e41f4b71Sopenharmony_ci| values   | [ValuesBucket](#valuesbucket)               | Yes  | Row of data to insert.                                  |
2437e41f4b71Sopenharmony_ci| conflict | [ConflictResolution](#conflictresolution10) | No  | Resolution used to resolve the conflict. The default value is **relationalStore.ConflictResolution.ON_CONFLICT_NONE**.|
2438e41f4b71Sopenharmony_ci
2439e41f4b71Sopenharmony_ci**Return value**
2440e41f4b71Sopenharmony_ci
2441e41f4b71Sopenharmony_ci| Type  | Description                                |
2442e41f4b71Sopenharmony_ci| ------ | ------------------------------------ |
2443e41f4b71Sopenharmony_ci| number | If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
2444e41f4b71Sopenharmony_ci
2445e41f4b71Sopenharmony_ci**Error codes**
2446e41f4b71Sopenharmony_ci
2447e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
2448e41f4b71Sopenharmony_ci
2449e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
2450e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------------------------ |
2451e41f4b71Sopenharmony_ci| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2452e41f4b71Sopenharmony_ci| 14800000     | Inner error.                                                 |
2453e41f4b71Sopenharmony_ci| 14800011     | Database corrupted.                                          |
2454e41f4b71Sopenharmony_ci| 14800014     | Already closed.                                              |
2455e41f4b71Sopenharmony_ci| 14800015     | The database does not respond.                                        |
2456e41f4b71Sopenharmony_ci| 14800021     | SQLite: Generic error.                                       |
2457e41f4b71Sopenharmony_ci| 14800022     | SQLite: Callback routine requested an abort.                 |
2458e41f4b71Sopenharmony_ci| 14800023     | SQLite: Access permission denied.                            |
2459e41f4b71Sopenharmony_ci| 14800024     | SQLite: The database file is locked.                         |
2460e41f4b71Sopenharmony_ci| 14800025     | SQLite: A table in the database is locked.                   |
2461e41f4b71Sopenharmony_ci| 14800026     | SQLite: The database is out of memory.                       |
2462e41f4b71Sopenharmony_ci| 14800027     | SQLite: Attempt to write a readonly database.                |
2463e41f4b71Sopenharmony_ci| 14800028     | SQLite: Some kind of disk I/O error occurred.                |
2464e41f4b71Sopenharmony_ci| 14800029     | SQLite: The database is full.                                |
2465e41f4b71Sopenharmony_ci| 14800030     | SQLite: Unable to open the database file.                    |
2466e41f4b71Sopenharmony_ci| 14800031     | SQLite: TEXT or BLOB exceeds size limit.                     |
2467e41f4b71Sopenharmony_ci| 14800032     | SQLite: Abort due to constraint violation.                   |
2468e41f4b71Sopenharmony_ci| 14800033     | SQLite: Data type mismatch.                                  |
2469e41f4b71Sopenharmony_ci| 14800034     | SQLite: Library used incorrectly.                            |
2470e41f4b71Sopenharmony_ci| 14800047     | The WAL file size exceeds the default limit.                 |
2471e41f4b71Sopenharmony_ci
2472e41f4b71Sopenharmony_ci**Example**
2473e41f4b71Sopenharmony_ci
2474e41f4b71Sopenharmony_ci```ts
2475e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2476e41f4b71Sopenharmony_ci
2477e41f4b71Sopenharmony_cilet value1 = "Lisa";
2478e41f4b71Sopenharmony_cilet value2 = 18;
2479e41f4b71Sopenharmony_cilet value3 = 100.5;
2480e41f4b71Sopenharmony_cilet value4 = new Uint8Array([1, 2, 3, 4, 5]);
2481e41f4b71Sopenharmony_ci
2482e41f4b71Sopenharmony_ci// You can use either of the following:
2483e41f4b71Sopenharmony_ciconst valueBucket1: relationalStore.ValuesBucket = {
2484e41f4b71Sopenharmony_ci  'NAME': value1,
2485e41f4b71Sopenharmony_ci  'AGE': value2,
2486e41f4b71Sopenharmony_ci  'SALARY': value3,
2487e41f4b71Sopenharmony_ci  'CODES': value4,
2488e41f4b71Sopenharmony_ci};
2489e41f4b71Sopenharmony_ciconst valueBucket2: relationalStore.ValuesBucket = {
2490e41f4b71Sopenharmony_ci  NAME: value1,
2491e41f4b71Sopenharmony_ci  AGE: value2,
2492e41f4b71Sopenharmony_ci  SALARY: value3,
2493e41f4b71Sopenharmony_ci  CODES: value4,
2494e41f4b71Sopenharmony_ci};
2495e41f4b71Sopenharmony_ciconst valueBucket3: relationalStore.ValuesBucket = {
2496e41f4b71Sopenharmony_ci  "NAME": value1,
2497e41f4b71Sopenharmony_ci  "AGE": value2,
2498e41f4b71Sopenharmony_ci  "SALARY": value3,
2499e41f4b71Sopenharmony_ci  "CODES": value4,
2500e41f4b71Sopenharmony_ci};
2501e41f4b71Sopenharmony_ci
2502e41f4b71Sopenharmony_ciif(store != undefined) {
2503e41f4b71Sopenharmony_ci  try {
2504e41f4b71Sopenharmony_ci    let rowId : number = (store as relationalStore.RdbStore).insertSync("EMPLOYEE", valueBucket1, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE);
2505e41f4b71Sopenharmony_ci    console.info(`Insert is successful, rowId = ${rowId}`);
2506e41f4b71Sopenharmony_ci  } catch (error) {
2507e41f4b71Sopenharmony_ci      console.error(`Insert is failed, code is ${error.code},message is ${error.message}`);
2508e41f4b71Sopenharmony_ci  }
2509e41f4b71Sopenharmony_ci}
2510e41f4b71Sopenharmony_ci```
2511e41f4b71Sopenharmony_ci
2512e41f4b71Sopenharmony_ci### insertSync<sup>12+</sup>
2513e41f4b71Sopenharmony_ci
2514e41f4b71Sopenharmony_ciinsertSync(table: string, values: sendableRelationalStore.ValuesBucket, conflict?: ConflictResolution):number
2515e41f4b71Sopenharmony_ci
2516e41f4b71Sopenharmony_ciInserts a row of Sendable data into a table. This API returns the result synchronously. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
2517e41f4b71Sopenharmony_ci
2518e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2519e41f4b71Sopenharmony_ci
2520e41f4b71Sopenharmony_ci**Parameters**
2521e41f4b71Sopenharmony_ci
2522e41f4b71Sopenharmony_ci| Name  | Type                                                                                          | Mandatory| Description                                                                           |
2523e41f4b71Sopenharmony_ci| -------- | ---------------------------------------------------------------------------------------------- | ---- | ------------------------------------------------------------------------------- |
2524e41f4b71Sopenharmony_ci| table    | string                                                                                         | Yes  | Name of the target table.                                                               |
2525e41f4b71Sopenharmony_ci| values   | [sendableRelationalStore.ValuesBucket](./js-apis-data-sendableRelationalStore.md#valuesbucket) | Yes  | Sendable data to insert.                                           |
2526e41f4b71Sopenharmony_ci| conflict | [ConflictResolution](#conflictresolution10)                                                    | No  | Resolution used to resolve the conflict. The default value is **relationalStore.ConflictResolution.ON_CONFLICT_NONE**.|
2527e41f4b71Sopenharmony_ci
2528e41f4b71Sopenharmony_ci**Return value**
2529e41f4b71Sopenharmony_ci
2530e41f4b71Sopenharmony_ci| Type  | Description                                |
2531e41f4b71Sopenharmony_ci| ------ | ------------------------------------ |
2532e41f4b71Sopenharmony_ci| number | If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
2533e41f4b71Sopenharmony_ci
2534e41f4b71Sopenharmony_ci**Error codes**
2535e41f4b71Sopenharmony_ci
2536e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
2537e41f4b71Sopenharmony_ci
2538e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
2539e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------------------------ |
2540e41f4b71Sopenharmony_ci| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2541e41f4b71Sopenharmony_ci| 14800000     | Inner error.                                                 |
2542e41f4b71Sopenharmony_ci| 14800011     | Database corrupted.                                          |
2543e41f4b71Sopenharmony_ci| 14800014     | Already closed.                                              |
2544e41f4b71Sopenharmony_ci| 14800015     | The database does not respond.                                        |
2545e41f4b71Sopenharmony_ci| 14800021     | SQLite: Generic error.                                       |
2546e41f4b71Sopenharmony_ci| 14800022     | SQLite: Callback routine requested an abort.                 |
2547e41f4b71Sopenharmony_ci| 14800023     | SQLite: Access permission denied.                            |
2548e41f4b71Sopenharmony_ci| 14800024     | SQLite: The database file is locked.                         |
2549e41f4b71Sopenharmony_ci| 14800025     | SQLite: A table in the database is locked.                   |
2550e41f4b71Sopenharmony_ci| 14800026     | SQLite: The database is out of memory.                       |
2551e41f4b71Sopenharmony_ci| 14800027     | SQLite: Attempt to write a readonly database.                |
2552e41f4b71Sopenharmony_ci| 14800028     | SQLite: Some kind of disk I/O error occurred.                |
2553e41f4b71Sopenharmony_ci| 14800029     | SQLite: The database is full.                                |
2554e41f4b71Sopenharmony_ci| 14800030     | SQLite: Unable to open the database file.                    |
2555e41f4b71Sopenharmony_ci| 14800031     | SQLite: TEXT or BLOB exceeds size limit.                     |
2556e41f4b71Sopenharmony_ci| 14800032     | SQLite: Abort due to constraint violation.                   |
2557e41f4b71Sopenharmony_ci| 14800033     | SQLite: Data type mismatch.                                  |
2558e41f4b71Sopenharmony_ci| 14800034     | SQLite: Library used incorrectly.                            |
2559e41f4b71Sopenharmony_ci| 14800047     | The WAL file size exceeds the default limit.                 |
2560e41f4b71Sopenharmony_ci
2561e41f4b71Sopenharmony_ci**Example**
2562e41f4b71Sopenharmony_ci
2563e41f4b71Sopenharmony_ci```ts
2564e41f4b71Sopenharmony_ciimport { sendableRelationalStore } from '@kit.ArkData';
2565e41f4b71Sopenharmony_ci
2566e41f4b71Sopenharmony_ciconst valuesBucket: relationalStore.ValuesBucket = {
2567e41f4b71Sopenharmony_ci  "NAME": 'hangman',
2568e41f4b71Sopenharmony_ci  "AGE": 18,
2569e41f4b71Sopenharmony_ci  "SALARY": 100.5,
2570e41f4b71Sopenharmony_ci  "CODES": new Uint8Array([1,2,3]),
2571e41f4b71Sopenharmony_ci};
2572e41f4b71Sopenharmony_ciconst sendableValuesBucket = sendableRelationalStore.toSendableValuesBucket(valuesBucket);
2573e41f4b71Sopenharmony_ci
2574e41f4b71Sopenharmony_ciif(store != undefined) {
2575e41f4b71Sopenharmony_ci  try {
2576e41f4b71Sopenharmony_ci    let rowId : number = (store as relationalStore.RdbStore).insertSync("EMPLOYEE", sendableValuesBucket, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE);
2577e41f4b71Sopenharmony_ci    console.info(`Insert is successful, rowId = ${rowId}`);
2578e41f4b71Sopenharmony_ci  } catch (error) {
2579e41f4b71Sopenharmony_ci    console.error(`Insert is failed, code is ${error.code},message is ${error.message}`);
2580e41f4b71Sopenharmony_ci  }
2581e41f4b71Sopenharmony_ci}
2582e41f4b71Sopenharmony_ci```
2583e41f4b71Sopenharmony_ci
2584e41f4b71Sopenharmony_ci### batchInsert
2585e41f4b71Sopenharmony_ci
2586e41f4b71Sopenharmony_cibatchInsert(table: string, values: Array&lt;ValuesBucket&gt;, callback: AsyncCallback&lt;number&gt;):void
2587e41f4b71Sopenharmony_ci
2588e41f4b71Sopenharmony_ciBatch inserts data into a table. This API uses an asynchronous callback to return the result.
2589e41f4b71Sopenharmony_ci
2590e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2591e41f4b71Sopenharmony_ci
2592e41f4b71Sopenharmony_ci**Parameters**
2593e41f4b71Sopenharmony_ci
2594e41f4b71Sopenharmony_ci| Name  | Type                                      | Mandatory| Description                                                        |
2595e41f4b71Sopenharmony_ci| -------- | ------------------------------------------ | ---- | ------------------------------------------------------------ |
2596e41f4b71Sopenharmony_ci| table    | string                                     | Yes  | Name of the target table.                                            |
2597e41f4b71Sopenharmony_ci| values   | Array&lt;[ValuesBucket](#valuesbucket)&gt; | Yes  | An array of data to insert.                                |
2598e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;number&gt;                | Yes  | Callback used to return the result. If the operation is successful, the number of inserted data records is returned. Otherwise, **-1** is returned.|
2599e41f4b71Sopenharmony_ci
2600e41f4b71Sopenharmony_ci**Error codes**
2601e41f4b71Sopenharmony_ci
2602e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
2603e41f4b71Sopenharmony_ci
2604e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
2605e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
2606e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2607e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
2608e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
2609e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
2610e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
2611e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
2612e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
2613e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
2614e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
2615e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
2616e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
2617e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
2618e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
2619e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
2620e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
2621e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
2622e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
2623e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
2624e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
2625e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
2626e41f4b71Sopenharmony_ci
2627e41f4b71Sopenharmony_ci**Example**
2628e41f4b71Sopenharmony_ci
2629e41f4b71Sopenharmony_ci```ts
2630e41f4b71Sopenharmony_ci
2631e41f4b71Sopenharmony_cilet value1 = "Lisa";
2632e41f4b71Sopenharmony_cilet value2 = 18;
2633e41f4b71Sopenharmony_cilet value3 = 100.5;
2634e41f4b71Sopenharmony_cilet value4 = new Uint8Array([1, 2, 3, 4, 5]);
2635e41f4b71Sopenharmony_cilet value5 = "Jack";
2636e41f4b71Sopenharmony_cilet value6 = 19;
2637e41f4b71Sopenharmony_cilet value7 = 101.5;
2638e41f4b71Sopenharmony_cilet value8 = new Uint8Array([6, 7, 8, 9, 10]);
2639e41f4b71Sopenharmony_cilet value9 = "Tom";
2640e41f4b71Sopenharmony_cilet value10 = 20;
2641e41f4b71Sopenharmony_cilet value11 = 102.5;
2642e41f4b71Sopenharmony_cilet value12 = new Uint8Array([11, 12, 13, 14, 15]);
2643e41f4b71Sopenharmony_ci
2644e41f4b71Sopenharmony_ciconst valueBucket1: relationalStore.ValuesBucket = {
2645e41f4b71Sopenharmony_ci  'NAME': value1,
2646e41f4b71Sopenharmony_ci  'AGE': value2,
2647e41f4b71Sopenharmony_ci  'SALARY': value3,
2648e41f4b71Sopenharmony_ci  'CODES': value4,
2649e41f4b71Sopenharmony_ci};
2650e41f4b71Sopenharmony_ciconst valueBucket2: relationalStore.ValuesBucket = {
2651e41f4b71Sopenharmony_ci  'NAME': value5,
2652e41f4b71Sopenharmony_ci  'AGE': value6,
2653e41f4b71Sopenharmony_ci  'SALARY': value7,
2654e41f4b71Sopenharmony_ci  'CODES': value8,
2655e41f4b71Sopenharmony_ci};
2656e41f4b71Sopenharmony_ciconst valueBucket3: relationalStore.ValuesBucket = {
2657e41f4b71Sopenharmony_ci  'NAME': value9,
2658e41f4b71Sopenharmony_ci  'AGE': value10,
2659e41f4b71Sopenharmony_ci  'SALARY': value11,
2660e41f4b71Sopenharmony_ci  'CODES': value12,
2661e41f4b71Sopenharmony_ci};
2662e41f4b71Sopenharmony_ci
2663e41f4b71Sopenharmony_cilet valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3);
2664e41f4b71Sopenharmony_ciif(store != undefined) {
2665e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).batchInsert("EMPLOYEE", valueBuckets, (err, insertNum) => {
2666e41f4b71Sopenharmony_ci    if (err) {
2667e41f4b71Sopenharmony_ci      console.error(`batchInsert is failed, code is ${err.code},message is ${err.message}`);
2668e41f4b71Sopenharmony_ci      return;
2669e41f4b71Sopenharmony_ci    }
2670e41f4b71Sopenharmony_ci    console.info(`batchInsert is successful, the number of values that were inserted = ${insertNum}`);
2671e41f4b71Sopenharmony_ci  })
2672e41f4b71Sopenharmony_ci}
2673e41f4b71Sopenharmony_ci```
2674e41f4b71Sopenharmony_ci
2675e41f4b71Sopenharmony_ci### batchInsert
2676e41f4b71Sopenharmony_ci
2677e41f4b71Sopenharmony_cibatchInsert(table: string, values: Array&lt;ValuesBucket&gt;):Promise&lt;number&gt;
2678e41f4b71Sopenharmony_ci
2679e41f4b71Sopenharmony_ciBatch inserts data into a table. This API uses a promise to return the result.
2680e41f4b71Sopenharmony_ci
2681e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2682e41f4b71Sopenharmony_ci
2683e41f4b71Sopenharmony_ci**Parameters**
2684e41f4b71Sopenharmony_ci
2685e41f4b71Sopenharmony_ci| Name| Type                                      | Mandatory| Description                        |
2686e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ---------------------------- |
2687e41f4b71Sopenharmony_ci| table  | string                                     | Yes  | Name of the target table.            |
2688e41f4b71Sopenharmony_ci| values | Array&lt;[ValuesBucket](#valuesbucket)&gt; | Yes  | An array of data to insert.|
2689e41f4b71Sopenharmony_ci
2690e41f4b71Sopenharmony_ci**Return value**
2691e41f4b71Sopenharmony_ci
2692e41f4b71Sopenharmony_ci| Type                 | Description                                                       |
2693e41f4b71Sopenharmony_ci| --------------------- | ----------------------------------------------------------- |
2694e41f4b71Sopenharmony_ci| Promise&lt;number&gt; | Promise used to return the result. If the operation is successful, the number of inserted data records is returned. Otherwise, **-1** is returned.|
2695e41f4b71Sopenharmony_ci
2696e41f4b71Sopenharmony_ci**Error codes**
2697e41f4b71Sopenharmony_ci
2698e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
2699e41f4b71Sopenharmony_ci
2700e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
2701e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
2702e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2703e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
2704e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
2705e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
2706e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
2707e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
2708e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
2709e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
2710e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
2711e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
2712e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
2713e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
2714e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
2715e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
2716e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
2717e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
2718e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
2719e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
2720e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
2721e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
2722e41f4b71Sopenharmony_ci
2723e41f4b71Sopenharmony_ci**Example**
2724e41f4b71Sopenharmony_ci
2725e41f4b71Sopenharmony_ci```ts
2726e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2727e41f4b71Sopenharmony_ci
2728e41f4b71Sopenharmony_cilet value1 = "Lisa";
2729e41f4b71Sopenharmony_cilet value2 = 18;
2730e41f4b71Sopenharmony_cilet value3 = 100.5;
2731e41f4b71Sopenharmony_cilet value4 = new Uint8Array([1, 2, 3, 4, 5]);
2732e41f4b71Sopenharmony_cilet value5 = "Jack";
2733e41f4b71Sopenharmony_cilet value6 = 19;
2734e41f4b71Sopenharmony_cilet value7 = 101.5;
2735e41f4b71Sopenharmony_cilet value8 = new Uint8Array([6, 7, 8, 9, 10]);
2736e41f4b71Sopenharmony_cilet value9 = "Tom";
2737e41f4b71Sopenharmony_cilet value10 = 20;
2738e41f4b71Sopenharmony_cilet value11 = 102.5;
2739e41f4b71Sopenharmony_cilet value12 = new Uint8Array([11, 12, 13, 14, 15]);
2740e41f4b71Sopenharmony_ci
2741e41f4b71Sopenharmony_ciconst valueBucket1: relationalStore.ValuesBucket = {
2742e41f4b71Sopenharmony_ci  'NAME': value1,
2743e41f4b71Sopenharmony_ci  'AGE': value2,
2744e41f4b71Sopenharmony_ci  'SALARY': value3,
2745e41f4b71Sopenharmony_ci  'CODES': value4,
2746e41f4b71Sopenharmony_ci};
2747e41f4b71Sopenharmony_ciconst valueBucket2: relationalStore.ValuesBucket = {
2748e41f4b71Sopenharmony_ci  'NAME': value5,
2749e41f4b71Sopenharmony_ci  'AGE': value6,
2750e41f4b71Sopenharmony_ci  'SALARY': value7,
2751e41f4b71Sopenharmony_ci  'CODES': value8,
2752e41f4b71Sopenharmony_ci};
2753e41f4b71Sopenharmony_ciconst valueBucket3: relationalStore.ValuesBucket = {
2754e41f4b71Sopenharmony_ci  'NAME': value9,
2755e41f4b71Sopenharmony_ci  'AGE': value10,
2756e41f4b71Sopenharmony_ci  'SALARY': value11,
2757e41f4b71Sopenharmony_ci  'CODES': value12,
2758e41f4b71Sopenharmony_ci};
2759e41f4b71Sopenharmony_ci
2760e41f4b71Sopenharmony_cilet valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3);
2761e41f4b71Sopenharmony_ciif(store != undefined) {
2762e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).batchInsert("EMPLOYEE", valueBuckets).then((insertNum: number) => {
2763e41f4b71Sopenharmony_ci    console.info(`batchInsert is successful, the number of values that were inserted = ${insertNum}`);
2764e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
2765e41f4b71Sopenharmony_ci    console.error(`batchInsert is failed, code is ${err.code},message is ${err.message}`);
2766e41f4b71Sopenharmony_ci  })
2767e41f4b71Sopenharmony_ci}
2768e41f4b71Sopenharmony_ci```
2769e41f4b71Sopenharmony_ci
2770e41f4b71Sopenharmony_ci### batchInsertSync<sup>12+</sup>
2771e41f4b71Sopenharmony_ci
2772e41f4b71Sopenharmony_cibatchInsertSync(table: string, values: Array&lt;ValuesBucket&gt;):number
2773e41f4b71Sopenharmony_ci
2774e41f4b71Sopenharmony_ciInserts a row of data into a table.
2775e41f4b71Sopenharmony_ci
2776e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2777e41f4b71Sopenharmony_ci
2778e41f4b71Sopenharmony_ci**Parameters**
2779e41f4b71Sopenharmony_ci
2780e41f4b71Sopenharmony_ci| Name| Type                                      | Mandatory| Description                        |
2781e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ---------------------------- |
2782e41f4b71Sopenharmony_ci| table  | string                                     | Yes  | Name of the target table.            |
2783e41f4b71Sopenharmony_ci| values | Array&lt;[ValuesBucket](#valuesbucket)&gt; | Yes  | An array of data to insert.|
2784e41f4b71Sopenharmony_ci
2785e41f4b71Sopenharmony_ci**Return value**
2786e41f4b71Sopenharmony_ci
2787e41f4b71Sopenharmony_ci| Type  | Description                                          |
2788e41f4b71Sopenharmony_ci| ------ | ---------------------------------------------- |
2789e41f4b71Sopenharmony_ci| number | If the operation is successful, the number of inserted data records is returned. Otherwise, **-1** is returned.|
2790e41f4b71Sopenharmony_ci
2791e41f4b71Sopenharmony_ci**Error codes**
2792e41f4b71Sopenharmony_ci
2793e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
2794e41f4b71Sopenharmony_ci
2795e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
2796e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------------------------ |
2797e41f4b71Sopenharmony_ci| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2798e41f4b71Sopenharmony_ci| 14800000     | Inner error.                                                 |
2799e41f4b71Sopenharmony_ci| 14800011     | Database corrupted.                                          |
2800e41f4b71Sopenharmony_ci| 14800014     | Already closed.                                              |
2801e41f4b71Sopenharmony_ci| 14800015     | The database does not respond.                                        |
2802e41f4b71Sopenharmony_ci| 14800021     | SQLite: Generic error.                                       |
2803e41f4b71Sopenharmony_ci| 14800022     | SQLite: Callback routine requested an abort.                 |
2804e41f4b71Sopenharmony_ci| 14800023     | SQLite: Access permission denied.                            |
2805e41f4b71Sopenharmony_ci| 14800024     | SQLite: The database file is locked.                         |
2806e41f4b71Sopenharmony_ci| 14800025     | SQLite: A table in the database is locked.                   |
2807e41f4b71Sopenharmony_ci| 14800026     | SQLite: The database is out of memory.                       |
2808e41f4b71Sopenharmony_ci| 14800027     | SQLite: Attempt to write a readonly database.                |
2809e41f4b71Sopenharmony_ci| 14800028     | SQLite: Some kind of disk I/O error occurred.                |
2810e41f4b71Sopenharmony_ci| 14800029     | SQLite: The database is full.                                |
2811e41f4b71Sopenharmony_ci| 14800030     | SQLite: Unable to open the database file.                    |
2812e41f4b71Sopenharmony_ci| 14800031     | SQLite: TEXT or BLOB exceeds size limit.                     |
2813e41f4b71Sopenharmony_ci| 14800032     | SQLite: Abort due to constraint violation.                   |
2814e41f4b71Sopenharmony_ci| 14800033     | SQLite: Data type mismatch.                                  |
2815e41f4b71Sopenharmony_ci| 14800034     | SQLite: Library used incorrectly.                            |
2816e41f4b71Sopenharmony_ci| 14800047     | The WAL file size exceeds the default limit.                 |
2817e41f4b71Sopenharmony_ci
2818e41f4b71Sopenharmony_ci**Example**
2819e41f4b71Sopenharmony_ci
2820e41f4b71Sopenharmony_ci```ts
2821e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
2822e41f4b71Sopenharmony_ci
2823e41f4b71Sopenharmony_cilet value1 = "Lisa";
2824e41f4b71Sopenharmony_cilet value2 = 18;
2825e41f4b71Sopenharmony_cilet value3 = 100.5;
2826e41f4b71Sopenharmony_cilet value4 = new Uint8Array([1, 2, 3, 4, 5]);
2827e41f4b71Sopenharmony_cilet value5 = "Jack";
2828e41f4b71Sopenharmony_cilet value6 = 19;
2829e41f4b71Sopenharmony_cilet value7 = 101.5;
2830e41f4b71Sopenharmony_cilet value8 = new Uint8Array([6, 7, 8, 9, 10]);
2831e41f4b71Sopenharmony_cilet value9 = "Tom";
2832e41f4b71Sopenharmony_cilet value10 = 20;
2833e41f4b71Sopenharmony_cilet value11 = 102.5;
2834e41f4b71Sopenharmony_cilet value12 = new Uint8Array([11, 12, 13, 14, 15]);
2835e41f4b71Sopenharmony_ci
2836e41f4b71Sopenharmony_ciconst valueBucket1: relationalStore.ValuesBucket = {
2837e41f4b71Sopenharmony_ci  'NAME': value1,
2838e41f4b71Sopenharmony_ci  'AGE': value2,
2839e41f4b71Sopenharmony_ci  'SALARY': value3,
2840e41f4b71Sopenharmony_ci  'CODES': value4,
2841e41f4b71Sopenharmony_ci};
2842e41f4b71Sopenharmony_ciconst valueBucket2: relationalStore.ValuesBucket = {
2843e41f4b71Sopenharmony_ci  'NAME': value5,
2844e41f4b71Sopenharmony_ci  'AGE': value6,
2845e41f4b71Sopenharmony_ci  'SALARY': value7,
2846e41f4b71Sopenharmony_ci  'CODES': value8,
2847e41f4b71Sopenharmony_ci};
2848e41f4b71Sopenharmony_ciconst valueBucket3: relationalStore.ValuesBucket = {
2849e41f4b71Sopenharmony_ci  'NAME': value9,
2850e41f4b71Sopenharmony_ci  'AGE': value10,
2851e41f4b71Sopenharmony_ci  'SALARY': value11,
2852e41f4b71Sopenharmony_ci  'CODES': value12,
2853e41f4b71Sopenharmony_ci};
2854e41f4b71Sopenharmony_ci
2855e41f4b71Sopenharmony_cilet valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3);
2856e41f4b71Sopenharmony_ciif(store != undefined) {
2857e41f4b71Sopenharmony_ci  try {
2858e41f4b71Sopenharmony_ci    let insertNum: number = (store as relationalStore.RdbStore).batchInsertSync("EMPLOYEE", valueBuckets);
2859e41f4b71Sopenharmony_ci    console.info(`batchInsert is successful, the number of values that were inserted = ${insertNum}`);
2860e41f4b71Sopenharmony_ci  } catch (err) {
2861e41f4b71Sopenharmony_ci      console.error(`batchInsert is failed, code is ${err.code},message is ${err.message}`);
2862e41f4b71Sopenharmony_ci  }
2863e41f4b71Sopenharmony_ci}
2864e41f4b71Sopenharmony_ci```
2865e41f4b71Sopenharmony_ci
2866e41f4b71Sopenharmony_ci### update
2867e41f4b71Sopenharmony_ci
2868e41f4b71Sopenharmony_ciupdate(values: ValuesBucket, predicates: RdbPredicates, callback: AsyncCallback&lt;number&gt;):void
2869e41f4b71Sopenharmony_ci
2870e41f4b71Sopenharmony_ciUpdates data in the RDB store based on the specified **RdbPredicates** object. This API uses an asynchronous callback to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
2871e41f4b71Sopenharmony_ci
2872e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2873e41f4b71Sopenharmony_ci
2874e41f4b71Sopenharmony_ci**Parameters**
2875e41f4b71Sopenharmony_ci
2876e41f4b71Sopenharmony_ci| Name    | Type                                | Mandatory| Description                                                        |
2877e41f4b71Sopenharmony_ci| ---------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
2878e41f4b71Sopenharmony_ci| values     | [ValuesBucket](#valuesbucket)        | Yes  | Rows of data to update in the RDB store. The key-value pair is associated with the column name in the target table.|
2879e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Update conditions specified by the **RdbPredicates** object.                   |
2880e41f4b71Sopenharmony_ci| callback   | AsyncCallback&lt;number&gt;          | Yes  | Callback used to return the number of rows updated.                  |
2881e41f4b71Sopenharmony_ci
2882e41f4b71Sopenharmony_ci**Error codes**
2883e41f4b71Sopenharmony_ci
2884e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
2885e41f4b71Sopenharmony_ci
2886e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
2887e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
2888e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2889e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
2890e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
2891e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
2892e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
2893e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
2894e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
2895e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
2896e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
2897e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
2898e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
2899e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
2900e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
2901e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
2902e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
2903e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
2904e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
2905e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
2906e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
2907e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
2908e41f4b71Sopenharmony_ci
2909e41f4b71Sopenharmony_ci**Example**
2910e41f4b71Sopenharmony_ci
2911e41f4b71Sopenharmony_ci```ts
2912e41f4b71Sopenharmony_ci
2913e41f4b71Sopenharmony_cilet value1 = "Rose";
2914e41f4b71Sopenharmony_cilet value2 = 22;
2915e41f4b71Sopenharmony_cilet value3 = 200.5;
2916e41f4b71Sopenharmony_cilet value4 = new Uint8Array([1, 2, 3, 4, 5]);
2917e41f4b71Sopenharmony_ci
2918e41f4b71Sopenharmony_ci// You can use either of the following:
2919e41f4b71Sopenharmony_ciconst valueBucket1: relationalStore.ValuesBucket = {
2920e41f4b71Sopenharmony_ci  'NAME': value1,
2921e41f4b71Sopenharmony_ci  'AGE': value2,
2922e41f4b71Sopenharmony_ci  'SALARY': value3,
2923e41f4b71Sopenharmony_ci  'CODES': value4,
2924e41f4b71Sopenharmony_ci};
2925e41f4b71Sopenharmony_ciconst valueBucket2: relationalStore.ValuesBucket = {
2926e41f4b71Sopenharmony_ci  NAME: value1,
2927e41f4b71Sopenharmony_ci  AGE: value2,
2928e41f4b71Sopenharmony_ci  SALARY: value3,
2929e41f4b71Sopenharmony_ci  CODES: value4,
2930e41f4b71Sopenharmony_ci};
2931e41f4b71Sopenharmony_ciconst valueBucket3: relationalStore.ValuesBucket = {
2932e41f4b71Sopenharmony_ci  "NAME": value1,
2933e41f4b71Sopenharmony_ci  "AGE": value2,
2934e41f4b71Sopenharmony_ci  "SALARY": value3,
2935e41f4b71Sopenharmony_ci  "CODES": value4,
2936e41f4b71Sopenharmony_ci};
2937e41f4b71Sopenharmony_ci
2938e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
2939e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Lisa");
2940e41f4b71Sopenharmony_ciif(store != undefined) {
2941e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).update(valueBucket1, predicates,(err, rows) => {
2942e41f4b71Sopenharmony_ci    if (err) {
2943e41f4b71Sopenharmony_ci      console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
2944e41f4b71Sopenharmony_ci      return;
2945e41f4b71Sopenharmony_ci    }
2946e41f4b71Sopenharmony_ci    console.info(`Updated row count: ${rows}`);
2947e41f4b71Sopenharmony_ci  })
2948e41f4b71Sopenharmony_ci}
2949e41f4b71Sopenharmony_ci```
2950e41f4b71Sopenharmony_ci
2951e41f4b71Sopenharmony_ci### update<sup>10+</sup>
2952e41f4b71Sopenharmony_ci
2953e41f4b71Sopenharmony_ciupdate(values: ValuesBucket, predicates: RdbPredicates, conflict: ConflictResolution, callback: AsyncCallback&lt;number&gt;):void
2954e41f4b71Sopenharmony_ci
2955e41f4b71Sopenharmony_ciUpdates data in the RDB store based on the specified **RdbPredicates** object. This API uses an asynchronous callback to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
2956e41f4b71Sopenharmony_ci
2957e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2958e41f4b71Sopenharmony_ci
2959e41f4b71Sopenharmony_ci**Parameters**
2960e41f4b71Sopenharmony_ci
2961e41f4b71Sopenharmony_ci| Name    | Type                                       | Mandatory| Description                                                        |
2962e41f4b71Sopenharmony_ci| ---------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
2963e41f4b71Sopenharmony_ci| values     | [ValuesBucket](#valuesbucket)               | Yes  | Rows of data to update in the RDB store. The key-value pair is associated with the column name in the target table.|
2964e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates)            | Yes  | Update conditions specified by the **RdbPredicates** object.                     |
2965e41f4b71Sopenharmony_ci| conflict   | [ConflictResolution](#conflictresolution10) | Yes  | Resolution used to resolve the conflict.                                          |
2966e41f4b71Sopenharmony_ci| callback   | AsyncCallback&lt;number&gt;                 | Yes  | Callback used to return the number of rows updated.                  |
2967e41f4b71Sopenharmony_ci
2968e41f4b71Sopenharmony_ci**Error codes**
2969e41f4b71Sopenharmony_ci
2970e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
2971e41f4b71Sopenharmony_ci
2972e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
2973e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
2974e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2975e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
2976e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
2977e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
2978e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
2979e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
2980e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
2981e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
2982e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
2983e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
2984e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
2985e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
2986e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
2987e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
2988e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
2989e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
2990e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
2991e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
2992e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
2993e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
2994e41f4b71Sopenharmony_ci
2995e41f4b71Sopenharmony_ci**Example**
2996e41f4b71Sopenharmony_ci
2997e41f4b71Sopenharmony_ci```ts
2998e41f4b71Sopenharmony_ci
2999e41f4b71Sopenharmony_cilet value1 = "Rose";
3000e41f4b71Sopenharmony_cilet value2 = 22;
3001e41f4b71Sopenharmony_cilet value3 = 200.5;
3002e41f4b71Sopenharmony_cilet value4 = new Uint8Array([1, 2, 3, 4, 5]);
3003e41f4b71Sopenharmony_ci
3004e41f4b71Sopenharmony_ci// You can use either of the following:
3005e41f4b71Sopenharmony_ciconst valueBucket1: relationalStore.ValuesBucket = {
3006e41f4b71Sopenharmony_ci  'NAME': value1,
3007e41f4b71Sopenharmony_ci  'AGE': value2,
3008e41f4b71Sopenharmony_ci  'SALARY': value3,
3009e41f4b71Sopenharmony_ci  'CODES': value4,
3010e41f4b71Sopenharmony_ci};
3011e41f4b71Sopenharmony_ciconst valueBucket2: relationalStore.ValuesBucket = {
3012e41f4b71Sopenharmony_ci  NAME: value1,
3013e41f4b71Sopenharmony_ci  AGE: value2,
3014e41f4b71Sopenharmony_ci  SALARY: value3,
3015e41f4b71Sopenharmony_ci  CODES: value4,
3016e41f4b71Sopenharmony_ci};
3017e41f4b71Sopenharmony_ciconst valueBucket3: relationalStore.ValuesBucket = {
3018e41f4b71Sopenharmony_ci  "NAME": value1,
3019e41f4b71Sopenharmony_ci  "AGE": value2,
3020e41f4b71Sopenharmony_ci  "SALARY": value3,
3021e41f4b71Sopenharmony_ci  "CODES": value4,
3022e41f4b71Sopenharmony_ci};
3023e41f4b71Sopenharmony_ci
3024e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3025e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Lisa");
3026e41f4b71Sopenharmony_ciif(store != undefined) {
3027e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).update(valueBucket1, predicates, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE, (err, rows) => {
3028e41f4b71Sopenharmony_ci    if (err) {
3029e41f4b71Sopenharmony_ci      console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
3030e41f4b71Sopenharmony_ci      return;
3031e41f4b71Sopenharmony_ci    }
3032e41f4b71Sopenharmony_ci    console.info(`Updated row count: ${rows}`);
3033e41f4b71Sopenharmony_ci  })
3034e41f4b71Sopenharmony_ci}
3035e41f4b71Sopenharmony_ci```
3036e41f4b71Sopenharmony_ci
3037e41f4b71Sopenharmony_ci### update
3038e41f4b71Sopenharmony_ci
3039e41f4b71Sopenharmony_ciupdate(values: ValuesBucket, predicates: RdbPredicates):Promise&lt;number&gt;
3040e41f4b71Sopenharmony_ci
3041e41f4b71Sopenharmony_ciUpdates data based on the specified **RdbPredicates** object. This API uses a promise to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
3042e41f4b71Sopenharmony_ci
3043e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3044e41f4b71Sopenharmony_ci
3045e41f4b71Sopenharmony_ci**Parameters**
3046e41f4b71Sopenharmony_ci
3047e41f4b71Sopenharmony_ci| Name      | Type                                | Mandatory| Description                                                        |
3048e41f4b71Sopenharmony_ci| ------------ | ------------------------------------ | ---- | ------------------------------------------------------------ |
3049e41f4b71Sopenharmony_ci| values       | [ValuesBucket](#valuesbucket)        | Yes  | Rows of data to update in the RDB store. The key-value pair is associated with the column name in the target table.|
3050e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Update conditions specified by the **RdbPredicates** object.                   |
3051e41f4b71Sopenharmony_ci
3052e41f4b71Sopenharmony_ci**Return value**
3053e41f4b71Sopenharmony_ci
3054e41f4b71Sopenharmony_ci| Type                 | Description                                     |
3055e41f4b71Sopenharmony_ci| --------------------- | ----------------------------------------- |
3056e41f4b71Sopenharmony_ci| Promise&lt;number&gt; | Promise used to return the number of rows updated.|
3057e41f4b71Sopenharmony_ci
3058e41f4b71Sopenharmony_ci**Error codes**
3059e41f4b71Sopenharmony_ci
3060e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
3061e41f4b71Sopenharmony_ci
3062e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
3063e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
3064e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3065e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
3066e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
3067e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
3068e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
3069e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
3070e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
3071e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
3072e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
3073e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
3074e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
3075e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
3076e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
3077e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
3078e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
3079e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
3080e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
3081e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
3082e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
3083e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
3084e41f4b71Sopenharmony_ci
3085e41f4b71Sopenharmony_ci**Example**
3086e41f4b71Sopenharmony_ci
3087e41f4b71Sopenharmony_ci```ts
3088e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3089e41f4b71Sopenharmony_ci
3090e41f4b71Sopenharmony_cilet value1 = "Rose";
3091e41f4b71Sopenharmony_cilet value2 = 22;
3092e41f4b71Sopenharmony_cilet value3 = 200.5;
3093e41f4b71Sopenharmony_cilet value4 = new Uint8Array([1, 2, 3, 4, 5]);
3094e41f4b71Sopenharmony_ci
3095e41f4b71Sopenharmony_ci// You can use either of the following:
3096e41f4b71Sopenharmony_ciconst valueBucket1: relationalStore.ValuesBucket = {
3097e41f4b71Sopenharmony_ci  'NAME': value1,
3098e41f4b71Sopenharmony_ci  'AGE': value2,
3099e41f4b71Sopenharmony_ci  'SALARY': value3,
3100e41f4b71Sopenharmony_ci  'CODES': value4,
3101e41f4b71Sopenharmony_ci};
3102e41f4b71Sopenharmony_ciconst valueBucket2: relationalStore.ValuesBucket = {
3103e41f4b71Sopenharmony_ci  NAME: value1,
3104e41f4b71Sopenharmony_ci  AGE: value2,
3105e41f4b71Sopenharmony_ci  SALARY: value3,
3106e41f4b71Sopenharmony_ci  CODES: value4,
3107e41f4b71Sopenharmony_ci};
3108e41f4b71Sopenharmony_ciconst valueBucket3: relationalStore.ValuesBucket = {
3109e41f4b71Sopenharmony_ci  "NAME": value1,
3110e41f4b71Sopenharmony_ci  "AGE": value2,
3111e41f4b71Sopenharmony_ci  "SALARY": value3,
3112e41f4b71Sopenharmony_ci  "CODES": value4,
3113e41f4b71Sopenharmony_ci};
3114e41f4b71Sopenharmony_ci
3115e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3116e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Lisa");
3117e41f4b71Sopenharmony_ciif(store != undefined) {
3118e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).update(valueBucket1, predicates).then(async (rows: Number) => {
3119e41f4b71Sopenharmony_ci    console.info(`Updated row count: ${rows}`);
3120e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
3121e41f4b71Sopenharmony_ci    console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
3122e41f4b71Sopenharmony_ci  })
3123e41f4b71Sopenharmony_ci}
3124e41f4b71Sopenharmony_ci```
3125e41f4b71Sopenharmony_ci
3126e41f4b71Sopenharmony_ci### update<sup>10+</sup>
3127e41f4b71Sopenharmony_ci
3128e41f4b71Sopenharmony_ciupdate(values: ValuesBucket, predicates: RdbPredicates, conflict: ConflictResolution):Promise&lt;number&gt;
3129e41f4b71Sopenharmony_ci
3130e41f4b71Sopenharmony_ciUpdates data based on the specified **RdbPredicates** object. This API uses a promise to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
3131e41f4b71Sopenharmony_ci
3132e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3133e41f4b71Sopenharmony_ci
3134e41f4b71Sopenharmony_ci**Parameters**
3135e41f4b71Sopenharmony_ci
3136e41f4b71Sopenharmony_ci| Name    | Type                                       | Mandatory| Description                                                        |
3137e41f4b71Sopenharmony_ci| ---------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
3138e41f4b71Sopenharmony_ci| values     | [ValuesBucket](#valuesbucket)               | Yes  | Rows of data to update in the RDB store. The key-value pair is associated with the column name in the target table.|
3139e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates)            | Yes  | Update conditions specified by the **RdbPredicates** object.                     |
3140e41f4b71Sopenharmony_ci| conflict   | [ConflictResolution](#conflictresolution10) | Yes  | Resolution used to resolve the conflict.                                          |
3141e41f4b71Sopenharmony_ci
3142e41f4b71Sopenharmony_ci**Return value**
3143e41f4b71Sopenharmony_ci
3144e41f4b71Sopenharmony_ci| Type                 | Description                                     |
3145e41f4b71Sopenharmony_ci| --------------------- | ----------------------------------------- |
3146e41f4b71Sopenharmony_ci| Promise&lt;number&gt; | Promise used to return the number of rows updated.|
3147e41f4b71Sopenharmony_ci
3148e41f4b71Sopenharmony_ci**Error codes**
3149e41f4b71Sopenharmony_ci
3150e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
3151e41f4b71Sopenharmony_ci
3152e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
3153e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
3154e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3155e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
3156e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
3157e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
3158e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
3159e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
3160e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
3161e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
3162e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
3163e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
3164e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
3165e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
3166e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
3167e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
3168e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
3169e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
3170e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
3171e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
3172e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
3173e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
3174e41f4b71Sopenharmony_ci
3175e41f4b71Sopenharmony_ci**Example**
3176e41f4b71Sopenharmony_ci
3177e41f4b71Sopenharmony_ci```ts
3178e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3179e41f4b71Sopenharmony_ci
3180e41f4b71Sopenharmony_cilet value1 = "Rose";
3181e41f4b71Sopenharmony_cilet value2 = 22;
3182e41f4b71Sopenharmony_cilet value3 = 200.5;
3183e41f4b71Sopenharmony_cilet value4 = new Uint8Array([1, 2, 3, 4, 5]);
3184e41f4b71Sopenharmony_ci
3185e41f4b71Sopenharmony_ci// You can use either of the following:
3186e41f4b71Sopenharmony_ciconst valueBucket1: relationalStore.ValuesBucket = {
3187e41f4b71Sopenharmony_ci  'NAME': value1,
3188e41f4b71Sopenharmony_ci  'AGE': value2,
3189e41f4b71Sopenharmony_ci  'SALARY': value3,
3190e41f4b71Sopenharmony_ci  'CODES': value4,
3191e41f4b71Sopenharmony_ci};
3192e41f4b71Sopenharmony_ciconst valueBucket2: relationalStore.ValuesBucket = {
3193e41f4b71Sopenharmony_ci  NAME: value1,
3194e41f4b71Sopenharmony_ci  AGE: value2,
3195e41f4b71Sopenharmony_ci  SALARY: value3,
3196e41f4b71Sopenharmony_ci  CODES: value4,
3197e41f4b71Sopenharmony_ci};
3198e41f4b71Sopenharmony_ciconst valueBucket3: relationalStore.ValuesBucket = {
3199e41f4b71Sopenharmony_ci  "NAME": value1,
3200e41f4b71Sopenharmony_ci  "AGE": value2,
3201e41f4b71Sopenharmony_ci  "SALARY": value3,
3202e41f4b71Sopenharmony_ci  "CODES": value4,
3203e41f4b71Sopenharmony_ci};
3204e41f4b71Sopenharmony_ci
3205e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3206e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Lisa");
3207e41f4b71Sopenharmony_ciif(store != undefined) {
3208e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).update(valueBucket1, predicates, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE).then(async (rows: Number) => {
3209e41f4b71Sopenharmony_ci    console.info(`Updated row count: ${rows}`);
3210e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
3211e41f4b71Sopenharmony_ci    console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
3212e41f4b71Sopenharmony_ci  })
3213e41f4b71Sopenharmony_ci}
3214e41f4b71Sopenharmony_ci```
3215e41f4b71Sopenharmony_ci
3216e41f4b71Sopenharmony_ci### updateSync<sup>12+</sup>
3217e41f4b71Sopenharmony_ci
3218e41f4b71Sopenharmony_ciupdateSync(values: ValuesBucket, predicates: RdbPredicates, conflict?: ConflictResolution):number
3219e41f4b71Sopenharmony_ci
3220e41f4b71Sopenharmony_ciUpdates data in the RDB store based on the specified **RdbPredicates** instance. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
3221e41f4b71Sopenharmony_ci
3222e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3223e41f4b71Sopenharmony_ci
3224e41f4b71Sopenharmony_ci**Parameters**
3225e41f4b71Sopenharmony_ci
3226e41f4b71Sopenharmony_ci| Name    | Type                                       | Mandatory| Description                                                        |
3227e41f4b71Sopenharmony_ci| ---------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
3228e41f4b71Sopenharmony_ci| values     | [ValuesBucket](#valuesbucket)               | Yes  | Rows of data to update in the RDB store. The key-value pair is associated with the column name in the target table.|
3229e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates)             | Yes  | Update conditions specified by the **RdbPredicates** object.                     |
3230e41f4b71Sopenharmony_ci| conflict   | [ConflictResolution](#conflictresolution10) | No  | Resolution used to resolve the conflict. The default value is **relationalStore.ConflictResolution.ON_CONFLICT_NONE**.|
3231e41f4b71Sopenharmony_ci
3232e41f4b71Sopenharmony_ci**Return value**
3233e41f4b71Sopenharmony_ci
3234e41f4b71Sopenharmony_ci| Type  | Description              |
3235e41f4b71Sopenharmony_ci| ------ | ------------------ |
3236e41f4b71Sopenharmony_ci| number | return the number of rows updated.|
3237e41f4b71Sopenharmony_ci
3238e41f4b71Sopenharmony_ci**Error codes**
3239e41f4b71Sopenharmony_ci
3240e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
3241e41f4b71Sopenharmony_ci
3242e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
3243e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------------------------ |
3244e41f4b71Sopenharmony_ci| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3245e41f4b71Sopenharmony_ci| 14800000     | Inner error.                                                 |
3246e41f4b71Sopenharmony_ci| 14800011     | Database corrupted.                                          |
3247e41f4b71Sopenharmony_ci| 14800014     | Already closed.                                              |
3248e41f4b71Sopenharmony_ci| 14800015     | The database does not respond.                                        |
3249e41f4b71Sopenharmony_ci| 14800021     | SQLite: Generic error.                                       |
3250e41f4b71Sopenharmony_ci| 14800022     | SQLite: Callback routine requested an abort.                 |
3251e41f4b71Sopenharmony_ci| 14800023     | SQLite: Access permission denied.                            |
3252e41f4b71Sopenharmony_ci| 14800024     | SQLite: The database file is locked.                         |
3253e41f4b71Sopenharmony_ci| 14800025     | SQLite: A table in the database is locked.                   |
3254e41f4b71Sopenharmony_ci| 14800026     | SQLite: The database is out of memory.                       |
3255e41f4b71Sopenharmony_ci| 14800027     | SQLite: Attempt to write a readonly database.                |
3256e41f4b71Sopenharmony_ci| 14800028     | SQLite: Some kind of disk I/O error occurred.                |
3257e41f4b71Sopenharmony_ci| 14800029     | SQLite: The database is full.                                |
3258e41f4b71Sopenharmony_ci| 14800030     | SQLite: Unable to open the database file.                    |
3259e41f4b71Sopenharmony_ci| 14800031     | SQLite: TEXT or BLOB exceeds size limit.                     |
3260e41f4b71Sopenharmony_ci| 14800032     | SQLite: Abort due to constraint violation.                   |
3261e41f4b71Sopenharmony_ci| 14800033     | SQLite: Data type mismatch.                                  |
3262e41f4b71Sopenharmony_ci| 14800034     | SQLite: Library used incorrectly.                            |
3263e41f4b71Sopenharmony_ci| 14800047     | The WAL file size exceeds the default limit.                 |
3264e41f4b71Sopenharmony_ci
3265e41f4b71Sopenharmony_ci**Example**
3266e41f4b71Sopenharmony_ci
3267e41f4b71Sopenharmony_ci```ts
3268e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3269e41f4b71Sopenharmony_ci
3270e41f4b71Sopenharmony_cilet value1 = "Rose";
3271e41f4b71Sopenharmony_cilet value2 = 22;
3272e41f4b71Sopenharmony_cilet value3 = 200.5;
3273e41f4b71Sopenharmony_cilet value4 = new Uint8Array([1, 2, 3, 4, 5]);
3274e41f4b71Sopenharmony_ci
3275e41f4b71Sopenharmony_ci// You can use either of the following:
3276e41f4b71Sopenharmony_ciconst valueBucket1: relationalStore.ValuesBucket = {
3277e41f4b71Sopenharmony_ci  'NAME': value1,
3278e41f4b71Sopenharmony_ci  'AGE': value2,
3279e41f4b71Sopenharmony_ci  'SALARY': value3,
3280e41f4b71Sopenharmony_ci  'CODES': value4,
3281e41f4b71Sopenharmony_ci};
3282e41f4b71Sopenharmony_ciconst valueBucket2: relationalStore.ValuesBucket = {
3283e41f4b71Sopenharmony_ci  NAME: value1,
3284e41f4b71Sopenharmony_ci  AGE: value2,
3285e41f4b71Sopenharmony_ci  SALARY: value3,
3286e41f4b71Sopenharmony_ci  CODES: value4,
3287e41f4b71Sopenharmony_ci};
3288e41f4b71Sopenharmony_ciconst valueBucket3: relationalStore.ValuesBucket = {
3289e41f4b71Sopenharmony_ci  "NAME": value1,
3290e41f4b71Sopenharmony_ci  "AGE": value2,
3291e41f4b71Sopenharmony_ci  "SALARY": value3,
3292e41f4b71Sopenharmony_ci  "CODES": value4,
3293e41f4b71Sopenharmony_ci};
3294e41f4b71Sopenharmony_ci
3295e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3296e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Lisa");
3297e41f4b71Sopenharmony_ciif(store != undefined) {
3298e41f4b71Sopenharmony_ci  try {
3299e41f4b71Sopenharmony_ci    let rows: Number = (store as relationalStore.RdbStore).updateSync(valueBucket1, predicates, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE);
3300e41f4b71Sopenharmony_ci    console.info(`Updated row count: ${rows}`);
3301e41f4b71Sopenharmony_ci  } catch (error) {
3302e41f4b71Sopenharmony_ci    console.error(`Updated failed, code is ${error.code},message is ${error.message}`);
3303e41f4b71Sopenharmony_ci  }
3304e41f4b71Sopenharmony_ci}
3305e41f4b71Sopenharmony_ci```
3306e41f4b71Sopenharmony_ci
3307e41f4b71Sopenharmony_ci### delete
3308e41f4b71Sopenharmony_ci
3309e41f4b71Sopenharmony_cidelete(predicates: RdbPredicates, callback: AsyncCallback&lt;number&gt;):void
3310e41f4b71Sopenharmony_ci
3311e41f4b71Sopenharmony_ciDeletes data from the RDB store based on the specified **RdbPredicates** object. This API uses an asynchronous callback to return the result.
3312e41f4b71Sopenharmony_ci
3313e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3314e41f4b71Sopenharmony_ci
3315e41f4b71Sopenharmony_ci**Parameters**
3316e41f4b71Sopenharmony_ci
3317e41f4b71Sopenharmony_ci| Name    | Type                                | Mandatory| Description                                     |
3318e41f4b71Sopenharmony_ci| ---------- | ------------------------------------ | ---- | ----------------------------------------- |
3319e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Conditions specified by the **RdbPredicates** object for deleting data.|
3320e41f4b71Sopenharmony_ci| callback   | AsyncCallback&lt;number&gt;          | Yes  | Callback used to return the number of rows deleted. |
3321e41f4b71Sopenharmony_ci
3322e41f4b71Sopenharmony_ci**Error codes**
3323e41f4b71Sopenharmony_ci
3324e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
3325e41f4b71Sopenharmony_ci
3326e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
3327e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
3328e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3329e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
3330e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
3331e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
3332e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
3333e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
3334e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
3335e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
3336e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
3337e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
3338e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
3339e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
3340e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
3341e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
3342e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
3343e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
3344e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
3345e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
3346e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
3347e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
3348e41f4b71Sopenharmony_ci
3349e41f4b71Sopenharmony_ci**Example**
3350e41f4b71Sopenharmony_ci
3351e41f4b71Sopenharmony_ci```ts
3352e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3353e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Lisa");
3354e41f4b71Sopenharmony_ciif(store != undefined) {
3355e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).delete(predicates, (err, rows) => {
3356e41f4b71Sopenharmony_ci    if (err) {
3357e41f4b71Sopenharmony_ci      console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
3358e41f4b71Sopenharmony_ci      return;
3359e41f4b71Sopenharmony_ci    }
3360e41f4b71Sopenharmony_ci    console.info(`Delete rows: ${rows}`);
3361e41f4b71Sopenharmony_ci  })
3362e41f4b71Sopenharmony_ci}
3363e41f4b71Sopenharmony_ci```
3364e41f4b71Sopenharmony_ci
3365e41f4b71Sopenharmony_ci### delete
3366e41f4b71Sopenharmony_ci
3367e41f4b71Sopenharmony_cidelete(predicates: RdbPredicates):Promise&lt;number&gt;
3368e41f4b71Sopenharmony_ci
3369e41f4b71Sopenharmony_ciDeletes data from the RDB store based on the specified **RdbPredicates** object. This API uses a promise to return the result.
3370e41f4b71Sopenharmony_ci
3371e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3372e41f4b71Sopenharmony_ci
3373e41f4b71Sopenharmony_ci**Parameters**
3374e41f4b71Sopenharmony_ci
3375e41f4b71Sopenharmony_ci| Name    | Type                                | Mandatory| Description                                     |
3376e41f4b71Sopenharmony_ci| ---------- | ------------------------------------ | ---- | ----------------------------------------- |
3377e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Conditions specified by the **RdbPredicates** object for deleting data.|
3378e41f4b71Sopenharmony_ci
3379e41f4b71Sopenharmony_ci**Return value**
3380e41f4b71Sopenharmony_ci
3381e41f4b71Sopenharmony_ci| Type                 | Description                           |
3382e41f4b71Sopenharmony_ci| --------------------- | ------------------------------- |
3383e41f4b71Sopenharmony_ci| Promise&lt;number&gt; | Promise used to return the number of rows deleted.|
3384e41f4b71Sopenharmony_ci
3385e41f4b71Sopenharmony_ci**Error codes**
3386e41f4b71Sopenharmony_ci
3387e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
3388e41f4b71Sopenharmony_ci
3389e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
3390e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
3391e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3392e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
3393e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
3394e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
3395e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
3396e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
3397e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
3398e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
3399e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
3400e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
3401e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
3402e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
3403e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
3404e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
3405e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
3406e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
3407e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
3408e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
3409e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
3410e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
3411e41f4b71Sopenharmony_ci
3412e41f4b71Sopenharmony_ci**Example**
3413e41f4b71Sopenharmony_ci
3414e41f4b71Sopenharmony_ci```ts
3415e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3416e41f4b71Sopenharmony_ci
3417e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3418e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Lisa");
3419e41f4b71Sopenharmony_ciif(store != undefined) {
3420e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).delete(predicates).then((rows: Number) => {
3421e41f4b71Sopenharmony_ci    console.info(`Delete rows: ${rows}`);
3422e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
3423e41f4b71Sopenharmony_ci    console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
3424e41f4b71Sopenharmony_ci  })
3425e41f4b71Sopenharmony_ci}
3426e41f4b71Sopenharmony_ci```
3427e41f4b71Sopenharmony_ci
3428e41f4b71Sopenharmony_ci### deleteSync<sup>12+</sup>
3429e41f4b71Sopenharmony_ci
3430e41f4b71Sopenharmony_cideleteSync(predicates: RdbPredicates):number
3431e41f4b71Sopenharmony_ci
3432e41f4b71Sopenharmony_ciDeletes data from the RDB store based on the specified **RdbPredicates** object.
3433e41f4b71Sopenharmony_ci
3434e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3435e41f4b71Sopenharmony_ci
3436e41f4b71Sopenharmony_ci**Parameters**
3437e41f4b71Sopenharmony_ci
3438e41f4b71Sopenharmony_ci| Name    | Type                           | Mandatory| Description                                   |
3439e41f4b71Sopenharmony_ci| ---------- | ------------------------------- | ---- | --------------------------------------- |
3440e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Conditions specified by the **RdbPredicates** object for deleting data.|
3441e41f4b71Sopenharmony_ci
3442e41f4b71Sopenharmony_ci**Return value**
3443e41f4b71Sopenharmony_ci
3444e41f4b71Sopenharmony_ci| Type  | Description              |
3445e41f4b71Sopenharmony_ci| ------ | ------------------ |
3446e41f4b71Sopenharmony_ci| number | return the number of rows updated.|
3447e41f4b71Sopenharmony_ci
3448e41f4b71Sopenharmony_ci**Error codes**
3449e41f4b71Sopenharmony_ci
3450e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
3451e41f4b71Sopenharmony_ci
3452e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
3453e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------------------------ |
3454e41f4b71Sopenharmony_ci| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3455e41f4b71Sopenharmony_ci| 14800000     | Inner error.                                                 |
3456e41f4b71Sopenharmony_ci| 14800011     | Database corrupted.                                          |
3457e41f4b71Sopenharmony_ci| 14800014     | Already closed.                                              |
3458e41f4b71Sopenharmony_ci| 14800015     | The database does not respond.                                        |
3459e41f4b71Sopenharmony_ci| 14800021     | SQLite: Generic error.                                       |
3460e41f4b71Sopenharmony_ci| 14800022     | SQLite: Callback routine requested an abort.                 |
3461e41f4b71Sopenharmony_ci| 14800023     | SQLite: Access permission denied.                            |
3462e41f4b71Sopenharmony_ci| 14800024     | SQLite: The database file is locked.                         |
3463e41f4b71Sopenharmony_ci| 14800025     | SQLite: A table in the database is locked.                   |
3464e41f4b71Sopenharmony_ci| 14800026     | SQLite: The database is out of memory.                       |
3465e41f4b71Sopenharmony_ci| 14800027     | SQLite: Attempt to write a readonly database.                |
3466e41f4b71Sopenharmony_ci| 14800028     | SQLite: Some kind of disk I/O error occurred.                |
3467e41f4b71Sopenharmony_ci| 14800029     | SQLite: The database is full.                                |
3468e41f4b71Sopenharmony_ci| 14800030     | SQLite: Unable to open the database file.                    |
3469e41f4b71Sopenharmony_ci| 14800031     | SQLite: TEXT or BLOB exceeds size limit.                     |
3470e41f4b71Sopenharmony_ci| 14800032     | SQLite: Abort due to constraint violation.                   |
3471e41f4b71Sopenharmony_ci| 14800033     | SQLite: Data type mismatch.                                  |
3472e41f4b71Sopenharmony_ci| 14800034     | SQLite: Library used incorrectly.                            |
3473e41f4b71Sopenharmony_ci| 14800047     | The WAL file size exceeds the default limit.                 |
3474e41f4b71Sopenharmony_ci
3475e41f4b71Sopenharmony_ci**Example**
3476e41f4b71Sopenharmony_ci
3477e41f4b71Sopenharmony_ci```ts
3478e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3479e41f4b71Sopenharmony_ci
3480e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3481e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Lisa");
3482e41f4b71Sopenharmony_ciif(store != undefined) {
3483e41f4b71Sopenharmony_ci  try {
3484e41f4b71Sopenharmony_ci    let rows: Number = (store as relationalStore.RdbStore).deleteSync(predicates)
3485e41f4b71Sopenharmony_ci    console.info(`Delete rows: ${rows}`);
3486e41f4b71Sopenharmony_ci  } catch (err) {
3487e41f4b71Sopenharmony_ci    console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
3488e41f4b71Sopenharmony_ci  }
3489e41f4b71Sopenharmony_ci}
3490e41f4b71Sopenharmony_ci```
3491e41f4b71Sopenharmony_ci
3492e41f4b71Sopenharmony_ci### query<sup>10+</sup>
3493e41f4b71Sopenharmony_ci
3494e41f4b71Sopenharmony_ciquery(predicates: RdbPredicates, callback: AsyncCallback&lt;ResultSet&gt;):void
3495e41f4b71Sopenharmony_ci
3496e41f4b71Sopenharmony_ciQueries data from the RDB store based on specified conditions. This API uses an asynchronous callback to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
3497e41f4b71Sopenharmony_ci
3498e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3499e41f4b71Sopenharmony_ci
3500e41f4b71Sopenharmony_ci**Parameters**
3501e41f4b71Sopenharmony_ci
3502e41f4b71Sopenharmony_ci| Name    | Type                                                        | Mandatory| Description                                                       |
3503e41f4b71Sopenharmony_ci| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
3504e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates)                         | Yes  | Query conditions specified by the **RdbPredicates** object.                  |
3505e41f4b71Sopenharmony_ci| callback   | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes  | Callback used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
3506e41f4b71Sopenharmony_ci
3507e41f4b71Sopenharmony_ci**Error codes**
3508e41f4b71Sopenharmony_ci
3509e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
3510e41f4b71Sopenharmony_ci
3511e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
3512e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
3513e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3514e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
3515e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
3516e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
3517e41f4b71Sopenharmony_ci
3518e41f4b71Sopenharmony_ci**Example**
3519e41f4b71Sopenharmony_ci
3520e41f4b71Sopenharmony_ci```ts
3521e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3522e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Rose");
3523e41f4b71Sopenharmony_ciif(store != undefined) {
3524e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).query(predicates, (err, resultSet) => {
3525e41f4b71Sopenharmony_ci    if (err) {
3526e41f4b71Sopenharmony_ci      console.error(`Query failed, code is ${err.code},message is ${err.message}`);
3527e41f4b71Sopenharmony_ci      return;
3528e41f4b71Sopenharmony_ci    }
3529e41f4b71Sopenharmony_ci    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3530e41f4b71Sopenharmony_ci    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3531e41f4b71Sopenharmony_ci    while (resultSet.goToNextRow()) {
3532e41f4b71Sopenharmony_ci      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3533e41f4b71Sopenharmony_ci      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3534e41f4b71Sopenharmony_ci      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3535e41f4b71Sopenharmony_ci      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3536e41f4b71Sopenharmony_ci      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3537e41f4b71Sopenharmony_ci    }
3538e41f4b71Sopenharmony_ci    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
3539e41f4b71Sopenharmony_ci    resultSet.close();
3540e41f4b71Sopenharmony_ci  })
3541e41f4b71Sopenharmony_ci}
3542e41f4b71Sopenharmony_ci```
3543e41f4b71Sopenharmony_ci
3544e41f4b71Sopenharmony_ci### query
3545e41f4b71Sopenharmony_ci
3546e41f4b71Sopenharmony_ciquery(predicates: RdbPredicates, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;ResultSet&gt;):void
3547e41f4b71Sopenharmony_ci
3548e41f4b71Sopenharmony_ciQueries data from the RDB store based on specified conditions. This API uses an asynchronous callback to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
3549e41f4b71Sopenharmony_ci
3550e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3551e41f4b71Sopenharmony_ci
3552e41f4b71Sopenharmony_ci**Parameters**
3553e41f4b71Sopenharmony_ci
3554e41f4b71Sopenharmony_ci| Name    | Type                                                        | Mandatory| Description                                                       |
3555e41f4b71Sopenharmony_ci| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
3556e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates)                         | Yes  | Query conditions specified by the **RdbPredicates** object.                  |
3557e41f4b71Sopenharmony_ci| columns    | Array&lt;string&gt;                                          | Yes  | Columns to query. If this parameter is not specified, the query applies to all columns.           |
3558e41f4b71Sopenharmony_ci| callback   | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes  | Callback used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
3559e41f4b71Sopenharmony_ci
3560e41f4b71Sopenharmony_ci**Error codes**
3561e41f4b71Sopenharmony_ci
3562e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
3563e41f4b71Sopenharmony_ci
3564e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
3565e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
3566e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3567e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
3568e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
3569e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
3570e41f4b71Sopenharmony_ci
3571e41f4b71Sopenharmony_ci**Example**
3572e41f4b71Sopenharmony_ci
3573e41f4b71Sopenharmony_ci```ts
3574e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3575e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Rose");
3576e41f4b71Sopenharmony_ciif(store != undefined) {
3577e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], (err, resultSet) => {
3578e41f4b71Sopenharmony_ci    if (err) {
3579e41f4b71Sopenharmony_ci      console.error(`Query failed, code is ${err.code},message is ${err.message}`);
3580e41f4b71Sopenharmony_ci      return;
3581e41f4b71Sopenharmony_ci    }
3582e41f4b71Sopenharmony_ci    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3583e41f4b71Sopenharmony_ci    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3584e41f4b71Sopenharmony_ci    while (resultSet.goToNextRow()) {
3585e41f4b71Sopenharmony_ci      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3586e41f4b71Sopenharmony_ci      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3587e41f4b71Sopenharmony_ci      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3588e41f4b71Sopenharmony_ci      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3589e41f4b71Sopenharmony_ci      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3590e41f4b71Sopenharmony_ci    }
3591e41f4b71Sopenharmony_ci    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
3592e41f4b71Sopenharmony_ci    resultSet.close();
3593e41f4b71Sopenharmony_ci  })
3594e41f4b71Sopenharmony_ci}
3595e41f4b71Sopenharmony_ci```
3596e41f4b71Sopenharmony_ci
3597e41f4b71Sopenharmony_ci### query
3598e41f4b71Sopenharmony_ci
3599e41f4b71Sopenharmony_ciquery(predicates: RdbPredicates, columns?: Array&lt;string&gt;):Promise&lt;ResultSet&gt;
3600e41f4b71Sopenharmony_ci
3601e41f4b71Sopenharmony_ciQueries data from the RDB store based on specified conditions. This API uses a promise to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
3602e41f4b71Sopenharmony_ci
3603e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3604e41f4b71Sopenharmony_ci
3605e41f4b71Sopenharmony_ci**Parameters**
3606e41f4b71Sopenharmony_ci
3607e41f4b71Sopenharmony_ci| Name    | Type                                | Mandatory| Description                                            |
3608e41f4b71Sopenharmony_ci| ---------- | ------------------------------------ | ---- | ------------------------------------------------ |
3609e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Query conditions specified by the **RdbPredicates** object.       |
3610e41f4b71Sopenharmony_ci| columns    | Array&lt;string&gt;                  | No  | Columns to query. If this parameter is not specified, the query applies to all columns.|
3611e41f4b71Sopenharmony_ci
3612e41f4b71Sopenharmony_ci**Error codes**
3613e41f4b71Sopenharmony_ci
3614e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
3615e41f4b71Sopenharmony_ci
3616e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
3617e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
3618e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3619e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
3620e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
3621e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
3622e41f4b71Sopenharmony_ci
3623e41f4b71Sopenharmony_ci**Return value**
3624e41f4b71Sopenharmony_ci
3625e41f4b71Sopenharmony_ci| Type                                                   | Description                                              |
3626e41f4b71Sopenharmony_ci| ------------------------------------------------------- | -------------------------------------------------- |
3627e41f4b71Sopenharmony_ci| Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
3628e41f4b71Sopenharmony_ci
3629e41f4b71Sopenharmony_ci**Example**
3630e41f4b71Sopenharmony_ci
3631e41f4b71Sopenharmony_ci```ts
3632e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3633e41f4b71Sopenharmony_ci
3634e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3635e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Rose");
3636e41f4b71Sopenharmony_ciif(store != undefined) {
3637e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet: relationalStore.ResultSet) => {
3638e41f4b71Sopenharmony_ci    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3639e41f4b71Sopenharmony_ci    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3640e41f4b71Sopenharmony_ci    while (resultSet.goToNextRow()) {
3641e41f4b71Sopenharmony_ci      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3642e41f4b71Sopenharmony_ci      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3643e41f4b71Sopenharmony_ci      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3644e41f4b71Sopenharmony_ci      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3645e41f4b71Sopenharmony_ci      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3646e41f4b71Sopenharmony_ci    }
3647e41f4b71Sopenharmony_ci    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
3648e41f4b71Sopenharmony_ci    resultSet.close();
3649e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
3650e41f4b71Sopenharmony_ci    console.error(`Query failed, code is ${err.code},message is ${err.message}`);
3651e41f4b71Sopenharmony_ci  })
3652e41f4b71Sopenharmony_ci}
3653e41f4b71Sopenharmony_ci```
3654e41f4b71Sopenharmony_ci
3655e41f4b71Sopenharmony_ci### querySync<sup>12+</sup>
3656e41f4b71Sopenharmony_ci
3657e41f4b71Sopenharmony_ciquerySync(predicates: RdbPredicates, columns?: Array&lt;string&gt;):ResultSet
3658e41f4b71Sopenharmony_ci
3659e41f4b71Sopenharmony_ciQueries data in the RDB store based on specified **RdbPredicates** instance.
3660e41f4b71Sopenharmony_ci
3661e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3662e41f4b71Sopenharmony_ci
3663e41f4b71Sopenharmony_ci**Parameters**
3664e41f4b71Sopenharmony_ci
3665e41f4b71Sopenharmony_ci| Name    | Type                           | Mandatory| Description                                                        |
3666e41f4b71Sopenharmony_ci| ---------- | ------------------------------- | ---- | ------------------------------------------------------------ |
3667e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Query conditions specified by the **RdbPredicates** object.                     |
3668e41f4b71Sopenharmony_ci| columns    | Array&lt;string&gt;             | No  | Columns to query. If this parameter is not specified, the query applies to all columns. This parameter is left blank by default.|
3669e41f4b71Sopenharmony_ci
3670e41f4b71Sopenharmony_ci**Error codes**
3671e41f4b71Sopenharmony_ci
3672e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
3673e41f4b71Sopenharmony_ci
3674e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
3675e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------------------------ |
3676e41f4b71Sopenharmony_ci| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3677e41f4b71Sopenharmony_ci| 14800000     | Inner error.                                                 |
3678e41f4b71Sopenharmony_ci| 14800014     | Already closed.                                              |
3679e41f4b71Sopenharmony_ci| 14800015     | The database does not respond.                                        |
3680e41f4b71Sopenharmony_ci
3681e41f4b71Sopenharmony_ci**Return value**
3682e41f4b71Sopenharmony_ci
3683e41f4b71Sopenharmony_ci| Type                   | Description                               |
3684e41f4b71Sopenharmony_ci| ----------------------- | ----------------------------------- |
3685e41f4b71Sopenharmony_ci| [ResultSet](#resultset) | If the operation is successful, a **ResultSet** object will be returned.|
3686e41f4b71Sopenharmony_ci
3687e41f4b71Sopenharmony_ci**Example**
3688e41f4b71Sopenharmony_ci
3689e41f4b71Sopenharmony_ci```ts
3690e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3691e41f4b71Sopenharmony_ci
3692e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3693e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Rose");
3694e41f4b71Sopenharmony_ciif(store != undefined) {
3695e41f4b71Sopenharmony_ci  try {
3696e41f4b71Sopenharmony_ci    let resultSet: relationalStore.ResultSet = (store as relationalStore.RdbStore).querySync(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
3697e41f4b71Sopenharmony_ci    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3698e41f4b71Sopenharmony_ci    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3699e41f4b71Sopenharmony_ci    while (resultSet.goToNextRow()) {
3700e41f4b71Sopenharmony_ci      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3701e41f4b71Sopenharmony_ci      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3702e41f4b71Sopenharmony_ci      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3703e41f4b71Sopenharmony_ci      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3704e41f4b71Sopenharmony_ci      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3705e41f4b71Sopenharmony_ci    }
3706e41f4b71Sopenharmony_ci    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
3707e41f4b71Sopenharmony_ci    resultSet.close();
3708e41f4b71Sopenharmony_ci  } catch (err) {
3709e41f4b71Sopenharmony_ci    console.error(`Query failed, code is ${err.code},message is ${err.message}`);
3710e41f4b71Sopenharmony_ci  }
3711e41f4b71Sopenharmony_ci}
3712e41f4b71Sopenharmony_ci```
3713e41f4b71Sopenharmony_ci
3714e41f4b71Sopenharmony_ci### remoteQuery
3715e41f4b71Sopenharmony_ci
3716e41f4b71Sopenharmony_ciremoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array&lt;string&gt; , callback: AsyncCallback&lt;ResultSet&gt;): void
3717e41f4b71Sopenharmony_ci
3718e41f4b71Sopenharmony_ciQueries data from the RDB store of a remote device based on specified conditions. This API uses an asynchronous callback to return the result.
3719e41f4b71Sopenharmony_ci
3720e41f4b71Sopenharmony_ci> **NOTE**
3721e41f4b71Sopenharmony_ci>
3722e41f4b71Sopenharmony_ci> **device** can be obtained by [deviceManager.getAvailableDeviceListSync](../apis-distributedservice-kit/js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
3723e41f4b71Sopenharmony_ci
3724e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3725e41f4b71Sopenharmony_ci
3726e41f4b71Sopenharmony_ci**Parameters**
3727e41f4b71Sopenharmony_ci
3728e41f4b71Sopenharmony_ci| Name    | Type                                        | Mandatory| Description                                                     |
3729e41f4b71Sopenharmony_ci| ---------- | -------------------------------------------- | ---- | --------------------------------------------------------- |
3730e41f4b71Sopenharmony_ci| device     | string                                       | Yes  | ID of the remote device.                                       |
3731e41f4b71Sopenharmony_ci| table      | string                                       | Yes  | Name of the target table.                                         |
3732e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates)              | Yes  | Query conditions specified by the **RdbPredicates** object.                |
3733e41f4b71Sopenharmony_ci| columns    | Array&lt;string&gt;                          | Yes  | Columns to query. If this parameter is not specified, the query applies to all columns.         |
3734e41f4b71Sopenharmony_ci| callback   | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes  | Callback used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
3735e41f4b71Sopenharmony_ci
3736e41f4b71Sopenharmony_ci**Error codes**
3737e41f4b71Sopenharmony_ci
3738e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
3739e41f4b71Sopenharmony_ci
3740e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
3741e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
3742e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3743e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
3744e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
3745e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
3746e41f4b71Sopenharmony_ci
3747e41f4b71Sopenharmony_ci**Example**
3748e41f4b71Sopenharmony_ci
3749e41f4b71Sopenharmony_ci```ts
3750e41f4b71Sopenharmony_ciimport { distributedDeviceManager } from '@kit.DistributedServiceKit';
3751e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3752e41f4b71Sopenharmony_ci
3753e41f4b71Sopenharmony_cilet dmInstance: distributedDeviceManager.DeviceManager;
3754e41f4b71Sopenharmony_cilet deviceId: string | undefined = undefined;
3755e41f4b71Sopenharmony_ci
3756e41f4b71Sopenharmony_citry {
3757e41f4b71Sopenharmony_ci  dmInstance = distributedDeviceManager.createDeviceManager("com.example.appdatamgrverify");
3758e41f4b71Sopenharmony_ci  let devices = dmInstance.getAvailableDeviceListSync();
3759e41f4b71Sopenharmony_ci  if(deviceId != undefined) {
3760e41f4b71Sopenharmony_ci    deviceId = devices[0].networkId;
3761e41f4b71Sopenharmony_ci  }
3762e41f4b71Sopenharmony_ci} catch (err) {
3763e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
3764e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
3765e41f4b71Sopenharmony_ci  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
3766e41f4b71Sopenharmony_ci}
3767e41f4b71Sopenharmony_ci
3768e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates('EMPLOYEE');
3769e41f4b71Sopenharmony_cipredicates.greaterThan("id", 0);
3770e41f4b71Sopenharmony_ciif(store != undefined && deviceId != undefined) {
3771e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet: relationalStore.ResultSet) => {
3772e41f4b71Sopenharmony_ci    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3773e41f4b71Sopenharmony_ci    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3774e41f4b71Sopenharmony_ci    while (resultSet.goToNextRow()) {
3775e41f4b71Sopenharmony_ci      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3776e41f4b71Sopenharmony_ci      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3777e41f4b71Sopenharmony_ci      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3778e41f4b71Sopenharmony_ci      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3779e41f4b71Sopenharmony_ci      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3780e41f4b71Sopenharmony_ci    }
3781e41f4b71Sopenharmony_ci    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
3782e41f4b71Sopenharmony_ci    resultSet.close();
3783e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
3784e41f4b71Sopenharmony_ci    console.error(`Failed to remoteQuery, code is ${err.code},message is ${err.message}`);
3785e41f4b71Sopenharmony_ci  })
3786e41f4b71Sopenharmony_ci}
3787e41f4b71Sopenharmony_ci```
3788e41f4b71Sopenharmony_ci
3789e41f4b71Sopenharmony_ci### remoteQuery
3790e41f4b71Sopenharmony_ci
3791e41f4b71Sopenharmony_ciremoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array&lt;string&gt;): Promise&lt;ResultSet&gt;
3792e41f4b71Sopenharmony_ci
3793e41f4b71Sopenharmony_ciQueries data from the RDB store of a remote device based on specified conditions. This API uses a promise to return the result.
3794e41f4b71Sopenharmony_ci
3795e41f4b71Sopenharmony_ci> **NOTE**
3796e41f4b71Sopenharmony_ci>
3797e41f4b71Sopenharmony_ci> **device** can be obtained by [deviceManager.getAvailableDeviceListSync](../apis-distributedservice-kit/js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
3798e41f4b71Sopenharmony_ci
3799e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3800e41f4b71Sopenharmony_ci
3801e41f4b71Sopenharmony_ci**Parameters**
3802e41f4b71Sopenharmony_ci
3803e41f4b71Sopenharmony_ci| Name    | Type                                | Mandatory| Description                                            |
3804e41f4b71Sopenharmony_ci| ---------- | ------------------------------------ | ---- | ------------------------------------------------ |
3805e41f4b71Sopenharmony_ci| device     | string                               | Yes  | ID of the remote device.                  |
3806e41f4b71Sopenharmony_ci| table      | string                               | Yes  | Name of the target table.                                |
3807e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Query conditions specified by the **RdbPredicates** object.     |
3808e41f4b71Sopenharmony_ci| columns    | Array&lt;string&gt;                  | Yes  | Columns to query. If this parameter is not specified, the query applies to all columns.|
3809e41f4b71Sopenharmony_ci
3810e41f4b71Sopenharmony_ci**Return value**
3811e41f4b71Sopenharmony_ci
3812e41f4b71Sopenharmony_ci| Type                                                        | Description                                              |
3813e41f4b71Sopenharmony_ci| ------------------------------------------------------------ | -------------------------------------------------- |
3814e41f4b71Sopenharmony_ci| Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
3815e41f4b71Sopenharmony_ci
3816e41f4b71Sopenharmony_ci**Error codes**
3817e41f4b71Sopenharmony_ci
3818e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
3819e41f4b71Sopenharmony_ci
3820e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
3821e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
3822e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3823e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
3824e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
3825e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
3826e41f4b71Sopenharmony_ci
3827e41f4b71Sopenharmony_ci**Example**
3828e41f4b71Sopenharmony_ci
3829e41f4b71Sopenharmony_ci```ts
3830e41f4b71Sopenharmony_ciimport { distributedDeviceManager } from '@kit.DistributedServiceKit';
3831e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
3832e41f4b71Sopenharmony_ci
3833e41f4b71Sopenharmony_cilet dmInstance: distributedDeviceManager.DeviceManager;
3834e41f4b71Sopenharmony_cilet deviceId: string | undefined = undefined;
3835e41f4b71Sopenharmony_ci
3836e41f4b71Sopenharmony_citry {
3837e41f4b71Sopenharmony_ci  dmInstance = distributedDeviceManager.createDeviceManager("com.example.appdatamgrverify");
3838e41f4b71Sopenharmony_ci  let devices: Array<distributedDeviceManager.DeviceBasicInfo> = dmInstance.getAvailableDeviceListSync();
3839e41f4b71Sopenharmony_ci  if(devices != undefined) {
3840e41f4b71Sopenharmony_ci    deviceId = devices[0].networkId;
3841e41f4b71Sopenharmony_ci  }
3842e41f4b71Sopenharmony_ci} catch (err) {
3843e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
3844e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
3845e41f4b71Sopenharmony_ci  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
3846e41f4b71Sopenharmony_ci}
3847e41f4b71Sopenharmony_ci
3848e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates('EMPLOYEE');
3849e41f4b71Sopenharmony_cipredicates.greaterThan("id", 0);
3850e41f4b71Sopenharmony_ciif(store != undefined && deviceId != undefined) {
3851e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet: relationalStore.ResultSet) => {
3852e41f4b71Sopenharmony_ci    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3853e41f4b71Sopenharmony_ci    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3854e41f4b71Sopenharmony_ci    while (resultSet.goToNextRow()) {
3855e41f4b71Sopenharmony_ci      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3856e41f4b71Sopenharmony_ci      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3857e41f4b71Sopenharmony_ci      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3858e41f4b71Sopenharmony_ci      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3859e41f4b71Sopenharmony_ci      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3860e41f4b71Sopenharmony_ci    }
3861e41f4b71Sopenharmony_ci    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
3862e41f4b71Sopenharmony_ci    resultSet.close();
3863e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
3864e41f4b71Sopenharmony_ci    console.error(`Failed to remoteQuery, code is ${err.code},message is ${err.message}`);
3865e41f4b71Sopenharmony_ci  })
3866e41f4b71Sopenharmony_ci}
3867e41f4b71Sopenharmony_ci```
3868e41f4b71Sopenharmony_ci
3869e41f4b71Sopenharmony_ci### querySql<sup>10+</sup>
3870e41f4b71Sopenharmony_ci
3871e41f4b71Sopenharmony_ciquerySql(sql: string, callback: AsyncCallback&lt;ResultSet&gt;):void
3872e41f4b71Sopenharmony_ci
3873e41f4b71Sopenharmony_ciQueries data using the specified SQL statement. This API uses an asynchronous callback to return the result.
3874e41f4b71Sopenharmony_ci
3875e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3876e41f4b71Sopenharmony_ci
3877e41f4b71Sopenharmony_ci**Parameters**
3878e41f4b71Sopenharmony_ci
3879e41f4b71Sopenharmony_ci| Name  | Type                                        | Mandatory| Description                                                        |
3880e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
3881e41f4b71Sopenharmony_ci| sql      | string                                       | Yes  | SQL statement to run.                                       |
3882e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes  | Callback used to return the result. If the operation is successful, a **ResultSet** object will be returned.   |
3883e41f4b71Sopenharmony_ci
3884e41f4b71Sopenharmony_ci**Error codes**
3885e41f4b71Sopenharmony_ci
3886e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
3887e41f4b71Sopenharmony_ci
3888e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
3889e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
3890e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3891e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
3892e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
3893e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
3894e41f4b71Sopenharmony_ci
3895e41f4b71Sopenharmony_ci**Example**
3896e41f4b71Sopenharmony_ci
3897e41f4b71Sopenharmony_ci```ts
3898e41f4b71Sopenharmony_ciif(store != undefined) {
3899e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = 'sanguo'", (err, resultSet) => {
3900e41f4b71Sopenharmony_ci    if (err) {
3901e41f4b71Sopenharmony_ci      console.error(`Query failed, code is ${err.code},message is ${err.message}`);
3902e41f4b71Sopenharmony_ci      return;
3903e41f4b71Sopenharmony_ci    }
3904e41f4b71Sopenharmony_ci    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3905e41f4b71Sopenharmony_ci    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3906e41f4b71Sopenharmony_ci    while (resultSet.goToNextRow()) {
3907e41f4b71Sopenharmony_ci      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3908e41f4b71Sopenharmony_ci      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3909e41f4b71Sopenharmony_ci      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3910e41f4b71Sopenharmony_ci      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3911e41f4b71Sopenharmony_ci      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3912e41f4b71Sopenharmony_ci    }
3913e41f4b71Sopenharmony_ci    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
3914e41f4b71Sopenharmony_ci    resultSet.close();
3915e41f4b71Sopenharmony_ci  })
3916e41f4b71Sopenharmony_ci}
3917e41f4b71Sopenharmony_ci```
3918e41f4b71Sopenharmony_ci
3919e41f4b71Sopenharmony_ci### querySql
3920e41f4b71Sopenharmony_ci
3921e41f4b71Sopenharmony_ciquerySql(sql: string, bindArgs: Array&lt;ValueType&gt;, callback: AsyncCallback&lt;ResultSet&gt;):void
3922e41f4b71Sopenharmony_ci
3923e41f4b71Sopenharmony_ciQueries data using the specified SQL statement. This API uses an asynchronous callback to return the result.
3924e41f4b71Sopenharmony_ci
3925e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3926e41f4b71Sopenharmony_ci
3927e41f4b71Sopenharmony_ci**Parameters**
3928e41f4b71Sopenharmony_ci
3929e41f4b71Sopenharmony_ci| Name  | Type                                        | Mandatory| Description                                                        |
3930e41f4b71Sopenharmony_ci| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
3931e41f4b71Sopenharmony_ci| sql      | string                                       | Yes  | SQL statement to run.                                       |
3932e41f4b71Sopenharmony_ci| bindArgs | Array&lt;[ValueType](#valuetype)&gt;         | Yes  | Arguments in the SQL statement. The value corresponds to the placeholders in the SQL parameter statement. If the SQL parameter statement is complete, the value of this parameter must be an empty array.|
3933e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes  | Callback used to return the result. If the operation is successful, a **ResultSet** object will be returned.   |
3934e41f4b71Sopenharmony_ci
3935e41f4b71Sopenharmony_ci**Error codes**
3936e41f4b71Sopenharmony_ci
3937e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
3938e41f4b71Sopenharmony_ci
3939e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
3940e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
3941e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3942e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
3943e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
3944e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
3945e41f4b71Sopenharmony_ci
3946e41f4b71Sopenharmony_ci**Example**
3947e41f4b71Sopenharmony_ci
3948e41f4b71Sopenharmony_ci```ts
3949e41f4b71Sopenharmony_ciif(store != undefined) {
3950e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'], (err, resultSet) => {
3951e41f4b71Sopenharmony_ci    if (err) {
3952e41f4b71Sopenharmony_ci      console.error(`Query failed, code is ${err.code},message is ${err.message}`);
3953e41f4b71Sopenharmony_ci      return;
3954e41f4b71Sopenharmony_ci    }
3955e41f4b71Sopenharmony_ci    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3956e41f4b71Sopenharmony_ci    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3957e41f4b71Sopenharmony_ci    while (resultSet.goToNextRow()) {
3958e41f4b71Sopenharmony_ci      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3959e41f4b71Sopenharmony_ci      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3960e41f4b71Sopenharmony_ci      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3961e41f4b71Sopenharmony_ci      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3962e41f4b71Sopenharmony_ci      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3963e41f4b71Sopenharmony_ci    }
3964e41f4b71Sopenharmony_ci    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
3965e41f4b71Sopenharmony_ci    resultSet.close();
3966e41f4b71Sopenharmony_ci  })
3967e41f4b71Sopenharmony_ci}
3968e41f4b71Sopenharmony_ci```
3969e41f4b71Sopenharmony_ci
3970e41f4b71Sopenharmony_ci### querySql
3971e41f4b71Sopenharmony_ci
3972e41f4b71Sopenharmony_ciquerySql(sql: string, bindArgs?: Array&lt;ValueType&gt;):Promise&lt;ResultSet&gt;
3973e41f4b71Sopenharmony_ci
3974e41f4b71Sopenharmony_ciQueries data using the specified SQL statement. This API uses a promise to return the result.
3975e41f4b71Sopenharmony_ci
3976e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3977e41f4b71Sopenharmony_ci
3978e41f4b71Sopenharmony_ci**Parameters**
3979e41f4b71Sopenharmony_ci
3980e41f4b71Sopenharmony_ci| Name  | Type                                | Mandatory| Description                                                        |
3981e41f4b71Sopenharmony_ci| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
3982e41f4b71Sopenharmony_ci| sql      | string                               | Yes  | SQL statement to run.                                       |
3983e41f4b71Sopenharmony_ci| bindArgs | Array&lt;[ValueType](#valuetype)&gt; | No  | Arguments in the SQL statement. The value corresponds to the placeholders in the SQL parameter statement. If the SQL parameter statement is complete, leave this parameter blank.|
3984e41f4b71Sopenharmony_ci
3985e41f4b71Sopenharmony_ci**Return value**
3986e41f4b71Sopenharmony_ci
3987e41f4b71Sopenharmony_ci| Type                                                   | Description                                              |
3988e41f4b71Sopenharmony_ci| ------------------------------------------------------- | -------------------------------------------------- |
3989e41f4b71Sopenharmony_ci| Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
3990e41f4b71Sopenharmony_ci
3991e41f4b71Sopenharmony_ci**Error codes**
3992e41f4b71Sopenharmony_ci
3993e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
3994e41f4b71Sopenharmony_ci
3995e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
3996e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
3997e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3998e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
3999e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
4000e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
4001e41f4b71Sopenharmony_ci
4002e41f4b71Sopenharmony_ci**Example**
4003e41f4b71Sopenharmony_ci
4004e41f4b71Sopenharmony_ci```ts
4005e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
4006e41f4b71Sopenharmony_ci
4007e41f4b71Sopenharmony_ciif(store != undefined) {
4008e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = 'sanguo'").then((resultSet: relationalStore.ResultSet) => {
4009e41f4b71Sopenharmony_ci    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
4010e41f4b71Sopenharmony_ci    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
4011e41f4b71Sopenharmony_ci    while (resultSet.goToNextRow()) {
4012e41f4b71Sopenharmony_ci      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
4013e41f4b71Sopenharmony_ci      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
4014e41f4b71Sopenharmony_ci      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
4015e41f4b71Sopenharmony_ci      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
4016e41f4b71Sopenharmony_ci      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
4017e41f4b71Sopenharmony_ci    }
4018e41f4b71Sopenharmony_ci    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
4019e41f4b71Sopenharmony_ci    resultSet.close();
4020e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
4021e41f4b71Sopenharmony_ci    console.error(`Query failed, code is ${err.code},message is ${err.message}`);
4022e41f4b71Sopenharmony_ci  })
4023e41f4b71Sopenharmony_ci}
4024e41f4b71Sopenharmony_ci```
4025e41f4b71Sopenharmony_ci
4026e41f4b71Sopenharmony_ci### querySqlSync<sup>12+</sup>
4027e41f4b71Sopenharmony_ci
4028e41f4b71Sopenharmony_ciquerySqlSync(sql: string, bindArgs?: Array&lt;ValueType&gt;):ResultSet
4029e41f4b71Sopenharmony_ci
4030e41f4b71Sopenharmony_ciExecutes the SQL statement to query data in this RDB store.
4031e41f4b71Sopenharmony_ci
4032e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4033e41f4b71Sopenharmony_ci
4034e41f4b71Sopenharmony_ci**Parameters**
4035e41f4b71Sopenharmony_ci
4036e41f4b71Sopenharmony_ci| Name  | Type                                | Mandatory| Description                                                        |
4037e41f4b71Sopenharmony_ci| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
4038e41f4b71Sopenharmony_ci| sql      | string                               | Yes  | SQL statement to run.                                       |
4039e41f4b71Sopenharmony_ci| bindArgs | Array&lt;[ValueType](#valuetype)&gt; | No  | Arguments in the SQL statement. The value corresponds to the placeholders in the SQL parameter statement. If the SQL parameter statement is complete, leave this parameter blank. This parameter is left blank by default.|
4040e41f4b71Sopenharmony_ci
4041e41f4b71Sopenharmony_ci**Return value**
4042e41f4b71Sopenharmony_ci
4043e41f4b71Sopenharmony_ci| Type                   | Description                               |
4044e41f4b71Sopenharmony_ci| ----------------------- | ----------------------------------- |
4045e41f4b71Sopenharmony_ci| [ResultSet](#resultset) | If the operation is successful, a **ResultSet** object will be returned.|
4046e41f4b71Sopenharmony_ci
4047e41f4b71Sopenharmony_ci**Error codes**
4048e41f4b71Sopenharmony_ci
4049e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
4050e41f4b71Sopenharmony_ci
4051e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
4052e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------------------------ |
4053e41f4b71Sopenharmony_ci| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4054e41f4b71Sopenharmony_ci| 14800000     | Inner error.                                                 |
4055e41f4b71Sopenharmony_ci| 14800014     | Already closed.                                              |
4056e41f4b71Sopenharmony_ci| 14800015     | The database does not respond.                                        |
4057e41f4b71Sopenharmony_ci
4058e41f4b71Sopenharmony_ci**Example**
4059e41f4b71Sopenharmony_ci
4060e41f4b71Sopenharmony_ci```ts
4061e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
4062e41f4b71Sopenharmony_ci
4063e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
4064e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Rose");
4065e41f4b71Sopenharmony_ciif(store != undefined) {
4066e41f4b71Sopenharmony_ci  try {
4067e41f4b71Sopenharmony_ci    let resultSet: relationalStore.ResultSet = (store as relationalStore.RdbStore).querySqlSync("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = 'sanguo'");
4068e41f4b71Sopenharmony_ci    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
4069e41f4b71Sopenharmony_ci    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
4070e41f4b71Sopenharmony_ci    while (resultSet.goToNextRow()) {
4071e41f4b71Sopenharmony_ci      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
4072e41f4b71Sopenharmony_ci      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
4073e41f4b71Sopenharmony_ci      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
4074e41f4b71Sopenharmony_ci      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
4075e41f4b71Sopenharmony_ci      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
4076e41f4b71Sopenharmony_ci    }
4077e41f4b71Sopenharmony_ci    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
4078e41f4b71Sopenharmony_ci    resultSet.close();
4079e41f4b71Sopenharmony_ci  } catch (err) {
4080e41f4b71Sopenharmony_ci    console.error(`Query failed, code is ${err.code},message is ${err.message}`);
4081e41f4b71Sopenharmony_ci  }
4082e41f4b71Sopenharmony_ci}
4083e41f4b71Sopenharmony_ci```
4084e41f4b71Sopenharmony_ci
4085e41f4b71Sopenharmony_ci### executeSql<sup>10+</sup>
4086e41f4b71Sopenharmony_ci
4087e41f4b71Sopenharmony_ciexecuteSql(sql: string, callback: AsyncCallback&lt;void&gt;):void
4088e41f4b71Sopenharmony_ci
4089e41f4b71Sopenharmony_ciExecutes an SQL statement that contains specified arguments but returns no value. This API uses an asynchronous callback to return the result.
4090e41f4b71Sopenharmony_ci
4091e41f4b71Sopenharmony_ciThis API does not support query, attach, or transaction operations. To perform these operations, use [querySql](#querysql10), [query](#query10), [attach](#attach12), [beginTransaction](#begintransaction), and [commit](#commit).
4092e41f4b71Sopenharmony_ci
4093e41f4b71Sopenharmony_ciStatements separated by semicolons (;) are not supported.
4094e41f4b71Sopenharmony_ci
4095e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4096e41f4b71Sopenharmony_ci
4097e41f4b71Sopenharmony_ci**Parameters**
4098e41f4b71Sopenharmony_ci
4099e41f4b71Sopenharmony_ci| Name  | Type                                | Mandatory| Description                                                        |
4100e41f4b71Sopenharmony_ci| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
4101e41f4b71Sopenharmony_ci| sql      | string                               | Yes  | SQL statement to run.                                       |
4102e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt;            | Yes  | Callback used to return the result.                                      |
4103e41f4b71Sopenharmony_ci
4104e41f4b71Sopenharmony_ci**Error codes**
4105e41f4b71Sopenharmony_ci
4106e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
4107e41f4b71Sopenharmony_ci
4108e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
4109e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
4110e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4111e41f4b71Sopenharmony_ci| 801       | Capability not supported the sql(attach,begin,commit,rollback etc.). |
4112e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
4113e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
4114e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
4115e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
4116e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
4117e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
4118e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
4119e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
4120e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
4121e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
4122e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
4123e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4124e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
4125e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
4126e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4127e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
4128e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
4129e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
4130e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
4131e41f4b71Sopenharmony_ci
4132e41f4b71Sopenharmony_ci**Example**
4133e41f4b71Sopenharmony_ci
4134e41f4b71Sopenharmony_ci```ts
4135e41f4b71Sopenharmony_ciconst SQL_DELETE_TABLE = "DELETE FROM test WHERE name = 'zhangsan'"
4136e41f4b71Sopenharmony_ciif(store != undefined) {
4137e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).executeSql(SQL_DELETE_TABLE, (err) => {
4138e41f4b71Sopenharmony_ci    if (err) {
4139e41f4b71Sopenharmony_ci      console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`);
4140e41f4b71Sopenharmony_ci      return;
4141e41f4b71Sopenharmony_ci    }
4142e41f4b71Sopenharmony_ci    console.info('Delete table done.');
4143e41f4b71Sopenharmony_ci  })
4144e41f4b71Sopenharmony_ci}
4145e41f4b71Sopenharmony_ci```
4146e41f4b71Sopenharmony_ci
4147e41f4b71Sopenharmony_ci### executeSql
4148e41f4b71Sopenharmony_ci
4149e41f4b71Sopenharmony_ciexecuteSql(sql: string, bindArgs: Array&lt;ValueType&gt;, callback: AsyncCallback&lt;void&gt;):void
4150e41f4b71Sopenharmony_ci
4151e41f4b71Sopenharmony_ciExecutes an SQL statement that contains specified arguments but returns no value. This API uses an asynchronous callback to return the result.
4152e41f4b71Sopenharmony_ci
4153e41f4b71Sopenharmony_ciThis API does not support query, attach, or transaction operations. To perform these operations, use [querySql](#querysql10), [query](#query10), [attach](#attach12), [beginTransaction](#begintransaction), and [commit](#commit).
4154e41f4b71Sopenharmony_ci
4155e41f4b71Sopenharmony_ciStatements separated by semicolons (;) are not supported.
4156e41f4b71Sopenharmony_ci
4157e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4158e41f4b71Sopenharmony_ci
4159e41f4b71Sopenharmony_ci**Parameters**
4160e41f4b71Sopenharmony_ci
4161e41f4b71Sopenharmony_ci| Name  | Type                                | Mandatory| Description                                                        |
4162e41f4b71Sopenharmony_ci| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
4163e41f4b71Sopenharmony_ci| sql      | string                               | Yes  | SQL statement to run.                                       |
4164e41f4b71Sopenharmony_ci| bindArgs | Array&lt;[ValueType](#valuetype)&gt; | Yes  | Arguments in the SQL statement. The value corresponds to the placeholders in the SQL parameter statement. If the SQL parameter statement is complete, the value of this parameter must be an empty array.|
4165e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt;            | Yes  | Callback used to return the result.                                      |
4166e41f4b71Sopenharmony_ci
4167e41f4b71Sopenharmony_ci**Error codes**
4168e41f4b71Sopenharmony_ci
4169e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
4170e41f4b71Sopenharmony_ci
4171e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
4172e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
4173e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4174e41f4b71Sopenharmony_ci| 801       | Capability not supported the sql(attach,begin,commit,rollback etc.). |
4175e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
4176e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
4177e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
4178e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
4179e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
4180e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
4181e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
4182e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
4183e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
4184e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
4185e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
4186e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4187e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
4188e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
4189e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4190e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
4191e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
4192e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
4193e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
4194e41f4b71Sopenharmony_ci
4195e41f4b71Sopenharmony_ci**Example**
4196e41f4b71Sopenharmony_ci
4197e41f4b71Sopenharmony_ci```ts
4198e41f4b71Sopenharmony_ciconst SQL_DELETE_TABLE = "DELETE FROM test WHERE name = ?"
4199e41f4b71Sopenharmony_ciif(store != undefined) {
4200e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).executeSql(SQL_DELETE_TABLE, ['zhangsan'], (err) => {
4201e41f4b71Sopenharmony_ci    if (err) {
4202e41f4b71Sopenharmony_ci      console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`);
4203e41f4b71Sopenharmony_ci      return;
4204e41f4b71Sopenharmony_ci    }
4205e41f4b71Sopenharmony_ci    console.info('Delete table done.');
4206e41f4b71Sopenharmony_ci  })
4207e41f4b71Sopenharmony_ci}
4208e41f4b71Sopenharmony_ci```
4209e41f4b71Sopenharmony_ci
4210e41f4b71Sopenharmony_ci### executeSql
4211e41f4b71Sopenharmony_ci
4212e41f4b71Sopenharmony_ciexecuteSql(sql: string, bindArgs?: Array&lt;ValueType&gt;):Promise&lt;void&gt;
4213e41f4b71Sopenharmony_ci
4214e41f4b71Sopenharmony_ciExecutes an SQL statement that contains specified arguments but returns no value. This API uses a promise to return the result.
4215e41f4b71Sopenharmony_ci
4216e41f4b71Sopenharmony_ciThis API does not support query, attach, or transaction operations. To perform these operations, use [querySql](#querysql10), [query](#query10), [attach](#attach12), [beginTransaction](#begintransaction), and [commit](#commit).
4217e41f4b71Sopenharmony_ci
4218e41f4b71Sopenharmony_ciStatements separated by semicolons (;) are not supported.
4219e41f4b71Sopenharmony_ci
4220e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4221e41f4b71Sopenharmony_ci
4222e41f4b71Sopenharmony_ci**Parameters**
4223e41f4b71Sopenharmony_ci
4224e41f4b71Sopenharmony_ci| Name  | Type                                | Mandatory| Description                                                        |
4225e41f4b71Sopenharmony_ci| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
4226e41f4b71Sopenharmony_ci| sql      | string                               | Yes  | SQL statement to run.                                       |
4227e41f4b71Sopenharmony_ci| bindArgs | Array&lt;[ValueType](#valuetype)&gt; | No  | Arguments in the SQL statement. The value corresponds to the placeholders in the SQL parameter statement. If the SQL parameter statement is complete, leave this parameter blank.|
4228e41f4b71Sopenharmony_ci
4229e41f4b71Sopenharmony_ci**Return value**
4230e41f4b71Sopenharmony_ci
4231e41f4b71Sopenharmony_ci| Type               | Description                     |
4232e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
4233e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
4234e41f4b71Sopenharmony_ci
4235e41f4b71Sopenharmony_ci**Error codes**
4236e41f4b71Sopenharmony_ci
4237e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
4238e41f4b71Sopenharmony_ci
4239e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
4240e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
4241e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4242e41f4b71Sopenharmony_ci| 801       | Capability not supported the sql(attach,begin,commit,rollback etc.). |
4243e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
4244e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
4245e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
4246e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
4247e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
4248e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
4249e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
4250e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
4251e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
4252e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
4253e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
4254e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4255e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
4256e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
4257e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4258e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
4259e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
4260e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
4261e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
4262e41f4b71Sopenharmony_ci
4263e41f4b71Sopenharmony_ci**Example**
4264e41f4b71Sopenharmony_ci
4265e41f4b71Sopenharmony_ci```ts
4266e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
4267e41f4b71Sopenharmony_ci
4268e41f4b71Sopenharmony_ciconst SQL_DELETE_TABLE = "DELETE FROM test WHERE name = 'zhangsan'"
4269e41f4b71Sopenharmony_ciif(store != undefined) {
4270e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).executeSql(SQL_DELETE_TABLE).then(() => {
4271e41f4b71Sopenharmony_ci    console.info('Delete table done.');
4272e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
4273e41f4b71Sopenharmony_ci    console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`);
4274e41f4b71Sopenharmony_ci  })
4275e41f4b71Sopenharmony_ci}
4276e41f4b71Sopenharmony_ci```
4277e41f4b71Sopenharmony_ci
4278e41f4b71Sopenharmony_ci
4279e41f4b71Sopenharmony_ci### execute<sup>12+</sup>
4280e41f4b71Sopenharmony_ci
4281e41f4b71Sopenharmony_ciexecute(sql: string, args?: Array&lt;ValueType&gt;):Promise&lt;ValueType&gt;
4282e41f4b71Sopenharmony_ci
4283e41f4b71Sopenharmony_ciExecutes an SQL statement that contains the specified parameters. This API uses a promise to return the result.
4284e41f4b71Sopenharmony_ci
4285e41f4b71Sopenharmony_ciThis API can be used to add, delete, and modify data, run SQL statements of the PRAGMA syntax, and create, delete, and modify a table. The type of the return value varies, depending on the execution result.
4286e41f4b71Sopenharmony_ci
4287e41f4b71Sopenharmony_ciThis API does not support query, attach, or transaction operations. To perform these operations, use [querySql](#querysql10), [query](#query10), [attach](#attach12), [beginTransaction](#begintransaction), and [commit](#commit).
4288e41f4b71Sopenharmony_ci
4289e41f4b71Sopenharmony_ciStatements separated by semicolons (;) are not supported.
4290e41f4b71Sopenharmony_ci
4291e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4292e41f4b71Sopenharmony_ci
4293e41f4b71Sopenharmony_ci**Parameters**
4294e41f4b71Sopenharmony_ci
4295e41f4b71Sopenharmony_ci| Name  | Type                                | Mandatory| Description                                                        |
4296e41f4b71Sopenharmony_ci| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
4297e41f4b71Sopenharmony_ci| sql      | string                               | Yes  | SQL statement to run.                                       |
4298e41f4b71Sopenharmony_ci| args | Array&lt;[ValueType](#valuetype)&gt; | No  | Arguments in the SQL statement. The value corresponds to the placeholders in the SQL parameter statement. If the SQL parameter statement is complete, leave this parameter blank.|
4299e41f4b71Sopenharmony_ci
4300e41f4b71Sopenharmony_ci**Return value**
4301e41f4b71Sopenharmony_ci
4302e41f4b71Sopenharmony_ci| Type               | Description                     |
4303e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
4304e41f4b71Sopenharmony_ci| Promise&lt;[ValueType](#valuetype)&gt; | Promise used to return the SQL execution result.|
4305e41f4b71Sopenharmony_ci
4306e41f4b71Sopenharmony_ci**Error codes**
4307e41f4b71Sopenharmony_ci
4308e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
4309e41f4b71Sopenharmony_ci
4310e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
4311e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
4312e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4313e41f4b71Sopenharmony_ci| 801       | Capability not supported the sql(attach,begin,commit,rollback etc.). |
4314e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
4315e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
4316e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
4317e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
4318e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
4319e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
4320e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
4321e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
4322e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
4323e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
4324e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
4325e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4326e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
4327e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
4328e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4329e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
4330e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
4331e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
4332e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
4333e41f4b71Sopenharmony_ci
4334e41f4b71Sopenharmony_ci**Example**
4335e41f4b71Sopenharmony_ci
4336e41f4b71Sopenharmony_ci```ts
4337e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
4338e41f4b71Sopenharmony_ci
4339e41f4b71Sopenharmony_ci// Check the RDB store integrity.
4340e41f4b71Sopenharmony_ciif(store != undefined) {
4341e41f4b71Sopenharmony_ci  const SQL_CHECK_INTEGRITY = 'PRAGMA integrity_check';
4342e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).execute(SQL_CHECK_INTEGRITY).then((data) => {
4343e41f4b71Sopenharmony_ci    console.info(`check result: ${data}`);
4344e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
4345e41f4b71Sopenharmony_ci    console.error(`check failed, code is ${err.code}, message is ${err.message}`);
4346e41f4b71Sopenharmony_ci  })
4347e41f4b71Sopenharmony_ci}
4348e41f4b71Sopenharmony_ci
4349e41f4b71Sopenharmony_ci// Delete all data from the table.
4350e41f4b71Sopenharmony_ciif(store != undefined) {
4351e41f4b71Sopenharmony_ci  const SQL_DELETE_TABLE = 'DELETE FROM test';
4352e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).execute(SQL_DELETE_TABLE).then((data) => {
4353e41f4b71Sopenharmony_ci    console.info(`delete result: ${data}`);
4354e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
4355e41f4b71Sopenharmony_ci    console.error(`delete failed, code is ${err.code}, message is ${err.message}`);
4356e41f4b71Sopenharmony_ci  })
4357e41f4b71Sopenharmony_ci}
4358e41f4b71Sopenharmony_ci
4359e41f4b71Sopenharmony_ci// Delete a table.
4360e41f4b71Sopenharmony_ciif(store != undefined) {
4361e41f4b71Sopenharmony_ci  const SQL_DROP_TABLE = 'DROP TABLE test';
4362e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).execute(SQL_DROP_TABLE).then((data) => {
4363e41f4b71Sopenharmony_ci    console.info(`drop result: ${data}`);
4364e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
4365e41f4b71Sopenharmony_ci    console.error(`drop failed, code is ${err.code}, message is ${err.message}`);
4366e41f4b71Sopenharmony_ci  })
4367e41f4b71Sopenharmony_ci}
4368e41f4b71Sopenharmony_ci```
4369e41f4b71Sopenharmony_ci
4370e41f4b71Sopenharmony_ci### execute<sup>12+</sup>
4371e41f4b71Sopenharmony_ci
4372e41f4b71Sopenharmony_ciexecute(sql: string, txId: number, args?: Array&lt;ValueType&gt;): Promise&lt;ValueType&gt;
4373e41f4b71Sopenharmony_ci
4374e41f4b71Sopenharmony_ciExecutes an SQL statement that contains the specified parameters. This API uses a promise to return the result.
4375e41f4b71Sopenharmony_ci
4376e41f4b71Sopenharmony_ci<!--RP1-->
4377e41f4b71Sopenharmony_ciThis API can be used only for a [vector database](js-apis-data-relationalStore-sys.md#storeconfig).<!--RP1End-->
4378e41f4b71Sopenharmony_ci
4379e41f4b71Sopenharmony_ciThis API does not support query, attach, or transaction operations. To perform these operations, use [querySql](#querysql10), [query](#query10), [attach](#attach12), [beginTransaction](#begintransaction), and [commit](#commit).
4380e41f4b71Sopenharmony_ci
4381e41f4b71Sopenharmony_ciStatements separated by semicolons (;) are not supported.
4382e41f4b71Sopenharmony_ci
4383e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4384e41f4b71Sopenharmony_ci
4385e41f4b71Sopenharmony_ci**Parameters**
4386e41f4b71Sopenharmony_ci
4387e41f4b71Sopenharmony_ci| Name  | Type                                | Mandatory| Description                                                        |
4388e41f4b71Sopenharmony_ci| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
4389e41f4b71Sopenharmony_ci| sql      | string                               | Yes  | SQL statement to run.                                       |
4390e41f4b71Sopenharmony_ci| txId      | number                               | Yes  | Transaction ID obtained via [beginTrans](#begintrans12). If the value is **0**, the SQL statement is executed in a separate transaction by default.                                     |
4391e41f4b71Sopenharmony_ci| args | Array&lt;[ValueType](#valuetype)&gt; | No  | Arguments in the SQL statement. The value corresponds to the placeholders in the SQL parameter statement. If this parameter is left blank or set to **null** or **undefined**, the SQL statement is complete.|
4392e41f4b71Sopenharmony_ci
4393e41f4b71Sopenharmony_ci**Return value**
4394e41f4b71Sopenharmony_ci
4395e41f4b71Sopenharmony_ci| Type               | Description                     |
4396e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
4397e41f4b71Sopenharmony_ci| Promise&lt;[ValueType](#valuetype)&gt; | Promise that returns **null**.|
4398e41f4b71Sopenharmony_ci
4399e41f4b71Sopenharmony_ci**Error codes**
4400e41f4b71Sopenharmony_ci
4401e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
4402e41f4b71Sopenharmony_ci
4403e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
4404e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
4405e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4406e41f4b71Sopenharmony_ci| 801       | Capability not supported the sql(attach,begin,commit,rollback etc.). |
4407e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
4408e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
4409e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
4410e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
4411e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
4412e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
4413e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
4414e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
4415e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
4416e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
4417e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
4418e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4419e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
4420e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
4421e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4422e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
4423e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
4424e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
4425e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
4426e41f4b71Sopenharmony_ci
4427e41f4b71Sopenharmony_ci**Example**
4428e41f4b71Sopenharmony_ci
4429e41f4b71Sopenharmony_ci```ts
4430e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
4431e41f4b71Sopenharmony_ciif(store != null) {
4432e41f4b71Sopenharmony_ci  let txId : number;
4433e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).beginTrans().then((txId : number) => {
4434e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).execute("DELETE FROM TEST WHERE age = ? OR age = ?", txId, ["18", "20"])
4435e41f4b71Sopenharmony_ci      .then(() => {
4436e41f4b71Sopenharmony_ci        (store as relationalStore.RdbStore).commit(txId);
4437e41f4b71Sopenharmony_ci    })
4438e41f4b71Sopenharmony_ci    .catch((err: BusinessError) => {
4439e41f4b71Sopenharmony_ci      (store as relationalStore.RdbStore).rollback(txId)
4440e41f4b71Sopenharmony_ci      console.error(`execute sql failed, code is ${err.code},message is ${err.message}`);
4441e41f4b71Sopenharmony_ci    });
4442e41f4b71Sopenharmony_ci  });
4443e41f4b71Sopenharmony_ci}
4444e41f4b71Sopenharmony_ci```
4445e41f4b71Sopenharmony_ci
4446e41f4b71Sopenharmony_ci### executeSync<sup>12+</sup>
4447e41f4b71Sopenharmony_ci
4448e41f4b71Sopenharmony_ciexecuteSync(sql: string, args?: Array&lt;ValueType&gt;): ValueType
4449e41f4b71Sopenharmony_ci
4450e41f4b71Sopenharmony_ciExecutes an SQL statement containing the specified parameters. The return value type is ValueType.
4451e41f4b71Sopenharmony_ci
4452e41f4b71Sopenharmony_ciYou can use this API to add, delete, or modify a row of data with SQL statements of the PRAGMA syntax, and create, delete, or modify a table. The type of the return value is determined by the execution result.
4453e41f4b71Sopenharmony_ci
4454e41f4b71Sopenharmony_ciThis API does not support query, attach, or transaction operations. To perform these operations, use [querySql](#querysql10), [query](#query10), [attach](#attach12), [beginTransaction](#begintransaction), and [commit](#commit).
4455e41f4b71Sopenharmony_ci
4456e41f4b71Sopenharmony_ciStatements separated by semicolons (;) are not supported.
4457e41f4b71Sopenharmony_ci
4458e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4459e41f4b71Sopenharmony_ci
4460e41f4b71Sopenharmony_ci**Parameters**
4461e41f4b71Sopenharmony_ci
4462e41f4b71Sopenharmony_ci| Name| Type                                | Mandatory| Description                                                        |
4463e41f4b71Sopenharmony_ci| ------ | ------------------------------------ | ---- | ------------------------------------------------------------ |
4464e41f4b71Sopenharmony_ci| sql    | string                               | Yes  | SQL statement to run.                                       |
4465e41f4b71Sopenharmony_ci| args   | Array&lt;[ValueType](#valuetype)&gt; | No  | Arguments in the SQL statement. The value corresponds to the placeholders in the SQL parameter statement. If this parameter is left blank or set to **null** or **undefined**, the SQL statement is complete. This parameter is left blank by default.|
4466e41f4b71Sopenharmony_ci
4467e41f4b71Sopenharmony_ci**Return value**
4468e41f4b71Sopenharmony_ci
4469e41f4b71Sopenharmony_ci| Type                   | Description               |
4470e41f4b71Sopenharmony_ci| ----------------------- | ------------------- |
4471e41f4b71Sopenharmony_ci| [ValueType](#valuetype) | SQL execution result.|
4472e41f4b71Sopenharmony_ci
4473e41f4b71Sopenharmony_ci**Error codes**
4474e41f4b71Sopenharmony_ci
4475e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
4476e41f4b71Sopenharmony_ci
4477e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
4478e41f4b71Sopenharmony_ci| ------------ | ------------------------------------------------------------ |
4479e41f4b71Sopenharmony_ci| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4480e41f4b71Sopenharmony_ci| 14800000     | Inner error.                                                 |
4481e41f4b71Sopenharmony_ci| 14800011     | Database corrupted.                                          |
4482e41f4b71Sopenharmony_ci| 14800014     | Already closed.                                              |
4483e41f4b71Sopenharmony_ci| 14800015     | The database does not respond.                               |
4484e41f4b71Sopenharmony_ci| 14800021     | SQLite: Generic error.                                       |
4485e41f4b71Sopenharmony_ci| 14800022     | SQLite: Callback routine requested an abort.                 |
4486e41f4b71Sopenharmony_ci| 14800023     | SQLite: Access permission denied.                            |
4487e41f4b71Sopenharmony_ci| 14800024     | SQLite: The database file is locked.                         |
4488e41f4b71Sopenharmony_ci| 14800025     | SQLite: A table in the database is locked.                   |
4489e41f4b71Sopenharmony_ci| 14800026     | SQLite: The database is out of memory.                       |
4490e41f4b71Sopenharmony_ci| 14800027     | SQLite: Attempt to write a readonly database.                |
4491e41f4b71Sopenharmony_ci| 14800028     | SQLite: Some kind of disk I/O error occurred.                |
4492e41f4b71Sopenharmony_ci| 14800029     | SQLite: The database is full.                                |
4493e41f4b71Sopenharmony_ci| 14800030     | SQLite: Unable to open the database file.                    |
4494e41f4b71Sopenharmony_ci| 14800031     | SQLite: TEXT or BLOB exceeds size limit.                     |
4495e41f4b71Sopenharmony_ci| 14800032     | SQLite: Abort due to constraint violation.                   |
4496e41f4b71Sopenharmony_ci| 14800033     | SQLite: Data type mismatch.                                  |
4497e41f4b71Sopenharmony_ci| 14800034     | SQLite: Library used incorrectly.                            |
4498e41f4b71Sopenharmony_ci| 14800047     | The WAL file size exceeds the default limit.                 |
4499e41f4b71Sopenharmony_ci
4500e41f4b71Sopenharmony_ci**Example**
4501e41f4b71Sopenharmony_ci
4502e41f4b71Sopenharmony_ci```ts
4503e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
4504e41f4b71Sopenharmony_ci
4505e41f4b71Sopenharmony_ci// Check the RDB store integrity.
4506e41f4b71Sopenharmony_ciif(store != undefined) {
4507e41f4b71Sopenharmony_ci  const SQL_CHECK_INTEGRITY = 'PRAGMA integrity_check';
4508e41f4b71Sopenharmony_ci  try {
4509e41f4b71Sopenharmony_ci    let data = (store as relationalStore.RdbStore).executeSync(SQL_CHECK_INTEGRITY)
4510e41f4b71Sopenharmony_ci    console.info(`check result: ${data}`);
4511e41f4b71Sopenharmony_ci  } catch (err) {
4512e41f4b71Sopenharmony_ci    console.error(`check failed, code is ${err.code}, message is ${err.message}`);
4513e41f4b71Sopenharmony_ci  }
4514e41f4b71Sopenharmony_ci}
4515e41f4b71Sopenharmony_ci
4516e41f4b71Sopenharmony_ci// Delete all data from the table.
4517e41f4b71Sopenharmony_ciif(store != undefined) {
4518e41f4b71Sopenharmony_ci  const SQL_DELETE_TABLE = 'DELETE FROM test';
4519e41f4b71Sopenharmony_ci  try {
4520e41f4b71Sopenharmony_ci    let data = (store as relationalStore.RdbStore).executeSync(SQL_DELETE_TABLE)
4521e41f4b71Sopenharmony_ci    console.info(`delete result: ${data}`);
4522e41f4b71Sopenharmony_ci  } catch (err) {
4523e41f4b71Sopenharmony_ci    console.error(`delete failed, code is ${err.code}, message is ${err.message}`);
4524e41f4b71Sopenharmony_ci  }
4525e41f4b71Sopenharmony_ci}
4526e41f4b71Sopenharmony_ci
4527e41f4b71Sopenharmony_ci// Delete a table.
4528e41f4b71Sopenharmony_ciif(store != undefined) {
4529e41f4b71Sopenharmony_ci  const SQL_DROP_TABLE = 'DROP TABLE test';
4530e41f4b71Sopenharmony_ci  try {
4531e41f4b71Sopenharmony_ci    let data = (store as relationalStore.RdbStore).executeSync(SQL_DROP_TABLE)
4532e41f4b71Sopenharmony_ci    console.info(`drop result: ${data}`);
4533e41f4b71Sopenharmony_ci  } catch (err) {
4534e41f4b71Sopenharmony_ci    console.error(`drop failed, code is ${err.code}, message is ${err.message}`);
4535e41f4b71Sopenharmony_ci  }
4536e41f4b71Sopenharmony_ci}
4537e41f4b71Sopenharmony_ci```
4538e41f4b71Sopenharmony_ci
4539e41f4b71Sopenharmony_ci### getModifyTime<sup>10+</sup>
4540e41f4b71Sopenharmony_ci
4541e41f4b71Sopenharmony_cigetModifyTime(table: string, columnName: string, primaryKeys: PRIKeyType[], callback: AsyncCallback&lt;ModifyTime&gt;): void
4542e41f4b71Sopenharmony_ci
4543e41f4b71Sopenharmony_ciObtains the last modification time of the data in a table. This API uses an asynchronous callback to return the result.
4544e41f4b71Sopenharmony_ci
4545e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4546e41f4b71Sopenharmony_ci
4547e41f4b71Sopenharmony_ci**Parameters**
4548e41f4b71Sopenharmony_ci
4549e41f4b71Sopenharmony_ci| Name     | Type                                            | Mandatory| Description                                                        |
4550e41f4b71Sopenharmony_ci| ----------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ |
4551e41f4b71Sopenharmony_ci| table       | string                                           | Yes  | Name of the database table to query.                                |
4552e41f4b71Sopenharmony_ci| columnName  | string                                           | Yes  | Column name of the database table to query.                                |
4553e41f4b71Sopenharmony_ci| primaryKeys | [PRIKeyType](#prikeytype10)[]                    | Yes  | Primary keys of the rows to query.<br>If the database table has no primary key, **rowid** must be passed in through **columnName**. In this case, **primaryKeys** specifies the row numbers of the database table to query.<br>If the database table has no primary key and no **rowid** is passed in through **columnName**, an error code will be returned.|
4554e41f4b71Sopenharmony_ci| callback    | AsyncCallback&lt;[ModifyTime](#modifytime10)&gt; | Yes  | Callback used to return the result. If the operation is successful, the **ModifyTime** object is returned.|
4555e41f4b71Sopenharmony_ci
4556e41f4b71Sopenharmony_ci**Error codes**
4557e41f4b71Sopenharmony_ci
4558e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
4559e41f4b71Sopenharmony_ci
4560e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
4561e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
4562e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Need 3 - 4  parameter(s)! 2. The RdbStore must be not nullptr.3. The tablesNames must be not empty string. 4. The columnName must be not empty string. 5. The PRIKey must be number or string. |
4563e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
4564e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
4565e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
4566e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
4567e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
4568e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
4569e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
4570e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
4571e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
4572e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
4573e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
4574e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
4575e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4576e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
4577e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
4578e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4579e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
4580e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
4581e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
4582e41f4b71Sopenharmony_ci
4583e41f4b71Sopenharmony_ci**Example**
4584e41f4b71Sopenharmony_ci
4585e41f4b71Sopenharmony_ci```ts
4586e41f4b71Sopenharmony_cilet PRIKey = [1, 4, 2, 3];
4587e41f4b71Sopenharmony_ciif(store != undefined) {
4588e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).getModifyTime("EMPLOYEE", "NAME", PRIKey, (err, modifyTime: relationalStore.ModifyTime) => {
4589e41f4b71Sopenharmony_ci    if (err) {
4590e41f4b71Sopenharmony_ci      console.error(`getModifyTime failed, code is ${err.code},message is ${err.message}`);
4591e41f4b71Sopenharmony_ci      return;
4592e41f4b71Sopenharmony_ci    }
4593e41f4b71Sopenharmony_ci    let size = modifyTime.size;
4594e41f4b71Sopenharmony_ci  });
4595e41f4b71Sopenharmony_ci}
4596e41f4b71Sopenharmony_ci```
4597e41f4b71Sopenharmony_ci
4598e41f4b71Sopenharmony_ci### getModifyTime<sup>10+</sup>
4599e41f4b71Sopenharmony_ci
4600e41f4b71Sopenharmony_cigetModifyTime(table: string, columnName: string, primaryKeys: PRIKeyType[]): Promise&lt;ModifyTime&gt;
4601e41f4b71Sopenharmony_ci
4602e41f4b71Sopenharmony_ciObtains the last modification time of the data in a table. This API uses a promise to return the result.
4603e41f4b71Sopenharmony_ci
4604e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4605e41f4b71Sopenharmony_ci
4606e41f4b71Sopenharmony_ci**Parameters**
4607e41f4b71Sopenharmony_ci
4608e41f4b71Sopenharmony_ci| Name     | Type                         | Mandatory| Description                                                        |
4609e41f4b71Sopenharmony_ci| ----------- | ----------------------------- | ---- | ------------------------------------------------------------ |
4610e41f4b71Sopenharmony_ci| table       | string                        | Yes  | Name of the database table to query.                                |
4611e41f4b71Sopenharmony_ci| columnName  | string                        | Yes  | Column name of the database table to query.                                |
4612e41f4b71Sopenharmony_ci| primaryKeys | [PRIKeyType](#prikeytype10)[] | Yes  | Primary keys of the rows to query.<br>If the database table has no primary key, **rowid** must be passed in through **columnName**. In this case, **primaryKeys** specifies the row numbers of the database table to query.<br>If the database table has no primary key and no **rowid** is passed in through **columnName**, an error code will be returned.|
4613e41f4b71Sopenharmony_ci
4614e41f4b71Sopenharmony_ci**Return value**
4615e41f4b71Sopenharmony_ci
4616e41f4b71Sopenharmony_ci| Type                                      | Description                                                     |
4617e41f4b71Sopenharmony_ci| ------------------------------------------ | --------------------------------------------------------- |
4618e41f4b71Sopenharmony_ci| Promise&lt;[ModifyTime](#modifytime10)&gt; | Promise used to return the **ModifyTime** object.|
4619e41f4b71Sopenharmony_ci
4620e41f4b71Sopenharmony_ci**Error codes**
4621e41f4b71Sopenharmony_ci
4622e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
4623e41f4b71Sopenharmony_ci
4624e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
4625e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
4626e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Need 3 - 4  parameter(s)! 2. The RdbStore must be not nullptr.3. The tablesNames must be not empty string. 4. The columnName must be not empty string. 5. The PRIKey must be number or string. |
4627e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
4628e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
4629e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
4630e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
4631e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
4632e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
4633e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
4634e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
4635e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
4636e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
4637e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
4638e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
4639e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4640e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
4641e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
4642e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4643e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
4644e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
4645e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
4646e41f4b71Sopenharmony_ci
4647e41f4b71Sopenharmony_ci**Example**
4648e41f4b71Sopenharmony_ci
4649e41f4b71Sopenharmony_ci```ts
4650e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
4651e41f4b71Sopenharmony_ci
4652e41f4b71Sopenharmony_cilet PRIKey = [1, 2, 3];
4653e41f4b71Sopenharmony_ciif(store != undefined) {
4654e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).getModifyTime("EMPLOYEE", "NAME", PRIKey)
4655e41f4b71Sopenharmony_ci    .then((modifyTime: relationalStore.ModifyTime) => {
4656e41f4b71Sopenharmony_ci      let size = modifyTime.size;
4657e41f4b71Sopenharmony_ci    })
4658e41f4b71Sopenharmony_ci    .catch((err: BusinessError) => {
4659e41f4b71Sopenharmony_ci      console.error(`getModifyTime failed, code is ${err.code},message is ${err.message}`);
4660e41f4b71Sopenharmony_ci    });
4661e41f4b71Sopenharmony_ci}
4662e41f4b71Sopenharmony_ci```
4663e41f4b71Sopenharmony_ci
4664e41f4b71Sopenharmony_ci### beginTransaction
4665e41f4b71Sopenharmony_ci
4666e41f4b71Sopenharmony_cibeginTransaction():void
4667e41f4b71Sopenharmony_ci
4668e41f4b71Sopenharmony_ciStarts the transaction before executing an SQL statement.
4669e41f4b71Sopenharmony_ciThis API does not allow nested transactions and cannot be used across processes or threads.
4670e41f4b71Sopenharmony_ci
4671e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4672e41f4b71Sopenharmony_ci
4673e41f4b71Sopenharmony_ci**Error codes**
4674e41f4b71Sopenharmony_ci
4675e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
4676e41f4b71Sopenharmony_ci
4677e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
4678e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
4679e41f4b71Sopenharmony_ci| 401       | Parameter error. The store must not be nullptr. |
4680e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
4681e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
4682e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
4683e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
4684e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
4685e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
4686e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
4687e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
4688e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
4689e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
4690e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
4691e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4692e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
4693e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
4694e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4695e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
4696e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
4697e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
4698e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
4699e41f4b71Sopenharmony_ci
4700e41f4b71Sopenharmony_ci**Example**
4701e41f4b71Sopenharmony_ci
4702e41f4b71Sopenharmony_ci```ts
4703e41f4b71Sopenharmony_ci
4704e41f4b71Sopenharmony_cilet value1 = "Lisa";
4705e41f4b71Sopenharmony_cilet value2 = 18;
4706e41f4b71Sopenharmony_cilet value3 = 100.5;
4707e41f4b71Sopenharmony_cilet value4 = new Uint8Array([1, 2, 3]);
4708e41f4b71Sopenharmony_ci
4709e41f4b71Sopenharmony_ciif(store != undefined) {
4710e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).beginTransaction();
4711e41f4b71Sopenharmony_ci  const valueBucket: relationalStore.ValuesBucket = {
4712e41f4b71Sopenharmony_ci    'NAME': value1,
4713e41f4b71Sopenharmony_ci    'AGE': value2,
4714e41f4b71Sopenharmony_ci    'SALARY': value3,
4715e41f4b71Sopenharmony_ci    'CODES': value4,
4716e41f4b71Sopenharmony_ci  };
4717e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).insert("test", valueBucket);
4718e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).commit();
4719e41f4b71Sopenharmony_ci}
4720e41f4b71Sopenharmony_ci```
4721e41f4b71Sopenharmony_ci
4722e41f4b71Sopenharmony_ci### beginTrans<sup>12+</sup>
4723e41f4b71Sopenharmony_ci
4724e41f4b71Sopenharmony_cibeginTrans(): Promise&lt;number&gt;
4725e41f4b71Sopenharmony_ci
4726e41f4b71Sopenharmony_ciBegins the transaction before executing the SQL statement. This API uses a promise to return the result.
4727e41f4b71Sopenharmony_ci
4728e41f4b71Sopenharmony_ciDifferent from [beginTransaction](#begintransaction), this API returns a transaction ID. [execute](#execute12-1) can specify the transaction ID to isolate different transactions.
4729e41f4b71Sopenharmony_ci
4730e41f4b71Sopenharmony_ci<!--RP1-->
4731e41f4b71Sopenharmony_ciThis API can be used only for a [vector database](js-apis-data-relationalStore-sys.md#storeconfig).<!--RP1End-->
4732e41f4b71Sopenharmony_ci
4733e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4734e41f4b71Sopenharmony_ci
4735e41f4b71Sopenharmony_ci**Return value**
4736e41f4b71Sopenharmony_ci
4737e41f4b71Sopenharmony_ci| Type               | Description                     |
4738e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
4739e41f4b71Sopenharmony_ci| Promise&lt;number&gt; | Promise used to return the transaction ID.|
4740e41f4b71Sopenharmony_ci
4741e41f4b71Sopenharmony_ci**Error codes**
4742e41f4b71Sopenharmony_ci
4743e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
4744e41f4b71Sopenharmony_ci
4745e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
4746e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
4747e41f4b71Sopenharmony_ci| 401       | Parameter error. The store must not be nullptr. |
4748e41f4b71Sopenharmony_ci| 801       | Capability not supported the sql(attach,begin,commit,rollback etc.). |
4749e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
4750e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
4751e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
4752e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
4753e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
4754e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
4755e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
4756e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
4757e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
4758e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
4759e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
4760e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4761e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
4762e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
4763e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4764e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
4765e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
4766e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
4767e41f4b71Sopenharmony_ci| 14800047  | The WAL file size exceeds the default limit. |
4768e41f4b71Sopenharmony_ci
4769e41f4b71Sopenharmony_ci**Example**
4770e41f4b71Sopenharmony_ci
4771e41f4b71Sopenharmony_ci```ts
4772e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
4773e41f4b71Sopenharmony_ciif(store != null) {
4774e41f4b71Sopenharmony_ci  let txId : number;
4775e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).beginTrans().then((txId : number) => {
4776e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).execute("DELETE FROM TEST WHERE age = ? OR age = ?", txId, ["18", "20"])
4777e41f4b71Sopenharmony_ci      .then(() => {
4778e41f4b71Sopenharmony_ci        (store as relationalStore.RdbStore).commit(txId);
4779e41f4b71Sopenharmony_ci    })
4780e41f4b71Sopenharmony_ci    .catch((err: BusinessError) => {
4781e41f4b71Sopenharmony_ci      (store as relationalStore.RdbStore).rollback(txId)
4782e41f4b71Sopenharmony_ci      console.error(`execute sql failed, code is ${err.code},message is ${err.message}`);
4783e41f4b71Sopenharmony_ci    });
4784e41f4b71Sopenharmony_ci  });
4785e41f4b71Sopenharmony_ci}
4786e41f4b71Sopenharmony_ci```
4787e41f4b71Sopenharmony_ci
4788e41f4b71Sopenharmony_ci### commit
4789e41f4b71Sopenharmony_ci
4790e41f4b71Sopenharmony_cicommit():void
4791e41f4b71Sopenharmony_ci
4792e41f4b71Sopenharmony_ciCommits the executed SQL statements.
4793e41f4b71Sopenharmony_ciThis API does not allow nested transactions and cannot be used across processes or threads.
4794e41f4b71Sopenharmony_ci
4795e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4796e41f4b71Sopenharmony_ci
4797e41f4b71Sopenharmony_ci**Error codes**
4798e41f4b71Sopenharmony_ci
4799e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
4800e41f4b71Sopenharmony_ci
4801e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
4802e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
4803e41f4b71Sopenharmony_ci| 401       | Parameter error. The store must not be nullptr. |
4804e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
4805e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
4806e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
4807e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
4808e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
4809e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
4810e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
4811e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
4812e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
4813e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
4814e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
4815e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4816e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
4817e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
4818e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4819e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
4820e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
4821e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
4822e41f4b71Sopenharmony_ci
4823e41f4b71Sopenharmony_ci**Example**
4824e41f4b71Sopenharmony_ci
4825e41f4b71Sopenharmony_ci```ts
4826e41f4b71Sopenharmony_ci
4827e41f4b71Sopenharmony_cilet value1 = "Lisa";
4828e41f4b71Sopenharmony_cilet value2 = 18;
4829e41f4b71Sopenharmony_cilet value3 = 100.5;
4830e41f4b71Sopenharmony_cilet value4 = new Uint8Array([1, 2, 3]);
4831e41f4b71Sopenharmony_ci
4832e41f4b71Sopenharmony_ciif(store != undefined) {
4833e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).beginTransaction();
4834e41f4b71Sopenharmony_ci  const valueBucket: relationalStore.ValuesBucket = {
4835e41f4b71Sopenharmony_ci    'NAME': value1,
4836e41f4b71Sopenharmony_ci    'AGE': value2,
4837e41f4b71Sopenharmony_ci    'SALARY': value3,
4838e41f4b71Sopenharmony_ci    'CODES': value4,
4839e41f4b71Sopenharmony_ci  };
4840e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).insert("test", valueBucket);
4841e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).commit();
4842e41f4b71Sopenharmony_ci}
4843e41f4b71Sopenharmony_ci```
4844e41f4b71Sopenharmony_ci
4845e41f4b71Sopenharmony_ci### commit<sup>12+</sup>
4846e41f4b71Sopenharmony_ci
4847e41f4b71Sopenharmony_cicommit(txId : number):Promise&lt;void&gt;
4848e41f4b71Sopenharmony_ci
4849e41f4b71Sopenharmony_ciCommits the executed SQL statements. This API must be used with [beginTrans](#begintrans12).
4850e41f4b71Sopenharmony_ci
4851e41f4b71Sopenharmony_ci<!--RP1-->
4852e41f4b71Sopenharmony_ciThis API can be used only for a [vector database](js-apis-data-relationalStore-sys.md#storeconfig).<!--RP1End-->
4853e41f4b71Sopenharmony_ci
4854e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4855e41f4b71Sopenharmony_ci
4856e41f4b71Sopenharmony_ci**Parameters**
4857e41f4b71Sopenharmony_ci
4858e41f4b71Sopenharmony_ci| Name  | Type                                | Mandatory| Description                                                        |
4859e41f4b71Sopenharmony_ci| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
4860e41f4b71Sopenharmony_ci| txId      | number                               | Yes  | Transaction ID obtained via [beginTrans](#begintrans12).                                       |
4861e41f4b71Sopenharmony_ci
4862e41f4b71Sopenharmony_ci**Return value**
4863e41f4b71Sopenharmony_ci
4864e41f4b71Sopenharmony_ci| Type               | Description                     |
4865e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
4866e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
4867e41f4b71Sopenharmony_ci
4868e41f4b71Sopenharmony_ci**Error codes**
4869e41f4b71Sopenharmony_ci
4870e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
4871e41f4b71Sopenharmony_ci
4872e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
4873e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
4874e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4875e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
4876e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
4877e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
4878e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
4879e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
4880e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
4881e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
4882e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
4883e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
4884e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
4885e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
4886e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4887e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
4888e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
4889e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4890e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
4891e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
4892e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
4893e41f4b71Sopenharmony_ci
4894e41f4b71Sopenharmony_ci**Example**
4895e41f4b71Sopenharmony_ci
4896e41f4b71Sopenharmony_ci```ts
4897e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
4898e41f4b71Sopenharmony_ciif(store != null) {
4899e41f4b71Sopenharmony_ci  let txId : number;
4900e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).beginTrans().then((txId : number) => {
4901e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).execute("DELETE FROM TEST WHERE age = ? OR age = ?", txId, ["18", "20"])
4902e41f4b71Sopenharmony_ci      .then(() => {
4903e41f4b71Sopenharmony_ci        (store as relationalStore.RdbStore).commit(txId);
4904e41f4b71Sopenharmony_ci    })
4905e41f4b71Sopenharmony_ci    .catch((err: BusinessError) => {
4906e41f4b71Sopenharmony_ci      (store as relationalStore.RdbStore).rollback(txId)
4907e41f4b71Sopenharmony_ci      console.error(`execute sql failed, code is ${err.code},message is ${err.message}`);
4908e41f4b71Sopenharmony_ci    });
4909e41f4b71Sopenharmony_ci  });
4910e41f4b71Sopenharmony_ci}
4911e41f4b71Sopenharmony_ci```
4912e41f4b71Sopenharmony_ci
4913e41f4b71Sopenharmony_ci### rollBack
4914e41f4b71Sopenharmony_ci
4915e41f4b71Sopenharmony_cirollBack():void
4916e41f4b71Sopenharmony_ci
4917e41f4b71Sopenharmony_ciRolls back the SQL statements that have been executed.
4918e41f4b71Sopenharmony_ciThis API does not allow nested transactions and cannot be used across processes or threads.
4919e41f4b71Sopenharmony_ci
4920e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4921e41f4b71Sopenharmony_ci
4922e41f4b71Sopenharmony_ci**Error codes**
4923e41f4b71Sopenharmony_ci
4924e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
4925e41f4b71Sopenharmony_ci
4926e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
4927e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
4928e41f4b71Sopenharmony_ci| 401       | Parameter error. The store must not be nullptr. |
4929e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
4930e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
4931e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
4932e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
4933e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
4934e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
4935e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
4936e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
4937e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
4938e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
4939e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
4940e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4941e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
4942e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
4943e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4944e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
4945e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
4946e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
4947e41f4b71Sopenharmony_ci
4948e41f4b71Sopenharmony_ci**Example**
4949e41f4b71Sopenharmony_ci
4950e41f4b71Sopenharmony_ci```ts
4951e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
4952e41f4b71Sopenharmony_ci
4953e41f4b71Sopenharmony_cilet value1 = "Lisa";
4954e41f4b71Sopenharmony_cilet value2 = 18;
4955e41f4b71Sopenharmony_cilet value3 = 100.5;
4956e41f4b71Sopenharmony_cilet value4 = new Uint8Array([1, 2, 3]);
4957e41f4b71Sopenharmony_ci
4958e41f4b71Sopenharmony_ciif(store != undefined) {
4959e41f4b71Sopenharmony_ci  try {
4960e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).beginTransaction()
4961e41f4b71Sopenharmony_ci    const valueBucket: relationalStore.ValuesBucket = {
4962e41f4b71Sopenharmony_ci      'NAME': value1,
4963e41f4b71Sopenharmony_ci      'AGE': value2,
4964e41f4b71Sopenharmony_ci      'SALARY': value3,
4965e41f4b71Sopenharmony_ci      'CODES': value4,
4966e41f4b71Sopenharmony_ci    };
4967e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).insert("test", valueBucket);
4968e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).commit();
4969e41f4b71Sopenharmony_ci  } catch (err) {
4970e41f4b71Sopenharmony_ci    let code = (err as BusinessError).code;
4971e41f4b71Sopenharmony_ci    let message = (err as BusinessError).message
4972e41f4b71Sopenharmony_ci    console.error(`Transaction failed, code is ${code},message is ${message}`);
4973e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).rollBack();
4974e41f4b71Sopenharmony_ci  }
4975e41f4b71Sopenharmony_ci}
4976e41f4b71Sopenharmony_ci```
4977e41f4b71Sopenharmony_ci
4978e41f4b71Sopenharmony_ci### rollback<sup>12+</sup>
4979e41f4b71Sopenharmony_ci
4980e41f4b71Sopenharmony_cirollback(txId : number):Promise&lt;void&gt;
4981e41f4b71Sopenharmony_ci
4982e41f4b71Sopenharmony_ciRolls back the executed SQL statements. This API must be used with [beginTrans](#begintrans12).
4983e41f4b71Sopenharmony_ci
4984e41f4b71Sopenharmony_ci<!--RP1-->
4985e41f4b71Sopenharmony_ciThis API can be used only for a [vector database](js-apis-data-relationalStore-sys.md#storeconfig).<!--RP1End-->
4986e41f4b71Sopenharmony_ci
4987e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4988e41f4b71Sopenharmony_ci
4989e41f4b71Sopenharmony_ci**Parameters**
4990e41f4b71Sopenharmony_ci
4991e41f4b71Sopenharmony_ci| Name  | Type                                | Mandatory| Description                                                        |
4992e41f4b71Sopenharmony_ci| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
4993e41f4b71Sopenharmony_ci| txId      | number                               | Yes  | Transaction ID obtained via [beginTrans](#begintrans12).                                       |
4994e41f4b71Sopenharmony_ci
4995e41f4b71Sopenharmony_ci**Return value**
4996e41f4b71Sopenharmony_ci
4997e41f4b71Sopenharmony_ci| Type               | Description                     |
4998e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
4999e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
5000e41f4b71Sopenharmony_ci
5001e41f4b71Sopenharmony_ci**Error codes**
5002e41f4b71Sopenharmony_ci
5003e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
5004e41f4b71Sopenharmony_ci
5005e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
5006e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
5007e41f4b71Sopenharmony_ci| 401       | Parameter error. The store must not be nullptr. |
5008e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
5009e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
5010e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
5011e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
5012e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
5013e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
5014e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
5015e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
5016e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
5017e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
5018e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
5019e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
5020e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
5021e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
5022e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
5023e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
5024e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
5025e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
5026e41f4b71Sopenharmony_ci
5027e41f4b71Sopenharmony_ci**Example**
5028e41f4b71Sopenharmony_ci
5029e41f4b71Sopenharmony_ci```ts
5030e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5031e41f4b71Sopenharmony_ciif(store != null) {
5032e41f4b71Sopenharmony_ci  let txId : number;
5033e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).beginTrans().then((txId : number) => {
5034e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).execute("DELETE FROM TEST WHERE age = ? OR age = ?", txId, ["18", "20"])
5035e41f4b71Sopenharmony_ci      .then(() => {
5036e41f4b71Sopenharmony_ci        (store as relationalStore.RdbStore).commit(txId);
5037e41f4b71Sopenharmony_ci    })
5038e41f4b71Sopenharmony_ci    .catch((err: BusinessError) => {
5039e41f4b71Sopenharmony_ci      (store as relationalStore.RdbStore).rollback(txId)
5040e41f4b71Sopenharmony_ci      console.error(`execute sql failed, code is ${err.code},message is ${err.message}`);
5041e41f4b71Sopenharmony_ci    });
5042e41f4b71Sopenharmony_ci  });
5043e41f4b71Sopenharmony_ci}
5044e41f4b71Sopenharmony_ci```
5045e41f4b71Sopenharmony_ci
5046e41f4b71Sopenharmony_ci### backup
5047e41f4b71Sopenharmony_ci
5048e41f4b71Sopenharmony_cibackup(destName:string, callback: AsyncCallback&lt;void&gt;):void
5049e41f4b71Sopenharmony_ci
5050e41f4b71Sopenharmony_ciBacks up an RDB store. This API uses an asynchronous callback to return the result.
5051e41f4b71Sopenharmony_ci
5052e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5053e41f4b71Sopenharmony_ci
5054e41f4b71Sopenharmony_ci**Parameters**
5055e41f4b71Sopenharmony_ci
5056e41f4b71Sopenharmony_ci| Name  | Type                     | Mandatory| Description                    |
5057e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ------------------------ |
5058e41f4b71Sopenharmony_ci| destName | string                    | Yes  | Name of the RDB store backup file.|
5059e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.  |
5060e41f4b71Sopenharmony_ci
5061e41f4b71Sopenharmony_ci**Error codes**
5062e41f4b71Sopenharmony_ci
5063e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
5064e41f4b71Sopenharmony_ci
5065e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
5066e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
5067e41f4b71Sopenharmony_ci| 401       | Parameter error. The store must not be nullptr. |
5068e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
5069e41f4b71Sopenharmony_ci| 14800010  | Invalid database path. |
5070e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
5071e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
5072e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
5073e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
5074e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
5075e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
5076e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
5077e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
5078e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
5079e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
5080e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
5081e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
5082e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
5083e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
5084e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
5085e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
5086e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
5087e41f4b71Sopenharmony_ci
5088e41f4b71Sopenharmony_ci**Example**
5089e41f4b71Sopenharmony_ci
5090e41f4b71Sopenharmony_ci```ts
5091e41f4b71Sopenharmony_ciif(store != undefined) {
5092e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).backup("dbBackup.db", (err) => {
5093e41f4b71Sopenharmony_ci    if (err) {
5094e41f4b71Sopenharmony_ci      console.error(`Backup failed, code is ${err.code},message is ${err.message}`);
5095e41f4b71Sopenharmony_ci      return;
5096e41f4b71Sopenharmony_ci    }
5097e41f4b71Sopenharmony_ci    console.info('Backup success.');
5098e41f4b71Sopenharmony_ci  })
5099e41f4b71Sopenharmony_ci}
5100e41f4b71Sopenharmony_ci```
5101e41f4b71Sopenharmony_ci
5102e41f4b71Sopenharmony_ci### backup
5103e41f4b71Sopenharmony_ci
5104e41f4b71Sopenharmony_cibackup(destName:string): Promise&lt;void&gt;
5105e41f4b71Sopenharmony_ci
5106e41f4b71Sopenharmony_ciBacks up an RDB store. This API uses a promise to return the result.
5107e41f4b71Sopenharmony_ci
5108e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5109e41f4b71Sopenharmony_ci
5110e41f4b71Sopenharmony_ci**Parameters**
5111e41f4b71Sopenharmony_ci
5112e41f4b71Sopenharmony_ci| Name  | Type  | Mandatory| Description                    |
5113e41f4b71Sopenharmony_ci| -------- | ------ | ---- | ------------------------ |
5114e41f4b71Sopenharmony_ci| destName | string | Yes  | Name of the RDB store backup file.|
5115e41f4b71Sopenharmony_ci
5116e41f4b71Sopenharmony_ci**Return value**
5117e41f4b71Sopenharmony_ci
5118e41f4b71Sopenharmony_ci| Type               | Description                     |
5119e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
5120e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
5121e41f4b71Sopenharmony_ci
5122e41f4b71Sopenharmony_ci**Error codes**
5123e41f4b71Sopenharmony_ci
5124e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
5125e41f4b71Sopenharmony_ci
5126e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
5127e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
5128e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5129e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
5130e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
5131e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
5132e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
5133e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
5134e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
5135e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
5136e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
5137e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
5138e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
5139e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
5140e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
5141e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
5142e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
5143e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
5144e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
5145e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
5146e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
5147e41f4b71Sopenharmony_ci
5148e41f4b71Sopenharmony_ci**Example**
5149e41f4b71Sopenharmony_ci
5150e41f4b71Sopenharmony_ci```ts
5151e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5152e41f4b71Sopenharmony_ci
5153e41f4b71Sopenharmony_ciif(store != undefined) {
5154e41f4b71Sopenharmony_ci  let promiseBackup = (store as relationalStore.RdbStore).backup("dbBackup.db");
5155e41f4b71Sopenharmony_ci  promiseBackup.then(() => {
5156e41f4b71Sopenharmony_ci    console.info('Backup success.');
5157e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
5158e41f4b71Sopenharmony_ci    console.error(`Backup failed, code is ${err.code},message is ${err.message}`);
5159e41f4b71Sopenharmony_ci  })
5160e41f4b71Sopenharmony_ci}
5161e41f4b71Sopenharmony_ci```
5162e41f4b71Sopenharmony_ci
5163e41f4b71Sopenharmony_ci### restore
5164e41f4b71Sopenharmony_ci
5165e41f4b71Sopenharmony_cirestore(srcName:string, callback: AsyncCallback&lt;void&gt;):void
5166e41f4b71Sopenharmony_ci
5167e41f4b71Sopenharmony_ciRestores an RDB store from a backup file. This API uses an asynchronous callback to return the result.
5168e41f4b71Sopenharmony_ci
5169e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5170e41f4b71Sopenharmony_ci
5171e41f4b71Sopenharmony_ci**Parameters**
5172e41f4b71Sopenharmony_ci
5173e41f4b71Sopenharmony_ci| Name  | Type                     | Mandatory| Description                    |
5174e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ------------------------ |
5175e41f4b71Sopenharmony_ci| srcName  | string                    | Yes  | Name of the RDB store backup file.|
5176e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.  |
5177e41f4b71Sopenharmony_ci
5178e41f4b71Sopenharmony_ci**Error codes**
5179e41f4b71Sopenharmony_ci
5180e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
5181e41f4b71Sopenharmony_ci
5182e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
5183e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
5184e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5185e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
5186e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
5187e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
5188e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
5189e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
5190e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
5191e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
5192e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
5193e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
5194e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
5195e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
5196e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
5197e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
5198e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
5199e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
5200e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
5201e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
5202e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
5203e41f4b71Sopenharmony_ci
5204e41f4b71Sopenharmony_ci**Example**
5205e41f4b71Sopenharmony_ci
5206e41f4b71Sopenharmony_ci```ts
5207e41f4b71Sopenharmony_ciif(store != undefined) {
5208e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).restore("dbBackup.db", (err) => {
5209e41f4b71Sopenharmony_ci    if (err) {
5210e41f4b71Sopenharmony_ci      console.error(`Restore failed, code is ${err.code},message is ${err.message}`);
5211e41f4b71Sopenharmony_ci      return;
5212e41f4b71Sopenharmony_ci    }
5213e41f4b71Sopenharmony_ci    console.info('Restore success.');
5214e41f4b71Sopenharmony_ci  })
5215e41f4b71Sopenharmony_ci}
5216e41f4b71Sopenharmony_ci```
5217e41f4b71Sopenharmony_ci
5218e41f4b71Sopenharmony_ci### restore
5219e41f4b71Sopenharmony_ci
5220e41f4b71Sopenharmony_cirestore(srcName:string): Promise&lt;void&gt;
5221e41f4b71Sopenharmony_ci
5222e41f4b71Sopenharmony_ciRestores an RDB store from a backup file. This API uses a promise to return the result.
5223e41f4b71Sopenharmony_ci
5224e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5225e41f4b71Sopenharmony_ci
5226e41f4b71Sopenharmony_ci**Parameters**
5227e41f4b71Sopenharmony_ci
5228e41f4b71Sopenharmony_ci| Name | Type  | Mandatory| Description                    |
5229e41f4b71Sopenharmony_ci| ------- | ------ | ---- | ------------------------ |
5230e41f4b71Sopenharmony_ci| srcName | string | Yes  | Name of the RDB store backup file.|
5231e41f4b71Sopenharmony_ci
5232e41f4b71Sopenharmony_ci**Return value**
5233e41f4b71Sopenharmony_ci
5234e41f4b71Sopenharmony_ci| Type               | Description                     |
5235e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
5236e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
5237e41f4b71Sopenharmony_ci
5238e41f4b71Sopenharmony_ci**Error codes**
5239e41f4b71Sopenharmony_ci
5240e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
5241e41f4b71Sopenharmony_ci
5242e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
5243e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
5244e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5245e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
5246e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
5247e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
5248e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
5249e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
5250e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
5251e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
5252e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
5253e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
5254e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
5255e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
5256e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
5257e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
5258e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
5259e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
5260e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
5261e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
5262e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
5263e41f4b71Sopenharmony_ci
5264e41f4b71Sopenharmony_ci**Example**
5265e41f4b71Sopenharmony_ci
5266e41f4b71Sopenharmony_ci```ts
5267e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5268e41f4b71Sopenharmony_ci
5269e41f4b71Sopenharmony_ciif(store != undefined) {
5270e41f4b71Sopenharmony_ci  let promiseRestore = (store as relationalStore.RdbStore).restore("dbBackup.db");
5271e41f4b71Sopenharmony_ci  promiseRestore.then(() => {
5272e41f4b71Sopenharmony_ci    console.info('Restore success.');
5273e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
5274e41f4b71Sopenharmony_ci    console.error(`Restore failed, code is ${err.code},message is ${err.message}`);
5275e41f4b71Sopenharmony_ci  })
5276e41f4b71Sopenharmony_ci}
5277e41f4b71Sopenharmony_ci```
5278e41f4b71Sopenharmony_ci
5279e41f4b71Sopenharmony_ci### setDistributedTables
5280e41f4b71Sopenharmony_ci
5281e41f4b71Sopenharmony_cisetDistributedTables(tables: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void
5282e41f4b71Sopenharmony_ci
5283e41f4b71Sopenharmony_ciSets distributed tables. This API uses an asynchronous callback to return the result.
5284e41f4b71Sopenharmony_ci
5285e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
5286e41f4b71Sopenharmony_ci
5287e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5288e41f4b71Sopenharmony_ci
5289e41f4b71Sopenharmony_ci**Parameters**
5290e41f4b71Sopenharmony_ci
5291e41f4b71Sopenharmony_ci| Name  | Type                     | Mandatory| Description                  |
5292e41f4b71Sopenharmony_ci| -------- | ------------------------- | ---- | ---------------------- |
5293e41f4b71Sopenharmony_ci| tables   | Array&lt;string&gt;       | Yes  | Names of the distributed tables to set.|
5294e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
5295e41f4b71Sopenharmony_ci
5296e41f4b71Sopenharmony_ci**Error codes**
5297e41f4b71Sopenharmony_ci
5298e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5299e41f4b71Sopenharmony_ci
5300e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
5301e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
5302e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5303e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
5304e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
5305e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
5306e41f4b71Sopenharmony_ci
5307e41f4b71Sopenharmony_ci**Example**
5308e41f4b71Sopenharmony_ci
5309e41f4b71Sopenharmony_ci```ts
5310e41f4b71Sopenharmony_ciif(store != undefined) {
5311e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"], (err) => {
5312e41f4b71Sopenharmony_ci    if (err) {
5313e41f4b71Sopenharmony_ci      console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
5314e41f4b71Sopenharmony_ci      return;
5315e41f4b71Sopenharmony_ci    }
5316e41f4b71Sopenharmony_ci    console.info('SetDistributedTables successfully.');
5317e41f4b71Sopenharmony_ci  })
5318e41f4b71Sopenharmony_ci}
5319e41f4b71Sopenharmony_ci```
5320e41f4b71Sopenharmony_ci
5321e41f4b71Sopenharmony_ci### setDistributedTables
5322e41f4b71Sopenharmony_ci
5323e41f4b71Sopenharmony_ci setDistributedTables(tables: Array&lt;string&gt;): Promise&lt;void&gt;
5324e41f4b71Sopenharmony_ci
5325e41f4b71Sopenharmony_ciSets distributed tables. This API uses a promise to return the result.
5326e41f4b71Sopenharmony_ci
5327e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
5328e41f4b71Sopenharmony_ci
5329e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5330e41f4b71Sopenharmony_ci
5331e41f4b71Sopenharmony_ci**Parameters**
5332e41f4b71Sopenharmony_ci
5333e41f4b71Sopenharmony_ci| Name| Type                    | Mandatory| Description                    |
5334e41f4b71Sopenharmony_ci| ------ | ------------------------ | ---- | ------------------------ |
5335e41f4b71Sopenharmony_ci| tables | ArrayArray&lt;string&gt; | Yes  | Names of the distributed tables to set.|
5336e41f4b71Sopenharmony_ci
5337e41f4b71Sopenharmony_ci**Return value**
5338e41f4b71Sopenharmony_ci
5339e41f4b71Sopenharmony_ci| Type               | Description                     |
5340e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
5341e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
5342e41f4b71Sopenharmony_ci
5343e41f4b71Sopenharmony_ci**Error codes**
5344e41f4b71Sopenharmony_ci
5345e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5346e41f4b71Sopenharmony_ci
5347e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
5348e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
5349e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5350e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
5351e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
5352e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
5353e41f4b71Sopenharmony_ci
5354e41f4b71Sopenharmony_ci**Example**
5355e41f4b71Sopenharmony_ci
5356e41f4b71Sopenharmony_ci```ts
5357e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5358e41f4b71Sopenharmony_ci
5359e41f4b71Sopenharmony_ciif(store != undefined) {
5360e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"]).then(() => {
5361e41f4b71Sopenharmony_ci    console.info('SetDistributedTables successfully.');
5362e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
5363e41f4b71Sopenharmony_ci    console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
5364e41f4b71Sopenharmony_ci  })
5365e41f4b71Sopenharmony_ci}
5366e41f4b71Sopenharmony_ci```
5367e41f4b71Sopenharmony_ci
5368e41f4b71Sopenharmony_ci### setDistributedTables<sup>10+</sup>
5369e41f4b71Sopenharmony_ci
5370e41f4b71Sopenharmony_cisetDistributedTables(tables: Array&lt;string&gt;, type: DistributedType, callback: AsyncCallback&lt;void&gt;): void
5371e41f4b71Sopenharmony_ci
5372e41f4b71Sopenharmony_ciSets distributed tables. This API uses an asynchronous callback to return the result.
5373e41f4b71Sopenharmony_ci
5374e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
5375e41f4b71Sopenharmony_ci
5376e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5377e41f4b71Sopenharmony_ci
5378e41f4b71Sopenharmony_ci**Parameters**
5379e41f4b71Sopenharmony_ci
5380e41f4b71Sopenharmony_ci| Name  | Type                                 | Mandatory| Description                        |
5381e41f4b71Sopenharmony_ci| -------- | ------------------------------------- | ---- | ---------------------------- |
5382e41f4b71Sopenharmony_ci| tables   | Array&lt;string&gt;                   | Yes  | Names of the distributed tables to set.|
5383e41f4b71Sopenharmony_ci| type     | [DistributedType](#distributedtype10) | Yes  | Distributed type of the tables.            |
5384e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt;             | Yes  | Callback used to return the result.      |
5385e41f4b71Sopenharmony_ci
5386e41f4b71Sopenharmony_ci**Error codes**
5387e41f4b71Sopenharmony_ci
5388e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5389e41f4b71Sopenharmony_ci
5390e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
5391e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
5392e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5393e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
5394e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
5395e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
5396e41f4b71Sopenharmony_ci| 14800051  | The type of the distributed table does not match. |
5397e41f4b71Sopenharmony_ci
5398e41f4b71Sopenharmony_ci**Example**
5399e41f4b71Sopenharmony_ci
5400e41f4b71Sopenharmony_ci```ts
5401e41f4b71Sopenharmony_ciif(store != undefined) {
5402e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"], relationalStore.DistributedType.DISTRIBUTED_CLOUD, (err) => {
5403e41f4b71Sopenharmony_ci    if (err) {
5404e41f4b71Sopenharmony_ci      console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
5405e41f4b71Sopenharmony_ci      return;
5406e41f4b71Sopenharmony_ci    }
5407e41f4b71Sopenharmony_ci    console.info('SetDistributedTables successfully.');
5408e41f4b71Sopenharmony_ci  })
5409e41f4b71Sopenharmony_ci}
5410e41f4b71Sopenharmony_ci```
5411e41f4b71Sopenharmony_ci
5412e41f4b71Sopenharmony_ci### setDistributedTables<sup>10+</sup>
5413e41f4b71Sopenharmony_ci
5414e41f4b71Sopenharmony_cisetDistributedTables(tables: Array&lt;string&gt;, type: DistributedType, config: DistributedConfig, callback: AsyncCallback&lt;void&gt;): void
5415e41f4b71Sopenharmony_ci
5416e41f4b71Sopenharmony_ciSets distributed tables. This API uses an asynchronous callback to return the result.
5417e41f4b71Sopenharmony_ci
5418e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
5419e41f4b71Sopenharmony_ci
5420e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5421e41f4b71Sopenharmony_ci
5422e41f4b71Sopenharmony_ci**Parameters**
5423e41f4b71Sopenharmony_ci
5424e41f4b71Sopenharmony_ci| Name     | Type                                 | Mandatory | Description             |
5425e41f4b71Sopenharmony_ci| -------- | ----------------------------------- | --- | --------------- |
5426e41f4b71Sopenharmony_ci| tables   | Array&lt;string&gt;                 | Yes  | Names of the distributed tables to set.    |
5427e41f4b71Sopenharmony_ci| type     | [DistributedType](#distributedtype10) | Yes  | Distributed type of the tables.|
5428e41f4b71Sopenharmony_ci| config | [DistributedConfig](#distributedconfig10) | Yes| Configuration of the distributed mode.|
5429e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt;           | Yes  | Callback used to return the result.|
5430e41f4b71Sopenharmony_ci
5431e41f4b71Sopenharmony_ci**Error codes**
5432e41f4b71Sopenharmony_ci
5433e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5434e41f4b71Sopenharmony_ci
5435e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
5436e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
5437e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5438e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
5439e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
5440e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
5441e41f4b71Sopenharmony_ci| 14800051  | The type of the distributed table does not match. |
5442e41f4b71Sopenharmony_ci
5443e41f4b71Sopenharmony_ci**Example**
5444e41f4b71Sopenharmony_ci
5445e41f4b71Sopenharmony_ci```ts
5446e41f4b71Sopenharmony_ciif(store != undefined) {
5447e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"], relationalStore.DistributedType.DISTRIBUTED_CLOUD, {
5448e41f4b71Sopenharmony_ci    autoSync: true
5449e41f4b71Sopenharmony_ci  }, (err) => {
5450e41f4b71Sopenharmony_ci    if (err) {
5451e41f4b71Sopenharmony_ci      console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
5452e41f4b71Sopenharmony_ci      return;
5453e41f4b71Sopenharmony_ci    }
5454e41f4b71Sopenharmony_ci    console.info('SetDistributedTables successfully.');
5455e41f4b71Sopenharmony_ci  })
5456e41f4b71Sopenharmony_ci}
5457e41f4b71Sopenharmony_ci```
5458e41f4b71Sopenharmony_ci
5459e41f4b71Sopenharmony_ci### setDistributedTables<sup>10+</sup>
5460e41f4b71Sopenharmony_ci
5461e41f4b71Sopenharmony_ci setDistributedTables(tables: Array&lt;string>, type?: DistributedType, config?: DistributedConfig): Promise&lt;void>
5462e41f4b71Sopenharmony_ci
5463e41f4b71Sopenharmony_ciSets distributed tables. This API uses a promise to return the result.
5464e41f4b71Sopenharmony_ci
5465e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
5466e41f4b71Sopenharmony_ci
5467e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5468e41f4b71Sopenharmony_ci
5469e41f4b71Sopenharmony_ci**Parameters**
5470e41f4b71Sopenharmony_ci
5471e41f4b71Sopenharmony_ci| Name| Type                                     | Mandatory| Description                                                        |
5472e41f4b71Sopenharmony_ci| ------ | ----------------------------------------- | ---- | ------------------------------------------------------------ |
5473e41f4b71Sopenharmony_ci| tables | Array&lt;string&gt;                       | Yes  | Names of the distributed tables to set.                                |
5474e41f4b71Sopenharmony_ci| type   | [DistributedType](#distributedtype10)     | No  | Distributed type of the tables. The default value is **relationalStore.DistributedType.DISTRIBUTED_DEVICE**.|
5475e41f4b71Sopenharmony_ci| config | [DistributedConfig](#distributedconfig10) | No  | Configuration of the distributed mode. If this parameter is not specified, the value of **autoSync** is **false** by default, which means only manual sync is supported.|
5476e41f4b71Sopenharmony_ci
5477e41f4b71Sopenharmony_ci**Return value**
5478e41f4b71Sopenharmony_ci
5479e41f4b71Sopenharmony_ci| Type               | Description                     |
5480e41f4b71Sopenharmony_ci| ------------------- | ------------------------- |
5481e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise that returns no value.|
5482e41f4b71Sopenharmony_ci
5483e41f4b71Sopenharmony_ci**Error codes**
5484e41f4b71Sopenharmony_ci
5485e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5486e41f4b71Sopenharmony_ci
5487e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
5488e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
5489e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5490e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
5491e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
5492e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
5493e41f4b71Sopenharmony_ci| 14800051  | The type of the distributed table does not match. |
5494e41f4b71Sopenharmony_ci
5495e41f4b71Sopenharmony_ci**Example**
5496e41f4b71Sopenharmony_ci
5497e41f4b71Sopenharmony_ci```ts
5498e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5499e41f4b71Sopenharmony_ci
5500e41f4b71Sopenharmony_ciif(store != undefined) {
5501e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"], relationalStore.DistributedType.DISTRIBUTED_CLOUD, {
5502e41f4b71Sopenharmony_ci    autoSync: true
5503e41f4b71Sopenharmony_ci  }).then(() => {
5504e41f4b71Sopenharmony_ci    console.info('SetDistributedTables successfully.');
5505e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
5506e41f4b71Sopenharmony_ci    console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
5507e41f4b71Sopenharmony_ci  })
5508e41f4b71Sopenharmony_ci}
5509e41f4b71Sopenharmony_ci```
5510e41f4b71Sopenharmony_ci
5511e41f4b71Sopenharmony_ci### obtainDistributedTableName
5512e41f4b71Sopenharmony_ci
5513e41f4b71Sopenharmony_ciobtainDistributedTableName(device: string, table: string, callback: AsyncCallback&lt;string&gt;): void
5514e41f4b71Sopenharmony_ci
5515e41f4b71Sopenharmony_ciObtains the distributed table name of a remote device based on the local table name of the device. The distributed table name is required when the RDB store of a remote device is queried.
5516e41f4b71Sopenharmony_ci
5517e41f4b71Sopenharmony_ci> **NOTE**
5518e41f4b71Sopenharmony_ci>
5519e41f4b71Sopenharmony_ci> **device** can be obtained by [deviceManager.getAvailableDeviceListSync](../apis-distributedservice-kit/js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
5520e41f4b71Sopenharmony_ci
5521e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
5522e41f4b71Sopenharmony_ci
5523e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5524e41f4b71Sopenharmony_ci
5525e41f4b71Sopenharmony_ci**Parameters**
5526e41f4b71Sopenharmony_ci
5527e41f4b71Sopenharmony_ci| Name  | Type                       | Mandatory| Description                                                        |
5528e41f4b71Sopenharmony_ci| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
5529e41f4b71Sopenharmony_ci| device   | string                      | Yes  | ID of the remote device.                                               |
5530e41f4b71Sopenharmony_ci| table    | string                      | Yes  | Local table name of the remote device.                                        |
5531e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the result. If the operation succeeds, the distributed table name of the remote device is returned.|
5532e41f4b71Sopenharmony_ci
5533e41f4b71Sopenharmony_ci**Error codes**
5534e41f4b71Sopenharmony_ci
5535e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5536e41f4b71Sopenharmony_ci
5537e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
5538e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
5539e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5540e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
5541e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
5542e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
5543e41f4b71Sopenharmony_ci
5544e41f4b71Sopenharmony_ci**Example**
5545e41f4b71Sopenharmony_ci
5546e41f4b71Sopenharmony_ci```ts
5547e41f4b71Sopenharmony_ciimport { distributedDeviceManager } from '@kit.DistributedServiceKit';
5548e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5549e41f4b71Sopenharmony_ci
5550e41f4b71Sopenharmony_cilet dmInstance: distributedDeviceManager.DeviceManager;
5551e41f4b71Sopenharmony_cilet deviceId: string | undefined = undefined;
5552e41f4b71Sopenharmony_ci
5553e41f4b71Sopenharmony_citry {
5554e41f4b71Sopenharmony_ci  dmInstance = distributedDeviceManager.createDeviceManager("com.example.appdatamgrverify");
5555e41f4b71Sopenharmony_ci  let devices = dmInstance.getAvailableDeviceListSync();
5556e41f4b71Sopenharmony_ci  deviceId = devices[0].networkId;
5557e41f4b71Sopenharmony_ci} catch (err) {
5558e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
5559e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message
5560e41f4b71Sopenharmony_ci  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
5561e41f4b71Sopenharmony_ci}
5562e41f4b71Sopenharmony_ci
5563e41f4b71Sopenharmony_ciif(store != undefined && deviceId != undefined) {
5564e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).obtainDistributedTableName(deviceId, "EMPLOYEE", (err, tableName) => {
5565e41f4b71Sopenharmony_ci    if (err) {
5566e41f4b71Sopenharmony_ci      console.error(`ObtainDistributedTableName failed, code is ${err.code},message is ${err.message}`);
5567e41f4b71Sopenharmony_ci      return;
5568e41f4b71Sopenharmony_ci    }
5569e41f4b71Sopenharmony_ci    console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`);
5570e41f4b71Sopenharmony_ci  })
5571e41f4b71Sopenharmony_ci}
5572e41f4b71Sopenharmony_ci```
5573e41f4b71Sopenharmony_ci
5574e41f4b71Sopenharmony_ci### obtainDistributedTableName
5575e41f4b71Sopenharmony_ci
5576e41f4b71Sopenharmony_ci obtainDistributedTableName(device: string, table: string): Promise&lt;string&gt;
5577e41f4b71Sopenharmony_ci
5578e41f4b71Sopenharmony_ciObtains the distributed table name of a remote device based on the local table name of the device. The distributed table name is required when the RDB store of a remote device is queried.
5579e41f4b71Sopenharmony_ci
5580e41f4b71Sopenharmony_ci> **NOTE**
5581e41f4b71Sopenharmony_ci>
5582e41f4b71Sopenharmony_ci> **device** can be obtained by [deviceManager.getAvailableDeviceListSync](../apis-distributedservice-kit/js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
5583e41f4b71Sopenharmony_ci
5584e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
5585e41f4b71Sopenharmony_ci
5586e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5587e41f4b71Sopenharmony_ci
5588e41f4b71Sopenharmony_ci**Parameters**
5589e41f4b71Sopenharmony_ci
5590e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                |
5591e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------- |
5592e41f4b71Sopenharmony_ci| device | string | Yes  | ID of the remote device.        |
5593e41f4b71Sopenharmony_ci| table  | string | Yes  | Local table name of the remote device.|
5594e41f4b71Sopenharmony_ci
5595e41f4b71Sopenharmony_ci**Return value**
5596e41f4b71Sopenharmony_ci
5597e41f4b71Sopenharmony_ci| Type                 | Description                                                 |
5598e41f4b71Sopenharmony_ci| --------------------- | ----------------------------------------------------- |
5599e41f4b71Sopenharmony_ci| Promise&lt;string&gt; | Promise used to return the result. If the operation succeeds, the distributed table name of the remote device is returned.|
5600e41f4b71Sopenharmony_ci
5601e41f4b71Sopenharmony_ci**Error codes**
5602e41f4b71Sopenharmony_ci
5603e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5604e41f4b71Sopenharmony_ci
5605e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
5606e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
5607e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5608e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
5609e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
5610e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
5611e41f4b71Sopenharmony_ci
5612e41f4b71Sopenharmony_ci**Example**
5613e41f4b71Sopenharmony_ci
5614e41f4b71Sopenharmony_ci```ts
5615e41f4b71Sopenharmony_ciimport { distributedDeviceManager } from '@kit.DistributedServiceKit';
5616e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5617e41f4b71Sopenharmony_ci
5618e41f4b71Sopenharmony_cilet dmInstance: distributedDeviceManager.DeviceManager;
5619e41f4b71Sopenharmony_cilet deviceId: string | undefined = undefined;
5620e41f4b71Sopenharmony_ci
5621e41f4b71Sopenharmony_citry {
5622e41f4b71Sopenharmony_ci  dmInstance = distributedDeviceManager.createDeviceManager("com.example.appdatamgrverify");
5623e41f4b71Sopenharmony_ci  let devices = dmInstance.getAvailableDeviceListSync();
5624e41f4b71Sopenharmony_ci  deviceId = devices[0].networkId;
5625e41f4b71Sopenharmony_ci} catch (err) {
5626e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
5627e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message
5628e41f4b71Sopenharmony_ci  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
5629e41f4b71Sopenharmony_ci}
5630e41f4b71Sopenharmony_ci
5631e41f4b71Sopenharmony_ciif(store != undefined && deviceId != undefined) {
5632e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).obtainDistributedTableName(deviceId, "EMPLOYEE").then((tableName: string) => {
5633e41f4b71Sopenharmony_ci    console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`);
5634e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
5635e41f4b71Sopenharmony_ci    console.error(`ObtainDistributedTableName failed, code is ${err.code},message is ${err.message}`);
5636e41f4b71Sopenharmony_ci  })
5637e41f4b71Sopenharmony_ci}
5638e41f4b71Sopenharmony_ci```
5639e41f4b71Sopenharmony_ci
5640e41f4b71Sopenharmony_ci### sync
5641e41f4b71Sopenharmony_ci
5642e41f4b71Sopenharmony_cisync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback&lt;Array&lt;[string, number]&gt;&gt;): void
5643e41f4b71Sopenharmony_ci
5644e41f4b71Sopenharmony_ciSynchronizes data between devices. This API uses an asynchronous callback to return the result.
5645e41f4b71Sopenharmony_ci
5646e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
5647e41f4b71Sopenharmony_ci
5648e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5649e41f4b71Sopenharmony_ci
5650e41f4b71Sopenharmony_ci**Parameters**
5651e41f4b71Sopenharmony_ci
5652e41f4b71Sopenharmony_ci| Name    | Type                                              | Mandatory| Description                                                        |
5653e41f4b71Sopenharmony_ci| ---------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ |
5654e41f4b71Sopenharmony_ci| mode       | [SyncMode](#syncmode)                             | Yes  | Data sync mode. The value can be **relationalStore.SyncMode.SYNC_MODE_PUSH** or **relationalStore.SyncMode.SYNC_MODE_PULL**.                              |
5655e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates)               | Yes  | **RdbPredicates** object that specifies the data and devices to synchronize.                                        |
5656e41f4b71Sopenharmony_ci| callback   | AsyncCallback&lt;Array&lt;[string, number]&gt;&gt; | Yes  | Callback used to send the sync result to the caller. <br>**string** indicates the device ID. <br>**number** indicates the sync status of that device. The value **0** indicates a successful sync. Other values indicate a sync failure. |
5657e41f4b71Sopenharmony_ci
5658e41f4b71Sopenharmony_ci**Error codes**
5659e41f4b71Sopenharmony_ci
5660e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5661e41f4b71Sopenharmony_ci
5662e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
5663e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
5664e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5665e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
5666e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
5667e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
5668e41f4b71Sopenharmony_ci
5669e41f4b71Sopenharmony_ci**Example**
5670e41f4b71Sopenharmony_ci
5671e41f4b71Sopenharmony_ci```ts
5672e41f4b71Sopenharmony_ciimport { distributedDeviceManager } from '@kit.DistributedServiceKit';
5673e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5674e41f4b71Sopenharmony_ci
5675e41f4b71Sopenharmony_cilet dmInstance: distributedDeviceManager.DeviceManager;
5676e41f4b71Sopenharmony_cilet deviceIds: Array<string> = [];
5677e41f4b71Sopenharmony_ci
5678e41f4b71Sopenharmony_citry {
5679e41f4b71Sopenharmony_ci  dmInstance = distributedDeviceManager.createDeviceManager("com.example.appdatamgrverify");
5680e41f4b71Sopenharmony_ci  let devices: Array<distributedDeviceManager.DeviceBasicInfo> = dmInstance.getAvailableDeviceListSync();
5681e41f4b71Sopenharmony_ci  for (let i = 0; i < devices.length; i++) {
5682e41f4b71Sopenharmony_ci    deviceIds[i] = devices[i].networkId!;
5683e41f4b71Sopenharmony_ci  }
5684e41f4b71Sopenharmony_ci} catch (err) {
5685e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
5686e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message
5687e41f4b71Sopenharmony_ci  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
5688e41f4b71Sopenharmony_ci}
5689e41f4b71Sopenharmony_ci
5690e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates('EMPLOYEE');
5691e41f4b71Sopenharmony_cipredicates.inDevices(deviceIds);
5692e41f4b71Sopenharmony_ciif(store != undefined) {
5693e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates, (err, result) => {
5694e41f4b71Sopenharmony_ci    if (err) {
5695e41f4b71Sopenharmony_ci      console.error(`Sync failed, code is ${err.code},message is ${err.message}`);
5696e41f4b71Sopenharmony_ci      return;
5697e41f4b71Sopenharmony_ci    }
5698e41f4b71Sopenharmony_ci    console.info('Sync done.');
5699e41f4b71Sopenharmony_ci    for (let i = 0; i < result.length; i++) {
5700e41f4b71Sopenharmony_ci      console.info(`device= ${result[i][0]}, status= ${result[i][1]}`);
5701e41f4b71Sopenharmony_ci    }
5702e41f4b71Sopenharmony_ci  })
5703e41f4b71Sopenharmony_ci}
5704e41f4b71Sopenharmony_ci```
5705e41f4b71Sopenharmony_ci
5706e41f4b71Sopenharmony_ci### sync
5707e41f4b71Sopenharmony_ci
5708e41f4b71Sopenharmony_ci sync(mode: SyncMode, predicates: RdbPredicates): Promise&lt;Array&lt;[string, number]&gt;&gt;
5709e41f4b71Sopenharmony_ci
5710e41f4b71Sopenharmony_ciSynchronizes data between devices. This API uses a promise to return the result.
5711e41f4b71Sopenharmony_ci
5712e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
5713e41f4b71Sopenharmony_ci
5714e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5715e41f4b71Sopenharmony_ci
5716e41f4b71Sopenharmony_ci**Parameters**
5717e41f4b71Sopenharmony_ci
5718e41f4b71Sopenharmony_ci| Name    | Type                                | Mandatory| Description                          |
5719e41f4b71Sopenharmony_ci| ---------- | ------------------------------------ | ---- | ------------------------------ |
5720e41f4b71Sopenharmony_ci| mode       | [SyncMode](#syncmode)               | Yes  | Data sync mode. The value can be **relationalStore.SyncMode.SYNC_MODE_PUSH** or **relationalStore.SyncMode.SYNC_MODE_PULL**.|
5721e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates) | Yes  | **RdbPredicates** object that specifies the data and devices to synchronize.          |
5722e41f4b71Sopenharmony_ci
5723e41f4b71Sopenharmony_ci**Return value**
5724e41f4b71Sopenharmony_ci
5725e41f4b71Sopenharmony_ci| Type                                        | Description                                                        |
5726e41f4b71Sopenharmony_ci| -------------------------------------------- | ------------------------------------------------------------ |
5727e41f4b71Sopenharmony_ci| Promise&lt;Array&lt;[string, number]&gt;&gt; | Promise used to send the sync result. <br>**string** indicates the device ID. <br>**number** indicates the sync status of that device. The value **0** indicates a successful sync. Other values indicate a sync failure.|
5728e41f4b71Sopenharmony_ci
5729e41f4b71Sopenharmony_ci**Error codes**
5730e41f4b71Sopenharmony_ci
5731e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5732e41f4b71Sopenharmony_ci
5733e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
5734e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
5735e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5736e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
5737e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
5738e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
5739e41f4b71Sopenharmony_ci
5740e41f4b71Sopenharmony_ci**Example**
5741e41f4b71Sopenharmony_ci
5742e41f4b71Sopenharmony_ci```ts
5743e41f4b71Sopenharmony_ciimport { distributedDeviceManager } from '@kit.DistributedServiceKit';
5744e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5745e41f4b71Sopenharmony_ci
5746e41f4b71Sopenharmony_cilet dmInstance: distributedDeviceManager.DeviceManager;
5747e41f4b71Sopenharmony_cilet deviceIds: Array<string> = [];
5748e41f4b71Sopenharmony_ci
5749e41f4b71Sopenharmony_citry {
5750e41f4b71Sopenharmony_ci  dmInstance = distributedDeviceManager.createDeviceManager("com.example.appdatamgrverify");
5751e41f4b71Sopenharmony_ci  let devices: Array<distributedDeviceManager.DeviceBasicInfo> = dmInstance.getAvailableDeviceListSync();
5752e41f4b71Sopenharmony_ci  for (let i = 0; i < devices.length; i++) {
5753e41f4b71Sopenharmony_ci    deviceIds[i] = devices[i].networkId!;
5754e41f4b71Sopenharmony_ci  }
5755e41f4b71Sopenharmony_ci} catch (err) {
5756e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
5757e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message
5758e41f4b71Sopenharmony_ci  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
5759e41f4b71Sopenharmony_ci}
5760e41f4b71Sopenharmony_ci
5761e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates('EMPLOYEE');
5762e41f4b71Sopenharmony_cipredicates.inDevices(deviceIds);
5763e41f4b71Sopenharmony_ciif(store != undefined) {
5764e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates).then((result: Object[][]) => {
5765e41f4b71Sopenharmony_ci    console.info('Sync done.');
5766e41f4b71Sopenharmony_ci    for (let i = 0; i < result.length; i++) {
5767e41f4b71Sopenharmony_ci      console.info(`device= ${result[i][0]}, status= ${result[i][1]}`);
5768e41f4b71Sopenharmony_ci    }
5769e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
5770e41f4b71Sopenharmony_ci    console.error(`Sync failed, code is ${err.code},message is ${err.message}`);
5771e41f4b71Sopenharmony_ci  })
5772e41f4b71Sopenharmony_ci}
5773e41f4b71Sopenharmony_ci```
5774e41f4b71Sopenharmony_ci
5775e41f4b71Sopenharmony_ci### cloudSync<sup>10+</sup>
5776e41f4b71Sopenharmony_ci
5777e41f4b71Sopenharmony_cicloudSync(mode: SyncMode, progress: Callback&lt;ProgressDetails&gt;, callback: AsyncCallback&lt;void&gt;): void
5778e41f4b71Sopenharmony_ci
5779e41f4b71Sopenharmony_ciManually starts device-cloud sync for all distributed tables. This API uses an asynchronous callback to return the result. Before using this API, ensure that the cloud service must be available.
5780e41f4b71Sopenharmony_ci
5781e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
5782e41f4b71Sopenharmony_ci
5783e41f4b71Sopenharmony_ci**Parameters**
5784e41f4b71Sopenharmony_ci
5785e41f4b71Sopenharmony_ci| Name  | Type                                                 | Mandatory| Description                                              |
5786e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------- | ---- | -------------------------------------------------- |
5787e41f4b71Sopenharmony_ci| mode     | [SyncMode](#syncmode)                                 | Yes  | Sync mode of the database.                            |
5788e41f4b71Sopenharmony_ci| progress | Callback&lt;[ProgressDetails](#progressdetails10)&gt; | Yes  | Callback used to process database sync details.            |
5789e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt;                             | Yes  | Callback used to send the sync result to the caller.|
5790e41f4b71Sopenharmony_ci
5791e41f4b71Sopenharmony_ci**Error codes**
5792e41f4b71Sopenharmony_ci
5793e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5794e41f4b71Sopenharmony_ci
5795e41f4b71Sopenharmony_ci| **ID**| **Error Message**       |
5796e41f4b71Sopenharmony_ci|-----------|-------|
5797e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Need 2 - 4  parameter(s). 2. The RdbStore must be not nullptr. 3. The mode must be a SyncMode of cloud. 4. The progress must be a callback type. 5. The callback must be a function. |
5798e41f4b71Sopenharmony_ci| 801       | Capability not supported.       |
5799e41f4b71Sopenharmony_ci| 14800014  | Already closed.        |
5800e41f4b71Sopenharmony_ci
5801e41f4b71Sopenharmony_ci**Example**
5802e41f4b71Sopenharmony_ci
5803e41f4b71Sopenharmony_ci```ts
5804e41f4b71Sopenharmony_ciif(store != undefined) {
5805e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, (progressDetails) => {
5806e41f4b71Sopenharmony_ci    console.info(`Progess: ${progressDetails}`);
5807e41f4b71Sopenharmony_ci  }, (err) => {
5808e41f4b71Sopenharmony_ci    if (err) {
5809e41f4b71Sopenharmony_ci      console.error(`Cloud sync failed, code is ${err.code},message is ${err.message}`);
5810e41f4b71Sopenharmony_ci      return;
5811e41f4b71Sopenharmony_ci    }
5812e41f4b71Sopenharmony_ci    console.info('Cloud sync succeeded');
5813e41f4b71Sopenharmony_ci  });
5814e41f4b71Sopenharmony_ci}
5815e41f4b71Sopenharmony_ci```
5816e41f4b71Sopenharmony_ci
5817e41f4b71Sopenharmony_ci### cloudSync<sup>10+</sup>
5818e41f4b71Sopenharmony_ci
5819e41f4b71Sopenharmony_cicloudSync(mode: SyncMode, progress: Callback&lt;ProgressDetails&gt;): Promise&lt;void&gt;
5820e41f4b71Sopenharmony_ci
5821e41f4b71Sopenharmony_ciManually starts device-cloud sync for all distributed tables. This API uses a promise to return the result. Before using this API, ensure that the cloud service must be available.
5822e41f4b71Sopenharmony_ci
5823e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
5824e41f4b71Sopenharmony_ci
5825e41f4b71Sopenharmony_ci**Parameters**
5826e41f4b71Sopenharmony_ci
5827e41f4b71Sopenharmony_ci| Name  | Type                                                 | Mandatory| Description                                  |
5828e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------- | ---- | -------------------------------------- |
5829e41f4b71Sopenharmony_ci| mode     | [SyncMode](#syncmode)                                 | Yes  | Sync mode of the database.                |
5830e41f4b71Sopenharmony_ci| progress | Callback&lt;[ProgressDetails](#progressdetails10)&gt; | Yes  | Callback used to process database sync details.|
5831e41f4b71Sopenharmony_ci
5832e41f4b71Sopenharmony_ci**Return value**
5833e41f4b71Sopenharmony_ci
5834e41f4b71Sopenharmony_ci| Type               | Description                                   |
5835e41f4b71Sopenharmony_ci| ------------------- | --------------------------------------- |
5836e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise used to send the sync result.|
5837e41f4b71Sopenharmony_ci
5838e41f4b71Sopenharmony_ci**Error codes**
5839e41f4b71Sopenharmony_ci
5840e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5841e41f4b71Sopenharmony_ci
5842e41f4b71Sopenharmony_ci| **ID**| **Error Message**   |
5843e41f4b71Sopenharmony_ci|-----------|------------------|
5844e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Need 2 - 4  parameter(s). 2. The RdbStore must be not nullptr. 3. The mode must be a SyncMode of cloud. 4. The progress must be a callback type. |
5845e41f4b71Sopenharmony_ci| 801       | Capability not supported.   |
5846e41f4b71Sopenharmony_ci| 14800014  | Already closed.           |
5847e41f4b71Sopenharmony_ci
5848e41f4b71Sopenharmony_ci**Example**
5849e41f4b71Sopenharmony_ci
5850e41f4b71Sopenharmony_ci```ts
5851e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5852e41f4b71Sopenharmony_ci
5853e41f4b71Sopenharmony_ciif(store != undefined) {
5854e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, (progressDetail: relationalStore.ProgressDetails) => {
5855e41f4b71Sopenharmony_ci    console.info(`progress: ${progressDetail}`);
5856e41f4b71Sopenharmony_ci  }).then(() => {
5857e41f4b71Sopenharmony_ci    console.info('Cloud sync succeeded');
5858e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
5859e41f4b71Sopenharmony_ci    console.error(`cloudSync failed, code is ${err.code},message is ${err.message}`);
5860e41f4b71Sopenharmony_ci  });
5861e41f4b71Sopenharmony_ci}
5862e41f4b71Sopenharmony_ci```
5863e41f4b71Sopenharmony_ci
5864e41f4b71Sopenharmony_ci### cloudSync<sup>10+</sup>
5865e41f4b71Sopenharmony_ci
5866e41f4b71Sopenharmony_cicloudSync(mode: SyncMode, tables: string[], progress: Callback&lt;ProgressDetails&gt;, callback: AsyncCallback&lt;void&gt;): void
5867e41f4b71Sopenharmony_ci
5868e41f4b71Sopenharmony_ciManually starts device-cloud sync of the specified table. This API uses an asynchronous callback to return the result. Before using this API, ensure that the cloud service must be available.
5869e41f4b71Sopenharmony_ci
5870e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
5871e41f4b71Sopenharmony_ci
5872e41f4b71Sopenharmony_ci**Parameters**
5873e41f4b71Sopenharmony_ci
5874e41f4b71Sopenharmony_ci| Name  | Type                                                 | Mandatory| Description                                              |
5875e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------- | ---- | -------------------------------------------------- |
5876e41f4b71Sopenharmony_ci| mode     | [SyncMode](#syncmode)                                 | Yes  | Sync mode of the database.                            |
5877e41f4b71Sopenharmony_ci| tables   | string[]                                              | Yes  | Name of the table to synchronize.                                  |
5878e41f4b71Sopenharmony_ci| progress | Callback&lt;[ProgressDetails](#progressdetails10)&gt; | Yes  | Callback used to process database sync details.            |
5879e41f4b71Sopenharmony_ci| callback | AsyncCallback&lt;void&gt;                             | Yes  | Callback used to send the sync result to the caller.|
5880e41f4b71Sopenharmony_ci
5881e41f4b71Sopenharmony_ci**Error codes**
5882e41f4b71Sopenharmony_ci
5883e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5884e41f4b71Sopenharmony_ci
5885e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                                                                                                                                 |
5886e41f4b71Sopenharmony_ci|-----------|-------|
5887e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Need 2 - 4  parameter(s). 2. The RdbStore must be not nullptr. 3. The mode must be a SyncMode of cloud. 4. The tablesNames must be not empty. 5. The progress must be a callback type. 6.The callback must be a function.|
5888e41f4b71Sopenharmony_ci| 801       | Capability not supported.   |
5889e41f4b71Sopenharmony_ci| 14800014  | Already closed.   |
5890e41f4b71Sopenharmony_ci
5891e41f4b71Sopenharmony_ci**Example**
5892e41f4b71Sopenharmony_ci
5893e41f4b71Sopenharmony_ci```ts
5894e41f4b71Sopenharmony_ciconst tables = ["table1", "table2"];
5895e41f4b71Sopenharmony_ci
5896e41f4b71Sopenharmony_ciif(store != undefined) {
5897e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, tables, (progressDetail: relationalStore.ProgressDetails) => {
5898e41f4b71Sopenharmony_ci    console.info(`Progess: ${progressDetail}`);
5899e41f4b71Sopenharmony_ci  }, (err) => {
5900e41f4b71Sopenharmony_ci    if (err) {
5901e41f4b71Sopenharmony_ci      console.error(`Cloud sync failed, code is ${err.code},message is ${err.message}`);
5902e41f4b71Sopenharmony_ci      return;
5903e41f4b71Sopenharmony_ci    }
5904e41f4b71Sopenharmony_ci    console.info('Cloud sync succeeded');
5905e41f4b71Sopenharmony_ci  });
5906e41f4b71Sopenharmony_ci};
5907e41f4b71Sopenharmony_ci```
5908e41f4b71Sopenharmony_ci
5909e41f4b71Sopenharmony_ci### cloudSync<sup>10+</sup>
5910e41f4b71Sopenharmony_ci
5911e41f4b71Sopenharmony_cicloudSync(mode: SyncMode, tables: string[], progress: Callback&lt;ProgressDetails&gt;): Promise&lt;void&gt;
5912e41f4b71Sopenharmony_ci
5913e41f4b71Sopenharmony_ciManually starts device-cloud sync of the specified table. This API uses a promise to return the result. Before using this API, ensure that the cloud service must be available.
5914e41f4b71Sopenharmony_ci
5915e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
5916e41f4b71Sopenharmony_ci
5917e41f4b71Sopenharmony_ci**Parameters**
5918e41f4b71Sopenharmony_ci
5919e41f4b71Sopenharmony_ci| Name  | Type                                                 | Mandatory| Description                                  |
5920e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------- | ---- | -------------------------------------- |
5921e41f4b71Sopenharmony_ci| mode     | [SyncMode](#syncmode)                                 | Yes  | Sync mode of the database.                |
5922e41f4b71Sopenharmony_ci| tables   | string[]                                              | Yes  | Name of the table to synchronize.                      |
5923e41f4b71Sopenharmony_ci| progress | Callback&lt;[ProgressDetails](#progressdetails10)&gt; | Yes  | Callback used to process database sync details.|
5924e41f4b71Sopenharmony_ci
5925e41f4b71Sopenharmony_ci**Return value**
5926e41f4b71Sopenharmony_ci
5927e41f4b71Sopenharmony_ci| Type               | Description                                   |
5928e41f4b71Sopenharmony_ci| ------------------- | --------------------------------------- |
5929e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise used to send the sync result.|
5930e41f4b71Sopenharmony_ci
5931e41f4b71Sopenharmony_ci**Error codes**
5932e41f4b71Sopenharmony_ci
5933e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5934e41f4b71Sopenharmony_ci
5935e41f4b71Sopenharmony_ci| **ID**| **Error Message**    |
5936e41f4b71Sopenharmony_ci|-----------|---------------|
5937e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Need 2 - 4  parameter(s). 2. The RdbStore must be not nullptr. 3. The mode must be a SyncMode of cloud. 4. The tablesNames must be not empty. 5. The progress must be a callback type |
5938e41f4b71Sopenharmony_ci| 801       | Capability not supported.    |
5939e41f4b71Sopenharmony_ci| 14800014  | Already closed.  |
5940e41f4b71Sopenharmony_ci
5941e41f4b71Sopenharmony_ci**Example**
5942e41f4b71Sopenharmony_ci
5943e41f4b71Sopenharmony_ci```ts
5944e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5945e41f4b71Sopenharmony_ci
5946e41f4b71Sopenharmony_ciconst tables = ["table1", "table2"];
5947e41f4b71Sopenharmony_ci
5948e41f4b71Sopenharmony_ciif(store != undefined) {
5949e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, tables, (progressDetail: relationalStore.ProgressDetails) => {
5950e41f4b71Sopenharmony_ci    console.info(`progress: ${progressDetail}`);
5951e41f4b71Sopenharmony_ci  }).then(() => {
5952e41f4b71Sopenharmony_ci    console.info('Cloud sync succeeded');
5953e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
5954e41f4b71Sopenharmony_ci    console.error(`cloudSync failed, code is ${err.code},message is ${err.message}`);
5955e41f4b71Sopenharmony_ci  });
5956e41f4b71Sopenharmony_ci};
5957e41f4b71Sopenharmony_ci```
5958e41f4b71Sopenharmony_ci
5959e41f4b71Sopenharmony_ci### on('dataChange')
5960e41f4b71Sopenharmony_ci
5961e41f4b71Sopenharmony_cion(event: 'dataChange', type: SubscribeType, observer: Callback&lt;Array&lt;string&gt;&gt;): void
5962e41f4b71Sopenharmony_ci
5963e41f4b71Sopenharmony_ciSubscribes to data changes of specified devices. When the data of the specified devices changes, a callback is invoked to return the data change.
5964e41f4b71Sopenharmony_ci
5965e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5966e41f4b71Sopenharmony_ci
5967e41f4b71Sopenharmony_ci**Parameters**
5968e41f4b71Sopenharmony_ci
5969e41f4b71Sopenharmony_ci| Name  | Type                                                        | Mandatory| Description                                                        |
5970e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
5971e41f4b71Sopenharmony_ci| event    | string                                                       | Yes  | Event type. The value is **'dataChange'**, which indicates data changes.                          |
5972e41f4b71Sopenharmony_ci| type     | [SubscribeType](#subscribetype)                              | Yes  | Type of data change to observe.                                                  |
5973e41f4b71Sopenharmony_ci| observer | Callback&lt;Array&lt;string&gt;&gt;                          | Yes  | Callback used to return the data change. Array&lt;string&gt; holds the IDs of the peer devices whose data is changed. |
5974e41f4b71Sopenharmony_ci
5975e41f4b71Sopenharmony_ci**Error codes**
5976e41f4b71Sopenharmony_ci
5977e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5978e41f4b71Sopenharmony_ci
5979e41f4b71Sopenharmony_ci| **ID**| **Error Message**       |
5980e41f4b71Sopenharmony_ci|-----------|-------------|
5981e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5982e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
5983e41f4b71Sopenharmony_ci| 14800014  | Already closed.    |
5984e41f4b71Sopenharmony_ci
5985e41f4b71Sopenharmony_ci**Example**
5986e41f4b71Sopenharmony_ci
5987e41f4b71Sopenharmony_ci```ts
5988e41f4b71Sopenharmony_ciimport { distributedDeviceManager } from '@kit.DistributedServiceKit';
5989e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
5990e41f4b71Sopenharmony_ci
5991e41f4b71Sopenharmony_cilet storeObserver = (devices: Array<string>) => {
5992e41f4b71Sopenharmony_ci  if (devices != undefined) {
5993e41f4b71Sopenharmony_ci    for (let i = 0; i < devices.length; i++) {
5994e41f4b71Sopenharmony_ci      console.info(`device= ${devices[i]} data changed`);
5995e41f4b71Sopenharmony_ci    }
5996e41f4b71Sopenharmony_ci  }
5997e41f4b71Sopenharmony_ci}
5998e41f4b71Sopenharmony_ci
5999e41f4b71Sopenharmony_citry {
6000e41f4b71Sopenharmony_ci  if (store != undefined) {
6001e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver)
6002e41f4b71Sopenharmony_ci  }
6003e41f4b71Sopenharmony_ci} catch (err) {
6004e41f4b71Sopenharmony_ci    let code = (err as BusinessError).code;
6005e41f4b71Sopenharmony_ci    let message = (err as BusinessError).message
6006e41f4b71Sopenharmony_ci    console.error(`Register observer failed, code is ${code},message is ${message}`);
6007e41f4b71Sopenharmony_ci}
6008e41f4b71Sopenharmony_ci```
6009e41f4b71Sopenharmony_ci
6010e41f4b71Sopenharmony_ci### on('dataChange')<sup>10+</sup>
6011e41f4b71Sopenharmony_ci
6012e41f4b71Sopenharmony_cion(event: 'dataChange', type: SubscribeType, observer: Callback&lt;Array&lt;string&gt;&gt;\| Callback&lt;Array&lt;ChangeInfo&gt;&gt;): void
6013e41f4b71Sopenharmony_ci
6014e41f4b71Sopenharmony_ciSubscribes to data changes of specified devices. A callback is called when data in a distributed or local RDB store changes.
6015e41f4b71Sopenharmony_ci
6016e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6017e41f4b71Sopenharmony_ci
6018e41f4b71Sopenharmony_ci**Parameters**
6019e41f4b71Sopenharmony_ci
6020e41f4b71Sopenharmony_ci| Name  | Type                               | Mandatory| Description                                       |
6021e41f4b71Sopenharmony_ci| -------- | ----------------------------------- | ---- | ------------------------------------------- |
6022e41f4b71Sopenharmony_ci| event    | string                              | Yes  | Event type. The value is **'dataChange'**, which indicates data changes.         |
6023e41f4b71Sopenharmony_ci| type     | [SubscribeType](#subscribetype)    | Yes  | Type of data change to observe.|
6024e41f4b71Sopenharmony_ci| observer | Callback&lt;Array&lt;string&gt;&gt; \| Callback&lt;Array&lt;[ChangeInfo](#changeinfo10)&gt;&gt; | Yes  | Callback used to return the data change.<br>- If **type** is **SUBSCRIBE_TYPE_REMOTE**, **observer** must be **Callback&lt;Array&lt;string&gt;&gt;**, where **Array&lt;string&gt;** holds the IDs of the peer devices with data changes.<br> - If **type** is **SUBSCRIBE_TYPE_CLOUD**, **observer** must be **Callback&lt;Array&lt;string&gt;&gt;**, where **Array&lt;string&gt;** holds the cloud accounts with data changes.<br> - If **type** is **SUBSCRIBE_TYPE_CLOUD_DETAILS**, **observer** must be **Callback&lt;Array&lt;ChangeInfo&gt;&gt;**, where **Array&lt;ChangeInfo&gt;** holds the details about the device-cloud sync.<br>If **type** is **SUBSCRIBE_TYPE_LOCAL_DETAILS**, **observer** must be **Callback&lt;Array&lt;ChangeInfo&gt;&gt;**, where **Array&lt;ChangeInfo&gt;** holds the data change details in the local RDB store.|
6025e41f4b71Sopenharmony_ci
6026e41f4b71Sopenharmony_ci**Error codes**
6027e41f4b71Sopenharmony_ci
6028e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6029e41f4b71Sopenharmony_ci
6030e41f4b71Sopenharmony_ci| **ID**| **Error Message**       |
6031e41f4b71Sopenharmony_ci|-----------|-------------|
6032e41f4b71Sopenharmony_ci| 202       | Permission verification failed, application which is not a system application uses system API. |
6033e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
6034e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
6035e41f4b71Sopenharmony_ci| 14800014  | Already closed.    |
6036e41f4b71Sopenharmony_ci
6037e41f4b71Sopenharmony_ciExample 1: **type** is **SUBSCRIBE_TYPE_REMOTE**.
6038e41f4b71Sopenharmony_ci
6039e41f4b71Sopenharmony_ci```ts
6040e41f4b71Sopenharmony_ciimport { distributedDeviceManager } from '@kit.DistributedServiceKit';
6041e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6042e41f4b71Sopenharmony_ci
6043e41f4b71Sopenharmony_cilet storeObserver = (devices: Array<string>) => {
6044e41f4b71Sopenharmony_ci  if (devices != undefined) {
6045e41f4b71Sopenharmony_ci    for (let i = 0; i < devices.length; i++) {
6046e41f4b71Sopenharmony_ci      console.info(`device= ${devices[i]} data changed`);
6047e41f4b71Sopenharmony_ci    }
6048e41f4b71Sopenharmony_ci  }
6049e41f4b71Sopenharmony_ci}
6050e41f4b71Sopenharmony_ci
6051e41f4b71Sopenharmony_citry {
6052e41f4b71Sopenharmony_ci  if(store != undefined) {
6053e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver);
6054e41f4b71Sopenharmony_ci  }
6055e41f4b71Sopenharmony_ci} catch (err) {
6056e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
6057e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
6058e41f4b71Sopenharmony_ci  console.error(`Register observer failed, code is ${code},message is ${message}`);
6059e41f4b71Sopenharmony_ci}
6060e41f4b71Sopenharmony_ci```
6061e41f4b71Sopenharmony_ci
6062e41f4b71Sopenharmony_ciExample 2: **type** is **SUBSCRIBE_TYPE_LOCAL_DETAILS**.
6063e41f4b71Sopenharmony_ci
6064e41f4b71Sopenharmony_ci```ts
6065e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6066e41f4b71Sopenharmony_ci
6067e41f4b71Sopenharmony_cilet changeInfos = (changeInfos: Array<relationalStore.ChangeInfo>) => {
6068e41f4b71Sopenharmony_ci  for (let i = 0; i < changeInfos.length; i++) {
6069e41f4b71Sopenharmony_ci    console.info(`changeInfos = ${changeInfos[i]}`);
6070e41f4b71Sopenharmony_ci  }
6071e41f4b71Sopenharmony_ci}
6072e41f4b71Sopenharmony_ci
6073e41f4b71Sopenharmony_citry {
6074e41f4b71Sopenharmony_ci  if(store != undefined) {
6075e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_LOCAL_DETAILS, changeInfos);
6076e41f4b71Sopenharmony_ci  }
6077e41f4b71Sopenharmony_ci} catch (err) {
6078e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
6079e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
6080e41f4b71Sopenharmony_ci  console.error(`on dataChange fail, code is ${code},message is ${message}`);
6081e41f4b71Sopenharmony_ci}
6082e41f4b71Sopenharmony_ci
6083e41f4b71Sopenharmony_cilet value1 = "Lisa";
6084e41f4b71Sopenharmony_cilet value2 = 18;
6085e41f4b71Sopenharmony_cilet value3 = 100.5;
6086e41f4b71Sopenharmony_cilet value4 = new Uint8Array([1, 2, 3]);
6087e41f4b71Sopenharmony_ci
6088e41f4b71Sopenharmony_citry {
6089e41f4b71Sopenharmony_ci  const valueBucket: relationalStore.ValuesBucket = {
6090e41f4b71Sopenharmony_ci    'name': value1,
6091e41f4b71Sopenharmony_ci    'age': value2,
6092e41f4b71Sopenharmony_ci    'salary': value3,
6093e41f4b71Sopenharmony_ci    'blobType': value4,
6094e41f4b71Sopenharmony_ci  };
6095e41f4b71Sopenharmony_ci
6096e41f4b71Sopenharmony_ci  if(store != undefined) {
6097e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).insert('test', valueBucket);
6098e41f4b71Sopenharmony_ci  }
6099e41f4b71Sopenharmony_ci} catch (err) {
6100e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
6101e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
6102e41f4b71Sopenharmony_ci  console.error(`insert fail, code is ${code},message is ${message}`);
6103e41f4b71Sopenharmony_ci}
6104e41f4b71Sopenharmony_ci```
6105e41f4b71Sopenharmony_ci
6106e41f4b71Sopenharmony_ci### on<sup>10+</sup>
6107e41f4b71Sopenharmony_ci
6108e41f4b71Sopenharmony_cion(event: string, interProcess: boolean, observer: Callback\<void>): void
6109e41f4b71Sopenharmony_ci
6110e41f4b71Sopenharmony_ciSubscribes to process events. This callback is invoked by [emit](#emit10).
6111e41f4b71Sopenharmony_ci
6112e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6113e41f4b71Sopenharmony_ci
6114e41f4b71Sopenharmony_ci**Parameters**
6115e41f4b71Sopenharmony_ci
6116e41f4b71Sopenharmony_ci| Name      | Type           | Mandatory| Description                                                        |
6117e41f4b71Sopenharmony_ci| ------------ | --------------- | ---- | ------------------------------------------------------------ |
6118e41f4b71Sopenharmony_ci| event        | string          | Yes  | Event name to observe.                                              |
6119e41f4b71Sopenharmony_ci| interProcess | boolean         | Yes  | Type of the data to observe.<br> The value **true** means inter-process events.<br> The value **false** means intra-process events.|
6120e41f4b71Sopenharmony_ci| observer     | Callback\<void> | Yes  | Callback used to return the result.                                                  |
6121e41f4b71Sopenharmony_ci
6122e41f4b71Sopenharmony_ci**Error codes**
6123e41f4b71Sopenharmony_ci
6124e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6125e41f4b71Sopenharmony_ci
6126e41f4b71Sopenharmony_ci| **ID**| **Error Message**       |
6127e41f4b71Sopenharmony_ci|-----------|-------------|
6128e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
6129e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
6130e41f4b71Sopenharmony_ci| 14800000  | Inner error.    |
6131e41f4b71Sopenharmony_ci| 14800014  | Already closed.    |
6132e41f4b71Sopenharmony_ci| 14800050  | Failed to obtain subscription service.    |
6133e41f4b71Sopenharmony_ci
6134e41f4b71Sopenharmony_ci**Example**
6135e41f4b71Sopenharmony_ci
6136e41f4b71Sopenharmony_ci```ts
6137e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6138e41f4b71Sopenharmony_ci
6139e41f4b71Sopenharmony_cilet storeObserver = () => {
6140e41f4b71Sopenharmony_ci  console.info(`storeObserver`);
6141e41f4b71Sopenharmony_ci}
6142e41f4b71Sopenharmony_ci
6143e41f4b71Sopenharmony_citry {
6144e41f4b71Sopenharmony_ci  if(store != undefined) {
6145e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).on('storeObserver', false, storeObserver);
6146e41f4b71Sopenharmony_ci  }
6147e41f4b71Sopenharmony_ci} catch (err) {
6148e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
6149e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message
6150e41f4b71Sopenharmony_ci  console.error(`Register observer failed, code is ${code},message is ${message}`);
6151e41f4b71Sopenharmony_ci}
6152e41f4b71Sopenharmony_ci```
6153e41f4b71Sopenharmony_ci
6154e41f4b71Sopenharmony_ci### on('autoSyncProgress')<sup>11+</sup>
6155e41f4b71Sopenharmony_ci
6156e41f4b71Sopenharmony_cion(event: 'autoSyncProgress', progress: Callback&lt;ProgressDetails&gt;): void
6157e41f4b71Sopenharmony_ci
6158e41f4b71Sopenharmony_ciSubscribes to the auto sync progress. This API can be called only when device-cloud sync is enabled and the network connection is normal. When auto sync is performed, a callback will be invoked to send a notification of the sync progress.
6159e41f4b71Sopenharmony_ci
6160e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6161e41f4b71Sopenharmony_ci
6162e41f4b71Sopenharmony_ci**Parameters**
6163e41f4b71Sopenharmony_ci
6164e41f4b71Sopenharmony_ci| Name      | Type                             | Mandatory| Description                               |
6165e41f4b71Sopenharmony_ci| ------------ |---------------------------------| ---- |-----------------------------------|
6166e41f4b71Sopenharmony_ci| event        | string                          | Yes  | Event type. The value is **'autoSyncProgress'**, which indicates the auto sync progress.|
6167e41f4b71Sopenharmony_ci| progress     | Callback&lt;[ProgressDetails](#progressdetails10)&gt; | Yes  | Callback used to return the auto sync progress.                            |
6168e41f4b71Sopenharmony_ci
6169e41f4b71Sopenharmony_ci**Error codes**
6170e41f4b71Sopenharmony_ci
6171e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6172e41f4b71Sopenharmony_ci
6173e41f4b71Sopenharmony_ci| **ID**| **Error Message**   |
6174e41f4b71Sopenharmony_ci|-----------|--------|
6175e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Need 2 - 3  parameter(s)! 2. The RdbStore must be valid. 3. The event must be a not empty string. 4. The progress must be function. |
6176e41f4b71Sopenharmony_ci| 801       | Capability not supported.  |
6177e41f4b71Sopenharmony_ci| 14800014  | Already closed.     |
6178e41f4b71Sopenharmony_ci
6179e41f4b71Sopenharmony_ci**Example**
6180e41f4b71Sopenharmony_ci
6181e41f4b71Sopenharmony_ci```ts
6182e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6183e41f4b71Sopenharmony_ci
6184e41f4b71Sopenharmony_cilet progressDetail = (progressDetail: relationalStore.ProgressDetails) => {
6185e41f4b71Sopenharmony_ci  console.info(`progress: ${progressDetail}`);
6186e41f4b71Sopenharmony_ci}
6187e41f4b71Sopenharmony_ci
6188e41f4b71Sopenharmony_citry {
6189e41f4b71Sopenharmony_ci  if(store != undefined) {
6190e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).on('autoSyncProgress', progressDetail)
6191e41f4b71Sopenharmony_ci  }
6192e41f4b71Sopenharmony_ci} catch (err) {
6193e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
6194e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message
6195e41f4b71Sopenharmony_ci  console.error(`Register observer failed, code is ${code},message is ${message}`);
6196e41f4b71Sopenharmony_ci}
6197e41f4b71Sopenharmony_ci```
6198e41f4b71Sopenharmony_ci
6199e41f4b71Sopenharmony_ci### on('statistics')<sup>12+</sup>
6200e41f4b71Sopenharmony_ci
6201e41f4b71Sopenharmony_cion(event: 'statistics', observer: Callback&lt;SqlExecutionInfo&gt;): void
6202e41f4b71Sopenharmony_ci
6203e41f4b71Sopenharmony_ciSubscribes to SQL statistics.
6204e41f4b71Sopenharmony_ci
6205e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6206e41f4b71Sopenharmony_ci
6207e41f4b71Sopenharmony_ci**Parameters**
6208e41f4b71Sopenharmony_ci
6209e41f4b71Sopenharmony_ci| Name      | Type                             | Mandatory| Description                               |
6210e41f4b71Sopenharmony_ci| ------------ |---------------------------------| ---- |-----------------------------------|
6211e41f4b71Sopenharmony_ci| event        | string                          | Yes  | Event type. The value is **statistics**, which indicates the statistics of the SQL execution time.|
6212e41f4b71Sopenharmony_ci| observer     | Callback&lt;[SqlExecutionInfo](#sqlexecutioninfo12)&gt; | Yes  | Callback used to return the statistics about the SQL execution time in the database. |
6213e41f4b71Sopenharmony_ci
6214e41f4b71Sopenharmony_ci**Error codes**
6215e41f4b71Sopenharmony_ci
6216e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6217e41f4b71Sopenharmony_ci
6218e41f4b71Sopenharmony_ci| **ID**| **Error Message**   |
6219e41f4b71Sopenharmony_ci|-----------|--------|
6220e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
6221e41f4b71Sopenharmony_ci| 801       | Capability not supported.  |
6222e41f4b71Sopenharmony_ci| 14800000  | Inner error.  |
6223e41f4b71Sopenharmony_ci| 14800014  | Already closed.     |
6224e41f4b71Sopenharmony_ci
6225e41f4b71Sopenharmony_ci**Example**
6226e41f4b71Sopenharmony_ci
6227e41f4b71Sopenharmony_ci```ts
6228e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6229e41f4b71Sopenharmony_ci
6230e41f4b71Sopenharmony_cilet sqlExecutionInfo = (sqlExecutionInfo: relationalStore.SqlExecutionInfo) => {
6231e41f4b71Sopenharmony_ci  console.info(`sql: ${sqlExecutionInfo.sql[0]}`);
6232e41f4b71Sopenharmony_ci  console.info(`totalTime: ${sqlExecutionInfo.totalTime}`);
6233e41f4b71Sopenharmony_ci  console.info(`waitTime: ${sqlExecutionInfo.waitTime}`);
6234e41f4b71Sopenharmony_ci  console.info(`prepareTime: ${sqlExecutionInfo.prepareTime}`);
6235e41f4b71Sopenharmony_ci  console.info(`executeTime: ${sqlExecutionInfo.executeTime}`);
6236e41f4b71Sopenharmony_ci}
6237e41f4b71Sopenharmony_ci
6238e41f4b71Sopenharmony_citry {
6239e41f4b71Sopenharmony_ci  if(store != undefined) {
6240e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).on('statistics', sqlExecutionInfo);
6241e41f4b71Sopenharmony_ci  }
6242e41f4b71Sopenharmony_ci} catch (err) {
6243e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
6244e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
6245e41f4b71Sopenharmony_ci  console.error(`Register observer failed, code is ${code},message is ${message}`);
6246e41f4b71Sopenharmony_ci}
6247e41f4b71Sopenharmony_ci
6248e41f4b71Sopenharmony_citry {
6249e41f4b71Sopenharmony_ci  let value1 = "Lisa";
6250e41f4b71Sopenharmony_ci  let value2 = 18;
6251e41f4b71Sopenharmony_ci  let value3 = 100.5;
6252e41f4b71Sopenharmony_ci  let value4 = new Uint8Array([1, 2, 3, 4, 5]);
6253e41f4b71Sopenharmony_ci
6254e41f4b71Sopenharmony_ci  const valueBucket: relationalStore.ValuesBucket = {
6255e41f4b71Sopenharmony_ci    'NAME': value1,
6256e41f4b71Sopenharmony_ci    'AGE': value2,
6257e41f4b71Sopenharmony_ci    'SALARY': value3,
6258e41f4b71Sopenharmony_ci    'CODES': value4,
6259e41f4b71Sopenharmony_ci  };
6260e41f4b71Sopenharmony_ci  if(store != undefined) {
6261e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).insert('test', valueBucket);
6262e41f4b71Sopenharmony_ci  }
6263e41f4b71Sopenharmony_ci} catch (err) {
6264e41f4b71Sopenharmony_ci  console.error(`insert fail, code:${err.code}, message: ${err.message}`);
6265e41f4b71Sopenharmony_ci}
6266e41f4b71Sopenharmony_ci```
6267e41f4b71Sopenharmony_ci
6268e41f4b71Sopenharmony_ci### off('dataChange')
6269e41f4b71Sopenharmony_ci
6270e41f4b71Sopenharmony_cioff(event:'dataChange', type: SubscribeType, observer: Callback&lt;Array&lt;string&gt;&gt;): void
6271e41f4b71Sopenharmony_ci
6272e41f4b71Sopenharmony_ciUnsubscribes from data changes of the specified devices.
6273e41f4b71Sopenharmony_ci
6274e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6275e41f4b71Sopenharmony_ci
6276e41f4b71Sopenharmony_ci**Parameters**
6277e41f4b71Sopenharmony_ci
6278e41f4b71Sopenharmony_ci| Name  | Type                                                        | Mandatory| Description                                                        |
6279e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
6280e41f4b71Sopenharmony_ci| event    | string                                                       | Yes  | Event type. The value is **'dataChange'**, which indicates data changes.                          |
6281e41f4b71Sopenharmony_ci| type     | [SubscribeType](#subscribetype) | Yes  | Type of data change to observe.                                                  |
6282e41f4b71Sopenharmony_ci| observer | Callback&lt;Array&lt;string&gt;&gt;                          | Yes  | Callback to unregister. Array&lt;string&gt; holds the IDs of the peer devices whose data is changed.|
6283e41f4b71Sopenharmony_ci
6284e41f4b71Sopenharmony_ci**Error codes**
6285e41f4b71Sopenharmony_ci
6286e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6287e41f4b71Sopenharmony_ci
6288e41f4b71Sopenharmony_ci| **ID**| **Error Message**       |
6289e41f4b71Sopenharmony_ci|-----------|-------------|
6290e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
6291e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
6292e41f4b71Sopenharmony_ci| 14800014  | Already closed.    |
6293e41f4b71Sopenharmony_ci
6294e41f4b71Sopenharmony_ci**Example**
6295e41f4b71Sopenharmony_ci
6296e41f4b71Sopenharmony_ci```ts
6297e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6298e41f4b71Sopenharmony_ci
6299e41f4b71Sopenharmony_cilet storeObserver = (devices: Array<string>) => {
6300e41f4b71Sopenharmony_ci  if (devices != undefined) {
6301e41f4b71Sopenharmony_ci    for (let i = 0; i < devices.length; i++) {
6302e41f4b71Sopenharmony_ci      console.info(`device= ${devices[i]} data changed`);
6303e41f4b71Sopenharmony_ci    }
6304e41f4b71Sopenharmony_ci  }
6305e41f4b71Sopenharmony_ci}
6306e41f4b71Sopenharmony_ci
6307e41f4b71Sopenharmony_citry {
6308e41f4b71Sopenharmony_ci  if (store != undefined) {
6309e41f4b71Sopenharmony_ci    // The Lambda expression cannot be used here.
6310e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver)
6311e41f4b71Sopenharmony_ci  }
6312e41f4b71Sopenharmony_ci} catch (err) {
6313e41f4b71Sopenharmony_ci    let code = (err as BusinessError).code;
6314e41f4b71Sopenharmony_ci    let message = (err as BusinessError).message
6315e41f4b71Sopenharmony_ci    console.error(`Register observer failed, code is ${code},message is ${message}`);
6316e41f4b71Sopenharmony_ci}
6317e41f4b71Sopenharmony_ci
6318e41f4b71Sopenharmony_citry {
6319e41f4b71Sopenharmony_ci  if(store != undefined) {
6320e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).off('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver);
6321e41f4b71Sopenharmony_ci  }
6322e41f4b71Sopenharmony_ci} catch (err) {
6323e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
6324e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message
6325e41f4b71Sopenharmony_ci  console.error(`Unregister observer failed, code is ${code},message is ${message}`);
6326e41f4b71Sopenharmony_ci}
6327e41f4b71Sopenharmony_ci```
6328e41f4b71Sopenharmony_ci
6329e41f4b71Sopenharmony_ci### off('dataChange')<sup>10+</sup>
6330e41f4b71Sopenharmony_ci
6331e41f4b71Sopenharmony_cioff(event:'dataChange', type: SubscribeType, observer?: Callback&lt;Array&lt;string&gt;&gt;\| Callback&lt;Array&lt;ChangeInfo&gt;&gt;): void
6332e41f4b71Sopenharmony_ci
6333e41f4b71Sopenharmony_ciUnsubscribes from data changes of this RDB store.
6334e41f4b71Sopenharmony_ci
6335e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6336e41f4b71Sopenharmony_ci
6337e41f4b71Sopenharmony_ci**Parameters**
6338e41f4b71Sopenharmony_ci
6339e41f4b71Sopenharmony_ci| Name  | Type                               | Mandatory| Description                                       |
6340e41f4b71Sopenharmony_ci| -------- | ---------------------------------- | ---- | ------------------------------------------ |
6341e41f4b71Sopenharmony_ci| event    | string                              | Yes  | Event type. The value is **'dataChange'**, which indicates data changes.         |
6342e41f4b71Sopenharmony_ci| type     | [SubscribeType](#subscribetype)     | Yes  | Type of data change to observe.                                |
6343e41f4b71Sopenharmony_ci| observer | Callback&lt;Array&lt;string&gt;&gt;\| Callback&lt;Array&lt;[ChangeInfo](#changeinfo10)&gt;&gt; | No| Callback to unregister.<br>- If **type** is **SUBSCRIBE_TYPE_REMOTE**, **observer** must be **Callback&lt;Array&lt;string&gt;&gt;**, where **Array&lt;string&gt;** holds the IDs of the peer devices with data changes.<br> - If **type** is **SUBSCRIBE_TYPE_CLOUD**, **observer** must be **Callback&lt;Array&lt;string&gt;&gt;**, where **Array&lt;string&gt;** holds the cloud accounts with data changes.<br> - If **type** is **SUBSCRIBE_TYPE_CLOUD_DETAILS**, **observer** must be **Callback&lt;Array&lt;ChangeInfo&gt;&gt;**, where **Array&lt;ChangeInfo&gt;** holds the details about the device-cloud sync.<br>- If **type** is **SUBSCRIBE_TYPE_LOCAL_DETAILS**, **observer** must be **Callback&lt;Array&lt;ChangeInfo&gt;&gt;**, where **Array&lt;ChangeInfo&gt;** holds the data change details in the local RDB store.<br> If **observer** is not specified, this API unregisters all callbacks for data changes of the specified **type**.|
6344e41f4b71Sopenharmony_ci
6345e41f4b71Sopenharmony_ci**Error codes**
6346e41f4b71Sopenharmony_ci
6347e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6348e41f4b71Sopenharmony_ci
6349e41f4b71Sopenharmony_ci| **ID**| **Error Message**       |
6350e41f4b71Sopenharmony_ci|-----------|-------------|
6351e41f4b71Sopenharmony_ci| 202       | Permission verification failed, application which is not a system application uses system API. |
6352e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
6353e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
6354e41f4b71Sopenharmony_ci| 14800014  | Already closed.    |
6355e41f4b71Sopenharmony_ci
6356e41f4b71Sopenharmony_ci**Example**
6357e41f4b71Sopenharmony_ci
6358e41f4b71Sopenharmony_ci```ts
6359e41f4b71Sopenharmony_ciimport { distributedDeviceManager } from '@kit.DistributedServiceKit';
6360e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6361e41f4b71Sopenharmony_ci
6362e41f4b71Sopenharmony_cilet storeObserver = (devices: Array<string>) => {
6363e41f4b71Sopenharmony_ci  if (devices != undefined) {
6364e41f4b71Sopenharmony_ci    for (let i = 0; i < devices.length; i++) {
6365e41f4b71Sopenharmony_ci      console.info(`device= ${devices[i]} data changed`);
6366e41f4b71Sopenharmony_ci    }
6367e41f4b71Sopenharmony_ci  }
6368e41f4b71Sopenharmony_ci}
6369e41f4b71Sopenharmony_ci
6370e41f4b71Sopenharmony_citry {
6371e41f4b71Sopenharmony_ci  if(store != undefined) {
6372e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver);
6373e41f4b71Sopenharmony_ci  }
6374e41f4b71Sopenharmony_ci} catch (err) {
6375e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
6376e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
6377e41f4b71Sopenharmony_ci  console.error(`Register observer failed, code is ${code},message is ${message}`);
6378e41f4b71Sopenharmony_ci}
6379e41f4b71Sopenharmony_ci
6380e41f4b71Sopenharmony_citry {
6381e41f4b71Sopenharmony_ci  if(store != undefined) {
6382e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).off('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver);
6383e41f4b71Sopenharmony_ci  }
6384e41f4b71Sopenharmony_ci} catch (err) {
6385e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
6386e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message
6387e41f4b71Sopenharmony_ci  console.error(`Unregister observer failed, code is ${code},message is ${message}`);
6388e41f4b71Sopenharmony_ci}
6389e41f4b71Sopenharmony_ci```
6390e41f4b71Sopenharmony_ci
6391e41f4b71Sopenharmony_ci### off<sup>10+</sup>
6392e41f4b71Sopenharmony_ci
6393e41f4b71Sopenharmony_cioff(event: string, interProcess: boolean, observer?: Callback\<void>): void
6394e41f4b71Sopenharmony_ci
6395e41f4b71Sopenharmony_ciUnsubscribes from process events.
6396e41f4b71Sopenharmony_ci
6397e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6398e41f4b71Sopenharmony_ci
6399e41f4b71Sopenharmony_ci**Parameters**
6400e41f4b71Sopenharmony_ci
6401e41f4b71Sopenharmony_ci| Name      | Type           | Mandatory| Description                                                        |
6402e41f4b71Sopenharmony_ci| ------------ | --------------- | ---- | ------------------------------------------------------------ |
6403e41f4b71Sopenharmony_ci| event        | string          | Yes  | Name of the event.                                          |
6404e41f4b71Sopenharmony_ci| interProcess | boolean         | Yes  | Type of the data to observe.<br> The value **true** means inter-process events.<br> The value **false** means intra-process events.|
6405e41f4b71Sopenharmony_ci| observer     | Callback\<void> | No  | Callback to unregister. If this parameter is not specified, this API unregisters all callbacks for the specified event.|
6406e41f4b71Sopenharmony_ci
6407e41f4b71Sopenharmony_ci**Error codes**
6408e41f4b71Sopenharmony_ci
6409e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6410e41f4b71Sopenharmony_ci
6411e41f4b71Sopenharmony_ci| **ID**| **Error Message**                          |
6412e41f4b71Sopenharmony_ci| ------------ | -------------------------------------- |
6413e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
6414e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
6415e41f4b71Sopenharmony_ci| 14800000     | Inner error.                           |
6416e41f4b71Sopenharmony_ci| 14800014  | Already closed.    |
6417e41f4b71Sopenharmony_ci| 14800050     | Failed to obtain subscription service. |
6418e41f4b71Sopenharmony_ci
6419e41f4b71Sopenharmony_ci**Example**
6420e41f4b71Sopenharmony_ci
6421e41f4b71Sopenharmony_ci```ts
6422e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6423e41f4b71Sopenharmony_ci
6424e41f4b71Sopenharmony_cilet storeObserver = () => {
6425e41f4b71Sopenharmony_ci  console.info(`storeObserver`);
6426e41f4b71Sopenharmony_ci}
6427e41f4b71Sopenharmony_ci
6428e41f4b71Sopenharmony_citry {
6429e41f4b71Sopenharmony_ci  if(store != undefined) {
6430e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).on('storeObserver', false, storeObserver);
6431e41f4b71Sopenharmony_ci  }
6432e41f4b71Sopenharmony_ci} catch (err) {
6433e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
6434e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message
6435e41f4b71Sopenharmony_ci  console.error(`Register observer failed, code is ${code},message is ${message}`);
6436e41f4b71Sopenharmony_ci}
6437e41f4b71Sopenharmony_ci
6438e41f4b71Sopenharmony_citry {
6439e41f4b71Sopenharmony_ci  if(store != undefined) {
6440e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).off('storeObserver', false, storeObserver);
6441e41f4b71Sopenharmony_ci  }
6442e41f4b71Sopenharmony_ci} catch (err) {
6443e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
6444e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message
6445e41f4b71Sopenharmony_ci  console.error(`Unregister observer failed, code is ${code},message is ${message}`);
6446e41f4b71Sopenharmony_ci}
6447e41f4b71Sopenharmony_ci```
6448e41f4b71Sopenharmony_ci
6449e41f4b71Sopenharmony_ci### off('autoSyncProgress')<sup>11+</sup>
6450e41f4b71Sopenharmony_ci
6451e41f4b71Sopenharmony_cioff(event: 'autoSyncProgress', progress?: Callback&lt;ProgressDetails&gt;): void
6452e41f4b71Sopenharmony_ci
6453e41f4b71Sopenharmony_ciUnsubscribes from the auto sync progress.
6454e41f4b71Sopenharmony_ci
6455e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6456e41f4b71Sopenharmony_ci
6457e41f4b71Sopenharmony_ci**Parameters**
6458e41f4b71Sopenharmony_ci
6459e41f4b71Sopenharmony_ci| Name      | Type                             | Mandatory| Description                                                              |
6460e41f4b71Sopenharmony_ci| ------------ |---------------------------------| ---- |------------------------------------------------------------------|
6461e41f4b71Sopenharmony_ci| event        | string                          | Yes  | Event type. The value is **'autoSyncProgress'**, which indicates the auto sync progress.                               |
6462e41f4b71Sopenharmony_ci| progress     | Callback&lt;[ProgressDetails](#progressdetails10)&gt; | No  | Callback to unregister. If this parameter is **null** or **undefined** or not specified, this API unregisters all callbacks for the auto sync progress.|
6463e41f4b71Sopenharmony_ci
6464e41f4b71Sopenharmony_ci**Error codes**
6465e41f4b71Sopenharmony_ci
6466e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6467e41f4b71Sopenharmony_ci
6468e41f4b71Sopenharmony_ci| **ID**| **Error Message**        |
6469e41f4b71Sopenharmony_ci| ------------ |--------------------|
6470e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Need 1 - 3  parameter(s)! 2. The RdbStore must be valid. 3. The event must be a not empty string. 4. The progress must be function. |
6471e41f4b71Sopenharmony_ci| 801       | Capability not supported.  |
6472e41f4b71Sopenharmony_ci| 14800014  | Already closed.       |
6473e41f4b71Sopenharmony_ci
6474e41f4b71Sopenharmony_ci**Example**
6475e41f4b71Sopenharmony_ci
6476e41f4b71Sopenharmony_ci```ts
6477e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6478e41f4b71Sopenharmony_ci
6479e41f4b71Sopenharmony_cilet progressDetail = (progressDetail: relationalStore.ProgressDetails) => {
6480e41f4b71Sopenharmony_ci  console.info(`progress: ${progressDetail}`);
6481e41f4b71Sopenharmony_ci}
6482e41f4b71Sopenharmony_ci
6483e41f4b71Sopenharmony_citry {
6484e41f4b71Sopenharmony_ci  if(store != undefined) {
6485e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).on('autoSyncProgress', progressDetail)
6486e41f4b71Sopenharmony_ci  }
6487e41f4b71Sopenharmony_ci} catch (err) {
6488e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
6489e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message
6490e41f4b71Sopenharmony_ci  console.error(`Register observer failed, code is ${code},message is ${message}`);
6491e41f4b71Sopenharmony_ci}
6492e41f4b71Sopenharmony_ci
6493e41f4b71Sopenharmony_citry {
6494e41f4b71Sopenharmony_ci  if(store != undefined) {
6495e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).off('autoSyncProgress', progressDetail);
6496e41f4b71Sopenharmony_ci  }
6497e41f4b71Sopenharmony_ci} catch (err) {
6498e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
6499e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
6500e41f4b71Sopenharmony_ci  console.error(`Unregister failed, code is ${code},message is ${message}`);
6501e41f4b71Sopenharmony_ci}
6502e41f4b71Sopenharmony_ci```
6503e41f4b71Sopenharmony_ci
6504e41f4b71Sopenharmony_ci### off('statistics')<sup>12+</sup>
6505e41f4b71Sopenharmony_ci
6506e41f4b71Sopenharmony_cioff(event: 'statistics', observer?: Callback&lt;SqlExecutionInfo&gt;): void
6507e41f4b71Sopenharmony_ci
6508e41f4b71Sopenharmony_ciUnsubscribes from SQL statistics.
6509e41f4b71Sopenharmony_ci
6510e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6511e41f4b71Sopenharmony_ci
6512e41f4b71Sopenharmony_ci**Parameters**
6513e41f4b71Sopenharmony_ci
6514e41f4b71Sopenharmony_ci| Name      | Type                             | Mandatory| Description                               |
6515e41f4b71Sopenharmony_ci| ------------ |---------------------------------| ---- |-----------------------------------|
6516e41f4b71Sopenharmony_ci| event        | string                          | Yes  | Event type. The value is **'statistics'**, which indicates the statistics of the SQL execution time.|
6517e41f4b71Sopenharmony_ci| observer     | Callback&lt;[SqlExecutionInfo](#sqlexecutioninfo12)&gt; | No  | Callback to unregister. If this parameter is not specified, this API unregisters all callbacks for the specified event. |
6518e41f4b71Sopenharmony_ci
6519e41f4b71Sopenharmony_ci
6520e41f4b71Sopenharmony_ci**Error codes**
6521e41f4b71Sopenharmony_ci
6522e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6523e41f4b71Sopenharmony_ci
6524e41f4b71Sopenharmony_ci| **ID**| **Error Message**   |
6525e41f4b71Sopenharmony_ci|-----------|--------|
6526e41f4b71Sopenharmony_ci| 401       | Parameter error.  |
6527e41f4b71Sopenharmony_ci| 801       | Capability not supported.  |
6528e41f4b71Sopenharmony_ci| 14800000  | Inner error.  |
6529e41f4b71Sopenharmony_ci| 14800014  | Already closed.     |
6530e41f4b71Sopenharmony_ci
6531e41f4b71Sopenharmony_ci```ts
6532e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6533e41f4b71Sopenharmony_ci
6534e41f4b71Sopenharmony_citry {
6535e41f4b71Sopenharmony_ci  if(store != undefined) {
6536e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).off('statistics');
6537e41f4b71Sopenharmony_ci  }
6538e41f4b71Sopenharmony_ci} catch (err) {
6539e41f4b71Sopenharmony_ci  let code = (err as BusinessError).code;
6540e41f4b71Sopenharmony_ci  let message = (err as BusinessError).message;
6541e41f4b71Sopenharmony_ci  console.error(`Unregister observer failed, code is ${code},message is ${message}`);
6542e41f4b71Sopenharmony_ci}
6543e41f4b71Sopenharmony_ci```
6544e41f4b71Sopenharmony_ci
6545e41f4b71Sopenharmony_ci### emit<sup>10+</sup>
6546e41f4b71Sopenharmony_ci
6547e41f4b71Sopenharmony_ciemit(event: string): void
6548e41f4b71Sopenharmony_ci
6549e41f4b71Sopenharmony_ciTriggers the inter-process or intra-process event listener registered in [on](#on10).
6550e41f4b71Sopenharmony_ci
6551e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6552e41f4b71Sopenharmony_ci
6553e41f4b71Sopenharmony_ci**Parameters**
6554e41f4b71Sopenharmony_ci
6555e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                |
6556e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------- |
6557e41f4b71Sopenharmony_ci| event  | string | Yes  | Name of the event.|
6558e41f4b71Sopenharmony_ci
6559e41f4b71Sopenharmony_ci**Error codes**
6560e41f4b71Sopenharmony_ci
6561e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6562e41f4b71Sopenharmony_ci
6563e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                     |
6564e41f4b71Sopenharmony_ci| --------- |---------------------------------------------------------------------------------------------------------------|
6565e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
6566e41f4b71Sopenharmony_ci| 801       | Capability not supported.     |
6567e41f4b71Sopenharmony_ci| 14800000  | Inner error.   |
6568e41f4b71Sopenharmony_ci| 14800014  | Already closed.     |
6569e41f4b71Sopenharmony_ci| 14800050  | Failed to obtain subscription service.    |
6570e41f4b71Sopenharmony_ci
6571e41f4b71Sopenharmony_ci
6572e41f4b71Sopenharmony_ci**Example**
6573e41f4b71Sopenharmony_ci
6574e41f4b71Sopenharmony_ci```ts
6575e41f4b71Sopenharmony_ciif(store != undefined) {
6576e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).emit('storeObserver');
6577e41f4b71Sopenharmony_ci}
6578e41f4b71Sopenharmony_ci```
6579e41f4b71Sopenharmony_ci
6580e41f4b71Sopenharmony_ci### cleanDirtyData<sup>11+</sup>
6581e41f4b71Sopenharmony_ci
6582e41f4b71Sopenharmony_cicleanDirtyData(table: string, cursor: number, callback: AsyncCallback&lt;void&gt;): void
6583e41f4b71Sopenharmony_ci
6584e41f4b71Sopenharmony_ciClears the dirty data whose cursor is smaller than the specified cursor from the local device. The dirty data is the data that has been deleted from the cloud.
6585e41f4b71Sopenharmony_ci
6586e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
6587e41f4b71Sopenharmony_ci
6588e41f4b71Sopenharmony_ci**Parameters**
6589e41f4b71Sopenharmony_ci
6590e41f4b71Sopenharmony_ci| Name  | Type                                                 | Mandatory| Description                                              |
6591e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------- | ---- | -------------------------------------------------- |
6592e41f4b71Sopenharmony_ci| table     | string                        | Yes  | Name of the table in the RDB store.                            |
6593e41f4b71Sopenharmony_ci| cursor    | number                        | Yes  | Cursor of the data, which is an integer. All the dirty data with the cursor smaller than the specified value will be cleared.    |
6594e41f4b71Sopenharmony_ci| callback  | AsyncCallback&lt;void&gt;     | Yes  | Callback used to return the result.|
6595e41f4b71Sopenharmony_ci
6596e41f4b71Sopenharmony_ci**Error codes**
6597e41f4b71Sopenharmony_ci
6598e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
6599e41f4b71Sopenharmony_ci
6600e41f4b71Sopenharmony_ci| **ID**| **Error Message**    |
6601e41f4b71Sopenharmony_ci|-----------|---------------|
6602e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Need 1 - 3  parameter(s)! 2. The RdbStore must be not nullptr. 3. The tablesNames must be not empty string. 4. The cursor must be valid cursor. |
6603e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
6604e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
6605e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
6606e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
6607e41f4b71Sopenharmony_ci| 14800015  | The database does not respond. |
6608e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
6609e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
6610e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
6611e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
6612e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
6613e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
6614e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
6615e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
6616e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
6617e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
6618e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
6619e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
6620e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
6621e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
6622e41f4b71Sopenharmony_ci
6623e41f4b71Sopenharmony_ci**Example**
6624e41f4b71Sopenharmony_ci
6625e41f4b71Sopenharmony_ci```ts
6626e41f4b71Sopenharmony_ciif(store != undefined) {
6627e41f4b71Sopenharmony_ci (store as relationalStore.RdbStore).cleanDirtyData('test_table', 100, (err) => {
6628e41f4b71Sopenharmony_ci    if (err) {
6629e41f4b71Sopenharmony_ci      console.error(`clean dirty data failed, code is ${err.code},message is ${err.message}`);
6630e41f4b71Sopenharmony_ci      return;
6631e41f4b71Sopenharmony_ci    }
6632e41f4b71Sopenharmony_ci    console.info('clean dirty data succeeded');
6633e41f4b71Sopenharmony_ci  })
6634e41f4b71Sopenharmony_ci}
6635e41f4b71Sopenharmony_ci```
6636e41f4b71Sopenharmony_ci
6637e41f4b71Sopenharmony_ci### cleanDirtyData<sup>11+</sup>
6638e41f4b71Sopenharmony_ci
6639e41f4b71Sopenharmony_cicleanDirtyData(table: string, callback: AsyncCallback&lt;void&gt;): void
6640e41f4b71Sopenharmony_ci
6641e41f4b71Sopenharmony_ciClears all dirty data from the local device. The dirty data is the data that has been deleted from the cloud.
6642e41f4b71Sopenharmony_ci
6643e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
6644e41f4b71Sopenharmony_ci
6645e41f4b71Sopenharmony_ci**Parameters**
6646e41f4b71Sopenharmony_ci
6647e41f4b71Sopenharmony_ci| Name  | Type                                                 | Mandatory| Description                                              |
6648e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------- | ---- | -------------------------------------------------- |
6649e41f4b71Sopenharmony_ci| table     | string                        | Yes  | Name of the table in the RDB store.|
6650e41f4b71Sopenharmony_ci| callback  | AsyncCallback&lt;void&gt;     | Yes  | Callback used to return the result.|
6651e41f4b71Sopenharmony_ci
6652e41f4b71Sopenharmony_ci**Error codes**
6653e41f4b71Sopenharmony_ci
6654e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
6655e41f4b71Sopenharmony_ci
6656e41f4b71Sopenharmony_ci| **ID**| **Error Message**      |
6657e41f4b71Sopenharmony_ci|-----------|---------|
6658e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Need 1 - 3  parameter(s). 2. The RdbStore must be not nullptr. 3. The tablesNames must be not empty string. |
6659e41f4b71Sopenharmony_ci| 801       | Capability not supported.    |
6660e41f4b71Sopenharmony_ci| 14800000  | Inner error.        |
6661e41f4b71Sopenharmony_ci| 14800011  | Database corrupted.   |
6662e41f4b71Sopenharmony_ci| 14800014  | Already closed.       |
6663e41f4b71Sopenharmony_ci| 14800015  | The database does not respond.      |
6664e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error.     |
6665e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
6666e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied.           |
6667e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked.        |
6668e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked.  |
6669e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory.      |
6670e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database.   |
6671e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred.  |
6672e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full.                |
6673e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file.            |
6674e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit.             |
6675e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation.   |
6676e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch.                  |
6677e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly.          |
6678e41f4b71Sopenharmony_ci
6679e41f4b71Sopenharmony_ci**Example**
6680e41f4b71Sopenharmony_ci
6681e41f4b71Sopenharmony_ci```ts
6682e41f4b71Sopenharmony_ciif(store != undefined) {
6683e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).cleanDirtyData('test_table', (err) => {
6684e41f4b71Sopenharmony_ci    if (err) {
6685e41f4b71Sopenharmony_ci      console.error(`clean dirty data failed, code is ${err.code},message is ${err.message}`);
6686e41f4b71Sopenharmony_ci      return;
6687e41f4b71Sopenharmony_ci    }
6688e41f4b71Sopenharmony_ci    console.info('clean dirty data succeeded');
6689e41f4b71Sopenharmony_ci  })
6690e41f4b71Sopenharmony_ci}
6691e41f4b71Sopenharmony_ci```
6692e41f4b71Sopenharmony_ci
6693e41f4b71Sopenharmony_ci### cleanDirtyData<sup>11+</sup>
6694e41f4b71Sopenharmony_ci
6695e41f4b71Sopenharmony_cicleanDirtyData(table: string, cursor?: number): Promise&lt;void&gt;
6696e41f4b71Sopenharmony_ci
6697e41f4b71Sopenharmony_ciClears the dirty data whose cursor is smaller than the specified cursor from the local device. The dirty data is the data that has been deleted from the cloud. If **cursor** is not specified, all the dirty data will be cleared.
6698e41f4b71Sopenharmony_ci
6699e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
6700e41f4b71Sopenharmony_ci
6701e41f4b71Sopenharmony_ci**Parameters**
6702e41f4b71Sopenharmony_ci
6703e41f4b71Sopenharmony_ci| Name  | Type                                                 | Mandatory| Description                                              |
6704e41f4b71Sopenharmony_ci| -------- | ----------------------------------------------------- | ---- | -------------------------------------------------- |
6705e41f4b71Sopenharmony_ci| table     | string           | Yes  | Name of the table in the RDB store.          |
6706e41f4b71Sopenharmony_ci| cursor    | number           | No  | Cursor of the data, which is an integer. All the dirty data with the cursor smaller than the specified value will be cleared. If this parameter is not specified, all dirty data in the current table will be cleared.|
6707e41f4b71Sopenharmony_ci
6708e41f4b71Sopenharmony_ci**Return value**
6709e41f4b71Sopenharmony_ci| Name   | Description                                              |
6710e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------- |
6711e41f4b71Sopenharmony_ci| Promise\<void> | Promise that returns no value.       |
6712e41f4b71Sopenharmony_ci
6713e41f4b71Sopenharmony_ci**Error codes**
6714e41f4b71Sopenharmony_ci
6715e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
6716e41f4b71Sopenharmony_ci
6717e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                                                                                                     |
6718e41f4b71Sopenharmony_ci|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
6719e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Need 1 - 3  parameter(s)! 2. The RdbStore must be not nullptr. 3. The tablesNames must be not empty string. 4. The cursor must be valid cursor. |
6720e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
6721e41f4b71Sopenharmony_ci| 14800000  | Inner error.            |
6722e41f4b71Sopenharmony_ci| 14800011  | Database corrupted.   |
6723e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
6724e41f4b71Sopenharmony_ci| 14800015  | The database does not respond.   |
6725e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error.   |
6726e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
6727e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied.          |
6728e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked.      |
6729e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
6730e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory.   |
6731e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
6732e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
6733e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full.   |
6734e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
6735e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
6736e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
6737e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
6738e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
6739e41f4b71Sopenharmony_ci
6740e41f4b71Sopenharmony_ci**Example**
6741e41f4b71Sopenharmony_ci
6742e41f4b71Sopenharmony_ci```ts
6743e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6744e41f4b71Sopenharmony_ci
6745e41f4b71Sopenharmony_ciif(store != undefined) {
6746e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).cleanDirtyData('test_table', 100).then(() => {
6747e41f4b71Sopenharmony_ci        console.info('clean dirty data  succeeded');
6748e41f4b71Sopenharmony_ci    }).catch ((err: BusinessError) => {
6749e41f4b71Sopenharmony_ci        console.error(`clean dirty data failed, code is ${err.code},message is ${err.message}`);
6750e41f4b71Sopenharmony_ci    })
6751e41f4b71Sopenharmony_ci}
6752e41f4b71Sopenharmony_ci```
6753e41f4b71Sopenharmony_ci
6754e41f4b71Sopenharmony_ci### attach<sup>12+</sup>
6755e41f4b71Sopenharmony_ci
6756e41f4b71Sopenharmony_ciattach(fullPath: string, attachName: string, waitTime?: number) : Promise&lt;number&gt;
6757e41f4b71Sopenharmony_ci
6758e41f4b71Sopenharmony_ciAttaches an RDB store to this RDB store so that the data in the attached RDB store can be directly accessed using the SQL statement.
6759e41f4b71Sopenharmony_ci
6760e41f4b71Sopenharmony_ciThe RDB store is attached via a database file. This API cannot be used for encrypted RDB stores. After the **attach()** API is called, the RDB store is switched to the non-WAL mode, which may affect the performance.
6761e41f4b71Sopenharmony_ci
6762e41f4b71Sopenharmony_ciBefore the RDB store is switched to the non-WAL mode, ensure that all **ResultSet**s are closed and all write operations are complete. Otherwise, error 14800015 will be reported.
6763e41f4b71Sopenharmony_ci
6764e41f4b71Sopenharmony_ciThe **attach()** API cannot be called concurrently. Concurrent calls may cause the system to become unresponsive and trigger 14800015. If this occurs, try to call **attach()** again later.
6765e41f4b71Sopenharmony_ci
6766e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6767e41f4b71Sopenharmony_ci
6768e41f4b71Sopenharmony_ci**Parameters**
6769e41f4b71Sopenharmony_ci
6770e41f4b71Sopenharmony_ci| Name       | Type    | Mandatory | Description          |
6771e41f4b71Sopenharmony_ci| ----------- | ------ | --- | ------------ |
6772e41f4b71Sopenharmony_ci| fullPath | string | Yes  | Path of the database file to attach.|
6773e41f4b71Sopenharmony_ci| attachName | string | Yes  | Alias of the RDB store formed after the attach operation.|
6774e41f4b71Sopenharmony_ci| waitTime | number | No  | Maximum time period (in seconds) allowed for attaching the database file. <br>Value range: 1 to 300<br>Default value: 2|
6775e41f4b71Sopenharmony_ci
6776e41f4b71Sopenharmony_ci**Return value**
6777e41f4b71Sopenharmony_ci
6778e41f4b71Sopenharmony_ci| Type             | Description                          |
6779e41f4b71Sopenharmony_ci| ---------------- | ---------------------------- |
6780e41f4b71Sopenharmony_ci|  Promise&lt;number&gt; | Promise used to return the number of attached RDB stores.|
6781e41f4b71Sopenharmony_ci
6782e41f4b71Sopenharmony_ci**Error codes**
6783e41f4b71Sopenharmony_ci
6784e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
6785e41f4b71Sopenharmony_ci
6786e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
6787e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
6788e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
6789e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
6790e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
6791e41f4b71Sopenharmony_ci| 14800010  | Invalid database path.               |
6792e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
6793e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
6794e41f4b71Sopenharmony_ci| 14800015  | The database does not respond.                 |
6795e41f4b71Sopenharmony_ci| 14800016  | The database is already attached.                |
6796e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
6797e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
6798e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
6799e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
6800e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
6801e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
6802e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
6803e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
6804e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
6805e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
6806e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
6807e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
6808e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
6809e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
6810e41f4b71Sopenharmony_ci
6811e41f4b71Sopenharmony_ci**Example**
6812e41f4b71Sopenharmony_ci
6813e41f4b71Sopenharmony_ci```ts
6814e41f4b71Sopenharmony_ci// Attach a non-encrypted RDB store to a non-encrypted RDB store.
6815e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6816e41f4b71Sopenharmony_ci
6817e41f4b71Sopenharmony_ciif(store != undefined) {
6818e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).attach("/path/rdbstore1.db", "attachDB").then((number: number) => {
6819e41f4b71Sopenharmony_ci        console.info('attach succeeded');
6820e41f4b71Sopenharmony_ci    }).catch ((err: BusinessError) => {
6821e41f4b71Sopenharmony_ci        console.error(`attach failed, code is ${err.code},message is ${err.message}`);
6822e41f4b71Sopenharmony_ci    })
6823e41f4b71Sopenharmony_ci}
6824e41f4b71Sopenharmony_ci```
6825e41f4b71Sopenharmony_ci
6826e41f4b71Sopenharmony_ci### attach<sup>12+</sup>
6827e41f4b71Sopenharmony_ci
6828e41f4b71Sopenharmony_ciattach(context: Context, config: StoreConfig, attachName: string, waitTime?: number) : Promise&lt;number&gt;
6829e41f4b71Sopenharmony_ci
6830e41f4b71Sopenharmony_ciAttaches an RDB store to this RDB store so that the data in the attached RDB store can be directly accessed using the SQL statement.
6831e41f4b71Sopenharmony_ci
6832e41f4b71Sopenharmony_ciThis API cannot be used to attach a non-encrypted RDB store to an encrypted RDB store. After the **attach()** API is called, the RDB store is switched to the non-WAL mode, which may affect the performance.
6833e41f4b71Sopenharmony_ci
6834e41f4b71Sopenharmony_ciBefore the RDB store is switched to the non-WAL mode, ensure that all **ResultSet**s are closed and all write operations are complete. Otherwise, error 14800015 will be reported.
6835e41f4b71Sopenharmony_ci
6836e41f4b71Sopenharmony_ciThe **attach()** API cannot be called concurrently. Concurrent calls may cause the system to become unresponsive and trigger 14800015. If this occurs, try to call **attach()** again later.
6837e41f4b71Sopenharmony_ci
6838e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6839e41f4b71Sopenharmony_ci
6840e41f4b71Sopenharmony_ci**Parameters**
6841e41f4b71Sopenharmony_ci
6842e41f4b71Sopenharmony_ci| Name       | Type    | Mandatory | Description          |
6843e41f4b71Sopenharmony_ci| ----------- | ------ | --- | ------------ |
6844e41f4b71Sopenharmony_ci| context | Context                          | Yes  | Application context.<br>For details about the application context of the FA model, see [Context](../apis-ability-kit/js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](../apis-ability-kit/js-apis-inner-application-uiAbilityContext.md).|
6845e41f4b71Sopenharmony_ci| config  | [StoreConfig](#storeconfig) | Yes  | Configuration of the RDB store to attach.                               |
6846e41f4b71Sopenharmony_ci| attachName | string | Yes  | Alias of the RDB store formed after the attach operation.|
6847e41f4b71Sopenharmony_ci| waitTime | number | No  | Maximum time period (in seconds) allowed for attaching the database file. <br>Value range: 1 to 300<br>Default value: 2|
6848e41f4b71Sopenharmony_ci
6849e41f4b71Sopenharmony_ci**Return value**
6850e41f4b71Sopenharmony_ci
6851e41f4b71Sopenharmony_ci| Type             | Description                          |
6852e41f4b71Sopenharmony_ci| ---------------- | ---------------------------- |
6853e41f4b71Sopenharmony_ci|  Promise&lt;number&gt; | Promise used to return the number of attached RDB stores.|
6854e41f4b71Sopenharmony_ci
6855e41f4b71Sopenharmony_ci**Error codes**
6856e41f4b71Sopenharmony_ci
6857e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
6858e41f4b71Sopenharmony_ci
6859e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
6860e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
6861e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
6862e41f4b71Sopenharmony_ci| 801       | Capability not supported. |
6863e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
6864e41f4b71Sopenharmony_ci| 14800010  | Invalid database path.               |
6865e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
6866e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
6867e41f4b71Sopenharmony_ci| 14800015  | The database does not respond.                 |
6868e41f4b71Sopenharmony_ci| 14800016  | The database is already attached.                |
6869e41f4b71Sopenharmony_ci| 14801001  | Only supported in stage mode.                 |
6870e41f4b71Sopenharmony_ci| 14801002  | The data group id is not valid.                |
6871e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
6872e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
6873e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
6874e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
6875e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
6876e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
6877e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
6878e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
6879e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
6880e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
6881e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
6882e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
6883e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
6884e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
6885e41f4b71Sopenharmony_ci
6886e41f4b71Sopenharmony_ciExample 1: Attach a non-encrypted RDB store to a non-encrypted RDB store.
6887e41f4b71Sopenharmony_ci
6888e41f4b71Sopenharmony_ci```ts
6889e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6890e41f4b71Sopenharmony_ci
6891e41f4b71Sopenharmony_cilet attachStore: relationalStore.RdbStore | undefined = undefined;
6892e41f4b71Sopenharmony_ci
6893e41f4b71Sopenharmony_ciconst STORE_CONFIG1: relationalStore.StoreConfig = {
6894e41f4b71Sopenharmony_ci    name: "rdbstore1.db",
6895e41f4b71Sopenharmony_ci    securityLevel: relationalStore.SecurityLevel.S3,
6896e41f4b71Sopenharmony_ci}
6897e41f4b71Sopenharmony_ci
6898e41f4b71Sopenharmony_cirelationalStore.getRdbStore(this.context, STORE_CONFIG1).then(async (rdbStore: relationalStore.RdbStore) => {
6899e41f4b71Sopenharmony_ci    attachStore = rdbStore;
6900e41f4b71Sopenharmony_ci    console.info('Get RdbStore successfully.')
6901e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
6902e41f4b71Sopenharmony_ci    console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
6903e41f4b71Sopenharmony_ci})
6904e41f4b71Sopenharmony_ci
6905e41f4b71Sopenharmony_ciif(store != undefined) {
6906e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).attach(this.context, STORE_CONFIG1, "attachDB").then((number: number) => {
6907e41f4b71Sopenharmony_ci        console.info(`attach succeeded, number is ${number}`);
6908e41f4b71Sopenharmony_ci    }).catch ((err: BusinessError) => {
6909e41f4b71Sopenharmony_ci        console.error(`attach failed, code is ${err.code},message is ${err.message}`);
6910e41f4b71Sopenharmony_ci    })
6911e41f4b71Sopenharmony_ci}
6912e41f4b71Sopenharmony_ci```
6913e41f4b71Sopenharmony_ci
6914e41f4b71Sopenharmony_ciExample 2: Attach an encrypted RDB store to a non-encrypted RDB store.
6915e41f4b71Sopenharmony_ci
6916e41f4b71Sopenharmony_ci```ts
6917e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6918e41f4b71Sopenharmony_ci
6919e41f4b71Sopenharmony_cilet attachStore: relationalStore.RdbStore | undefined = undefined;
6920e41f4b71Sopenharmony_ci
6921e41f4b71Sopenharmony_ci
6922e41f4b71Sopenharmony_ciconst STORE_CONFIG2: relationalStore.StoreConfig = {
6923e41f4b71Sopenharmony_ci    name: "rdbstore2.db",
6924e41f4b71Sopenharmony_ci    encrypt: true,
6925e41f4b71Sopenharmony_ci    securityLevel: relationalStore.SecurityLevel.S3,
6926e41f4b71Sopenharmony_ci}
6927e41f4b71Sopenharmony_ci
6928e41f4b71Sopenharmony_cirelationalStore.getRdbStore(this.context, STORE_CONFIG2).then(async (rdbStore: relationalStore.RdbStore) => {
6929e41f4b71Sopenharmony_ci    attachStore = rdbStore;
6930e41f4b71Sopenharmony_ci    console.info('Get RdbStore successfully.')
6931e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => {
6932e41f4b71Sopenharmony_ci    console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
6933e41f4b71Sopenharmony_ci})
6934e41f4b71Sopenharmony_ci
6935e41f4b71Sopenharmony_ciif(store != undefined) {
6936e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).attach(this.context, STORE_CONFIG2, "attachDB2", 10).then((number: number) => {
6937e41f4b71Sopenharmony_ci        console.info(`attach succeeded, number is ${number}`);
6938e41f4b71Sopenharmony_ci    }).catch ((err: BusinessError) => {
6939e41f4b71Sopenharmony_ci        console.error(`attach failed, code is ${err.code},message is ${err.message}`);
6940e41f4b71Sopenharmony_ci    })
6941e41f4b71Sopenharmony_ci}
6942e41f4b71Sopenharmony_ci```
6943e41f4b71Sopenharmony_ci
6944e41f4b71Sopenharmony_ci### detach<sup>12+</sup>
6945e41f4b71Sopenharmony_ci
6946e41f4b71Sopenharmony_cidetach(attachName: string, waitTime?: number) : Promise&lt;number&gt;
6947e41f4b71Sopenharmony_ci
6948e41f4b71Sopenharmony_ciDetaches an RDB store from this RDB store.
6949e41f4b71Sopenharmony_ci
6950e41f4b71Sopenharmony_ciAfter all attached RDB stores are detached, the RDB is switched to the WAL mode.
6951e41f4b71Sopenharmony_ci
6952e41f4b71Sopenharmony_ciBefore calling **detach()**, ensure that all database operations are complete and all **ResultSet**s are closed. In addition, **detach()** cannot be called concurrently. Concurrent calls may cause the system to become unresponsive. If this occurs, try to call **detach()** again later.
6953e41f4b71Sopenharmony_ci
6954e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6955e41f4b71Sopenharmony_ci
6956e41f4b71Sopenharmony_ci**Parameters**
6957e41f4b71Sopenharmony_ci
6958e41f4b71Sopenharmony_ci| Name       | Type    | Mandatory | Description          |
6959e41f4b71Sopenharmony_ci| ----------- | ------ | --- | ------------ |
6960e41f4b71Sopenharmony_ci| attachName | string | Yes  | Alias of the RDB store formed after the attach operation.|
6961e41f4b71Sopenharmony_ci| waitTime | number | No  | Maximum time period (in seconds) allowed for detaching the RDB store. <br>Value range: 1 to 300<br>Default value: 2|
6962e41f4b71Sopenharmony_ci
6963e41f4b71Sopenharmony_ci**Return value**
6964e41f4b71Sopenharmony_ci
6965e41f4b71Sopenharmony_ci| Type             | Description                          |
6966e41f4b71Sopenharmony_ci| ---------------- | ---------------------------- |
6967e41f4b71Sopenharmony_ci|  Promise&lt;number&gt; | Promise used to return the number of remaining attached RDB stores.|
6968e41f4b71Sopenharmony_ci
6969e41f4b71Sopenharmony_ci**Error codes**
6970e41f4b71Sopenharmony_ci
6971e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
6972e41f4b71Sopenharmony_ci
6973e41f4b71Sopenharmony_ci| **ID**| **Error Message**      |
6974e41f4b71Sopenharmony_ci|-----------|------------------------|
6975e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
6976e41f4b71Sopenharmony_ci| 14800000  | Inner error.            |
6977e41f4b71Sopenharmony_ci| 14800011  | Database corrupted.         |
6978e41f4b71Sopenharmony_ci| 14800014  | Already closed.        |
6979e41f4b71Sopenharmony_ci| 14800015  | The database does not respond.         |
6980e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error.            |
6981e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort.       |
6982e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied.           |
6983e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked.        |
6984e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked.       |
6985e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory.     |
6986e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database.        |
6987e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred.    |
6988e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full.      |
6989e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file.       |
6990e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit.      |
6991e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation.    |
6992e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch.       |
6993e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly.       |
6994e41f4b71Sopenharmony_ci
6995e41f4b71Sopenharmony_ci**Example**
6996e41f4b71Sopenharmony_ci
6997e41f4b71Sopenharmony_ci```ts
6998e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
6999e41f4b71Sopenharmony_ci
7000e41f4b71Sopenharmony_ciif(store != undefined) {
7001e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).detach("attachDB").then((number: number) => {
7002e41f4b71Sopenharmony_ci        console.info(`detach succeeded, number is ${number}`);
7003e41f4b71Sopenharmony_ci    }).catch ((err: BusinessError) => {
7004e41f4b71Sopenharmony_ci        console.error(`detach failed, code is ${err.code},message is ${err.message}`);
7005e41f4b71Sopenharmony_ci    })
7006e41f4b71Sopenharmony_ci}
7007e41f4b71Sopenharmony_ci```
7008e41f4b71Sopenharmony_ci
7009e41f4b71Sopenharmony_ci### lockRow<sup>12+</sup>
7010e41f4b71Sopenharmony_ci
7011e41f4b71Sopenharmony_cilockRow(predicates: RdbPredicates):Promise&lt;void&gt;
7012e41f4b71Sopenharmony_ci
7013e41f4b71Sopenharmony_ciLocks data in this RDB store. This API uses a promise to return the result. The locked data is blocked from device-cloud sync.
7014e41f4b71Sopenharmony_ci
7015e41f4b71Sopenharmony_ciThis API supports only the tables with the primary keys of the basic types. It is not available to shared tables, tables without primary keys, or tables with primary keys of composite types.
7016e41f4b71Sopenharmony_ciThis API does not support lock transfer between tables with dependencies. If this table has dependent tables, you need to call this API for the related tables based on the dependency relationships.
7017e41f4b71Sopenharmony_ciThis API cannot be used for deleted data.
7018e41f4b71Sopenharmony_ci
7019e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7020e41f4b71Sopenharmony_ci
7021e41f4b71Sopenharmony_ci**Parameters**
7022e41f4b71Sopenharmony_ci
7023e41f4b71Sopenharmony_ci| Name    | Type                                | Mandatory| Description                                     |
7024e41f4b71Sopenharmony_ci| ---------- | ------------------------------------ | ---- | ----------------------------------------- |
7025e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Conditions for locking data.|
7026e41f4b71Sopenharmony_ci
7027e41f4b71Sopenharmony_ci**Return value**
7028e41f4b71Sopenharmony_ci
7029e41f4b71Sopenharmony_ci| Type                 | Description                           |
7030e41f4b71Sopenharmony_ci| --------------------- | ------------------------------- |
7031e41f4b71Sopenharmony_ci| Promise&lt;void&gt;   | Promise that returns no value.       |
7032e41f4b71Sopenharmony_ci
7033e41f4b71Sopenharmony_ci**Error codes**
7034e41f4b71Sopenharmony_ci
7035e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
7036e41f4b71Sopenharmony_ci
7037e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                                                    |
7038e41f4b71Sopenharmony_ci|-----------|----------------------------------------------------------------------------------------------|
7039e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7040e41f4b71Sopenharmony_ci| 14800000  | Inner error.                                                                                 |
7041e41f4b71Sopenharmony_ci| 14800011  | Database corrupted.                                                                          |
7042e41f4b71Sopenharmony_ci| 14800014  | Already closed.                                                                              |
7043e41f4b71Sopenharmony_ci| 14800015  | The database does not respond.                                                                        |
7044e41f4b71Sopenharmony_ci| 14800018  | No data meets the condition.                                                                 |
7045e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error.                                                                       |
7046e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort.                                                 |
7047e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied.                                                            |
7048e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked.                                                         |
7049e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked.                                                   |
7050e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory.                                                       |
7051e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database.                                                |
7052e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred.                                                |
7053e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full.                                                                |
7054e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file.                                                    |
7055e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit.                                                     |
7056e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation.                                                   |
7057e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch.                                                                  |
7058e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly.                                                            |
7059e41f4b71Sopenharmony_ci
7060e41f4b71Sopenharmony_ci**Example**
7061e41f4b71Sopenharmony_ci
7062e41f4b71Sopenharmony_ci```ts
7063e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
7064e41f4b71Sopenharmony_ci
7065e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
7066e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Lisa");
7067e41f4b71Sopenharmony_ciif(store != undefined) {
7068e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).lockRow(predicates).then(() => {
7069e41f4b71Sopenharmony_ci    console.info(`Lock success`);
7070e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
7071e41f4b71Sopenharmony_ci    console.error(`Lock failed, code is ${err.code},message is ${err.message}`);
7072e41f4b71Sopenharmony_ci  })
7073e41f4b71Sopenharmony_ci}
7074e41f4b71Sopenharmony_ci```
7075e41f4b71Sopenharmony_ci
7076e41f4b71Sopenharmony_ci### unlockRow<sup>12+</sup>
7077e41f4b71Sopenharmony_ci
7078e41f4b71Sopenharmony_ciunlockRow(predicates: RdbPredicates):Promise&lt;void&gt;
7079e41f4b71Sopenharmony_ci
7080e41f4b71Sopenharmony_ciUnlocks data in this RDB store. This API uses a promise to return the result.
7081e41f4b71Sopenharmony_ci
7082e41f4b71Sopenharmony_ciThis API supports only the tables with the primary keys of the basic types. It is not available to shared tables, tables without primary keys, or tables with primary keys of composite types.
7083e41f4b71Sopenharmony_ciThis API does not support lock transfer between tables with dependencies. If this table has dependent tables, you need to call this API for the related tables based on the dependency relationships.
7084e41f4b71Sopenharmony_ciThis API cannot be used for deleted data.
7085e41f4b71Sopenharmony_ci
7086e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7087e41f4b71Sopenharmony_ci
7088e41f4b71Sopenharmony_ci**Parameters**
7089e41f4b71Sopenharmony_ci
7090e41f4b71Sopenharmony_ci| Name    | Type                                | Mandatory| Description                                     |
7091e41f4b71Sopenharmony_ci| ---------- | ------------------------------------ | ---- | ----------------------------------------- |
7092e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Conditions for unlocking data.|
7093e41f4b71Sopenharmony_ci
7094e41f4b71Sopenharmony_ci**Return value**
7095e41f4b71Sopenharmony_ci
7096e41f4b71Sopenharmony_ci| Type                 | Description                           |
7097e41f4b71Sopenharmony_ci| --------------------- | ------------------------------- |
7098e41f4b71Sopenharmony_ci| Promise&lt;void&gt;   | Promise that returns no value.       |
7099e41f4b71Sopenharmony_ci
7100e41f4b71Sopenharmony_ci**Error codes**
7101e41f4b71Sopenharmony_ci
7102e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
7103e41f4b71Sopenharmony_ci
7104e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
7105e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
7106e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7107e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
7108e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
7109e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
7110e41f4b71Sopenharmony_ci| 14800015  | The database does not respond.                 |
7111e41f4b71Sopenharmony_ci| 14800018  | No data meets the condition.                |
7112e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
7113e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
7114e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
7115e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
7116e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
7117e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
7118e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
7119e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7120e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
7121e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
7122e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7123e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
7124e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
7125e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
7126e41f4b71Sopenharmony_ci
7127e41f4b71Sopenharmony_ci**Example**
7128e41f4b71Sopenharmony_ci
7129e41f4b71Sopenharmony_ci```ts
7130e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
7131e41f4b71Sopenharmony_ci
7132e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
7133e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Lisa");
7134e41f4b71Sopenharmony_ciif(store != undefined) {
7135e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).unlockRow(predicates).then(() => {
7136e41f4b71Sopenharmony_ci    console.info(`Unlock success`);
7137e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
7138e41f4b71Sopenharmony_ci    console.error(`Unlock failed, code is ${err.code},message is ${err.message}`);
7139e41f4b71Sopenharmony_ci  })
7140e41f4b71Sopenharmony_ci}
7141e41f4b71Sopenharmony_ci```
7142e41f4b71Sopenharmony_ci
7143e41f4b71Sopenharmony_ci### queryLockedRow<sup>12+</sup>
7144e41f4b71Sopenharmony_ci
7145e41f4b71Sopenharmony_ciqueryLockedRow(predicates: RdbPredicates, columns?: Array&lt;string&gt;):Promise&lt;ResultSet&gt;
7146e41f4b71Sopenharmony_ci
7147e41f4b71Sopenharmony_ciQueries the locked data in this RDB store. This API uses a promise to return the result.
7148e41f4b71Sopenharmony_ciDue to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
7149e41f4b71Sopenharmony_ci
7150e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7151e41f4b71Sopenharmony_ci
7152e41f4b71Sopenharmony_ci**Parameters**
7153e41f4b71Sopenharmony_ci
7154e41f4b71Sopenharmony_ci| Name    | Type                                | Mandatory| Description                                            |
7155e41f4b71Sopenharmony_ci| ---------- | ------------------------------------ | ---- | ------------------------------------------------ |
7156e41f4b71Sopenharmony_ci| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Query conditions specified by the **RdbPredicates** object.       |
7157e41f4b71Sopenharmony_ci| columns    | Array&lt;string&gt;                  | No  | Columns to query. If this parameter is not specified, the query applies to all columns.|
7158e41f4b71Sopenharmony_ci
7159e41f4b71Sopenharmony_ci**Error codes**
7160e41f4b71Sopenharmony_ci
7161e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
7162e41f4b71Sopenharmony_ci
7163e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
7164e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
7165e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7166e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
7167e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
7168e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
7169e41f4b71Sopenharmony_ci| 14800015  | The database does not respond.                 |
7170e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
7171e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
7172e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
7173e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
7174e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
7175e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
7176e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
7177e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7178e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
7179e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
7180e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7181e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
7182e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
7183e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
7184e41f4b71Sopenharmony_ci
7185e41f4b71Sopenharmony_ci**Return value**
7186e41f4b71Sopenharmony_ci
7187e41f4b71Sopenharmony_ci| Type                                                   | Description                                              |
7188e41f4b71Sopenharmony_ci| ------------------------------------------------------- | -------------------------------------------------- |
7189e41f4b71Sopenharmony_ci| Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
7190e41f4b71Sopenharmony_ci
7191e41f4b71Sopenharmony_ci**Example**
7192e41f4b71Sopenharmony_ci
7193e41f4b71Sopenharmony_ci```ts
7194e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
7195e41f4b71Sopenharmony_ci
7196e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
7197e41f4b71Sopenharmony_cipredicates.equalTo("NAME", "Rose");
7198e41f4b71Sopenharmony_ciif(store != undefined) {
7199e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).queryLockedRow(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet: relationalStore.ResultSet) => {
7200e41f4b71Sopenharmony_ci    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
7201e41f4b71Sopenharmony_ci    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
7202e41f4b71Sopenharmony_ci    while (resultSet.goToNextRow()) {
7203e41f4b71Sopenharmony_ci      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
7204e41f4b71Sopenharmony_ci      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
7205e41f4b71Sopenharmony_ci      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
7206e41f4b71Sopenharmony_ci      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
7207e41f4b71Sopenharmony_ci      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
7208e41f4b71Sopenharmony_ci    }
7209e41f4b71Sopenharmony_ci    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
7210e41f4b71Sopenharmony_ci    resultSet.close();
7211e41f4b71Sopenharmony_ci  }).catch((err: BusinessError) => {
7212e41f4b71Sopenharmony_ci    console.error(`Query failed, code is ${err.code},message is ${err.message}`);
7213e41f4b71Sopenharmony_ci  })
7214e41f4b71Sopenharmony_ci}
7215e41f4b71Sopenharmony_ci```
7216e41f4b71Sopenharmony_ci### close<sup>12+</sup>
7217e41f4b71Sopenharmony_ci
7218e41f4b71Sopenharmony_ciclose(): Promise&lt;void&gt;
7219e41f4b71Sopenharmony_ci
7220e41f4b71Sopenharmony_ciCloses this RDB store. This API uses a promise to return the result.
7221e41f4b71Sopenharmony_ci
7222e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7223e41f4b71Sopenharmony_ci
7224e41f4b71Sopenharmony_ci**Return value**
7225e41f4b71Sopenharmony_ci
7226e41f4b71Sopenharmony_ci| Type               | Description         |
7227e41f4b71Sopenharmony_ci| ------------------- | ------------- |
7228e41f4b71Sopenharmony_ci| Promise&lt;void&gt; | Promise used to|
7229e41f4b71Sopenharmony_ci
7230e41f4b71Sopenharmony_ci**Error codes**
7231e41f4b71Sopenharmony_ci
7232e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
7233e41f4b71Sopenharmony_ci
7234e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                   |
7235e41f4b71Sopenharmony_ci| ------------ | ----------------------------------------------- |
7236e41f4b71Sopenharmony_ci| 401          | Parameter error. The store must not be nullptr. |
7237e41f4b71Sopenharmony_ci| 14800000     | Inner error.                                    |
7238e41f4b71Sopenharmony_ci
7239e41f4b71Sopenharmony_ci**Example**
7240e41f4b71Sopenharmony_ci
7241e41f4b71Sopenharmony_ci```ts
7242e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit';
7243e41f4b71Sopenharmony_ci
7244e41f4b71Sopenharmony_ciif(store != undefined) {
7245e41f4b71Sopenharmony_ci    (store as relationalStore.RdbStore).close().then(() => {
7246e41f4b71Sopenharmony_ci        console.info(`close succeeded`);
7247e41f4b71Sopenharmony_ci    }).catch ((err: BusinessError) => {
7248e41f4b71Sopenharmony_ci        console.error(`close failed, code is ${err.code},message is ${err.message}`);
7249e41f4b71Sopenharmony_ci    })
7250e41f4b71Sopenharmony_ci}
7251e41f4b71Sopenharmony_ci```
7252e41f4b71Sopenharmony_ci
7253e41f4b71Sopenharmony_ci## ResultSet
7254e41f4b71Sopenharmony_ci
7255e41f4b71Sopenharmony_ciProvides APIs to access the **resultSet** object returned by **query()**.
7256e41f4b71Sopenharmony_ci
7257e41f4b71Sopenharmony_ci### Usage
7258e41f4b71Sopenharmony_ci
7259e41f4b71Sopenharmony_ciObtain the **resultSet** object first.
7260e41f4b71Sopenharmony_ci
7261e41f4b71Sopenharmony_ci**Example**
7262e41f4b71Sopenharmony_ci
7263e41f4b71Sopenharmony_ci<!--code_no_check-->
7264e41f4b71Sopenharmony_ci```ts
7265e41f4b71Sopenharmony_cilet resultSet: relationalStore.ResultSet | undefined = undefined;
7266e41f4b71Sopenharmony_cilet predicates = new relationalStore.RdbPredicates("EMPLOYEE");
7267e41f4b71Sopenharmony_cipredicates.equalTo("AGE", 18);
7268e41f4b71Sopenharmony_ciif(store != undefined) {
7269e41f4b71Sopenharmony_ci  (store as relationalStore.RdbStore).query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((result: relationalStore.ResultSet) => {
7270e41f4b71Sopenharmony_ci    resultSet = result;
7271e41f4b71Sopenharmony_ci    console.info(`resultSet columnNames: ${resultSet.columnNames}`);
7272e41f4b71Sopenharmony_ci    console.info(`resultSet columnCount: ${resultSet.columnCount}`);
7273e41f4b71Sopenharmony_ci  });
7274e41f4b71Sopenharmony_ci}
7275e41f4b71Sopenharmony_ci```
7276e41f4b71Sopenharmony_ci
7277e41f4b71Sopenharmony_ci### Properties
7278e41f4b71Sopenharmony_ci
7279e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7280e41f4b71Sopenharmony_ci
7281e41f4b71Sopenharmony_ci| Name        | Type           | Mandatory| Description                            |
7282e41f4b71Sopenharmony_ci| ------------ | ------------------- | ---- | -------------------------------- |
7283e41f4b71Sopenharmony_ci| columnNames  | Array&lt;string&gt; | Yes  | Names of all columns in the result set.      |
7284e41f4b71Sopenharmony_ci| columnCount  | number              | Yes  | Number of columns in the result set.            |
7285e41f4b71Sopenharmony_ci| rowCount     | number              | Yes  | Number of rows in the result set.            |
7286e41f4b71Sopenharmony_ci| rowIndex     | number              | Yes  | Index of the current row in the result set.        |
7287e41f4b71Sopenharmony_ci| isAtFirstRow | boolean             | Yes  | Whether the cursor is in the first row of the result set.      |
7288e41f4b71Sopenharmony_ci| isAtLastRow  | boolean             | Yes  | Whether the cursor is in the last row of the result set.    |
7289e41f4b71Sopenharmony_ci| isEnded      | boolean             | Yes  | Whether the cursor is after the last row of the result set.|
7290e41f4b71Sopenharmony_ci| isStarted    | boolean             | Yes  | Whether the cursor has been moved.            |
7291e41f4b71Sopenharmony_ci| isClosed     | boolean             | Yes  | Whether the result set is closed.        |
7292e41f4b71Sopenharmony_ci
7293e41f4b71Sopenharmony_ci### getColumnIndex
7294e41f4b71Sopenharmony_ci
7295e41f4b71Sopenharmony_cigetColumnIndex(columnName: string): number
7296e41f4b71Sopenharmony_ci
7297e41f4b71Sopenharmony_ciObtains the column index based on the column name.
7298e41f4b71Sopenharmony_ci
7299e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7300e41f4b71Sopenharmony_ci
7301e41f4b71Sopenharmony_ci**Parameters**
7302e41f4b71Sopenharmony_ci
7303e41f4b71Sopenharmony_ci| Name    | Type  | Mandatory| Description                      |
7304e41f4b71Sopenharmony_ci| ---------- | ------ | ---- | -------------------------- |
7305e41f4b71Sopenharmony_ci| columnName | string | Yes  | Column name.|
7306e41f4b71Sopenharmony_ci
7307e41f4b71Sopenharmony_ci**Return value**
7308e41f4b71Sopenharmony_ci
7309e41f4b71Sopenharmony_ci| Type  | Description              |
7310e41f4b71Sopenharmony_ci| ------ | ------------------ |
7311e41f4b71Sopenharmony_ci| number | Column index obtained.|
7312e41f4b71Sopenharmony_ci
7313e41f4b71Sopenharmony_ci**Error codes**
7314e41f4b71Sopenharmony_ci
7315e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
7316e41f4b71Sopenharmony_ci
7317e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
7318e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
7319e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7320e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
7321e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
7322e41f4b71Sopenharmony_ci| 14800013  | Column out of bounds. |
7323e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
7324e41f4b71Sopenharmony_ci| 14800019  | The SQL must be a query statement. |
7325e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
7326e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
7327e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
7328e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
7329e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
7330e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
7331e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
7332e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7333e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
7334e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
7335e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7336e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
7337e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
7338e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
7339e41f4b71Sopenharmony_ci
7340e41f4b71Sopenharmony_ci**Example**
7341e41f4b71Sopenharmony_ci
7342e41f4b71Sopenharmony_ci```ts
7343e41f4b71Sopenharmony_ciif(resultSet != undefined) {
7344e41f4b71Sopenharmony_ci  const id = (resultSet as relationalStore.ResultSet).getLong((resultSet as relationalStore.ResultSet).getColumnIndex("ID"));
7345e41f4b71Sopenharmony_ci  const name = (resultSet as relationalStore.ResultSet).getString((resultSet as relationalStore.ResultSet).getColumnIndex("NAME"));
7346e41f4b71Sopenharmony_ci  const age = (resultSet as relationalStore.ResultSet).getLong((resultSet as relationalStore.ResultSet).getColumnIndex("AGE"));
7347e41f4b71Sopenharmony_ci  const salary = (resultSet as relationalStore.ResultSet).getDouble((resultSet as relationalStore.ResultSet).getColumnIndex("SALARY"));
7348e41f4b71Sopenharmony_ci}
7349e41f4b71Sopenharmony_ci```
7350e41f4b71Sopenharmony_ci
7351e41f4b71Sopenharmony_ci### getColumnName
7352e41f4b71Sopenharmony_ci
7353e41f4b71Sopenharmony_cigetColumnName(columnIndex: number): string
7354e41f4b71Sopenharmony_ci
7355e41f4b71Sopenharmony_ciObtains the column name based on the specified column index.
7356e41f4b71Sopenharmony_ci
7357e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7358e41f4b71Sopenharmony_ci
7359e41f4b71Sopenharmony_ci**Parameters**
7360e41f4b71Sopenharmony_ci
7361e41f4b71Sopenharmony_ci| Name     | Type  | Mandatory| Description                      |
7362e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | -------------------------- |
7363e41f4b71Sopenharmony_ci| columnIndex | number | Yes  | Column index.|
7364e41f4b71Sopenharmony_ci
7365e41f4b71Sopenharmony_ci**Return value**
7366e41f4b71Sopenharmony_ci
7367e41f4b71Sopenharmony_ci| Type  | Description              |
7368e41f4b71Sopenharmony_ci| ------ | ------------------ |
7369e41f4b71Sopenharmony_ci| string | Column name obtained.|
7370e41f4b71Sopenharmony_ci
7371e41f4b71Sopenharmony_ci**Error codes**
7372e41f4b71Sopenharmony_ci
7373e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
7374e41f4b71Sopenharmony_ci
7375e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
7376e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
7377e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7378e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
7379e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
7380e41f4b71Sopenharmony_ci| 14800013  | Column out of bounds. |
7381e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
7382e41f4b71Sopenharmony_ci| 14800019  | The SQL must be a query statement. |
7383e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
7384e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
7385e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
7386e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
7387e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
7388e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
7389e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
7390e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7391e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
7392e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
7393e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7394e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
7395e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
7396e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
7397e41f4b71Sopenharmony_ci
7398e41f4b71Sopenharmony_ci**Example**
7399e41f4b71Sopenharmony_ci
7400e41f4b71Sopenharmony_ci```ts
7401e41f4b71Sopenharmony_ciif(resultSet != undefined) {
7402e41f4b71Sopenharmony_ci  const id = (resultSet as relationalStore.ResultSet).getColumnName(0);
7403e41f4b71Sopenharmony_ci  const name = (resultSet as relationalStore.ResultSet).getColumnName(1);
7404e41f4b71Sopenharmony_ci  const age = (resultSet as relationalStore.ResultSet).getColumnName(2);
7405e41f4b71Sopenharmony_ci}
7406e41f4b71Sopenharmony_ci```
7407e41f4b71Sopenharmony_ci
7408e41f4b71Sopenharmony_ci### goTo
7409e41f4b71Sopenharmony_ci
7410e41f4b71Sopenharmony_cigoTo(offset:number): boolean
7411e41f4b71Sopenharmony_ci
7412e41f4b71Sopenharmony_ciMoves the cursor to the row based on the specified offset.
7413e41f4b71Sopenharmony_ci
7414e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7415e41f4b71Sopenharmony_ci
7416e41f4b71Sopenharmony_ci**Parameters**
7417e41f4b71Sopenharmony_ci
7418e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                        |
7419e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------------- |
7420e41f4b71Sopenharmony_ci| offset | number | Yes  | Offset relative to the current position.|
7421e41f4b71Sopenharmony_ci
7422e41f4b71Sopenharmony_ci**Return value**
7423e41f4b71Sopenharmony_ci
7424e41f4b71Sopenharmony_ci| Type   | Description                                         |
7425e41f4b71Sopenharmony_ci| ------- | --------------------------------------------- |
7426e41f4b71Sopenharmony_ci| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
7427e41f4b71Sopenharmony_ci
7428e41f4b71Sopenharmony_ci**Error codes**
7429e41f4b71Sopenharmony_ci
7430e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
7431e41f4b71Sopenharmony_ci
7432e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
7433e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
7434e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7435e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
7436e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
7437e41f4b71Sopenharmony_ci| 14800012  | Row out of bounds. |
7438e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
7439e41f4b71Sopenharmony_ci| 14800019  | The SQL must be a query statement. |
7440e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
7441e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
7442e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
7443e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
7444e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
7445e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
7446e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
7447e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7448e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
7449e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
7450e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7451e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
7452e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
7453e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
7454e41f4b71Sopenharmony_ci
7455e41f4b71Sopenharmony_ci**Example**
7456e41f4b71Sopenharmony_ci
7457e41f4b71Sopenharmony_ci```ts
7458e41f4b71Sopenharmony_ciif(resultSet != undefined) {
7459e41f4b71Sopenharmony_ci  (resultSet as relationalStore.ResultSet).goTo(1);
7460e41f4b71Sopenharmony_ci}
7461e41f4b71Sopenharmony_ci```
7462e41f4b71Sopenharmony_ci
7463e41f4b71Sopenharmony_ci### goToRow
7464e41f4b71Sopenharmony_ci
7465e41f4b71Sopenharmony_cigoToRow(position: number): boolean
7466e41f4b71Sopenharmony_ci
7467e41f4b71Sopenharmony_ciMoves to the specified row in the result set.
7468e41f4b71Sopenharmony_ci
7469e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7470e41f4b71Sopenharmony_ci
7471e41f4b71Sopenharmony_ci**Parameters**
7472e41f4b71Sopenharmony_ci
7473e41f4b71Sopenharmony_ci| Name  | Type  | Mandatory| Description                    |
7474e41f4b71Sopenharmony_ci| -------- | ------ | ---- | ------------------------ |
7475e41f4b71Sopenharmony_ci| position | number | Yes  | Destination position to move to.|
7476e41f4b71Sopenharmony_ci
7477e41f4b71Sopenharmony_ci**Return value**
7478e41f4b71Sopenharmony_ci
7479e41f4b71Sopenharmony_ci| Type   | Description                                         |
7480e41f4b71Sopenharmony_ci| ------- | --------------------------------------------- |
7481e41f4b71Sopenharmony_ci| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
7482e41f4b71Sopenharmony_ci
7483e41f4b71Sopenharmony_ci**Error codes**
7484e41f4b71Sopenharmony_ci
7485e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
7486e41f4b71Sopenharmony_ci
7487e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
7488e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
7489e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7490e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
7491e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
7492e41f4b71Sopenharmony_ci| 14800012  | Row out of bounds. |
7493e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
7494e41f4b71Sopenharmony_ci| 14800019  | The SQL must be a query statement. |
7495e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
7496e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
7497e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
7498e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
7499e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
7500e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
7501e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
7502e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7503e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
7504e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
7505e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7506e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
7507e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
7508e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
7509e41f4b71Sopenharmony_ci
7510e41f4b71Sopenharmony_ci**Example**
7511e41f4b71Sopenharmony_ci
7512e41f4b71Sopenharmony_ci```ts
7513e41f4b71Sopenharmony_ciif(resultSet != undefined) {
7514e41f4b71Sopenharmony_ci  (resultSet as relationalStore.ResultSet).goToRow(5);
7515e41f4b71Sopenharmony_ci}
7516e41f4b71Sopenharmony_ci```
7517e41f4b71Sopenharmony_ci
7518e41f4b71Sopenharmony_ci### goToFirstRow
7519e41f4b71Sopenharmony_ci
7520e41f4b71Sopenharmony_cigoToFirstRow(): boolean
7521e41f4b71Sopenharmony_ci
7522e41f4b71Sopenharmony_ci
7523e41f4b71Sopenharmony_ciMoves to the first row of the result set.
7524e41f4b71Sopenharmony_ci
7525e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7526e41f4b71Sopenharmony_ci
7527e41f4b71Sopenharmony_ci**Return value**
7528e41f4b71Sopenharmony_ci
7529e41f4b71Sopenharmony_ci| Type   | Description                                         |
7530e41f4b71Sopenharmony_ci| ------- | --------------------------------------------- |
7531e41f4b71Sopenharmony_ci| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
7532e41f4b71Sopenharmony_ci
7533e41f4b71Sopenharmony_ci**Error codes**
7534e41f4b71Sopenharmony_ci
7535e41f4b71Sopenharmony_ciFor details about the error codes, see [RDB Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
7536e41f4b71Sopenharmony_ci
7537e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
7538e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
7539e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
7540e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
7541e41f4b71Sopenharmony_ci| 14800012  | Row out of bounds. |
7542e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
7543e41f4b71Sopenharmony_ci| 14800019  | The SQL must be a query statement. |
7544e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
7545e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
7546e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
7547e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
7548e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
7549e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
7550e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
7551e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7552e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
7553e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
7554e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7555e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
7556e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
7557e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
7558e41f4b71Sopenharmony_ci
7559e41f4b71Sopenharmony_ci**Example**
7560e41f4b71Sopenharmony_ci
7561e41f4b71Sopenharmony_ci```ts
7562e41f4b71Sopenharmony_ciif(resultSet != undefined) {
7563e41f4b71Sopenharmony_ci  (resultSet as relationalStore.ResultSet).goToFirstRow();
7564e41f4b71Sopenharmony_ci}
7565e41f4b71Sopenharmony_ci```
7566e41f4b71Sopenharmony_ci
7567e41f4b71Sopenharmony_ci### goToLastRow
7568e41f4b71Sopenharmony_ci
7569e41f4b71Sopenharmony_cigoToLastRow(): boolean
7570e41f4b71Sopenharmony_ci
7571e41f4b71Sopenharmony_ciMoves to the last row of the result set.
7572e41f4b71Sopenharmony_ci
7573e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7574e41f4b71Sopenharmony_ci
7575e41f4b71Sopenharmony_ci**Return value**
7576e41f4b71Sopenharmony_ci
7577e41f4b71Sopenharmony_ci| Type   | Description                                         |
7578e41f4b71Sopenharmony_ci| ------- | --------------------------------------------- |
7579e41f4b71Sopenharmony_ci| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
7580e41f4b71Sopenharmony_ci
7581e41f4b71Sopenharmony_ci**Error codes**
7582e41f4b71Sopenharmony_ci
7583e41f4b71Sopenharmony_ciFor details about the error codes, see [RDB Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
7584e41f4b71Sopenharmony_ci
7585e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
7586e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
7587e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
7588e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
7589e41f4b71Sopenharmony_ci| 14800012  | Row out of bounds. |
7590e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
7591e41f4b71Sopenharmony_ci| 14800019  | The SQL must be a query statement. |
7592e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
7593e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
7594e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
7595e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
7596e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
7597e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
7598e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
7599e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7600e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
7601e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
7602e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7603e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
7604e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
7605e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
7606e41f4b71Sopenharmony_ci
7607e41f4b71Sopenharmony_ci**Example**
7608e41f4b71Sopenharmony_ci
7609e41f4b71Sopenharmony_ci```ts
7610e41f4b71Sopenharmony_ciif(resultSet != undefined) {
7611e41f4b71Sopenharmony_ci  (resultSet as relationalStore.ResultSet).goToLastRow();
7612e41f4b71Sopenharmony_ci}
7613e41f4b71Sopenharmony_ci```
7614e41f4b71Sopenharmony_ci
7615e41f4b71Sopenharmony_ci### goToNextRow
7616e41f4b71Sopenharmony_ci
7617e41f4b71Sopenharmony_cigoToNextRow(): boolean
7618e41f4b71Sopenharmony_ci
7619e41f4b71Sopenharmony_ciMoves to the next row in the result set.
7620e41f4b71Sopenharmony_ci
7621e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7622e41f4b71Sopenharmony_ci
7623e41f4b71Sopenharmony_ci**Return value**
7624e41f4b71Sopenharmony_ci
7625e41f4b71Sopenharmony_ci| Type   | Description                                         |
7626e41f4b71Sopenharmony_ci| ------- | --------------------------------------------- |
7627e41f4b71Sopenharmony_ci| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
7628e41f4b71Sopenharmony_ci
7629e41f4b71Sopenharmony_ci**Error codes**
7630e41f4b71Sopenharmony_ci
7631e41f4b71Sopenharmony_ciFor details about the error codes, see [RDB Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
7632e41f4b71Sopenharmony_ci
7633e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
7634e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
7635e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
7636e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
7637e41f4b71Sopenharmony_ci| 14800012  | Row out of bounds. |
7638e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
7639e41f4b71Sopenharmony_ci| 14800019  | The SQL must be a query statement. |
7640e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
7641e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
7642e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
7643e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
7644e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
7645e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
7646e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
7647e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7648e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
7649e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
7650e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7651e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
7652e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
7653e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
7654e41f4b71Sopenharmony_ci
7655e41f4b71Sopenharmony_ci**Example**
7656e41f4b71Sopenharmony_ci
7657e41f4b71Sopenharmony_ci```ts
7658e41f4b71Sopenharmony_ciif(resultSet != undefined) {
7659e41f4b71Sopenharmony_ci  (resultSet as relationalStore.ResultSet).goToNextRow();
7660e41f4b71Sopenharmony_ci}
7661e41f4b71Sopenharmony_ci```
7662e41f4b71Sopenharmony_ci
7663e41f4b71Sopenharmony_ci### goToPreviousRow
7664e41f4b71Sopenharmony_ci
7665e41f4b71Sopenharmony_cigoToPreviousRow(): boolean
7666e41f4b71Sopenharmony_ci
7667e41f4b71Sopenharmony_ciMoves to the previous row in the result set.
7668e41f4b71Sopenharmony_ci
7669e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7670e41f4b71Sopenharmony_ci
7671e41f4b71Sopenharmony_ci**Return value**
7672e41f4b71Sopenharmony_ci
7673e41f4b71Sopenharmony_ci| Type   | Description                                         |
7674e41f4b71Sopenharmony_ci| ------- | --------------------------------------------- |
7675e41f4b71Sopenharmony_ci| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
7676e41f4b71Sopenharmony_ci
7677e41f4b71Sopenharmony_ci**Error codes**
7678e41f4b71Sopenharmony_ci
7679e41f4b71Sopenharmony_ciFor details about the error codes, see [RDB Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
7680e41f4b71Sopenharmony_ci
7681e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
7682e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
7683e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
7684e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
7685e41f4b71Sopenharmony_ci| 14800012  | Row out of bounds. |
7686e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
7687e41f4b71Sopenharmony_ci| 14800019  | The SQL must be a query statement. |
7688e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
7689e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
7690e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
7691e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
7692e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
7693e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
7694e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
7695e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7696e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
7697e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
7698e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7699e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
7700e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
7701e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
7702e41f4b71Sopenharmony_ci
7703e41f4b71Sopenharmony_ci**Example**
7704e41f4b71Sopenharmony_ci
7705e41f4b71Sopenharmony_ci```ts
7706e41f4b71Sopenharmony_ciif(resultSet != undefined) {
7707e41f4b71Sopenharmony_ci  (resultSet as relationalStore.ResultSet).goToPreviousRow();
7708e41f4b71Sopenharmony_ci}
7709e41f4b71Sopenharmony_ci```
7710e41f4b71Sopenharmony_ci
7711e41f4b71Sopenharmony_ci### getValue<sup>12+</sup>
7712e41f4b71Sopenharmony_ci
7713e41f4b71Sopenharmony_cigetValue(columnIndex: number): ValueType
7714e41f4b71Sopenharmony_ci
7715e41f4b71Sopenharmony_ciObtains the value from the specified column and current row. If the value type is any of **ValueType**, the value of the corresponding type will be returned. Otherwise, **14800000** will be returned.
7716e41f4b71Sopenharmony_ci
7717e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7718e41f4b71Sopenharmony_ci
7719e41f4b71Sopenharmony_ci**Parameters**
7720e41f4b71Sopenharmony_ci
7721e41f4b71Sopenharmony_ci| Name     | Type  | Mandatory| Description                   |
7722e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | ----------------------- |
7723e41f4b71Sopenharmony_ci| columnIndex | number | Yes  | Index of the target column, starting from 0.|
7724e41f4b71Sopenharmony_ci
7725e41f4b71Sopenharmony_ci**Return value**
7726e41f4b71Sopenharmony_ci
7727e41f4b71Sopenharmony_ci| Type      | Description                            |
7728e41f4b71Sopenharmony_ci| ---------- | -------------------------------- |
7729e41f4b71Sopenharmony_ci| [ValueType](#valuetype) | Value obtained. |
7730e41f4b71Sopenharmony_ci
7731e41f4b71Sopenharmony_ci**Error codes**
7732e41f4b71Sopenharmony_ci
7733e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
7734e41f4b71Sopenharmony_ci
7735e41f4b71Sopenharmony_ci| **ID**| **Error Message**    |
7736e41f4b71Sopenharmony_ci|-----------|---------|
7737e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7738e41f4b71Sopenharmony_ci| 14800000  | Inner error.      |
7739e41f4b71Sopenharmony_ci| 14800011  | Database corrupted.        |
7740e41f4b71Sopenharmony_ci| 14800012  | Row out of bounds.       |
7741e41f4b71Sopenharmony_ci| 14800013  | Column out of bounds.   |
7742e41f4b71Sopenharmony_ci| 14800014  | Already closed.       |
7743e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error.    |
7744e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort.     |
7745e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied.    |
7746e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked.    |
7747e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked.  |
7748e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory.    |
7749e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database.    |
7750e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred.    |
7751e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full.   |
7752e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file.    |
7753e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit.    |
7754e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation.   |
7755e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch.      |
7756e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly.    |
7757e41f4b71Sopenharmony_ci
7758e41f4b71Sopenharmony_ci**Example**
7759e41f4b71Sopenharmony_ci
7760e41f4b71Sopenharmony_ci```ts
7761e41f4b71Sopenharmony_ciif(resultSet != undefined) {
7762e41f4b71Sopenharmony_ci  const codes = (resultSet as relationalStore.ResultSet).getValue((resultSet as relationalStore.ResultSet).getColumnIndex("BIGINT_COLUMN"));
7763e41f4b71Sopenharmony_ci}
7764e41f4b71Sopenharmony_ci```
7765e41f4b71Sopenharmony_ci
7766e41f4b71Sopenharmony_ci### getBlob
7767e41f4b71Sopenharmony_ci
7768e41f4b71Sopenharmony_cigetBlob(columnIndex: number): Uint8Array
7769e41f4b71Sopenharmony_ci
7770e41f4b71Sopenharmony_ci
7771e41f4b71Sopenharmony_ciObtains the value from the specified column and current row, and returns it in a byte array.<br>If the type of the value in the specified column is INTEGER, DOUBLE, TEXT, or BLOB, the value will be converted into a byte array and returned. If the column is empty, an empty byte array will be returned. If the value is of any other type, **14800000** will be returned.
7772e41f4b71Sopenharmony_ci
7773e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7774e41f4b71Sopenharmony_ci
7775e41f4b71Sopenharmony_ci**Parameters**
7776e41f4b71Sopenharmony_ci
7777e41f4b71Sopenharmony_ci| Name     | Type  | Mandatory| Description                   |
7778e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | ----------------------- |
7779e41f4b71Sopenharmony_ci| columnIndex | number | Yes  | Index of the target column, starting from 0.|
7780e41f4b71Sopenharmony_ci
7781e41f4b71Sopenharmony_ci**Return value**
7782e41f4b71Sopenharmony_ci
7783e41f4b71Sopenharmony_ci| Type      | Description                            |
7784e41f4b71Sopenharmony_ci| ---------- | -------------------------------- |
7785e41f4b71Sopenharmony_ci| Uint8Array | Value obtained.|
7786e41f4b71Sopenharmony_ci
7787e41f4b71Sopenharmony_ci**Error codes**
7788e41f4b71Sopenharmony_ci
7789e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
7790e41f4b71Sopenharmony_ci
7791e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
7792e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
7793e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7794e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
7795e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
7796e41f4b71Sopenharmony_ci| 14800012  | Row out of bounds. |
7797e41f4b71Sopenharmony_ci| 14800013  | Column out of bounds. |
7798e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
7799e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
7800e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
7801e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
7802e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
7803e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
7804e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
7805e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
7806e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7807e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
7808e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
7809e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7810e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
7811e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
7812e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
7813e41f4b71Sopenharmony_ci
7814e41f4b71Sopenharmony_ci**Example**
7815e41f4b71Sopenharmony_ci
7816e41f4b71Sopenharmony_ci```ts
7817e41f4b71Sopenharmony_ciif(resultSet != undefined) {
7818e41f4b71Sopenharmony_ci  const codes = (resultSet as relationalStore.ResultSet).getBlob((resultSet as relationalStore.ResultSet).getColumnIndex("CODES"));
7819e41f4b71Sopenharmony_ci}
7820e41f4b71Sopenharmony_ci```
7821e41f4b71Sopenharmony_ci
7822e41f4b71Sopenharmony_ci### getString
7823e41f4b71Sopenharmony_ci
7824e41f4b71Sopenharmony_cigetString(columnIndex: number): string
7825e41f4b71Sopenharmony_ci
7826e41f4b71Sopenharmony_ciObtains the value from the specified column and current row, and returns it in the form of a string.<br>If the type of the value in the specified column is INTEGER, DOUBLE, TEXT, or BLOB, a string will be returned. If the value type is INTEGER and the column is empty, an empty string will be returned. If the value is of any other type, **14800000** will be returned.
7827e41f4b71Sopenharmony_ci
7828e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7829e41f4b71Sopenharmony_ci
7830e41f4b71Sopenharmony_ci**Parameters**
7831e41f4b71Sopenharmony_ci
7832e41f4b71Sopenharmony_ci| Name     | Type  | Mandatory| Description                   |
7833e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | ----------------------- |
7834e41f4b71Sopenharmony_ci| columnIndex | number | Yes  | Index of the target column, starting from 0.|
7835e41f4b71Sopenharmony_ci
7836e41f4b71Sopenharmony_ci**Return value**
7837e41f4b71Sopenharmony_ci
7838e41f4b71Sopenharmony_ci| Type  | Description                        |
7839e41f4b71Sopenharmony_ci| ------ | ---------------------------- |
7840e41f4b71Sopenharmony_ci| string | String obtained.|
7841e41f4b71Sopenharmony_ci
7842e41f4b71Sopenharmony_ci**Error codes**
7843e41f4b71Sopenharmony_ci
7844e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
7845e41f4b71Sopenharmony_ci
7846e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
7847e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
7848e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7849e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
7850e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
7851e41f4b71Sopenharmony_ci| 14800012  | Row out of bounds. |
7852e41f4b71Sopenharmony_ci| 14800013  | Column out of bounds. |
7853e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
7854e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
7855e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
7856e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
7857e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
7858e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
7859e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
7860e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
7861e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7862e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
7863e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
7864e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7865e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
7866e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
7867e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
7868e41f4b71Sopenharmony_ci
7869e41f4b71Sopenharmony_ci**Example**
7870e41f4b71Sopenharmony_ci
7871e41f4b71Sopenharmony_ci```ts
7872e41f4b71Sopenharmony_ciif(resultSet != undefined) {
7873e41f4b71Sopenharmony_ci  const name = (resultSet as relationalStore.ResultSet).getString((resultSet as relationalStore.ResultSet).getColumnIndex("NAME"));
7874e41f4b71Sopenharmony_ci}
7875e41f4b71Sopenharmony_ci```
7876e41f4b71Sopenharmony_ci
7877e41f4b71Sopenharmony_ci### getLong
7878e41f4b71Sopenharmony_ci
7879e41f4b71Sopenharmony_cigetLong(columnIndex: number): number
7880e41f4b71Sopenharmony_ci
7881e41f4b71Sopenharmony_ciObtains the value from the specified column and current row, and returns a value of Long type.<br>If the type of the value in the specified column is INTEGER, DOUBLE, TEXT, or BLOB, a value of Long type will be returned. If the column is empty, **0** will be returned. If the value is of any other type, **14800000** will be returned.
7882e41f4b71Sopenharmony_ci
7883e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7884e41f4b71Sopenharmony_ci
7885e41f4b71Sopenharmony_ci**Parameters**
7886e41f4b71Sopenharmony_ci
7887e41f4b71Sopenharmony_ci| Name     | Type  | Mandatory| Description                   |
7888e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | ----------------------- |
7889e41f4b71Sopenharmony_ci| columnIndex | number | Yes  | Index of the target column, starting from 0.|
7890e41f4b71Sopenharmony_ci
7891e41f4b71Sopenharmony_ci**Return value**
7892e41f4b71Sopenharmony_ci
7893e41f4b71Sopenharmony_ci| Type  | Description                                                        |
7894e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ |
7895e41f4b71Sopenharmony_ci| number | Value obtained.<br>The value range supported by this API is **Number.MIN_SAFE_INTEGER** to **Number.MAX_SAFE_INTEGER**. If the value is out of this range, use [getDouble](#getdouble).|
7896e41f4b71Sopenharmony_ci
7897e41f4b71Sopenharmony_ci**Error codes**
7898e41f4b71Sopenharmony_ci
7899e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
7900e41f4b71Sopenharmony_ci
7901e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
7902e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
7903e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7904e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
7905e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
7906e41f4b71Sopenharmony_ci| 14800012  | Row out of bounds. |
7907e41f4b71Sopenharmony_ci| 14800013  | Column out of bounds. |
7908e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
7909e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
7910e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
7911e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
7912e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
7913e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
7914e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
7915e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
7916e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7917e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
7918e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
7919e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7920e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
7921e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
7922e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
7923e41f4b71Sopenharmony_ci
7924e41f4b71Sopenharmony_ci**Example**
7925e41f4b71Sopenharmony_ci
7926e41f4b71Sopenharmony_ci```ts
7927e41f4b71Sopenharmony_ciif(resultSet != undefined) {
7928e41f4b71Sopenharmony_ci  const age = (resultSet as relationalStore.ResultSet).getLong((resultSet as relationalStore.ResultSet).getColumnIndex("AGE"));
7929e41f4b71Sopenharmony_ci }
7930e41f4b71Sopenharmony_ci```
7931e41f4b71Sopenharmony_ci
7932e41f4b71Sopenharmony_ci### getDouble
7933e41f4b71Sopenharmony_ci
7934e41f4b71Sopenharmony_cigetDouble(columnIndex: number): number
7935e41f4b71Sopenharmony_ci
7936e41f4b71Sopenharmony_ciObtains the value from the specified column and current row, and returns a value of double type.<br>If the type of the value in the specified column is INTEGER, DOUBLE, TEXT, or BLOB, a value of double type will be returned. If the column is empty, **0.0** will be returned. If the value is of any other type, **14800000** will be returned.
7937e41f4b71Sopenharmony_ci
7938e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7939e41f4b71Sopenharmony_ci
7940e41f4b71Sopenharmony_ci**Parameters**
7941e41f4b71Sopenharmony_ci
7942e41f4b71Sopenharmony_ci| Name     | Type  | Mandatory| Description                   |
7943e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | ----------------------- |
7944e41f4b71Sopenharmony_ci| columnIndex | number | Yes  | Index of the target column, starting from 0.|
7945e41f4b71Sopenharmony_ci
7946e41f4b71Sopenharmony_ci**Return value**
7947e41f4b71Sopenharmony_ci
7948e41f4b71Sopenharmony_ci| Type  | Description                        |
7949e41f4b71Sopenharmony_ci| ------ | ---------------------------- |
7950e41f4b71Sopenharmony_ci| number | Returns the value obtained.|
7951e41f4b71Sopenharmony_ci
7952e41f4b71Sopenharmony_ci**Error codes**
7953e41f4b71Sopenharmony_ci
7954e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
7955e41f4b71Sopenharmony_ci
7956e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
7957e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
7958e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7959e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
7960e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
7961e41f4b71Sopenharmony_ci| 14800012  | Row out of bounds. |
7962e41f4b71Sopenharmony_ci| 14800013  | Column out of bounds. |
7963e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
7964e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
7965e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
7966e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
7967e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
7968e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
7969e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
7970e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
7971e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7972e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
7973e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
7974e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7975e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
7976e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
7977e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
7978e41f4b71Sopenharmony_ci
7979e41f4b71Sopenharmony_ci**Example**
7980e41f4b71Sopenharmony_ci
7981e41f4b71Sopenharmony_ci```ts
7982e41f4b71Sopenharmony_ciif(resultSet != undefined) {
7983e41f4b71Sopenharmony_ci  const salary = (resultSet as relationalStore.ResultSet).getDouble((resultSet as relationalStore.ResultSet).getColumnIndex("SALARY"));
7984e41f4b71Sopenharmony_ci}
7985e41f4b71Sopenharmony_ci```
7986e41f4b71Sopenharmony_ci
7987e41f4b71Sopenharmony_ci### getAsset<sup>10+</sup>
7988e41f4b71Sopenharmony_ci
7989e41f4b71Sopenharmony_cigetAsset(columnIndex: number): Asset
7990e41f4b71Sopenharmony_ci
7991e41f4b71Sopenharmony_ciObtains the value from the specified column and current row, and returns the value in the [Asset](#asset10) format. If the type of the value in the column is **Asset**, the value of the Asset type is returned. If the value in the column is null, **null** is returned. If the value in the column is of other types, **14800000** is returned.
7992e41f4b71Sopenharmony_ci
7993e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7994e41f4b71Sopenharmony_ci
7995e41f4b71Sopenharmony_ci**Parameters**
7996e41f4b71Sopenharmony_ci
7997e41f4b71Sopenharmony_ci| Name        | Type    | Mandatory | Description          |
7998e41f4b71Sopenharmony_ci| ----------- | ------ | --- | ------------ |
7999e41f4b71Sopenharmony_ci| columnIndex | number | Yes  | Index of the target column, starting from 0.|
8000e41f4b71Sopenharmony_ci
8001e41f4b71Sopenharmony_ci**Return value**
8002e41f4b71Sopenharmony_ci
8003e41f4b71Sopenharmony_ci| Type             | Description                        |
8004e41f4b71Sopenharmony_ci| --------------- | -------------------------- |
8005e41f4b71Sopenharmony_ci| [Asset](#asset10) | Returns the value obtained.|
8006e41f4b71Sopenharmony_ci
8007e41f4b71Sopenharmony_ci**Error codes**
8008e41f4b71Sopenharmony_ci
8009e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
8010e41f4b71Sopenharmony_ci
8011e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
8012e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
8013e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
8014e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
8015e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
8016e41f4b71Sopenharmony_ci| 14800012  | Row out of bounds. |
8017e41f4b71Sopenharmony_ci| 14800013  | Column out of bounds. |
8018e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
8019e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
8020e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
8021e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
8022e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
8023e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
8024e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
8025e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
8026e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
8027e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
8028e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
8029e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
8030e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
8031e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
8032e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
8033e41f4b71Sopenharmony_ci
8034e41f4b71Sopenharmony_ci**Example**
8035e41f4b71Sopenharmony_ci
8036e41f4b71Sopenharmony_ci```ts
8037e41f4b71Sopenharmony_ciif(resultSet != undefined) {
8038e41f4b71Sopenharmony_ci  const doc = (resultSet as relationalStore.ResultSet).getAsset((resultSet as relationalStore.ResultSet).getColumnIndex("DOC"));
8039e41f4b71Sopenharmony_ci}
8040e41f4b71Sopenharmony_ci```
8041e41f4b71Sopenharmony_ci
8042e41f4b71Sopenharmony_ci### getAssets<sup>10+</sup>
8043e41f4b71Sopenharmony_ci
8044e41f4b71Sopenharmony_cigetAssets(columnIndex: number): Assets
8045e41f4b71Sopenharmony_ci
8046e41f4b71Sopenharmony_ciObtains the value from the specified column and current row, and returns the value in the [Assets](#assets10) format. If the type of the value in the column is **Assets**, the value of the Assets type is returned. If the value in the column is null, **null** is returned. If the value in the column is of other types, **14800000** is returned.
8047e41f4b71Sopenharmony_ci
8048e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
8049e41f4b71Sopenharmony_ci
8050e41f4b71Sopenharmony_ci**Parameters**
8051e41f4b71Sopenharmony_ci
8052e41f4b71Sopenharmony_ci| Name        | Type    | Mandatory | Description          |
8053e41f4b71Sopenharmony_ci| ----------- | ------ | --- | ------------ |
8054e41f4b71Sopenharmony_ci| columnIndex | number | Yes  | Index of the target column, starting from 0.|
8055e41f4b71Sopenharmony_ci
8056e41f4b71Sopenharmony_ci**Return value**
8057e41f4b71Sopenharmony_ci
8058e41f4b71Sopenharmony_ci| Type             | Description                          |
8059e41f4b71Sopenharmony_ci| ---------------- | ---------------------------- |
8060e41f4b71Sopenharmony_ci| [Assets](#assets10)| Returns the value obtained.|
8061e41f4b71Sopenharmony_ci
8062e41f4b71Sopenharmony_ci**Error codes**
8063e41f4b71Sopenharmony_ci
8064e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
8065e41f4b71Sopenharmony_ci
8066e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
8067e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
8068e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
8069e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
8070e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
8071e41f4b71Sopenharmony_ci| 14800012  | Row out of bounds. |
8072e41f4b71Sopenharmony_ci| 14800013  | Column out of bounds. |
8073e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
8074e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
8075e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
8076e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
8077e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
8078e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
8079e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
8080e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
8081e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
8082e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
8083e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
8084e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
8085e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
8086e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
8087e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
8088e41f4b71Sopenharmony_ci
8089e41f4b71Sopenharmony_ci**Example**
8090e41f4b71Sopenharmony_ci
8091e41f4b71Sopenharmony_ci```ts
8092e41f4b71Sopenharmony_ciif(resultSet != undefined) {
8093e41f4b71Sopenharmony_ci  const docs = (resultSet as relationalStore.ResultSet).getAssets((resultSet as relationalStore.ResultSet).getColumnIndex("DOCS"));
8094e41f4b71Sopenharmony_ci}
8095e41f4b71Sopenharmony_ci```
8096e41f4b71Sopenharmony_ci
8097e41f4b71Sopenharmony_ci### getRow<sup>11+</sup>
8098e41f4b71Sopenharmony_ci
8099e41f4b71Sopenharmony_cigetRow(): ValuesBucket
8100e41f4b71Sopenharmony_ci
8101e41f4b71Sopenharmony_ciObtains the data in the current row.
8102e41f4b71Sopenharmony_ci
8103e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
8104e41f4b71Sopenharmony_ci
8105e41f4b71Sopenharmony_ci**Return value**
8106e41f4b71Sopenharmony_ci
8107e41f4b71Sopenharmony_ci| Type             | Description                          |
8108e41f4b71Sopenharmony_ci| ---------------- | ---------------------------- |
8109e41f4b71Sopenharmony_ci| [ValuesBucket](#valuesbucket) | Data obtained.|
8110e41f4b71Sopenharmony_ci
8111e41f4b71Sopenharmony_ci**Error codes**
8112e41f4b71Sopenharmony_ci
8113e41f4b71Sopenharmony_ciFor details about the error codes, see [RDB Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
8114e41f4b71Sopenharmony_ci
8115e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
8116e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
8117e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
8118e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
8119e41f4b71Sopenharmony_ci| 14800012  | Row out of bounds. |
8120e41f4b71Sopenharmony_ci| 14800013  | Column out of bounds. |
8121e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
8122e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
8123e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
8124e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
8125e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
8126e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
8127e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
8128e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
8129e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
8130e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
8131e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
8132e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
8133e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
8134e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
8135e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
8136e41f4b71Sopenharmony_ci
8137e41f4b71Sopenharmony_ci**Example**
8138e41f4b71Sopenharmony_ci
8139e41f4b71Sopenharmony_ci```ts
8140e41f4b71Sopenharmony_ciif(resultSet != undefined) {
8141e41f4b71Sopenharmony_ci  const row = (resultSet as relationalStore.ResultSet).getRow();
8142e41f4b71Sopenharmony_ci}
8143e41f4b71Sopenharmony_ci```
8144e41f4b71Sopenharmony_ci
8145e41f4b71Sopenharmony_ci### getSendableRow<sup>12+</sup>
8146e41f4b71Sopenharmony_ci
8147e41f4b71Sopenharmony_cigetSendableRow(): sendableRelationalStore.ValuesBucket
8148e41f4b71Sopenharmony_ci
8149e41f4b71Sopenharmony_ciObtains the Sendable data from the current row. The data obtained is used for cross-thread transfer.
8150e41f4b71Sopenharmony_ci
8151e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
8152e41f4b71Sopenharmony_ci
8153e41f4b71Sopenharmony_ci**Return value**
8154e41f4b71Sopenharmony_ci
8155e41f4b71Sopenharmony_ci| Type                                                                                          | Description                                          |
8156e41f4b71Sopenharmony_ci| ---------------------------------------------------------------------------------------------- | ---------------------------------------------- |
8157e41f4b71Sopenharmony_ci| [sendableRelationalStore.ValuesBucket](./js-apis-data-sendableRelationalStore.md#valuesbucket) | Sendable data obtained for cross-thread transfer.|
8158e41f4b71Sopenharmony_ci
8159e41f4b71Sopenharmony_ci**Error codes**
8160e41f4b71Sopenharmony_ci
8161e41f4b71Sopenharmony_ciFor details about the error codes, see [RDB Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
8162e41f4b71Sopenharmony_ci
8163e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                 |
8164e41f4b71Sopenharmony_ci| ------------ | --------------------------------------------- |
8165e41f4b71Sopenharmony_ci| 14800000     | Inner error.                                  |
8166e41f4b71Sopenharmony_ci| 14800011     | Database corrupted.                           |
8167e41f4b71Sopenharmony_ci| 14800012     | Row out of bounds.                            |
8168e41f4b71Sopenharmony_ci| 14800013     | Column out of bounds.                         |
8169e41f4b71Sopenharmony_ci| 14800014     | Already closed.                               |
8170e41f4b71Sopenharmony_ci| 14800021     | SQLite: Generic error.                        |
8171e41f4b71Sopenharmony_ci| 14800022     | SQLite: Callback routine requested an abort.  |
8172e41f4b71Sopenharmony_ci| 14800023     | SQLite: Access permission denied.             |
8173e41f4b71Sopenharmony_ci| 14800024     | SQLite: The database file is locked.          |
8174e41f4b71Sopenharmony_ci| 14800025     | SQLite: A table in the database is locked.    |
8175e41f4b71Sopenharmony_ci| 14800026     | SQLite: The database is out of memory.        |
8176e41f4b71Sopenharmony_ci| 14800027     | SQLite: Attempt to write a readonly database. |
8177e41f4b71Sopenharmony_ci| 14800028     | SQLite: Some kind of disk I/O error occurred. |
8178e41f4b71Sopenharmony_ci| 14800029     | SQLite: The database is full.                 |
8179e41f4b71Sopenharmony_ci| 14800030     | SQLite: Unable to open the database file.     |
8180e41f4b71Sopenharmony_ci| 14800031     | SQLite: TEXT or BLOB exceeds size limit.      |
8181e41f4b71Sopenharmony_ci| 14800032     | SQLite: Abort due to constraint violation.    |
8182e41f4b71Sopenharmony_ci| 14800033     | SQLite: Data type mismatch.                   |
8183e41f4b71Sopenharmony_ci| 14800034     | SQLite: Library used incorrectly.             |
8184e41f4b71Sopenharmony_ci
8185e41f4b71Sopenharmony_ci**Example**
8186e41f4b71Sopenharmony_ci
8187e41f4b71Sopenharmony_ci```ts
8188e41f4b71Sopenharmony_ciimport { taskpool } from '@kit.ArkTS';
8189e41f4b71Sopenharmony_ciimport type ctx from '@ohos.app.ability.common';
8190e41f4b71Sopenharmony_ciimport { sendableRelationalStore } from '@kit.ArkData';
8191e41f4b71Sopenharmony_ci
8192e41f4b71Sopenharmony_ci@Concurrent
8193e41f4b71Sopenharmony_ciasync function getDataByName(name: string, context: ctx.UIAbilityContext) {
8194e41f4b71Sopenharmony_ci  const STORE_CONFIG: relationalStore.StoreConfig = {
8195e41f4b71Sopenharmony_ci    name: "RdbTest.db",
8196e41f4b71Sopenharmony_ci    securityLevel: relationalStore.SecurityLevel.S3
8197e41f4b71Sopenharmony_ci  };
8198e41f4b71Sopenharmony_ci  const store = await relationalStore.getRdbStore(context, STORE_CONFIG);
8199e41f4b71Sopenharmony_ci  const predicates = new relationalStore.RdbPredicates("EMPLOYEE");
8200e41f4b71Sopenharmony_ci  predicates.equalTo("NAME", name);
8201e41f4b71Sopenharmony_ci  const resultSet = store.querySync(predicates);
8202e41f4b71Sopenharmony_ci
8203e41f4b71Sopenharmony_ci  if (resultSet.rowCount > 0) {
8204e41f4b71Sopenharmony_ci    resultSet.goToFirstRow();
8205e41f4b71Sopenharmony_ci    const sendableValuesBucket = resultSet.getSendableRow();
8206e41f4b71Sopenharmony_ci    return sendableValuesBucket;
8207e41f4b71Sopenharmony_ci  } else {
8208e41f4b71Sopenharmony_ci    return null;
8209e41f4b71Sopenharmony_ci  }
8210e41f4b71Sopenharmony_ci}
8211e41f4b71Sopenharmony_ci
8212e41f4b71Sopenharmony_ciconst task = new taskpool.Task(getDataByName, 'Lisa', this.context);
8213e41f4b71Sopenharmony_ciconst sendableValuesBucket  = await taskpool.execute(task) as sendableRelationalStore.ValuesBucket;
8214e41f4b71Sopenharmony_ci
8215e41f4b71Sopenharmony_ciif (sendableValuesBucket) {
8216e41f4b71Sopenharmony_ci  const columnCount = sendableValuesBucket.size;
8217e41f4b71Sopenharmony_ci  const age = sendableValuesBucket.get('age');
8218e41f4b71Sopenharmony_ci  const name = sendableValuesBucket.get('name');
8219e41f4b71Sopenharmony_ci  console.info(`Query data in taskpool succeeded, name is "${name}", age is "${age}"`)
8220e41f4b71Sopenharmony_ci}
8221e41f4b71Sopenharmony_ci```
8222e41f4b71Sopenharmony_ci
8223e41f4b71Sopenharmony_ci### isColumnNull
8224e41f4b71Sopenharmony_ci
8225e41f4b71Sopenharmony_ciisColumnNull(columnIndex: number): boolean
8226e41f4b71Sopenharmony_ci
8227e41f4b71Sopenharmony_ciChecks whether the value in the specified column is null.
8228e41f4b71Sopenharmony_ci
8229e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
8230e41f4b71Sopenharmony_ci
8231e41f4b71Sopenharmony_ci**Parameters**
8232e41f4b71Sopenharmony_ci
8233e41f4b71Sopenharmony_ci| Name     | Type  | Mandatory| Description                   |
8234e41f4b71Sopenharmony_ci| ----------- | ------ | ---- | ----------------------- |
8235e41f4b71Sopenharmony_ci| columnIndex | number | Yes  | Index of the target column, starting from 0.|
8236e41f4b71Sopenharmony_ci
8237e41f4b71Sopenharmony_ci**Return value**
8238e41f4b71Sopenharmony_ci
8239e41f4b71Sopenharmony_ci| Type   | Description                                                     |
8240e41f4b71Sopenharmony_ci| ------- | --------------------------------------------------------- |
8241e41f4b71Sopenharmony_ci| boolean | Returns **true** if the value is null; returns **false** otherwise.|
8242e41f4b71Sopenharmony_ci
8243e41f4b71Sopenharmony_ci**Error codes**
8244e41f4b71Sopenharmony_ci
8245e41f4b71Sopenharmony_ciFor details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md). For details about how to handle error 14800011, see [Database Backup and Restore](../../database/data-backup-and-restore.md).
8246e41f4b71Sopenharmony_ci
8247e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
8248e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------- |
8249e41f4b71Sopenharmony_ci| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
8250e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
8251e41f4b71Sopenharmony_ci| 14800011  | Database corrupted. |
8252e41f4b71Sopenharmony_ci| 14800012  | Row out of bounds. |
8253e41f4b71Sopenharmony_ci| 14800013  | Column out of bounds. |
8254e41f4b71Sopenharmony_ci| 14800014  | Already closed. |
8255e41f4b71Sopenharmony_ci| 14800021  | SQLite: Generic error. |
8256e41f4b71Sopenharmony_ci| 14800022  | SQLite: Callback routine requested an abort. |
8257e41f4b71Sopenharmony_ci| 14800023  | SQLite: Access permission denied. |
8258e41f4b71Sopenharmony_ci| 14800024  | SQLite: The database file is locked. |
8259e41f4b71Sopenharmony_ci| 14800025  | SQLite: A table in the database is locked. |
8260e41f4b71Sopenharmony_ci| 14800026  | SQLite: The database is out of memory. |
8261e41f4b71Sopenharmony_ci| 14800027  | SQLite: Attempt to write a readonly database. |
8262e41f4b71Sopenharmony_ci| 14800028  | SQLite: Some kind of disk I/O error occurred. |
8263e41f4b71Sopenharmony_ci| 14800029  | SQLite: The database is full. |
8264e41f4b71Sopenharmony_ci| 14800030  | SQLite: Unable to open the database file. |
8265e41f4b71Sopenharmony_ci| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
8266e41f4b71Sopenharmony_ci| 14800032  | SQLite: Abort due to constraint violation. |
8267e41f4b71Sopenharmony_ci| 14800033  | SQLite: Data type mismatch. |
8268e41f4b71Sopenharmony_ci| 14800034  | SQLite: Library used incorrectly. |
8269e41f4b71Sopenharmony_ci
8270e41f4b71Sopenharmony_ci**Example**
8271e41f4b71Sopenharmony_ci
8272e41f4b71Sopenharmony_ci```ts
8273e41f4b71Sopenharmony_ciif(resultSet != undefined) {
8274e41f4b71Sopenharmony_ci  const isColumnNull = (resultSet as relationalStore.ResultSet).isColumnNull((resultSet as relationalStore.ResultSet).getColumnIndex("CODES"));
8275e41f4b71Sopenharmony_ci}
8276e41f4b71Sopenharmony_ci```
8277e41f4b71Sopenharmony_ci
8278e41f4b71Sopenharmony_ci### close
8279e41f4b71Sopenharmony_ci
8280e41f4b71Sopenharmony_ciclose(): void
8281e41f4b71Sopenharmony_ci
8282e41f4b71Sopenharmony_ciCloses this **resultSet** to release memory. If the **resultSet** is not closed, FD or memory leaks may occur.
8283e41f4b71Sopenharmony_ci
8284e41f4b71Sopenharmony_ci**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
8285e41f4b71Sopenharmony_ci
8286e41f4b71Sopenharmony_ci**Example**
8287e41f4b71Sopenharmony_ci
8288e41f4b71Sopenharmony_ci```ts
8289e41f4b71Sopenharmony_ciif(resultSet != undefined) {
8290e41f4b71Sopenharmony_ci  (resultSet as relationalStore.ResultSet).close();
8291e41f4b71Sopenharmony_ci}
8292e41f4b71Sopenharmony_ci```
8293e41f4b71Sopenharmony_ci
8294e41f4b71Sopenharmony_ci**Error codes**
8295e41f4b71Sopenharmony_ci
8296e41f4b71Sopenharmony_ciFor details about the error codes, see [RDB Error Codes](errorcode-data-rdb.md).
8297e41f4b71Sopenharmony_ci
8298e41f4b71Sopenharmony_ci| **ID**| **Error Message**                                                |
8299e41f4b71Sopenharmony_ci|-----------| ------------------------------------------------------------ |
8300e41f4b71Sopenharmony_ci| 14800000  | Inner error. |
8301e41f4b71Sopenharmony_ci| 14800012  | Row out of bounds. |
8302