1# @ohos.data.relationalStore (RDB Store)
2
3The relational database (RDB) store manages data based on relational models. The **relationalStore** module provides a complete mechanism for managing local databases based on the underlying SQLite. You can use the APIs to perform operations such as adding, deleting, modifying, and querying data, and directly run SQL statements. You can also use [ResultSet.getSendableRow](#getsendablerow12) to obtain sendable data for cross-thread transmission.
4
5The 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.
6
7Querying data from a large amount of data may take time or even cause application suspension. In this case, you can perform batch operations. For details, see [Batch Database Operations](../../arkts-utils/batch-database-operations-guide.md). Moreover, observe the following:
8- The number of data records to be queried at a time should not exceed 5000.
9- Use [TaskPool](../apis-arkts/js-apis-taskpool.md) if there is a large amount of data needs to be queried.
10- Keep concatenated SQL statements as concise as possible.
11- Query data in batches.
12
13The **relationalStore** module provides the following functionality:
14
15- [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.
16- [RdbStore](#rdbstore): provides APIs for managing data in an RDB store.
17- [Resultset](#resultset): provides APIs for accessing the result set obtained from the RDB store.
18
19> **NOTE**
20>
21> 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.
22
23## Modules to Import
24
25```ts
26import { relationalStore } from '@kit.ArkData';
27```
28
29## relationalStore.getRdbStore
30
31getRdbStore(context: Context, config: StoreConfig, callback: AsyncCallback<RdbStore>): void
32
33Obtains 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.
34
35| Opening Mode | RDB Store Encryption Type          | Behavior|
36| ------- | -------------------------------- | ---- |
37| Not encrypt| Encrypt                         | Encrypts the RDB store and opens it.  |
38|  Encrypt| Not encrypt                         | Opens the RDB store in non-encryption mode.  |
39
40The parameter [encrypt](#storeconfig) takes effect only when the RDB store is created for the first time, and cannot be modified. It is important to set this parameter correctly.
41
42Currently, **getRdbStore()** does not support multi-thread concurrent operations.
43
44**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
45
46**Parameters**
47
48| Name  | Type                                          | Mandatory| Description                                                        |
49| -------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ |
50| 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).|
51| config   | [StoreConfig](#storeconfig)               | Yes  | Configuration of the RDB store.                               |
52| callback | AsyncCallback&lt;[RdbStore](#rdbstore)&gt; | Yes  | Callback used to return the RDB store obtained.                  |
53
54**Error codes**
55
56For 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).
57
58| **ID**| **Error Message**  |
59|-----------|---------|
60| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
61| 14800000  | Inner error.     |
62| 14800010  | Invalid database path.   |
63| 14800011  | Database corrupted.    |
64| 14801001  | Only supported in stage mode.    |
65| 14801002  | The data group id is not valid.     |
66| 14800017  | Config changed.   |
67| 14800021  | SQLite: Generic error.    |
68| 14800022  | SQLite: Callback routine requested an abort.   |
69| 14800023  | SQLite: Access permission denied.    |
70| 14800027  | SQLite: Attempt to write a readonly database.   |
71| 14800028  | SQLite: Some kind of disk I/O error occurred.     |
72| 14800029  | SQLite: The database is full.  |
73| 14800030  | SQLite: Unable to open the database file.   |
74
75**Example**
76
77FA model:
78
79<!--code_no_check_fa-->
80```js
81import { featureAbility } from '@kit.AbilityKit';
82import { BusinessError } from '@kit.BasicServicesKit';
83
84let store: relationalStore.RdbStore | undefined = undefined;
85let context = featureAbility.getContext();
86
87const STORE_CONFIG: relationalStore.StoreConfig = {
88  name: "RdbTest.db",
89  securityLevel: relationalStore.SecurityLevel.S3
90};
91
92relationalStore.getRdbStore(context, STORE_CONFIG, (err: BusinessError, rdbStore: relationalStore.RdbStore) => {
93  store = rdbStore;
94  if (err) {
95    console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
96    return;
97  }
98  console.info('Get RdbStore successfully.');
99})
100```
101
102Stage model:
103
104```ts
105import { UIAbility } from '@kit.AbilityKit';
106import { window } from '@kit.ArkUI';
107import { BusinessError } from '@kit.BasicServicesKit';
108
109let store: relationalStore.RdbStore | undefined = undefined;
110
111class EntryAbility extends UIAbility {
112  onWindowStageCreate(windowStage: window.WindowStage) {
113    const STORE_CONFIG: relationalStore.StoreConfig = {
114      name: "RdbTest.db",
115      securityLevel: relationalStore.SecurityLevel.S3
116    };
117
118    relationalStore.getRdbStore(this.context, STORE_CONFIG, (err: BusinessError, rdbStore: relationalStore.RdbStore) => {
119      store = rdbStore;
120      if (err) {
121        console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
122        return;
123      }
124      console.info('Get RdbStore successfully.');
125    })
126  }
127}
128```
129
130## relationalStore.getRdbStore
131
132getRdbStore(context: Context, config: StoreConfig): Promise&lt;RdbStore&gt;
133
134Obtains 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.
135
136| Opening Mode | RDB Store Encryption Type          | Behavior|
137| ------- | -------------------------------- | ---- |
138| Not encrypt| Encrypt                         | Encrypts the RDB store and opens it.  |
139| Encrypt| Not encrypt                         | Opens the RDB store in non-encryption mode.  |
140
141The parameter [encrypt](#storeconfig) takes effect only when the RDB store is created for the first time, and cannot be modified. It is important to set this parameter correctly.
142
143Currently, **getRdbStore()** does not support multi-thread concurrent operations.
144
145**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
146
147**Parameters**
148
149| Name | Type                            | Mandatory| Description                                                        |
150| ------- | -------------------------------- | ---- | ------------------------------------------------------------ |
151| 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).|
152| config  | [StoreConfig](#storeconfig) | Yes  | Configuration of the RDB store.                               |
153
154**Return value**
155
156| Type                                     | Description                             |
157| ----------------------------------------- | --------------------------------- |
158| Promise&lt;[RdbStore](#rdbstore)&gt; | Promise used to return the **RdbStore** object obtained.|
159
160**Error codes**
161
162For 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).
163
164| **ID**| **Error Message**                                                |
165|-----------| ------------------------------------------------------------ |
166| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
167| 14800000  | Inner error. |
168| 14800010  | Invalid database path. |
169| 14800011  | Database corrupted.  |
170| 14801001  | Only supported in stage mode.                               |
171| 14801002  | The data group id is not valid.                             |
172| 14800017  | Config changed. |
173| 14800021  | SQLite: Generic error. |
174| 14800027  | SQLite: Attempt to write a readonly database. |
175| 14800028  | SQLite: Some kind of disk I/O error occurred. |
176| 14800029  | SQLite: The database is full. |
177| 14800030  | SQLite: Unable to open the database file. |
178
179**Example**
180
181FA model:
182
183<!--code_no_check_fa-->
184```js
185import { featureAbility } from '@kit.AbilityKit';
186import { BusinessError } from '@kit.BasicServicesKit';
187
188let store: relationalStore.RdbStore | undefined = undefined;
189let context = featureAbility.getContext();
190
191const STORE_CONFIG: relationalStore.StoreConfig = {
192  name: "RdbTest.db",
193  securityLevel: relationalStore.SecurityLevel.S3
194};
195
196relationalStore.getRdbStore(context, STORE_CONFIG).then(async (rdbStore: relationalStore.RdbStore) => {
197  store = rdbStore;
198  console.info('Get RdbStore successfully.')
199}).catch((err: BusinessError) => {
200  console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
201})
202```
203
204Stage model:
205
206```ts
207import { UIAbility } from '@kit.AbilityKit';
208import { window } from '@kit.ArkUI';
209import { BusinessError } from '@kit.BasicServicesKit';
210
211let store: relationalStore.RdbStore | undefined = undefined;
212
213class EntryAbility extends UIAbility {
214  onWindowStageCreate(windowStage: window.WindowStage) {
215    const STORE_CONFIG: relationalStore.StoreConfig = {
216      name: "RdbTest.db",
217      securityLevel: relationalStore.SecurityLevel.S3
218    };
219
220    relationalStore.getRdbStore(this.context, STORE_CONFIG).then(async (rdbStore: relationalStore.RdbStore) => {
221      store = rdbStore;
222      console.info('Get RdbStore successfully.')
223    }).catch((err: BusinessError) => {
224      console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
225    })
226  }
227}
228```
229
230## relationalStore.deleteRdbStore
231
232deleteRdbStore(context: Context, name: string, callback: AsyncCallback&lt;void&gt;): void
233
234Deletes an RDB store. This API uses an asynchronous callback to return the result.
235
236After 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.
237
238**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
239
240**Parameters**
241
242| Name  | Type                     | Mandatory| Description                                                        |
243| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
244| 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).|
245| name     | string                    | Yes  | Name of the RDB store to delete.                                                |
246| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.                                      |
247
248**Error codes**
249
250For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
251
252| **ID**| **Error Message**                       |
253|-----------|---------------------------------------|
254| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
255| 14800000  | Inner error.     |
256| 14800010  | Failed to open or delete database by invalid database path. |
257
258**Example**
259
260FA model:
261
262<!--code_no_check_fa-->
263```js
264import { featureAbility } from '@kit.AbilityKit';
265import { BusinessError } from '@kit.BasicServicesKit';
266
267let store: relationalStore.RdbStore | undefined = undefined;
268let context = featureAbility.getContext();
269
270relationalStore.deleteRdbStore(context, "RdbTest.db", (err: BusinessError) => {
271  if (err) {
272    console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
273    return;
274  }
275  store = undefined;
276  console.info('Delete RdbStore successfully.');
277})
278```
279
280Stage model:
281
282```ts
283import { UIAbility } from '@kit.AbilityKit';
284import { window } from '@kit.ArkUI';
285import { BusinessError } from '@kit.BasicServicesKit';
286
287let store: relationalStore.RdbStore | undefined = undefined;
288
289class EntryAbility extends UIAbility {
290  onWindowStageCreate(windowStage: window.WindowStage){
291    relationalStore.deleteRdbStore(this.context, "RdbTest.db", (err: BusinessError) => {
292      if (err) {
293        console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
294        return;
295      }
296      store = undefined;
297      console.info('Delete RdbStore successfully.');
298    })
299  }
300}
301```
302
303## relationalStore.deleteRdbStore
304
305deleteRdbStore(context: Context, name: string): Promise&lt;void&gt;
306
307Deletes an RDB store. This API uses a promise to return the result.
308
309After 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.
310
311**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
312
313**Parameters**
314
315| Name | Type   | Mandatory| Description                                                        |
316| ------- | ------- | ---- | ------------------------------------------------------------ |
317| 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).|
318| name    | string  | Yes  | Name of the RDB store to delete.                                                |
319
320**Return value**
321
322| Type               | Description                     |
323| ------------------- | ------------------------- |
324| Promise&lt;void&gt; | Promise that returns no value.|
325
326**Error codes**
327
328For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
329
330| **ID**| **Error Message**                                                                        |
331|-----------|----------------------------------------------------------------------------------|
332| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
333| 14800000  | Inner error.                                                                     |
334| 14800010  | Invalid database path.                      |
335
336**Example**
337
338FA model:
339
340<!--code_no_check_fa-->
341```js
342import { featureAbility } from '@kit.AbilityKit';
343import { BusinessError } from '@kit.BasicServicesKit';
344
345let store: relationalStore.RdbStore | undefined = undefined;
346let context = featureAbility.getContext();
347
348relationalStore.deleteRdbStore(context, "RdbTest.db").then(()=>{
349  store = undefined;
350  console.info('Delete RdbStore successfully.');
351}).catch((err: BusinessError) => {
352  console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
353})
354```
355
356Stage model:
357
358```ts
359import { UIAbility } from '@kit.AbilityKit';
360import { window } from '@kit.ArkUI';
361import { BusinessError } from '@kit.BasicServicesKit';
362
363let store: relationalStore.RdbStore | undefined = undefined;
364
365class EntryAbility extends UIAbility {
366  onWindowStageCreate(windowStage: window.WindowStage){
367    relationalStore.deleteRdbStore(this.context, "RdbTest.db").then(()=>{
368      store = undefined;
369      console.info('Delete RdbStore successfully.');
370    }).catch((err: BusinessError) => {
371      console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
372    })
373  }
374}
375```
376
377## relationalStore.deleteRdbStore<sup>10+</sup>
378
379deleteRdbStore(context: Context, config: StoreConfig, callback: AsyncCallback\<void>): void
380
381Deletes an RDB store. This API uses an asynchronous callback to return the result.
382
383After 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).
384
385**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
386
387**Parameters**
388
389| Name  | Type                       | Mandatory| Description                                                        |
390| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
391| 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).|
392| config   | [StoreConfig](#storeconfig) | Yes  | Configuration of the RDB store.                               |
393| callback | AsyncCallback&lt;void&gt;   | Yes  | Callback used to return the result.                                      |
394
395**Error codes**
396
397For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
398
399| **ID**| **Error Message**         |
400|-----------|----------|
401| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
402| 14800000  | Inner error.        |
403| 14800010  | Failed to open or delete database by invalid database path.        |
404| 14801001  | Only supported in stage mode.         |
405| 14801002  | The data group id is not valid.        |
406
407**Example**
408
409FA model:
410
411<!--code_no_check_fa-->
412```js
413import { featureAbility } from '@kit.AbilityKit';
414import { BusinessError } from '@kit.BasicServicesKit';
415
416let store: relationalStore.RdbStore | undefined = undefined;
417let context = featureAbility.getContext();
418
419const STORE_CONFIG: relationalStore.StoreConfig = {
420  name: "RdbTest.db",
421  securityLevel: relationalStore.SecurityLevel.S3
422};
423
424relationalStore.deleteRdbStore(context, STORE_CONFIG, (err: BusinessError) => {
425  if (err) {
426    console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
427    return;
428  }
429  store = undefined;
430  console.info('Delete RdbStore successfully.');
431})
432```
433
434Stage model:
435
436```ts
437import { UIAbility } from '@kit.AbilityKit';
438import { window } from '@kit.ArkUI';
439import { BusinessError } from '@kit.BasicServicesKit';
440
441let store: relationalStore.RdbStore | undefined = undefined;
442
443class EntryAbility extends UIAbility {
444  onWindowStageCreate(windowStage: window.WindowStage){
445    const STORE_CONFIG: relationalStore.StoreConfig = {
446      name: "RdbTest.db",
447      securityLevel: relationalStore.SecurityLevel.S3
448    };
449    relationalStore.deleteRdbStore(this.context, STORE_CONFIG, (err: BusinessError) => {
450      if (err) {
451        console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
452        return;
453      }
454      store = undefined;
455      console.info('Delete RdbStore successfully.');
456    })
457  }
458}
459```
460
461## relationalStore.deleteRdbStore<sup>10+</sup>
462
463deleteRdbStore(context: Context, config: StoreConfig): Promise\<void>
464
465Deletes an RDB store. This API uses a promise to return the result.
466
467After 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).
468
469**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
470
471**Parameters**
472
473| Name | Type                       | Mandatory| Description                                                        |
474| ------- | --------------------------- | ---- | ------------------------------------------------------------ |
475| 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).|
476| config  | [StoreConfig](#storeconfig) | Yes  | Configuration of the RDB store.                               |
477
478**Return value**
479
480| Type               | Description                     |
481| ------------------- | ------------------------- |
482| Promise&lt;void&gt; | Promise that returns no value.|
483
484**Error codes**
485
486For details about the error codes, see [RDB Error Codes](errorcode-data-rdb.md).
487
488| **ID**| **Error Message**            |
489|-----------|---------------------|
490| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
491| 801       | Capability not supported.      |
492| 14800000  | Inner error.      |
493| 14800010  | Invalid database path.   |
494| 14801001  | Only supported in stage mode.   |
495| 14801002  | The data group id is not valid.   |
496
497
498**Example**
499
500FA model:
501
502<!--code_no_check_fa-->
503```js
504import { featureAbility } from "@kit.AbilityKit";
505import { BusinessError } from '@kit.BasicServicesKit';
506
507let store: relationalStore.RdbStore | undefined = undefined;
508let context = featureAbility.getContext();
509
510const STORE_CONFIG: relationalStore.StoreConfig = {
511  name: "RdbTest.db",
512  securityLevel: relationalStore.SecurityLevel.S3
513};
514
515relationalStore.deleteRdbStore(context, STORE_CONFIG).then(()=>{
516  store = undefined;
517  console.info('Delete RdbStore successfully.');
518}).catch((err: BusinessError) => {
519  console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
520})
521```
522
523Stage model:
524
525```ts
526import { UIAbility } from '@kit.AbilityKit';
527import { window } from '@kit.ArkUI';
528import { BusinessError } from '@kit.BasicServicesKit';
529
530let store: relationalStore.RdbStore | undefined = undefined;
531
532class EntryAbility extends UIAbility {
533  onWindowStageCreate(windowStage: window.WindowStage){
534    const STORE_CONFIG: relationalStore.StoreConfig = {
535      name: "RdbTest.db",
536      securityLevel: relationalStore.SecurityLevel.S3
537    };
538    relationalStore.deleteRdbStore(this.context, STORE_CONFIG).then(()=>{
539      store = undefined;
540      console.info('Delete RdbStore successfully.');
541    }).catch((err: BusinessError) => {
542      console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
543    })
544  }
545}
546```
547
548## StoreConfig
549
550Defines the RDB store configuration.
551
552| Name       | Type         | Mandatory| Description                                                     |
553| ------------- | ------------- | ---- | --------------------------------------------------------- |
554| name          | string        | Yes  | Database file name, which is the unique identifier of the database.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core  |
555| securityLevel | [SecurityLevel](#securitylevel) | Yes  | Security level of the RDB store.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
556| 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|
557| dataGroupId<sup>10+</sup> | string | No| Application group ID, which needs to be obtained from AppGallery Connect (AGC). 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|
558| 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|
559| 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|
560| 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|
561| 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|
562| pluginLibs<sup>12+</sup> | Array\<string> | No| Dynamic libraries with capabilities such as Full-Text Search (FTS).<br>**Constraints**<br>1. The maximum number of dynamic library names is 16. If the number of dynamic library names exceeds 16, the library fails to be opened and an error is returned.<br>2. The dynamic libraries must be in the sandbox directory or system directory of the application. If a dynamic library fails to be loaded, the RDB store cannot be opened and an error will be returned.<br>3. The dynamic library name must be a complete path that can be loaded by SQLite.<br>Example: **context.bundleCodeDir + "/libs/arm64/" + libtokenizer.so**, where **context.bundleCodeDir** indicates the application sandbox path, **/libs/arm64/** is the subdirectory, **libtokenizer.so** indicates the file name of the dynamic library. If this parameter is left blank, dynamic libraries are not loaded by default.<br>4. The dynamic library must contain all its dependencies to prevent the failure caused by the lack of dependencies.<br>For example, in an NDK project, the default compilation parameters are used to build **libtokenizer.so**, which depends on the C++ standard library. When the dynamic library is loaded, **libc++_shared.so** is linked by mistake because the namespace is different from that during compilation. As a result, the **__emutls_get_address** symbol cannot be found. To solve this problem, you need to statically link the C++ standard library during compilation. For details, see [NDK Project Building Overview](../../napi/build-with-ndk-overview.md).<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core |
563| cryptoParam<sup>14+</sup> | [CryptoParam](#cryptoparam14) | No| Custom encryption parameters.<br>If this parameter is left empty, the default encryption parameters are used. For details, see default values of [CryptoParam](#cryptoparam14).<br>This parameter is valid only when **encrypt** is **true**.<br>This parameter is supported since API version 14.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
564
565## SecurityLevel
566
567Enumerates the RDB store security levels. Use the enum name rather than the enum value.
568
569> **NOTE**
570>
571> 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 [Access Control Mechanism in Cross-Device Sync](../../database/access-control-by-device-and-data-level.md#access-control-mechanism-in-cross-device-sync).
572
573**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
574
575| Name| Value  | Description                                                        |
576| ---- | ---- | ------------------------------------------------------------ |
577| 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.|
578| 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.|
579| 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.|
580| 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.|
581
582## CryptoParam<sup>14+</sup>
583
584Represents the configuration of database encryption parameters. This parameter is valid only when **encrypt** in **StoreConfig** is **true**.
585
586**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
587
588| Name         | Type  | Mandatory| Description                                                        |
589| ------------- | ------ | ---- | ------------------------------------------------------------ |
590| encryptionKey | Uint8Array | Yes  | Key used for database encryption and decryption.<br>If this parameter is not specified, the RDB store generates a key, saves the key, and uses the key to open the database file.<br>If the key is not required, you need to set the key to 0s.|
591| iterationCount | number | No| Number of iterations of the PBKDF2 algorithm used in the RDB store. The value is an integer. The default value is **10000**.<br>The value must be an integer greater than 0. If it is not an integer, the value is rounded down.<br>If this parameter is not specified or is set to **0**, the default value **10000** and the default encryption algorithm **AES_256_GCM** are used.|
592| encryptionAlgo | [EncryptionAlgo](#encryptionalgo14) | No| Algorithm used for database encryption and decryption. <br/>The default value is **AES_256_GCM**. |
593| hmacAlgo | [HmacAlgo](#hmacalgo14) | No| HMAC algorithm used for database encryption and decryption. <br/>The default value is **SHA256**. |
594| kdfAlgo | [KdfAlgo](#kdfalgo14) | No| PBKDF2 algorithm used for database encryption and decryption. <br/>The default value is the same as the HMAC algorithm used. |
595| cryptoPageSize | number | No| Page size used for database encryption and decryption. <br/>The default value is **1024** bytes.<br>The value must be an integer within the range of 1024 to 65536 and must be 2<sup>n</sup>. If the specified value is not an integer, the value is rounded down. |
596
597## EncryptionAlgo<sup>14+</sup>
598
599Enumerates the database encryption algorithms. Use the enum name rather than the enum value.
600
601**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
602
603| Name| Value  | Description|
604| ---- | ---- | ---- |
605| AES_256_GCM |  0    | AES_256_GCM.    |
606| AES_256_CBC |  1    | AES_256_CBC.    |
607
608## HmacAlgo<sup>14+</sup>
609
610Enumerates the HMAC algorithms for the database. Use the enum name rather than the enum value.
611
612**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
613
614| Name| Value  | Description|
615| ---- | ---- | ---- |
616| SHA1 |  0    | HMAC_SHA1.    |
617| SHA256 |  1    | HMAC_SHA256.    |
618| SHA512 |  2    | HMAC_SHA512.   |
619
620## KdfAlgo<sup>14+</sup>
621
622Enumerates the PBKDF2 algorithms for the database. Use the enum name rather than the enum value.
623
624**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
625
626| Name| Value  | Description|
627| ---- | ---- | ---- |
628| KDF_SHA1 |  0    | PBKDF2_HMAC_SHA1.    |
629| KDF_SHA256 |  1    | PBKDF2_HMAC_SHA256.    |
630| KDF_SHA512 |  2    | PBKDF2_HMAC_SHA512.    |
631
632## AssetStatus<sup>10+</sup>
633
634Enumerates the asset statuses. Use the enum name rather than the enum value.
635
636**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
637
638| Name                             | Value  | Description            |
639| ------------------------------- | --- | -------------- |
640| ASSET_NORMAL     | 1  | The asset is in normal status.     |
641| ASSET_INSERT | 2 | The asset is to be inserted to the cloud.|
642| ASSET_UPDATE | 3 | The asset is to be updated to the cloud.|
643| ASSET_DELETE | 4 | The asset is to be deleted from the cloud.|
644| ASSET_ABNORMAL    | 5   | The asset is in abnormal status.     |
645| ASSET_DOWNLOADING | 6   | The asset is being downloaded to a local device.|
646
647## Asset<sup>10+</sup>
648
649Defines information about an asset (such as a document, image, and video).
650
651**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
652
653| Name         | Type                         | Mandatory | Description          |
654| ----------- | --------------------------- | --- | ------------ |
655| name        | string                      | Yes  | Asset name.      |
656| uri         | string                      | Yes  | Asset URI, which is an absolute path in the system.      |
657| path        | string                      | Yes  | Application sandbox path of the asset.      |
658| createTime  | string                      | Yes  | Time when the asset was created.  |
659| modifyTime  | string                      | Yes  | Time when the asset was last modified.|
660| size        | string                      | Yes  | Size of the asset.   |
661| status      | [AssetStatus](#assetstatus10) | No  | Asset status. The default value is **ASSET_NORMAL**.       |
662
663## Assets<sup>10+</sup>
664
665type Assets = Asset[]
666
667Defines an array of the [Asset](#asset10) type.
668
669**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
670
671| Type   | Description                |
672| ------- | -------------------- |
673| [Asset](#asset10)[] | Array of assets.  |
674
675## ValueType
676
677type ValueType = null | number | string | boolean | Uint8Array | Asset | Assets | Float32Array | bigint
678
679Enumerates the types of the value in a KV pair. The type varies with the parameter function.
680
681**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
682
683| Type   | Description                |
684| ------- | -------------------- |
685| null<sup>10+</sup>    | Null.  |
686| number  | Number.  |
687| string  | String. |
688| boolean | Boolean.|
689| Uint8Array<sup>10+</sup>           | Uint8 array.           |
690| Asset<sup>10+</sup>  | [Asset](#asset10).<br>If the value type is Asset, the type in the SQL statement for creating a table must be ASSET.|
691| Assets<sup>10+</sup> | [Assets](#assets10).<br>If the value type is Assets, the type in the SQL statement for creating a table must be ASSETS.|
692| 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).|
693| 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. |
694
695## ValuesBucket
696
697type ValuesBucket = Record<string, ValueType>
698
699Defines the data in the form of a KV pair. **ValuesBucket** cannot be passed across threads.
700
701**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
702
703| Type             | Description                          |
704| ---------------- | ---------------------------- |
705| 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).|
706
707## PRIKeyType<sup>10+</sup>
708
709type PRIKeyType = number | string
710
711Enumerates the types of the primary key in a row of a database table.
712
713**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
714
715| Type            | Description                              |
716| ---------------- | ---------------------------------- |
717| number | The primary key is a number.|
718| string | The primary key is a string.|
719
720## UTCTime<sup>10+</sup>
721
722type UTCTime = Date
723
724Represents the data type of the UTC time.
725
726**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
727
728| Type| Description           |
729| ---- | --------------- |
730| Date | UTC time.|
731
732## ModifyTime<sup>10+</sup>
733
734type ModifyTime = Map<PRIKeyType, UTCTime>
735
736Represents the data type of the primary key and modification time of a database table.
737
738**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
739
740| Type                                                   | Description                                                        |
741| ------------------------------------------------------- | ------------------------------------------------------------ |
742| 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.|
743
744## SyncMode
745
746Enumerates the database sync modes. Use the enum name rather than the enum value.
747
748| Name          | Value  | Description                              |
749| -------------- | ---- | ---------------------------------- |
750| SYNC_MODE_PUSH                       | 0   | Push data from a local device to a remote device.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
751| SYNC_MODE_PULL                       | 1   | Pull data from a remote device to a local device.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
752| SYNC_MODE_TIME_FIRST<sup>10+</sup>   | 4   | Synchronize with the data with the latest modification time.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
753| SYNC_MODE_NATIVE_FIRST<sup>10+</sup> | 5   | Synchronize data from a local device to the cloud.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
754| SYNC_MODE_CLOUD_FIRST<sup>10+</sup>  | 6   | Synchronize data from the cloud to a local device.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
755
756## Origin<sup>11+</sup>
757
758Enumerates the data sources. Use the enum name rather than the enum value.
759
760**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
761
762| Name          | Value  | Description                              |
763| -------------- | ---- | ---------------------------------- |
764| LOCAL       | 0   | Local data.     |
765| CLOUD       | 1   | Cloud data.    |
766| REMOTE      | 2   | Remote device data.|
767
768## Field<sup>11+</sup>
769
770Enumerates the special fields used in predicates. Use the enum name rather than the enum value.
771
772**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
773
774| Name          | Value  | Description                              |
775| -------------- | ---- | ---------------------------------- |
776| CURSOR_FIELD        | '#_cursor'     | Field name to be searched based on the cursor.|
777| ORIGIN_FIELD        | '#_origin'     | Data source to be searched based on the cursor.   |
778| 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.|
779| 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.|
780| 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.|
781| 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.|
782| SHARING_RESOURCE_FIELD   | '#_sharing_resource_field' | Resource shared. It fills in the result set returned when the shared resource is searched.|
783
784## SubscribeType
785
786Enumerates the subscription types. Use the enum name rather than the enum value.
787
788| Name                 | Value  | Description              |
789| --------------------- | ---- | ------------------ |
790| SUBSCRIBE_TYPE_REMOTE | 0    | Subscribe to remote data changes.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
791| SUBSCRIBE_TYPE_CLOUD<sup>10+</sup> | 1  | Subscribe to cloud data changes.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
792| SUBSCRIBE_TYPE_CLOUD_DETAILS<sup>10+</sup> | 2  | Subscribe to cloud data change details.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
793| SUBSCRIBE_TYPE_LOCAL_DETAILS<sup>12+</sup> | 3  | Subscribe to details of the local data change.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
794
795## RebuildType<sup>12+</sup>
796
797Enumerates the RDB store rebuild types. Use the enum name rather than the enum value.
798
799**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
800
801| Name   | Value  | Description                                                                                                            |
802| ------- | ---- |----------------------------------------------------------------------------------------------------------------|
803| NONE    | 0    | The RDB store is not rebuilt.                                                                                                   |
804| REBUILT | 1    | The RDB store is rebuilt, and an empty database is created. You need to create tables and restore data.                                                                            |
805| REPAIRED | 2    | The RDB store is repaired and undamaged data is restored. <!--RP2-->Currently, this value is available only to a [vector database](js-apis-data-relationalStore-sys.md#storeconfig).<!--RP2End--> |
806
807## ChangeType<sup>10+</sup>
808
809Enumerates data change types. Use the enum name rather than the enum value.
810
811**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
812
813| Name                        | Value  | Description                        |
814| -------------------------- | --- | -------------------------- |
815| DATA_CHANGE  | 0   | Data change.  |
816| ASSET_CHANGE | 1   | Asset change.|
817
818## ChangeInfo<sup>10+</sup>
819
820Represents the detail information about the device-cloud sync process.
821
822**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
823
824| Name    | Type                              | Mandatory| Description                                                        |
825| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ |
826| table    | string                             | Yes  | Name of the table with data changes.                                    |
827| type     | [ChangeType](#changetype10)        | Yes  | Type of the data changed, which can be data or asset.        |
828| 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.|
829| 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.|
830| 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.|
831
832## DistributedType<sup>10+</sup>
833
834Enumerates the distributed table types. Use the enum name rather than the enum value.
835
836| Name               | Value  | Description                                                                                                |
837| ------------------ | --- | -------------------------------------------------------------------------------------------------- |
838| DISTRIBUTED_DEVICE | 0  | Distributed database table between devices.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core              |
839| DISTRIBUTED_CLOUD  | 1   | Distributed database table between the device and the cloud.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
840
841## DistributedConfig<sup>10+</sup>
842
843Defines the configuration of the distributed mode of tables.
844
845**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
846
847| Name    | Type   | Mandatory| Description                                                        |
848| -------- | ------- | ---- | ------------------------------------------------------------ |
849| 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.|
850
851## ConflictResolution<sup>10+</sup>
852
853Defines the resolution to use when a conflict occurs during data insertion or modification. Use the enum name rather than the enum value.
854
855**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
856
857| Name                | Value  | Description                                                        |
858| -------------------- | ---- | ------------------------------------------------------------ |
859| ON_CONFLICT_NONE | 0 | No operation is performed.|
860| ON_CONFLICT_ROLLBACK | 1    | Abort the SQL statement and roll back the current transaction.               |
861| 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.|
862| 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.|
863| ON_CONFLICT_IGNORE   | 4    | Skip the rows that contain constraint violations and continue to process the subsequent rows of the SQL statement.|
864| 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.|
865
866## Progress<sup>10+</sup>
867
868Enumerates the stages in the device-cloud sync progress. Use the enum name rather than the enum value.
869
870**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
871
872| Name            | Value  | Description                    |
873| ---------------- | ---- | ------------------------ |
874| SYNC_BEGIN       | 0    | The device-cloud sync starts.  |
875| SYNC_IN_PROGRESS | 1    | The device-cloud sync is in progress.|
876| SYNC_FINISH      | 2    | The device-cloud sync is complete.|
877
878## Statistic<sup>10+</sup>
879
880Represents the device-cloud sync statistics information.
881
882**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
883
884| Name      | Type  | Mandatory| Description                                    |
885| ---------- | ------ | ---- | ---------------------------------------- |
886| total      | number | Yes  | Total number of rows to be synchronized between the device and cloud in the database table.    |
887| successful | number | Yes  | Number of rows that are successfully synchronized between the device and cloud in the database table.      |
888| failed     | number | Yes  | Number of rows that failed to be synchronized between the device and cloud in the database table.      |
889| remained   | number | Yes  | Number of rows that are not executed for device-cloud sync in the database table.|
890
891## TableDetails<sup>10+</sup>
892
893Represents the upload and download statistics of device-cloud sync tasks.
894
895**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
896
897| Name    | Type                     | Mandatory| Description                                      |
898| -------- | ------------------------- | ---- | ------------------------------------------ |
899| upload   | [Statistic](#statistic10) | Yes  | Statistics of the device-cloud upload tasks.|
900| download | [Statistic](#statistic10) | Yes  | Statistics of the device-cloud download tasks.|
901
902## ProgressCode<sup>10+</sup>
903
904Enumerates the device-cloud sync states. Use the enum name rather than the enum value.
905
906**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
907
908| Name                 | Value  | Description                                                        |
909| --------------------- | ---- | ------------------------------------------------------------ |
910| SUCCESS               | 0    | The device-cloud sync is successful.                                      |
911| UNKNOWN_ERROR         | 1    | An unknown error occurs during device-cloud sync.                              |
912| NETWORK_ERROR         | 2    | A network error occurs during device-cloud sync.                              |
913| CLOUD_DISABLED        | 3    | The cloud is unavailable.                                            |
914| 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.|
915| 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.|
916| NO_SPACE_FOR_ASSET    | 6    | The remaining cloud space is less than the size of the data to be synchronized.                    |
917| BLOCKED_BY_NETWORK_STRATEGY<sup>12+</sup>    | 7    | The device-cloud sync is blocked due to the network strategy.                    |
918
919## ProgressDetails<sup>10+</sup>
920
921Represents the statistics of the overall device-cloud sync (upload and download) tasks.
922
923**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
924
925| Name    | Type                                             | Mandatory| Description                                                        |
926| -------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
927| schedule | [Progress](#progress10)                           | Yes  | Device-cloud sync progress.                                          |
928| code     | [ProgressCode](#progresscode10)                   | Yes  | Device-cloud sync state.                                    |
929| 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.|
930
931## SqlExecutionInfo<sup>12+</sup>
932
933Represents statistics about SQL statements executed by the database.
934
935**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
936
937| Name    | Type                                              | Read-Only| Optional |Description                                                        |
938| -------- | ------------------------------------------------- | ---- | ---- | -------------------------------------------------------- |
939| 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.     |
940| totalTime<sup>12+</sup>      | number                        | Yes  |   No  | Total time used to execute the SQL statements, in μs.                                   |
941| waitTime<sup>12+</sup>       | number                        | Yes  |   No  | Time used to obtain the handle, in μs.                                        |
942| prepareTime<sup>12+</sup>    | number                        | Yes  |   No  | Time used to get the SQL statements ready and bind parameters, in μs.                                |
943| executeTime<sup>12+</sup>    | number                        | Yes  |   No  | Total time used to execute the SQL statements, in μs.|
944
945## RdbPredicates
946
947Defines 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. **RdbPredicates** cannot be passed across threads.
948
949### constructor
950
951constructor(name: string)
952
953A constructor used to create an **RdbPredicates** object.
954
955**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
956
957**Parameters**
958
959| Name| Type  | Mandatory| Description        |
960| ------ | ------ | ---- | ------------ |
961| name   | string | Yes  | Database table name.|
962
963**Error codes**
964
965For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
966
967| **ID**| **Error Message**                                                                                                      |
968| --------- |----------------------------------------------------------------------------------------------------------------|
969| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
970
971**Example**
972
973```ts
974let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
975```
976
977### inDevices
978
979inDevices(devices: Array&lt;string&gt;): RdbPredicates
980
981Sets an **RdbPredicates** object to specify the remote devices to connect during the distributed database sync.
982
983> **NOTE**
984>
985> **devices** can be obtained by [deviceManager.getAvailableDeviceListSync](../apis-distributedservice-kit/js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
986If **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.
987
988**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
989
990**Parameters**
991
992| Name | Type               | Mandatory| Description                      |
993| ------- | ------------------- | ---- | -------------------------- |
994| devices | Array&lt;string&gt; | Yes  | IDs of the remote devices in the same network.|
995
996**Return value**
997
998| Type                                | Description                      |
999| ------------------------------------ | -------------------------- |
1000| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1001
1002**Error codes**
1003
1004For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1005
1006| **ID**| **Error Message**                                                                                                      |
1007| --------- |----------------------------------------------------------------------------------------------------------------|
1008| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1009
1010**Example**
1011
1012```ts
1013import { distributedDeviceManager } from '@kit.DistributedServiceKit';
1014import { BusinessError } from '@kit.BasicServicesKit';
1015
1016let dmInstance: distributedDeviceManager.DeviceManager;
1017let deviceIds: Array<string> = [];
1018
1019try {
1020  dmInstance = distributedDeviceManager.createDeviceManager("com.example.appdatamgrverify");
1021  let devices: Array<distributedDeviceManager.DeviceBasicInfo> = dmInstance.getAvailableDeviceListSync();
1022  for (let i = 0; i < devices.length; i++) {
1023    deviceIds[i] = devices[i].networkId!;
1024  }
1025} catch (err) {
1026  let code = (err as BusinessError).code;
1027  let message = (err as BusinessError).message
1028  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
1029}
1030
1031let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1032predicates.inDevices(deviceIds);
1033```
1034
1035### inAllDevices
1036
1037inAllDevices(): RdbPredicates
1038
1039Sets an **RdbPredicates** instance to specify all remote devices to connect during the distributed database sync.
1040
1041
1042**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1043
1044**Return value**
1045
1046| Type                                | Description                      |
1047| ------------------------------------ | -------------------------- |
1048| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1049
1050**Example**
1051
1052```ts
1053let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1054predicates.inAllDevices();
1055```
1056
1057### equalTo
1058
1059equalTo(field: string, value: ValueType): RdbPredicates
1060
1061Sets an **RdbPredicates** object to match the fields in the specified column that are equal to the given value.
1062
1063**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1064
1065**Parameters**
1066
1067| Name| Type                   | Mandatory| Description                  |
1068| ------ | ----------------------- | ---- | ---------------------- |
1069| field  | string                  | Yes  | Column name in the database table.    |
1070| value  | [ValueType](#valuetype) | Yes  | Value to match the **RdbPredicates**.|
1071
1072**Return value**
1073
1074| Type                                | Description                      |
1075| ------------------------------------ | -------------------------- |
1076| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1077
1078**Error codes**
1079
1080For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1081
1082| **ID**| **Error Message**                                                                                                      |
1083| --------- |----------------------------------------------------------------------------------------------------------------|
1084| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1085
1086**Example**
1087
1088```ts
1089// Locate data of Lisa in the EMPLOYEE table.
1090let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1091predicates.equalTo("NAME", "Lisa");
1092```
1093
1094
1095### notEqualTo
1096
1097notEqualTo(field: string, value: ValueType): RdbPredicates
1098
1099Sets an **RdbPredicates** object to match the fields in the specified column that are not equal to the given value.
1100
1101**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1102
1103**Parameters**
1104
1105| Name| Type                   | Mandatory| Description                  |
1106| ------ | ----------------------- | ---- | ---------------------- |
1107| field  | string                  | Yes  | Column name in the database table.    |
1108| value  | [ValueType](#valuetype) | Yes  | Value to match the **RdbPredicates**.|
1109
1110**Return value**
1111
1112| Type                                | Description                      |
1113| ------------------------------------ | -------------------------- |
1114| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1115
1116**Error codes**
1117
1118For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1119
1120| **ID**| **Error Message**                                                                                                      |
1121| --------- |----------------------------------------------------------------------------------------------------------------|
1122| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1123
1124**Example**
1125
1126```ts
1127// Locate data of the employees whose name is not Lisa in the table.
1128let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1129predicates.notEqualTo("NAME", "Lisa");
1130```
1131
1132
1133### beginWrap
1134
1135beginWrap(): RdbPredicates
1136
1137Adds a left parenthesis to the **RdbPredicates**.
1138
1139**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1140
1141**Return value**
1142
1143| Type                                | Description                     |
1144| ------------------------------------ | ------------------------- |
1145| [RdbPredicates](#rdbpredicates) | **RdbPredicates** with a left parenthesis.|
1146
1147**Example**
1148
1149```ts
1150let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1151predicates.equalTo("NAME", "Lisa")
1152    .beginWrap()
1153    .equalTo("AGE", 18)
1154    .or()
1155    .equalTo("SALARY", 200.5)
1156    .endWrap()
1157```
1158
1159### endWrap
1160
1161endWrap(): RdbPredicates
1162
1163Adds a right parenthesis to the **RdbPredicates**.
1164
1165**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1166
1167**Return value**
1168
1169| Type                                | Description                     |
1170| ------------------------------------ | ------------------------- |
1171| [RdbPredicates](#rdbpredicates) | **RdbPredicates** with a right parenthesis.|
1172
1173**Example**
1174
1175```ts
1176let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1177predicates.equalTo("NAME", "Lisa")
1178    .beginWrap()
1179    .equalTo("AGE", 18)
1180    .or()
1181    .equalTo("SALARY", 200.5)
1182    .endWrap()
1183```
1184
1185### or
1186
1187or(): RdbPredicates
1188
1189Adds the OR condition to the **RdbPredicates**.
1190
1191**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1192
1193**Return value**
1194
1195| Type                                | Description                     |
1196| ------------------------------------ | ------------------------- |
1197| [RdbPredicates](#rdbpredicates) | **RdbPredicates** with the OR condition.|
1198
1199**Example**
1200
1201```ts
1202// Locate the employees named Lisa or Rose in the table.
1203let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1204predicates.equalTo("NAME", "Lisa")
1205    .or()
1206    .equalTo("NAME", "Rose")
1207```
1208
1209### and
1210
1211and(): RdbPredicates
1212
1213Adds the AND condition to the **RdbPredicates**.
1214
1215**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1216
1217**Return value**
1218
1219| Type                                | Description                     |
1220| ------------------------------------ | ------------------------- |
1221| [RdbPredicates](#rdbpredicates) | **RdbPredicates** with the AND condition.|
1222
1223**Example**
1224
1225```ts
1226// Locate the field with name of Lisa and salary of 200.5 in the table.
1227let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1228predicates.equalTo("NAME", "Lisa")
1229    .and()
1230    .equalTo("SALARY", 200.5)
1231```
1232
1233### contains
1234
1235contains(field: string, value: string): RdbPredicates
1236
1237Sets an **RdbPredicates** object to match the fields in the specified column that contain the given value.
1238
1239**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1240
1241**Parameters**
1242
1243| Name| Type  | Mandatory| Description                  |
1244| ------ | ------ | ---- | ---------------------- |
1245| field  | string | Yes  | Column name in the database table.    |
1246| value  | string | Yes  | Value to match the **RdbPredicates**.|
1247
1248**Return value**
1249
1250| Type                                | Description                      |
1251| ------------------------------------ | -------------------------- |
1252| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1253
1254**Error codes**
1255
1256For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1257
1258| **ID**| **Error Message**                                                                                                      |
1259| --------- |----------------------------------------------------------------------------------------------------------------|
1260| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1261
1262**Example**
1263
1264```ts
1265// Locate data of the employees whose name contains os, for example, Rose, in the table.
1266let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1267predicates.contains("NAME", "os");
1268```
1269
1270### beginsWith
1271
1272beginsWith(field: string, value: string): RdbPredicates
1273
1274Sets an **RdbPredicates** object to match the fields in the specified column that begin with the given value.
1275
1276**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1277
1278**Parameters**
1279
1280| Name| Type  | Mandatory| Description                  |
1281| ------ | ------ | ---- | ---------------------- |
1282| field  | string | Yes  | Column name in the database table.    |
1283| value  | string | Yes  | Value to match the **RdbPredicates**.|
1284
1285**Return value**
1286
1287| Type                                | Description                      |
1288| ------------------------------------ | -------------------------- |
1289| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1290
1291**Error codes**
1292
1293For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1294
1295| **ID**| **Error Message**                                                                                                      |
1296| --------- |----------------------------------------------------------------------------------------------------------------|
1297| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1298
1299**Example**
1300
1301```ts
1302// Locate data of the employees whose name begins with Li, for example, Lisa, in the table.
1303let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1304predicates.beginsWith("NAME", "Li");
1305```
1306
1307### endsWith
1308
1309endsWith(field: string, value: string): RdbPredicates
1310
1311Sets an **RdbPredicates** object to match the fields in the specified column that end with the given value.
1312
1313**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1314
1315**Parameters**
1316
1317| Name| Type  | Mandatory| Description                  |
1318| ------ | ------ | ---- | ---------------------- |
1319| field  | string | Yes  | Column name in the database table.    |
1320| value  | string | Yes  | Value to match the **RdbPredicates**.|
1321
1322**Return value**
1323
1324| Type                                | Description                      |
1325| ------------------------------------ | -------------------------- |
1326| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1327
1328**Error codes**
1329
1330For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1331
1332| **ID**| **Error Message**                                                                                                      |
1333| --------- |----------------------------------------------------------------------------------------------------------------|
1334| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1335
1336**Example**
1337
1338```ts
1339// Locate data of the employees whose name ends with se, for example, Rose, in the table.
1340let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1341predicates.endsWith("NAME", "se");
1342```
1343
1344### isNull
1345
1346isNull(field: string): RdbPredicates
1347
1348Sets an **RdbPredicates** object to match the fields in the specified column that are **null**.
1349
1350**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1351
1352**Parameters**
1353
1354| Name| Type  | Mandatory| Description              |
1355| ------ | ------ | ---- | ------------------ |
1356| field  | string | Yes  | Column name in the database table.|
1357
1358**Return value**
1359
1360| Type                                | Description                      |
1361| ------------------------------------ | -------------------------- |
1362| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1363
1364**Error codes**
1365
1366For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1367
1368| **ID**| **Error Message**                                                                                                      |
1369| --------- |----------------------------------------------------------------------------------------------------------------|
1370| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1371
1372**Example**
1373
1374```ts
1375let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1376predicates.isNull("NAME");
1377```
1378
1379### isNotNull
1380
1381isNotNull(field: string): RdbPredicates
1382
1383Sets an **RdbPredicates** object to match the fields in the specified column that are not **null**.
1384
1385**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1386
1387**Parameters**
1388
1389| Name| Type  | Mandatory| Description              |
1390| ------ | ------ | ---- | ------------------ |
1391| field  | string | Yes  | Column name in the database table.|
1392
1393**Return value**
1394
1395| Type                                | Description                      |
1396| ------------------------------------ | -------------------------- |
1397| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1398
1399**Error codes**
1400
1401For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1402
1403| **ID**| **Error Message**                                                                                                      |
1404| --------- |----------------------------------------------------------------------------------------------------------------|
1405| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1406
1407**Example**
1408
1409```ts
1410let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1411predicates.isNotNull("NAME");
1412```
1413
1414### like
1415
1416like(field: string, value: string): RdbPredicates
1417
1418Sets an **RdbPredicates** object to match the fields in the specified column that are similar to the given value.
1419
1420**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1421
1422**Parameters**
1423
1424| Name| Type  | Mandatory| Description                  |
1425| ------ | ------ | ---- | ---------------------- |
1426| field  | string | Yes  | Column name in the database table.    |
1427| value  | string | Yes  | Value to match the **RdbPredicates**.|
1428
1429**Return value**
1430
1431| Type                                | Description                      |
1432| ------------------------------------ | -------------------------- |
1433| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1434
1435**Error codes**
1436
1437For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1438
1439| **ID**| **Error Message**                                                                                                      |
1440| --------- |----------------------------------------------------------------------------------------------------------------|
1441| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1442
1443**Example**
1444
1445```ts
1446// Locate data of the employees whose name is similar to os in the table, for example, Rose.
1447let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1448predicates.like("NAME", "%os%");
1449```
1450
1451### glob
1452
1453glob(field: string, value: string): RdbPredicates
1454
1455Sets an **RdbPredicates** object to locate the fields in the specified column that match the given string.
1456
1457**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1458
1459**Parameters**
1460
1461| Name| Type  | Mandatory| Description                                                        |
1462| ------ | ------ | ---- | ------------------------------------------------------------ |
1463| field  | string | Yes  | Column name in the database table.                                          |
1464| 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.|
1465
1466**Return value**
1467
1468| Type                                | Description                      |
1469| ------------------------------------ | -------------------------- |
1470| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1471
1472**Error codes**
1473
1474For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1475
1476| **ID**| **Error Message**                                                                                                      |
1477| --------- |----------------------------------------------------------------------------------------------------------------|
1478| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1479
1480**Example**
1481
1482```ts
1483// Locate data of the employees whose name matches the "?h*g" string in the table.
1484let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1485predicates.glob("NAME", "?h*g");
1486```
1487
1488### between
1489
1490between(field: string, low: ValueType, high: ValueType): RdbPredicates
1491
1492Sets an **RdbPredicates** object to match the fields in the specified column that are within the given range (including the min. and max. values).
1493
1494**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1495
1496**Parameters**
1497
1498| Name| Type                   | Mandatory| Description                      |
1499| ------ | ----------------------- | ---- | -------------------------- |
1500| field  | string                  | Yes  | Column name in the database table.        |
1501| low    | [ValueType](#valuetype) | Yes  | Minimum value to match.  |
1502| high   | [ValueType](#valuetype) | Yes  | Maximum value to match.|
1503
1504**Return value**
1505
1506| Type                                | Description                      |
1507| ------------------------------------ | -------------------------- |
1508| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1509
1510**Error codes**
1511
1512For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1513
1514| **ID**| **Error Message**                                                                                                      |
1515| --------- |----------------------------------------------------------------------------------------------------------------|
1516| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1517
1518**Example**
1519
1520```ts
1521// Locate data of the employees with age between 10 and 50 (including 10 and 50) in the table.
1522let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1523predicates.between("AGE", 10, 50);
1524```
1525
1526### notBetween
1527
1528notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates
1529
1530Sets an **RdbPredicates** object to match the fields in the specified column that are out of the given range (excluding the min. and max. values).
1531
1532**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1533
1534**Parameters**
1535
1536| Name| Type                   | Mandatory| Description                      |
1537| ------ | ----------------------- | ---- | -------------------------- |
1538| field  | string                  | Yes  | Column name in the database table.        |
1539| low    | [ValueType](#valuetype) | Yes  | Minimum value to match.  |
1540| high   | [ValueType](#valuetype) | Yes  | Maximum value to match.|
1541
1542**Return value**
1543
1544| Type                                | Description                      |
1545| ------------------------------------ | -------------------------- |
1546| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1547
1548**Error codes**
1549
1550For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1551
1552| **ID**| **Error Message**                                                                                                      |
1553| --------- |----------------------------------------------------------------------------------------------------------------|
1554| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1555
1556**Example**
1557
1558```ts
1559// Locate data of the employees who are younger than 10 or older than 50 in the table.
1560let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1561predicates.notBetween("AGE", 10, 50);
1562```
1563
1564### greaterThan
1565
1566greaterThan(field: string, value: ValueType): RdbPredicates
1567
1568Sets an **RdbPredicates** object to match the fields in the specified column that are greater than the given value.
1569
1570**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1571
1572**Parameters**
1573
1574| Name| Type                   | Mandatory| Description                  |
1575| ------ | ----------------------- | ---- | ---------------------- |
1576| field  | string                  | Yes  | Column name in the database table.    |
1577| value  | [ValueType](#valuetype) | Yes  | Value to match the **RdbPredicates**.|
1578
1579**Return value**
1580
1581| Type                                | Description                      |
1582| ------------------------------------ | -------------------------- |
1583| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1584
1585**Error codes**
1586
1587For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1588
1589| **ID**| **Error Message**                                                                                                      |
1590| --------- |----------------------------------------------------------------------------------------------------------------|
1591| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1592
1593**Example**
1594
1595```ts
1596// Locate data of the employees who are older than 18 in the table.
1597let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1598predicates.greaterThan("AGE", 18);
1599```
1600
1601### lessThan
1602
1603lessThan(field: string, value: ValueType): RdbPredicates
1604
1605Sets an **RdbPredicates** object to match the fields in the specified column that are less than the given value.
1606
1607**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1608
1609**Parameters**
1610
1611| Name| Type                   | Mandatory| Description                  |
1612| ------ | ----------------------- | ---- | ---------------------- |
1613| field  | string                  | Yes  | Column name in the database table.    |
1614| value  | [ValueType](#valuetype) | Yes  | Value to match the **RdbPredicates**.|
1615
1616**Return value**
1617
1618| Type                                | Description                      |
1619| ------------------------------------ | -------------------------- |
1620| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1621
1622**Error codes**
1623
1624For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1625
1626| **ID**| **Error Message**                                                                                                      |
1627| --------- |----------------------------------------------------------------------------------------------------------------|
1628| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1629
1630**Example**
1631
1632```ts
1633// Locate data of the employees who are younger than 20 in the table.
1634let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1635predicates.lessThan("AGE", 20);
1636```
1637
1638### greaterThanOrEqualTo
1639
1640greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates
1641
1642Sets an **RdbPredicates** object to match the fields in the specified column that are greater than or equal to the given value.
1643
1644**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1645
1646**Parameters**
1647
1648| Name| Type                   | Mandatory| Description                  |
1649| ------ | ----------------------- | ---- | ---------------------- |
1650| field  | string                  | Yes  | Column name in the database table.    |
1651| value  | [ValueType](#valuetype) | Yes  | Value to match the **RdbPredicates**.|
1652
1653**Return value**
1654
1655| Type                                | Description                      |
1656| ------------------------------------ | -------------------------- |
1657| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1658
1659**Error codes**
1660
1661For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1662
1663| **ID**| **Error Message**                                                                                                      |
1664| --------- |----------------------------------------------------------------------------------------------------------------|
1665| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1666
1667**Example**
1668
1669```ts
1670// Locate data of the employees who are 18 or older in the table.
1671let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1672predicates.greaterThanOrEqualTo("AGE", 18);
1673```
1674
1675### lessThanOrEqualTo
1676
1677lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates
1678
1679Sets an **RdbPredicates** object to match the fields in the specified column that are less than or equal to the given value.
1680
1681**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1682
1683**Parameters**
1684
1685| Name| Type                   | Mandatory| Description                  |
1686| ------ | ----------------------- | ---- | ---------------------- |
1687| field  | string                  | Yes  | Column name in the database table.    |
1688| value  | [ValueType](#valuetype) | Yes  | Value to match the **RdbPredicates**.|
1689
1690**Return value**
1691
1692| Type                                | Description                      |
1693| ------------------------------------ | -------------------------- |
1694| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1695
1696**Error codes**
1697
1698For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1699
1700| **ID**| **Error Message**                                                                                                      |
1701| --------- |----------------------------------------------------------------------------------------------------------------|
1702| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1703
1704**Example**
1705
1706```ts
1707// Locate data of the employees who are 20 or younger in the table.
1708let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1709predicates.lessThanOrEqualTo("AGE", 20);
1710```
1711
1712### orderByAsc
1713
1714orderByAsc(field: string): RdbPredicates
1715
1716Sets an **RdbPredicates** object to sort the fields in the specified column in ascending order.
1717
1718**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1719
1720**Parameters**
1721
1722| Name| Type  | Mandatory| Description              |
1723| ------ | ------ | ---- | ------------------ |
1724| field  | string | Yes  | Column name in the database table.|
1725
1726**Return value**
1727
1728| Type                                | Description                      |
1729| ------------------------------------ | -------------------------- |
1730| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1731
1732**Error codes**
1733
1734For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1735
1736| **ID**| **Error Message**                                                                                                      |
1737| --------- |----------------------------------------------------------------------------------------------------------------|
1738| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1739
1740**Example**
1741
1742```ts
1743let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1744predicates.orderByAsc("NAME");
1745```
1746
1747### orderByDesc
1748
1749orderByDesc(field: string): RdbPredicates
1750
1751Sets an **RdbPredicates** object to sort the fields in the specified column in descending order.
1752
1753**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1754
1755**Parameters**
1756
1757| Name| Type  | Mandatory| Description              |
1758| ------ | ------ | ---- | ------------------ |
1759| field  | string | Yes  | Column name in the database table.|
1760
1761**Return value**
1762
1763| Type                                | Description                      |
1764| ------------------------------------ | -------------------------- |
1765| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1766
1767**Error codes**
1768
1769For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1770
1771| **ID**| **Error Message**                                                                                                      |
1772| --------- |----------------------------------------------------------------------------------------------------------------|
1773| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1774
1775**Example**
1776
1777```ts
1778let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1779predicates.orderByDesc("AGE");
1780```
1781
1782### distinct
1783
1784distinct(): RdbPredicates
1785
1786Sets an **RdbPredicates** object to filter out duplicate records.
1787
1788**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1789
1790**Return value**
1791
1792| Type                                | Description                          |
1793| ------------------------------------ | ------------------------------ |
1794| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that can filter out duplicate records.|
1795
1796**Example**
1797
1798```ts
1799let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1800predicates.equalTo("NAME", "Rose").distinct();
1801```
1802
1803### limitAs
1804
1805limitAs(value: number): RdbPredicates
1806
1807Sets an **RdbPredicates** object to specify the maximum number of records.
1808
1809**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1810
1811**Parameters**
1812
1813| Name| Type  | Mandatory| Description            |
1814| ------ | ------ | ---- | ---------------- |
1815| value  | number | Yes  | Maximum number of records.|
1816
1817**Return value**
1818
1819| Type                                | Description                                |
1820| ------------------------------------ | ------------------------------------ |
1821| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the maximum number of records.|
1822
1823**Error codes**
1824
1825For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1826
1827| **ID**| **Error Message**              |
1828| --------- |--------------------------|
1829| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1830
1831**Example**
1832
1833```ts
1834let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1835predicates.equalTo("NAME", "Rose").limitAs(3);
1836```
1837
1838### offsetAs
1839
1840offsetAs(rowOffset: number): RdbPredicates
1841
1842Sets an **RdbPredicates** object to specify the start position of the returned result.
1843
1844**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1845
1846**Parameters**
1847
1848| Name   | Type  | Mandatory| Description                              |
1849| --------- | ------ | ---- | ---------------------------------- |
1850| rowOffset | number | Yes  | Number of rows to offset from the beginning. The value is a positive integer.|
1851
1852**Return value**
1853
1854| Type                                | Description                                |
1855| ------------------------------------ | ------------------------------------ |
1856| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the start position of the returned result.|
1857
1858**Error codes**
1859
1860For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1861
1862| **ID**| **Error Message**                                                                                                      |
1863| --------- |----------------------------------------------------------------------------------------------------------------|
1864| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1865
1866**Example**
1867
1868```ts
1869let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1870predicates.equalTo("NAME", "Rose").offsetAs(3);
1871```
1872
1873### groupBy
1874
1875groupBy(fields: Array&lt;string&gt;): RdbPredicates
1876
1877Sets an **RdbPredicates** object to group rows that have the same value into summary rows.
1878
1879**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1880
1881**Parameters**
1882
1883| Name| Type               | Mandatory| Description                |
1884| ------ | ------------------- | ---- | -------------------- |
1885| fields | Array&lt;string&gt; | Yes  | Names of columns to group.|
1886
1887**Return value**
1888
1889| Type                                | Description                  |
1890| ------------------------------------ | ---------------------- |
1891| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that groups rows with the same value.|
1892
1893**Error codes**
1894
1895For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1896
1897| **ID**| **Error Message**                                                                                                      |
1898| --------- |----------------------------------------------------------------------------------------------------------------|
1899| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1900
1901**Example**
1902
1903```ts
1904let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1905predicates.groupBy(["AGE", "NAME"]);
1906```
1907
1908### indexedBy
1909
1910indexedBy(field: string): RdbPredicates
1911
1912Sets an **RdbPredicates** object to specify the index column.
1913
1914**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1915
1916**Parameters**
1917
1918| Name| Type  | Mandatory| Description          |
1919| ------ | ------ | ---- | -------------- |
1920| field  | string | Yes  | Name of the index column.|
1921
1922**Return value**
1923
1924
1925| Type                                | Description                                 |
1926| ------------------------------------ | ------------------------------------- |
1927| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the index column.|
1928
1929**Error codes**
1930
1931For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1932
1933| **ID**| **Error Message**                                                                                                      |
1934| --------- |----------------------------------------------------------------------------------------------------------------|
1935| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1936
1937**Example**
1938
1939```ts
1940let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1941predicates.indexedBy("SALARY");
1942```
1943
1944### in
1945
1946in(field: string, value: Array&lt;ValueType&gt;): RdbPredicates
1947
1948Sets an **RdbPredicates** object to match the fields in the specified column that are in the given range.
1949
1950**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1951
1952**Parameters**
1953
1954| Name| Type                                | Mandatory| Description                                   |
1955| ------ | ------------------------------------ | ---- | --------------------------------------- |
1956| field  | string                               | Yes  | Column name in the database table.                     |
1957| value  | Array&lt;[ValueType](#valuetype)&gt; | Yes  | Array of **ValueType**s to match.|
1958
1959**Return value**
1960
1961| Type                                | Description                      |
1962| ------------------------------------ | -------------------------- |
1963| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1964
1965**Error codes**
1966
1967For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1968
1969| **ID**| **Error Message**                                                                                                      |
1970| --------- |----------------------------------------------------------------------------------------------------------------|
1971| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
1972
1973**Example**
1974
1975```ts
1976// Locate data of the employees with age of [18, 20] in the table.
1977let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1978predicates.in("AGE", [18, 20]);
1979```
1980
1981### notIn
1982
1983notIn(field: string, value: Array&lt;ValueType&gt;): RdbPredicates
1984
1985Sets an **RdbPredicates** object to match the fields in the specified column that are out of the given range.
1986
1987**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1988
1989**Parameters**
1990
1991| Name| Type                                | Mandatory| Description                                 |
1992| ------ | ------------------------------------ | ---- | ------------------------------------- |
1993| field  | string                               | Yes  | Column name in the database table.                   |
1994| value  | Array&lt;[ValueType](#valuetype)&gt; | Yes  | Array of **ValueType**s to match.|
1995
1996**Return value**
1997
1998| Type                                | Description                      |
1999| ------------------------------------ | -------------------------- |
2000| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
2001
2002**Error codes**
2003
2004For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
2005
2006| **ID**| **Error Message**                                                                                                      |
2007| --------- |----------------------------------------------------------------------------------------------------------------|
2008| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
2009
2010**Example**
2011
2012```ts
2013// Locate data of all the employees except Lisa and Rose in the table.
2014let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
2015predicates.notIn("NAME", ["Lisa", "Rose"]);
2016```
2017
2018### notContains<sup>12+</sup>
2019
2020notContains(field: string, value: string): RdbPredicates
2021
2022Sets an **RdbPredicates** object to match the fields in the specified column that do not contain the given value.
2023
2024**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2025
2026**Parameters**
2027
2028| Name| Type  | Mandatory| Description                  |
2029| ------ | ------ | ---- | ---------------------- |
2030| field  | string | Yes  | Column name in the database table.    |
2031| value  | string | Yes  | Value to match the **RdbPredicates**.|
2032
2033**Return value**
2034
2035| Type                           | Description                      |
2036| ------------------------------- | -------------------------- |
2037| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
2038
2039**Error codes**
2040
2041For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
2042
2043| **ID**| **Error Message**                                                                                                      |
2044| --------- |----------------------------------------------------------------------------------------------------------------|
2045| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
2046
2047**Example**
2048
2049```ts
2050// Match the fields that do not contain "os" in the NAME column of the data table, for example, Lisa in the list.
2051let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
2052predicates.notContains("NAME", "os");
2053```
2054
2055### notLike<sup>12+</sup>
2056
2057notLike(field: string, value: string): RdbPredicates
2058
2059Sets an **RdbPredicates** object to match the fields in the specified column that are not similar to the given value.
2060
2061**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2062
2063**Parameters**
2064
2065| Name| Type  | Mandatory| Description                  |
2066| ------ | ------ | ---- | ---------------------- |
2067| field  | string | Yes  | Column name in the database table.    |
2068| value  | string | Yes  | Value to match the **RdbPredicates**.|
2069
2070**Return value**
2071
2072| Type                           | Description                      |
2073| ------------------------------- | -------------------------- |
2074| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
2075
2076**Error codes**
2077
2078For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
2079
2080| **ID**| **Error Message**                                                                                                      |
2081| --------- |----------------------------------------------------------------------------------------------------------------|
2082| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;  2. Incorrect parameter types. |
2083
2084**Example**
2085
2086```ts
2087// Match the fields that are not "os" in the NAME column of the data table, for example, Rose in the list.
2088let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
2089predicates.notLike("NAME", "os");
2090```
2091
2092
2093
2094## RdbStore
2095
2096Provides APIs to manage an RDB store.
2097
2098Before using the APIs of this class, use [executeSql](#executesql) to initialize the database table structure and related data.
2099
2100### Properties
2101
2102**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2103
2104| Name        | Type           | Read-Only      | Optional| Description                            |
2105| ------------ | ----------- | ---- | -------------------------------- | -------------------------------- |
2106| version<sup>10+</sup>  | number | No| No  | RDB store version, which is an integer greater than 0.      |
2107| rebuilt<sup>12+</sup> | [RebuildType](#rebuildtype12) | Yes| No| Whether the RDB store has been rebuilt or repaired.|
2108
2109**Error codes**
2110
2111For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
2112
2113| **ID**| **Error Message**                                                |
2114|-----------| ------------------------------------------------------------ |
2115| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2116| 801       | Capability not supported. |
2117| 14800000  | Inner error. |
2118| 14800014  | Already closed. |
2119| 14800015  | The database does not respond. |
2120| 14800021  | SQLite: Generic error. |
2121| 14800023  | SQLite: Access permission denied. |
2122| 14800024  | SQLite: The database file is locked. |
2123| 14800025  | SQLite: A table in the database is locked. |
2124| 14800026  | SQLite: The database is out of memory. |
2125| 14800027  | SQLite: Attempt to write a readonly database. |
2126| 14800028  | SQLite: Some kind of disk I/O error occurred. |
2127| 14800029  | SQLite: The database is full. |
2128| 14800030  | SQLite: Unable to open the database file. |
2129
2130**Example**
2131
2132```ts
2133// Set the RDB store version.
2134if(store != undefined) {
2135  (store as relationalStore.RdbStore).version = 3;
2136  // Obtain the RDB store version.
2137  console.info(`RdbStore version is ${store.version}`);
2138  // Whether the RDB store has been rebuilt.
2139  console.info(`RdbStore rebuilt is ${store.rebuilt}`);
2140}
2141```
2142
2143### insert
2144
2145insert(table: string, values: ValuesBucket, callback: AsyncCallback&lt;number&gt;):void
2146
2147Inserts 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.
2148
2149**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2150
2151**Parameters**
2152
2153| Name  | Type                         | Mandatory| Description                                                      |
2154| -------- | ----------------------------- | ---- | ---------------------------------------------------------- |
2155| table    | string                        | Yes  | Name of the target table.                                          |
2156| values   | [ValuesBucket](#valuesbucket) | Yes  | Row of data to insert.                                |
2157| 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.|
2158
2159**Error codes**
2160
2161For 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).
2162
2163| **ID**| **Error Message**                                                |
2164|-----------| ------------------------------------------------------------ |
2165| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2166| 14800000  | Inner error. |
2167| 14800011  | Database corrupted. |
2168| 14800014  | Already closed. |
2169| 14800015  | The database does not respond. |
2170| 14800021  | SQLite: Generic error. |
2171| 14800022  | SQLite: Callback routine requested an abort. |
2172| 14800023  | SQLite: Access permission denied. |
2173| 14800024  | SQLite: The database file is locked. |
2174| 14800025  | SQLite: A table in the database is locked. |
2175| 14800026  | SQLite: The database is out of memory. |
2176| 14800027  | SQLite: Attempt to write a readonly database. |
2177| 14800028  | SQLite: Some kind of disk I/O error occurred. |
2178| 14800029  | SQLite: The database is full. |
2179| 14800030  | SQLite: Unable to open the database file. |
2180| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
2181| 14800032  | SQLite: Abort due to constraint violation. |
2182| 14800033  | SQLite: Data type mismatch. |
2183| 14800034  | SQLite: Library used incorrectly. |
2184| 14800047  | The WAL file size exceeds the default limit. |
2185
2186**Example**
2187
2188```ts
2189let value1 = "Lisa";
2190let value2 = 18;
2191let value3 = 100.5;
2192let value4 = new Uint8Array([1, 2, 3, 4, 5]);
2193
2194// You can use either of the following:
2195const valueBucket1: relationalStore.ValuesBucket = {
2196  'NAME': value1,
2197  'AGE': value2,
2198  'SALARY': value3,
2199  'CODES': value4,
2200};
2201const valueBucket2: relationalStore.ValuesBucket = {
2202  NAME: value1,
2203  AGE: value2,
2204  SALARY: value3,
2205  CODES: value4,
2206};
2207const valueBucket3: relationalStore.ValuesBucket = {
2208  "NAME": value1,
2209  "AGE": value2,
2210  "SALARY": value3,
2211  "CODES": value4,
2212};
2213
2214if(store != undefined) {
2215  (store as relationalStore.RdbStore).insert("EMPLOYEE", valueBucket1, (err: BusinessError, rowId: number) => {
2216    if (err) {
2217      console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
2218      return;
2219    }
2220    console.info(`Insert is successful, rowId = ${rowId}`);
2221  })
2222}
2223```
2224
2225### insert<sup>10+</sup>
2226
2227insert(table: string, values: ValuesBucket,  conflict: ConflictResolution, callback: AsyncCallback&lt;number&gt;):void
2228
2229Inserts 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.
2230
2231**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2232
2233**Parameters**
2234
2235| Name  | Type                                       | Mandatory| Description                                                      |
2236| -------- | ------------------------------------------- | ---- | ---------------------------------------------------------- |
2237| table    | string                                      | Yes  | Name of the target table.                                          |
2238| values   | [ValuesBucket](#valuesbucket)               | Yes  | Row of data to insert.                                |
2239| conflict | [ConflictResolution](#conflictresolution10) | Yes  | Resolution used to resolve the conflict.                                        |
2240| 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.|
2241
2242**Error codes**
2243
2244For 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).
2245
2246| **ID**| **Error Message**                                                |
2247|-----------| ---------------------------------------------------- |
2248| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2249| 14800000  | Inner error. |
2250| 14800011  | Database corrupted. |
2251| 14800014  | Already closed. |
2252| 14800015  | The database does not respond. |
2253| 14800021  | SQLite: Generic error. |
2254| 14800022  | SQLite: Callback routine requested an abort. |
2255| 14800023  | SQLite: Access permission denied. |
2256| 14800024  | SQLite: The database file is locked. |
2257| 14800025  | SQLite: A table in the database is locked. |
2258| 14800026  | SQLite: The database is out of memory. |
2259| 14800027  | SQLite: Attempt to write a readonly database. |
2260| 14800028  | SQLite: Some kind of disk I/O error occurred. |
2261| 14800029  | SQLite: The database is full. |
2262| 14800030  | SQLite: Unable to open the database file. |
2263| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
2264| 14800032  | SQLite: Abort due to constraint violation. |
2265| 14800033  | SQLite: Data type mismatch. |
2266| 14800034  | SQLite: Library used incorrectly. |
2267| 14800047  | The WAL file size exceeds the default limit. |
2268
2269**Example**
2270
2271```ts
2272let value1 = "Lisa";
2273let value2 = 18;
2274let value3 = 100.5;
2275let value4 = new Uint8Array([1, 2, 3, 4, 5]);
2276
2277// You can use either of the following:
2278const valueBucket1: relationalStore.ValuesBucket = {
2279  'NAME': value1,
2280  'AGE': value2,
2281  'SALARY': value3,
2282  'CODES': value4,
2283};
2284const valueBucket2: relationalStore.ValuesBucket = {
2285  NAME: value1,
2286  AGE: value2,
2287  SALARY: value3,
2288  CODES: value4,
2289};
2290const valueBucket3: relationalStore.ValuesBucket = {
2291  "NAME": value1,
2292  "AGE": value2,
2293  "SALARY": value3,
2294  "CODES": value4,
2295};
2296
2297if(store != undefined) {
2298  (store as relationalStore.RdbStore).insert("EMPLOYEE", valueBucket1, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE,
2299    (err: BusinessError, rowId: number) => {
2300      if (err) {
2301        console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
2302        return;
2303      }
2304      console.info(`Insert is successful, rowId = ${rowId}`);
2305  })
2306}
2307```
2308
2309### insert
2310
2311insert(table: string, values: ValuesBucket):Promise&lt;number&gt;
2312
2313Inserts 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.
2314
2315**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2316
2317**Parameters**
2318
2319| Name| Type                         | Mandatory| Description                      |
2320| ------ | ----------------------------- | ---- | -------------------------- |
2321| table  | string                        | Yes  | Name of the target table.          |
2322| values | [ValuesBucket](#valuesbucket) | Yes  | Row of data to insert.|
2323
2324**Return value**
2325
2326| Type                 | Description                                             |
2327| --------------------- | ------------------------------------------------- |
2328| 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.|
2329
2330**Error codes**
2331
2332For 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).
2333
2334| **ID**| **Error Message**                                                |
2335|-----------| ------------------------------------------------------------ |
2336| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2337| 14800000  | Inner error. |
2338| 14800011  | Database corrupted. |
2339| 14800014  | Already closed. |
2340| 14800015  | The database does not respond. |
2341| 14800021  | SQLite: Generic error. |
2342| 14800022  | SQLite: Callback routine requested an abort. |
2343| 14800023  | SQLite: Access permission denied. |
2344| 14800024  | SQLite: The database file is locked. |
2345| 14800025  | SQLite: A table in the database is locked. |
2346| 14800026  | SQLite: The database is out of memory. |
2347| 14800027  | SQLite: Attempt to write a readonly database. |
2348| 14800028  | SQLite: Some kind of disk I/O error occurred. |
2349| 14800029  | SQLite: The database is full. |
2350| 14800030  | SQLite: Unable to open the database file. |
2351| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
2352| 14800032  | SQLite: Abort due to constraint violation. |
2353| 14800033  | SQLite: Data type mismatch. |
2354| 14800034  | SQLite: Library used incorrectly. |
2355| 14800047  | The WAL file size exceeds the default limit. |
2356
2357**Example**
2358
2359```ts
2360import { BusinessError } from '@kit.BasicServicesKit';
2361
2362let value1 = "Lisa";
2363let value2 = 18;
2364let value3 = 100.5;
2365let value4 = new Uint8Array([1, 2, 3, 4, 5]);
2366
2367// You can use either of the following:
2368const valueBucket1: relationalStore.ValuesBucket = {
2369  'NAME': value1,
2370  'AGE': value2,
2371  'SALARY': value3,
2372  'CODES': value4,
2373};
2374const valueBucket2: relationalStore.ValuesBucket = {
2375  NAME: value1,
2376  AGE: value2,
2377  SALARY: value3,
2378  CODES: value4,
2379};
2380const valueBucket3: relationalStore.ValuesBucket = {
2381  "NAME": value1,
2382  "AGE": value2,
2383  "SALARY": value3,
2384  "CODES": value4,
2385};
2386
2387if(store != undefined) {
2388  (store as relationalStore.RdbStore).insert("EMPLOYEE", valueBucket1).then((rowId: number) => {
2389    console.info(`Insert is successful, rowId = ${rowId}`);
2390  }).catch((err: BusinessError) => {
2391    console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
2392  })
2393}
2394```
2395
2396### insert<sup>10+</sup>
2397
2398insert(table: string, values: ValuesBucket,  conflict: ConflictResolution):Promise&lt;number&gt;
2399
2400Inserts 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.
2401
2402**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2403
2404**Parameters**
2405
2406| Name  | Type                                       | Mandatory| Description                      |
2407| -------- | ------------------------------------------- | ---- | -------------------------- |
2408| table    | string                                      | Yes  | Name of the target table.          |
2409| values   | [ValuesBucket](#valuesbucket)               | Yes  | Row of data to insert.|
2410| conflict | [ConflictResolution](#conflictresolution10) | Yes  | Resolution used to resolve the conflict.        |
2411
2412**Return value**
2413
2414| Type                 | Description                                             |
2415| --------------------- | ------------------------------------------------- |
2416| 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.|
2417
2418**Error codes**
2419
2420For 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).
2421
2422| **ID**| **Error Message**                                                |
2423|-----------| ------------------------------------------------------------ |
2424| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2425| 14800000  | Inner error. |
2426| 14800011  | Database corrupted. |
2427| 14800014  | Already closed. |
2428| 14800015  | The database does not respond. |
2429| 14800021  | SQLite: Generic error. |
2430| 14800022  | SQLite: Callback routine requested an abort. |
2431| 14800023  | SQLite: Access permission denied. |
2432| 14800024  | SQLite: The database file is locked. |
2433| 14800025  | SQLite: A table in the database is locked. |
2434| 14800026  | SQLite: The database is out of memory. |
2435| 14800027  | SQLite: Attempt to write a readonly database. |
2436| 14800028  | SQLite: Some kind of disk I/O error occurred. |
2437| 14800029  | SQLite: The database is full. |
2438| 14800030  | SQLite: Unable to open the database file. |
2439| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
2440| 14800032  | SQLite: Abort due to constraint violation. |
2441| 14800033  | SQLite: Data type mismatch. |
2442| 14800034  | SQLite: Library used incorrectly. |
2443| 14800047  | The WAL file size exceeds the default limit. |
2444
2445**Example**
2446
2447```ts
2448import { BusinessError } from '@kit.BasicServicesKit';
2449
2450let value1 = "Lisa";
2451let value2 = 18;
2452let value3 = 100.5;
2453let value4 = new Uint8Array([1, 2, 3, 4, 5]);
2454
2455// You can use either of the following:
2456const valueBucket1: relationalStore.ValuesBucket = {
2457  'NAME': value1,
2458  'AGE': value2,
2459  'SALARY': value3,
2460  'CODES': value4,
2461};
2462const valueBucket2: relationalStore.ValuesBucket = {
2463  NAME: value1,
2464  AGE: value2,
2465  SALARY: value3,
2466  CODES: value4,
2467};
2468const valueBucket3: relationalStore.ValuesBucket = {
2469  "NAME": value1,
2470  "AGE": value2,
2471  "SALARY": value3,
2472  "CODES": value4,
2473};
2474
2475if(store != undefined) {
2476  (store as relationalStore.RdbStore).insert("EMPLOYEE", valueBucket1, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE).then((rowId: number) => {
2477    console.info(`Insert is successful, rowId = ${rowId}`);
2478  }).catch((err: BusinessError) => {
2479    console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
2480  })
2481}
2482```
2483
2484### insertSync<sup>12+</sup>
2485
2486insertSync(table: string, values: ValuesBucket,  conflict?: ConflictResolution):number
2487
2488Inserts 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.
2489
2490**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2491
2492**Parameters**
2493
2494| Name  | Type                                       | Mandatory| Description                                                        |
2495| -------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
2496| table    | string                                      | Yes  | Name of the target table.                                            |
2497| values   | [ValuesBucket](#valuesbucket)               | Yes  | Row of data to insert.                                  |
2498| conflict | [ConflictResolution](#conflictresolution10) | No  | Resolution used to resolve the conflict. The default value is **relationalStore.ConflictResolution.ON_CONFLICT_NONE**.|
2499
2500**Return value**
2501
2502| Type  | Description                                |
2503| ------ | ------------------------------------ |
2504| number | If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
2505
2506**Error codes**
2507
2508For 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).
2509
2510| **ID**| **Error Message**                                                |
2511| ------------ | ------------------------------------------------------------ |
2512| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2513| 14800000     | Inner error.                                                 |
2514| 14800011     | Database corrupted.                                          |
2515| 14800014     | Already closed.                                              |
2516| 14800015     | The database does not respond.                                        |
2517| 14800021     | SQLite: Generic error.                                       |
2518| 14800022     | SQLite: Callback routine requested an abort.                 |
2519| 14800023     | SQLite: Access permission denied.                            |
2520| 14800024     | SQLite: The database file is locked.                         |
2521| 14800025     | SQLite: A table in the database is locked.                   |
2522| 14800026     | SQLite: The database is out of memory.                       |
2523| 14800027     | SQLite: Attempt to write a readonly database.                |
2524| 14800028     | SQLite: Some kind of disk I/O error occurred.                |
2525| 14800029     | SQLite: The database is full.                                |
2526| 14800030     | SQLite: Unable to open the database file.                    |
2527| 14800031     | SQLite: TEXT or BLOB exceeds size limit.                     |
2528| 14800032     | SQLite: Abort due to constraint violation.                   |
2529| 14800033     | SQLite: Data type mismatch.                                  |
2530| 14800034     | SQLite: Library used incorrectly.                            |
2531| 14800047     | The WAL file size exceeds the default limit.                 |
2532
2533**Example**
2534
2535```ts
2536import { BusinessError } from '@kit.BasicServicesKit';
2537
2538let value1 = "Lisa";
2539let value2 = 18;
2540let value3 = 100.5;
2541let value4 = new Uint8Array([1, 2, 3, 4, 5]);
2542
2543// You can use either of the following:
2544const valueBucket1: relationalStore.ValuesBucket = {
2545  'NAME': value1,
2546  'AGE': value2,
2547  'SALARY': value3,
2548  'CODES': value4,
2549};
2550const valueBucket2: relationalStore.ValuesBucket = {
2551  NAME: value1,
2552  AGE: value2,
2553  SALARY: value3,
2554  CODES: value4,
2555};
2556const valueBucket3: relationalStore.ValuesBucket = {
2557  "NAME": value1,
2558  "AGE": value2,
2559  "SALARY": value3,
2560  "CODES": value4,
2561};
2562
2563if(store != undefined) {
2564  try {
2565    let rowId : number = (store as relationalStore.RdbStore).insertSync("EMPLOYEE", valueBucket1, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE);
2566    console.info(`Insert is successful, rowId = ${rowId}`);
2567  } catch (error) {
2568      console.error(`Insert is failed, code is ${error.code},message is ${error.message}`);
2569  }
2570}
2571```
2572
2573### insertSync<sup>12+</sup>
2574
2575insertSync(table: string, values: sendableRelationalStore.ValuesBucket, conflict?: ConflictResolution):number
2576
2577Inserts 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.
2578
2579**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2580
2581**Parameters**
2582
2583| Name  | Type                                                                                          | Mandatory| Description                                                                           |
2584| -------- | ---------------------------------------------------------------------------------------------- | ---- | ------------------------------------------------------------------------------- |
2585| table    | string                                                                                         | Yes  | Name of the target table.                                                               |
2586| values   | [sendableRelationalStore.ValuesBucket](./js-apis-data-sendableRelationalStore.md#valuesbucket) | Yes  | Sendable data to insert.                                           |
2587| conflict | [ConflictResolution](#conflictresolution10)                                                    | No  | Resolution used to resolve the conflict. The default value is **relationalStore.ConflictResolution.ON_CONFLICT_NONE**.|
2588
2589**Return value**
2590
2591| Type  | Description                                |
2592| ------ | ------------------------------------ |
2593| number | If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
2594
2595**Error codes**
2596
2597For 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).
2598
2599| **ID**| **Error Message**                                                |
2600| ------------ | ------------------------------------------------------------ |
2601| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2602| 14800000     | Inner error.                                                 |
2603| 14800011     | Database corrupted.                                          |
2604| 14800014     | Already closed.                                              |
2605| 14800015     | The database does not respond.                                        |
2606| 14800021     | SQLite: Generic error.                                       |
2607| 14800022     | SQLite: Callback routine requested an abort.                 |
2608| 14800023     | SQLite: Access permission denied.                            |
2609| 14800024     | SQLite: The database file is locked.                         |
2610| 14800025     | SQLite: A table in the database is locked.                   |
2611| 14800026     | SQLite: The database is out of memory.                       |
2612| 14800027     | SQLite: Attempt to write a readonly database.                |
2613| 14800028     | SQLite: Some kind of disk I/O error occurred.                |
2614| 14800029     | SQLite: The database is full.                                |
2615| 14800030     | SQLite: Unable to open the database file.                    |
2616| 14800031     | SQLite: TEXT or BLOB exceeds size limit.                     |
2617| 14800032     | SQLite: Abort due to constraint violation.                   |
2618| 14800033     | SQLite: Data type mismatch.                                  |
2619| 14800034     | SQLite: Library used incorrectly.                            |
2620| 14800047     | The WAL file size exceeds the default limit.                 |
2621
2622**Example**
2623
2624```ts
2625import { sendableRelationalStore } from '@kit.ArkData';
2626
2627const valuesBucket: relationalStore.ValuesBucket = {
2628  "NAME": 'hangman',
2629  "AGE": 18,
2630  "SALARY": 100.5,
2631  "CODES": new Uint8Array([1,2,3]),
2632};
2633const sendableValuesBucket = sendableRelationalStore.toSendableValuesBucket(valuesBucket);
2634
2635if(store != undefined) {
2636  try {
2637    let rowId : number = (store as relationalStore.RdbStore).insertSync("EMPLOYEE", sendableValuesBucket, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE);
2638    console.info(`Insert is successful, rowId = ${rowId}`);
2639  } catch (error) {
2640    console.error(`Insert is failed, code is ${error.code},message is ${error.message}`);
2641  }
2642}
2643```
2644
2645### batchInsert
2646
2647batchInsert(table: string, values: Array&lt;ValuesBucket&gt;, callback: AsyncCallback&lt;number&gt;):void
2648
2649Batch inserts data into a table. This API uses an asynchronous callback to return the result.
2650
2651**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2652
2653**Parameters**
2654
2655| Name  | Type                                      | Mandatory| Description                                                        |
2656| -------- | ------------------------------------------ | ---- | ------------------------------------------------------------ |
2657| table    | string                                     | Yes  | Name of the target table.                                            |
2658| values   | Array&lt;[ValuesBucket](#valuesbucket)&gt; | Yes  | An array of data to insert.                                |
2659| 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.|
2660
2661**Error codes**
2662
2663For 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).
2664
2665| **ID**| **Error Message**                                                |
2666|-----------| ------------------------------------------------------------ |
2667| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2668| 14800000  | Inner error. |
2669| 14800011  | Database corrupted. |
2670| 14800014  | Already closed. |
2671| 14800015  | The database does not respond. |
2672| 14800021  | SQLite: Generic error. |
2673| 14800022  | SQLite: Callback routine requested an abort. |
2674| 14800023  | SQLite: Access permission denied. |
2675| 14800024  | SQLite: The database file is locked. |
2676| 14800025  | SQLite: A table in the database is locked. |
2677| 14800026  | SQLite: The database is out of memory. |
2678| 14800027  | SQLite: Attempt to write a readonly database. |
2679| 14800028  | SQLite: Some kind of disk I/O error occurred. |
2680| 14800029  | SQLite: The database is full. |
2681| 14800030  | SQLite: Unable to open the database file. |
2682| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
2683| 14800032  | SQLite: Abort due to constraint violation. |
2684| 14800033  | SQLite: Data type mismatch. |
2685| 14800034  | SQLite: Library used incorrectly. |
2686| 14800047  | The WAL file size exceeds the default limit. |
2687
2688**Example**
2689
2690```ts
2691
2692let value1 = "Lisa";
2693let value2 = 18;
2694let value3 = 100.5;
2695let value4 = new Uint8Array([1, 2, 3, 4, 5]);
2696let value5 = "Jack";
2697let value6 = 19;
2698let value7 = 101.5;
2699let value8 = new Uint8Array([6, 7, 8, 9, 10]);
2700let value9 = "Tom";
2701let value10 = 20;
2702let value11 = 102.5;
2703let value12 = new Uint8Array([11, 12, 13, 14, 15]);
2704
2705const valueBucket1: relationalStore.ValuesBucket = {
2706  'NAME': value1,
2707  'AGE': value2,
2708  'SALARY': value3,
2709  'CODES': value4,
2710};
2711const valueBucket2: relationalStore.ValuesBucket = {
2712  'NAME': value5,
2713  'AGE': value6,
2714  'SALARY': value7,
2715  'CODES': value8,
2716};
2717const valueBucket3: relationalStore.ValuesBucket = {
2718  'NAME': value9,
2719  'AGE': value10,
2720  'SALARY': value11,
2721  'CODES': value12,
2722};
2723
2724let valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3);
2725if(store != undefined) {
2726  (store as relationalStore.RdbStore).batchInsert("EMPLOYEE", valueBuckets, (err, insertNum) => {
2727    if (err) {
2728      console.error(`batchInsert is failed, code is ${err.code},message is ${err.message}`);
2729      return;
2730    }
2731    console.info(`batchInsert is successful, the number of values that were inserted = ${insertNum}`);
2732  })
2733}
2734```
2735
2736### batchInsert
2737
2738batchInsert(table: string, values: Array&lt;ValuesBucket&gt;):Promise&lt;number&gt;
2739
2740Batch inserts data into a table. This API uses a promise to return the result.
2741
2742**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2743
2744**Parameters**
2745
2746| Name| Type                                      | Mandatory| Description                        |
2747| ------ | ------------------------------------------ | ---- | ---------------------------- |
2748| table  | string                                     | Yes  | Name of the target table.            |
2749| values | Array&lt;[ValuesBucket](#valuesbucket)&gt; | Yes  | An array of data to insert.|
2750
2751**Return value**
2752
2753| Type                 | Description                                                       |
2754| --------------------- | ----------------------------------------------------------- |
2755| 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.|
2756
2757**Error codes**
2758
2759For 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).
2760
2761| **ID**| **Error Message**                                                |
2762|-----------| ------------------------------------------------------------ |
2763| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2764| 14800000  | Inner error. |
2765| 14800011  | Database corrupted. |
2766| 14800014  | Already closed. |
2767| 14800015  | The database does not respond. |
2768| 14800021  | SQLite: Generic error. |
2769| 14800022  | SQLite: Callback routine requested an abort. |
2770| 14800023  | SQLite: Access permission denied. |
2771| 14800024  | SQLite: The database file is locked. |
2772| 14800025  | SQLite: A table in the database is locked. |
2773| 14800026  | SQLite: The database is out of memory. |
2774| 14800027  | SQLite: Attempt to write a readonly database. |
2775| 14800028  | SQLite: Some kind of disk I/O error occurred. |
2776| 14800029  | SQLite: The database is full. |
2777| 14800030  | SQLite: Unable to open the database file. |
2778| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
2779| 14800032  | SQLite: Abort due to constraint violation. |
2780| 14800033  | SQLite: Data type mismatch. |
2781| 14800034  | SQLite: Library used incorrectly. |
2782| 14800047  | The WAL file size exceeds the default limit. |
2783
2784**Example**
2785
2786```ts
2787import { BusinessError } from '@kit.BasicServicesKit';
2788
2789let value1 = "Lisa";
2790let value2 = 18;
2791let value3 = 100.5;
2792let value4 = new Uint8Array([1, 2, 3, 4, 5]);
2793let value5 = "Jack";
2794let value6 = 19;
2795let value7 = 101.5;
2796let value8 = new Uint8Array([6, 7, 8, 9, 10]);
2797let value9 = "Tom";
2798let value10 = 20;
2799let value11 = 102.5;
2800let value12 = new Uint8Array([11, 12, 13, 14, 15]);
2801
2802const valueBucket1: relationalStore.ValuesBucket = {
2803  'NAME': value1,
2804  'AGE': value2,
2805  'SALARY': value3,
2806  'CODES': value4,
2807};
2808const valueBucket2: relationalStore.ValuesBucket = {
2809  'NAME': value5,
2810  'AGE': value6,
2811  'SALARY': value7,
2812  'CODES': value8,
2813};
2814const valueBucket3: relationalStore.ValuesBucket = {
2815  'NAME': value9,
2816  'AGE': value10,
2817  'SALARY': value11,
2818  'CODES': value12,
2819};
2820
2821let valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3);
2822if(store != undefined) {
2823  (store as relationalStore.RdbStore).batchInsert("EMPLOYEE", valueBuckets).then((insertNum: number) => {
2824    console.info(`batchInsert is successful, the number of values that were inserted = ${insertNum}`);
2825  }).catch((err: BusinessError) => {
2826    console.error(`batchInsert is failed, code is ${err.code},message is ${err.message}`);
2827  })
2828}
2829```
2830
2831### batchInsertSync<sup>12+</sup>
2832
2833batchInsertSync(table: string, values: Array&lt;ValuesBucket&gt;):number
2834
2835Inserts a row of data into a table.
2836
2837**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2838
2839**Parameters**
2840
2841| Name| Type                                      | Mandatory| Description                        |
2842| ------ | ------------------------------------------ | ---- | ---------------------------- |
2843| table  | string                                     | Yes  | Name of the target table.            |
2844| values | Array&lt;[ValuesBucket](#valuesbucket)&gt; | Yes  | An array of data to insert.|
2845
2846**Return value**
2847
2848| Type  | Description                                          |
2849| ------ | ---------------------------------------------- |
2850| number | If the operation is successful, the number of inserted data records is returned. Otherwise, **-1** is returned.|
2851
2852**Error codes**
2853
2854For 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).
2855
2856| **ID**| **Error Message**                                                |
2857| ------------ | ------------------------------------------------------------ |
2858| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2859| 14800000     | Inner error.                                                 |
2860| 14800011     | Database corrupted.                                          |
2861| 14800014     | Already closed.                                              |
2862| 14800015     | The database does not respond.                                        |
2863| 14800021     | SQLite: Generic error.                                       |
2864| 14800022     | SQLite: Callback routine requested an abort.                 |
2865| 14800023     | SQLite: Access permission denied.                            |
2866| 14800024     | SQLite: The database file is locked.                         |
2867| 14800025     | SQLite: A table in the database is locked.                   |
2868| 14800026     | SQLite: The database is out of memory.                       |
2869| 14800027     | SQLite: Attempt to write a readonly database.                |
2870| 14800028     | SQLite: Some kind of disk I/O error occurred.                |
2871| 14800029     | SQLite: The database is full.                                |
2872| 14800030     | SQLite: Unable to open the database file.                    |
2873| 14800031     | SQLite: TEXT or BLOB exceeds size limit.                     |
2874| 14800032     | SQLite: Abort due to constraint violation.                   |
2875| 14800033     | SQLite: Data type mismatch.                                  |
2876| 14800034     | SQLite: Library used incorrectly.                            |
2877| 14800047     | The WAL file size exceeds the default limit.                 |
2878
2879**Example**
2880
2881```ts
2882import { BusinessError } from '@kit.BasicServicesKit';
2883
2884let value1 = "Lisa";
2885let value2 = 18;
2886let value3 = 100.5;
2887let value4 = new Uint8Array([1, 2, 3, 4, 5]);
2888let value5 = "Jack";
2889let value6 = 19;
2890let value7 = 101.5;
2891let value8 = new Uint8Array([6, 7, 8, 9, 10]);
2892let value9 = "Tom";
2893let value10 = 20;
2894let value11 = 102.5;
2895let value12 = new Uint8Array([11, 12, 13, 14, 15]);
2896
2897const valueBucket1: relationalStore.ValuesBucket = {
2898  'NAME': value1,
2899  'AGE': value2,
2900  'SALARY': value3,
2901  'CODES': value4,
2902};
2903const valueBucket2: relationalStore.ValuesBucket = {
2904  'NAME': value5,
2905  'AGE': value6,
2906  'SALARY': value7,
2907  'CODES': value8,
2908};
2909const valueBucket3: relationalStore.ValuesBucket = {
2910  'NAME': value9,
2911  'AGE': value10,
2912  'SALARY': value11,
2913  'CODES': value12,
2914};
2915
2916let valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3);
2917if(store != undefined) {
2918  try {
2919    let insertNum: number = (store as relationalStore.RdbStore).batchInsertSync("EMPLOYEE", valueBuckets);
2920    console.info(`batchInsert is successful, the number of values that were inserted = ${insertNum}`);
2921  } catch (err) {
2922      console.error(`batchInsert is failed, code is ${err.code},message is ${err.message}`);
2923  }
2924}
2925```
2926
2927### update
2928
2929update(values: ValuesBucket, predicates: RdbPredicates, callback: AsyncCallback&lt;number&gt;):void
2930
2931Updates 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.
2932
2933**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2934
2935**Parameters**
2936
2937| Name    | Type                                | Mandatory| Description                                                        |
2938| ---------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
2939| 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.|
2940| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Update conditions specified by the **RdbPredicates** object.                   |
2941| callback   | AsyncCallback&lt;number&gt;          | Yes  | Callback used to return the number of rows updated.                  |
2942
2943**Error codes**
2944
2945For 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).
2946
2947| **ID**| **Error Message**                                                |
2948|-----------| ------------------------------------------------------------ |
2949| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
2950| 14800000  | Inner error. |
2951| 14800011  | Database corrupted. |
2952| 14800014  | Already closed. |
2953| 14800015  | The database does not respond. |
2954| 14800021  | SQLite: Generic error. |
2955| 14800022  | SQLite: Callback routine requested an abort. |
2956| 14800023  | SQLite: Access permission denied. |
2957| 14800024  | SQLite: The database file is locked. |
2958| 14800025  | SQLite: A table in the database is locked. |
2959| 14800026  | SQLite: The database is out of memory. |
2960| 14800027  | SQLite: Attempt to write a readonly database. |
2961| 14800028  | SQLite: Some kind of disk I/O error occurred. |
2962| 14800029  | SQLite: The database is full. |
2963| 14800030  | SQLite: Unable to open the database file. |
2964| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
2965| 14800032  | SQLite: Abort due to constraint violation. |
2966| 14800033  | SQLite: Data type mismatch. |
2967| 14800034  | SQLite: Library used incorrectly. |
2968| 14800047  | The WAL file size exceeds the default limit. |
2969
2970**Example**
2971
2972```ts
2973
2974let value1 = "Rose";
2975let value2 = 22;
2976let value3 = 200.5;
2977let value4 = new Uint8Array([1, 2, 3, 4, 5]);
2978
2979// You can use either of the following:
2980const valueBucket1: relationalStore.ValuesBucket = {
2981  'NAME': value1,
2982  'AGE': value2,
2983  'SALARY': value3,
2984  'CODES': value4,
2985};
2986const valueBucket2: relationalStore.ValuesBucket = {
2987  NAME: value1,
2988  AGE: value2,
2989  SALARY: value3,
2990  CODES: value4,
2991};
2992const valueBucket3: relationalStore.ValuesBucket = {
2993  "NAME": value1,
2994  "AGE": value2,
2995  "SALARY": value3,
2996  "CODES": value4,
2997};
2998
2999let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3000predicates.equalTo("NAME", "Lisa");
3001if(store != undefined) {
3002  (store as relationalStore.RdbStore).update(valueBucket1, predicates,(err, rows) => {
3003    if (err) {
3004      console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
3005      return;
3006    }
3007    console.info(`Updated row count: ${rows}`);
3008  })
3009}
3010```
3011
3012### update<sup>10+</sup>
3013
3014update(values: ValuesBucket, predicates: RdbPredicates, conflict: ConflictResolution, callback: AsyncCallback&lt;number&gt;):void
3015
3016Updates 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.
3017
3018**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3019
3020**Parameters**
3021
3022| Name    | Type                                       | Mandatory| Description                                                        |
3023| ---------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
3024| 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.|
3025| predicates | [RdbPredicates](#rdbpredicates)            | Yes  | Update conditions specified by the **RdbPredicates** object.                     |
3026| conflict   | [ConflictResolution](#conflictresolution10) | Yes  | Resolution used to resolve the conflict.                                          |
3027| callback   | AsyncCallback&lt;number&gt;                 | Yes  | Callback used to return the number of rows updated.                  |
3028
3029**Error codes**
3030
3031For 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).
3032
3033| **ID**| **Error Message**                                                |
3034|-----------| ------------------------------------------------------------ |
3035| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3036| 14800000  | Inner error. |
3037| 14800011  | Database corrupted. |
3038| 14800014  | Already closed. |
3039| 14800015  | The database does not respond. |
3040| 14800021  | SQLite: Generic error. |
3041| 14800022  | SQLite: Callback routine requested an abort. |
3042| 14800023  | SQLite: Access permission denied. |
3043| 14800024  | SQLite: The database file is locked. |
3044| 14800025  | SQLite: A table in the database is locked. |
3045| 14800026  | SQLite: The database is out of memory. |
3046| 14800027  | SQLite: Attempt to write a readonly database. |
3047| 14800028  | SQLite: Some kind of disk I/O error occurred. |
3048| 14800029  | SQLite: The database is full. |
3049| 14800030  | SQLite: Unable to open the database file. |
3050| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
3051| 14800032  | SQLite: Abort due to constraint violation. |
3052| 14800033  | SQLite: Data type mismatch. |
3053| 14800034  | SQLite: Library used incorrectly. |
3054| 14800047  | The WAL file size exceeds the default limit. |
3055
3056**Example**
3057
3058```ts
3059
3060let value1 = "Rose";
3061let value2 = 22;
3062let value3 = 200.5;
3063let value4 = new Uint8Array([1, 2, 3, 4, 5]);
3064
3065// You can use either of the following:
3066const valueBucket1: relationalStore.ValuesBucket = {
3067  'NAME': value1,
3068  'AGE': value2,
3069  'SALARY': value3,
3070  'CODES': value4,
3071};
3072const valueBucket2: relationalStore.ValuesBucket = {
3073  NAME: value1,
3074  AGE: value2,
3075  SALARY: value3,
3076  CODES: value4,
3077};
3078const valueBucket3: relationalStore.ValuesBucket = {
3079  "NAME": value1,
3080  "AGE": value2,
3081  "SALARY": value3,
3082  "CODES": value4,
3083};
3084
3085let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3086predicates.equalTo("NAME", "Lisa");
3087if(store != undefined) {
3088  (store as relationalStore.RdbStore).update(valueBucket1, predicates, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE, (err, rows) => {
3089    if (err) {
3090      console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
3091      return;
3092    }
3093    console.info(`Updated row count: ${rows}`);
3094  })
3095}
3096```
3097
3098### update
3099
3100update(values: ValuesBucket, predicates: RdbPredicates):Promise&lt;number&gt;
3101
3102Updates 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.
3103
3104**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3105
3106**Parameters**
3107
3108| Name      | Type                                | Mandatory| Description                                                        |
3109| ------------ | ------------------------------------ | ---- | ------------------------------------------------------------ |
3110| 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.|
3111| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Update conditions specified by the **RdbPredicates** object.                   |
3112
3113**Return value**
3114
3115| Type                 | Description                                     |
3116| --------------------- | ----------------------------------------- |
3117| Promise&lt;number&gt; | Promise used to return the number of rows updated.|
3118
3119**Error codes**
3120
3121For 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).
3122
3123| **ID**| **Error Message**                                                |
3124|-----------| ------------------------------------------------------------ |
3125| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3126| 14800000  | Inner error. |
3127| 14800011  | Database corrupted. |
3128| 14800014  | Already closed. |
3129| 14800015  | The database does not respond. |
3130| 14800021  | SQLite: Generic error. |
3131| 14800022  | SQLite: Callback routine requested an abort. |
3132| 14800023  | SQLite: Access permission denied. |
3133| 14800024  | SQLite: The database file is locked. |
3134| 14800025  | SQLite: A table in the database is locked. |
3135| 14800026  | SQLite: The database is out of memory. |
3136| 14800027  | SQLite: Attempt to write a readonly database. |
3137| 14800028  | SQLite: Some kind of disk I/O error occurred. |
3138| 14800029  | SQLite: The database is full. |
3139| 14800030  | SQLite: Unable to open the database file. |
3140| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
3141| 14800032  | SQLite: Abort due to constraint violation. |
3142| 14800033  | SQLite: Data type mismatch. |
3143| 14800034  | SQLite: Library used incorrectly. |
3144| 14800047  | The WAL file size exceeds the default limit. |
3145
3146**Example**
3147
3148```ts
3149import { BusinessError } from '@kit.BasicServicesKit';
3150
3151let value1 = "Rose";
3152let value2 = 22;
3153let value3 = 200.5;
3154let value4 = new Uint8Array([1, 2, 3, 4, 5]);
3155
3156// You can use either of the following:
3157const valueBucket1: relationalStore.ValuesBucket = {
3158  'NAME': value1,
3159  'AGE': value2,
3160  'SALARY': value3,
3161  'CODES': value4,
3162};
3163const valueBucket2: relationalStore.ValuesBucket = {
3164  NAME: value1,
3165  AGE: value2,
3166  SALARY: value3,
3167  CODES: value4,
3168};
3169const valueBucket3: relationalStore.ValuesBucket = {
3170  "NAME": value1,
3171  "AGE": value2,
3172  "SALARY": value3,
3173  "CODES": value4,
3174};
3175
3176let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3177predicates.equalTo("NAME", "Lisa");
3178if(store != undefined) {
3179  (store as relationalStore.RdbStore).update(valueBucket1, predicates).then(async (rows: Number) => {
3180    console.info(`Updated row count: ${rows}`);
3181  }).catch((err: BusinessError) => {
3182    console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
3183  })
3184}
3185```
3186
3187### update<sup>10+</sup>
3188
3189update(values: ValuesBucket, predicates: RdbPredicates, conflict: ConflictResolution):Promise&lt;number&gt;
3190
3191Updates 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.
3192
3193**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3194
3195**Parameters**
3196
3197| Name    | Type                                       | Mandatory| Description                                                        |
3198| ---------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
3199| 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.|
3200| predicates | [RdbPredicates](#rdbpredicates)            | Yes  | Update conditions specified by the **RdbPredicates** object.                     |
3201| conflict   | [ConflictResolution](#conflictresolution10) | Yes  | Resolution used to resolve the conflict.                                          |
3202
3203**Return value**
3204
3205| Type                 | Description                                     |
3206| --------------------- | ----------------------------------------- |
3207| Promise&lt;number&gt; | Promise used to return the number of rows updated.|
3208
3209**Error codes**
3210
3211For 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).
3212
3213| **ID**| **Error Message**                                                |
3214|-----------| ------------------------------------------------------------ |
3215| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3216| 14800000  | Inner error. |
3217| 14800011  | Database corrupted. |
3218| 14800014  | Already closed. |
3219| 14800015  | The database does not respond. |
3220| 14800021  | SQLite: Generic error. |
3221| 14800022  | SQLite: Callback routine requested an abort. |
3222| 14800023  | SQLite: Access permission denied. |
3223| 14800024  | SQLite: The database file is locked. |
3224| 14800025  | SQLite: A table in the database is locked. |
3225| 14800026  | SQLite: The database is out of memory. |
3226| 14800027  | SQLite: Attempt to write a readonly database. |
3227| 14800028  | SQLite: Some kind of disk I/O error occurred. |
3228| 14800029  | SQLite: The database is full. |
3229| 14800030  | SQLite: Unable to open the database file. |
3230| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
3231| 14800032  | SQLite: Abort due to constraint violation. |
3232| 14800033  | SQLite: Data type mismatch. |
3233| 14800034  | SQLite: Library used incorrectly. |
3234| 14800047  | The WAL file size exceeds the default limit. |
3235
3236**Example**
3237
3238```ts
3239import { BusinessError } from '@kit.BasicServicesKit';
3240
3241let value1 = "Rose";
3242let value2 = 22;
3243let value3 = 200.5;
3244let value4 = new Uint8Array([1, 2, 3, 4, 5]);
3245
3246// You can use either of the following:
3247const valueBucket1: relationalStore.ValuesBucket = {
3248  'NAME': value1,
3249  'AGE': value2,
3250  'SALARY': value3,
3251  'CODES': value4,
3252};
3253const valueBucket2: relationalStore.ValuesBucket = {
3254  NAME: value1,
3255  AGE: value2,
3256  SALARY: value3,
3257  CODES: value4,
3258};
3259const valueBucket3: relationalStore.ValuesBucket = {
3260  "NAME": value1,
3261  "AGE": value2,
3262  "SALARY": value3,
3263  "CODES": value4,
3264};
3265
3266let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3267predicates.equalTo("NAME", "Lisa");
3268if(store != undefined) {
3269  (store as relationalStore.RdbStore).update(valueBucket1, predicates, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE).then(async (rows: Number) => {
3270    console.info(`Updated row count: ${rows}`);
3271  }).catch((err: BusinessError) => {
3272    console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
3273  })
3274}
3275```
3276
3277### updateSync<sup>12+</sup>
3278
3279updateSync(values: ValuesBucket, predicates: RdbPredicates, conflict?: ConflictResolution):number
3280
3281Updates 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.
3282
3283**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3284
3285**Parameters**
3286
3287| Name    | Type                                       | Mandatory| Description                                                        |
3288| ---------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
3289| 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.|
3290| predicates | [RdbPredicates](#rdbpredicates)             | Yes  | Update conditions specified by the **RdbPredicates** object.                     |
3291| conflict   | [ConflictResolution](#conflictresolution10) | No  | Resolution used to resolve the conflict. The default value is **relationalStore.ConflictResolution.ON_CONFLICT_NONE**.|
3292
3293**Return value**
3294
3295| Type  | Description              |
3296| ------ | ------------------ |
3297| number | return the number of rows updated.|
3298
3299**Error codes**
3300
3301For 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).
3302
3303| **ID**| **Error Message**                                                |
3304| ------------ | ------------------------------------------------------------ |
3305| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3306| 14800000     | Inner error.                                                 |
3307| 14800011     | Database corrupted.                                          |
3308| 14800014     | Already closed.                                              |
3309| 14800015     | The database does not respond.                                        |
3310| 14800021     | SQLite: Generic error.                                       |
3311| 14800022     | SQLite: Callback routine requested an abort.                 |
3312| 14800023     | SQLite: Access permission denied.                            |
3313| 14800024     | SQLite: The database file is locked.                         |
3314| 14800025     | SQLite: A table in the database is locked.                   |
3315| 14800026     | SQLite: The database is out of memory.                       |
3316| 14800027     | SQLite: Attempt to write a readonly database.                |
3317| 14800028     | SQLite: Some kind of disk I/O error occurred.                |
3318| 14800029     | SQLite: The database is full.                                |
3319| 14800030     | SQLite: Unable to open the database file.                    |
3320| 14800031     | SQLite: TEXT or BLOB exceeds size limit.                     |
3321| 14800032     | SQLite: Abort due to constraint violation.                   |
3322| 14800033     | SQLite: Data type mismatch.                                  |
3323| 14800034     | SQLite: Library used incorrectly.                            |
3324| 14800047     | The WAL file size exceeds the default limit.                 |
3325
3326**Example**
3327
3328```ts
3329import { BusinessError } from '@kit.BasicServicesKit';
3330
3331let value1 = "Rose";
3332let value2 = 22;
3333let value3 = 200.5;
3334let value4 = new Uint8Array([1, 2, 3, 4, 5]);
3335
3336// You can use either of the following:
3337const valueBucket1: relationalStore.ValuesBucket = {
3338  'NAME': value1,
3339  'AGE': value2,
3340  'SALARY': value3,
3341  'CODES': value4,
3342};
3343const valueBucket2: relationalStore.ValuesBucket = {
3344  NAME: value1,
3345  AGE: value2,
3346  SALARY: value3,
3347  CODES: value4,
3348};
3349const valueBucket3: relationalStore.ValuesBucket = {
3350  "NAME": value1,
3351  "AGE": value2,
3352  "SALARY": value3,
3353  "CODES": value4,
3354};
3355
3356let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3357predicates.equalTo("NAME", "Lisa");
3358if(store != undefined) {
3359  try {
3360    let rows: Number = (store as relationalStore.RdbStore).updateSync(valueBucket1, predicates, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE);
3361    console.info(`Updated row count: ${rows}`);
3362  } catch (error) {
3363    console.error(`Updated failed, code is ${error.code},message is ${error.message}`);
3364  }
3365}
3366```
3367
3368### delete
3369
3370delete(predicates: RdbPredicates, callback: AsyncCallback&lt;number&gt;):void
3371
3372Deletes data from the RDB store based on the specified **RdbPredicates** object. This API uses an asynchronous callback to return the result.
3373
3374**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3375
3376**Parameters**
3377
3378| Name    | Type                                | Mandatory| Description                                     |
3379| ---------- | ------------------------------------ | ---- | ----------------------------------------- |
3380| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Conditions specified by the **RdbPredicates** object for deleting data.|
3381| callback   | AsyncCallback&lt;number&gt;          | Yes  | Callback used to return the number of rows deleted. |
3382
3383**Error codes**
3384
3385For 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).
3386
3387| **ID**| **Error Message**                                                |
3388|-----------| ------------------------------------------------------------ |
3389| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3390| 14800000  | Inner error. |
3391| 14800011  | Database corrupted. |
3392| 14800014  | Already closed. |
3393| 14800015  | The database does not respond. |
3394| 14800021  | SQLite: Generic error. |
3395| 14800022  | SQLite: Callback routine requested an abort. |
3396| 14800023  | SQLite: Access permission denied. |
3397| 14800024  | SQLite: The database file is locked. |
3398| 14800025  | SQLite: A table in the database is locked. |
3399| 14800026  | SQLite: The database is out of memory. |
3400| 14800027  | SQLite: Attempt to write a readonly database. |
3401| 14800028  | SQLite: Some kind of disk I/O error occurred. |
3402| 14800029  | SQLite: The database is full. |
3403| 14800030  | SQLite: Unable to open the database file. |
3404| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
3405| 14800032  | SQLite: Abort due to constraint violation. |
3406| 14800033  | SQLite: Data type mismatch. |
3407| 14800034  | SQLite: Library used incorrectly. |
3408| 14800047  | The WAL file size exceeds the default limit. |
3409
3410**Example**
3411
3412```ts
3413let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3414predicates.equalTo("NAME", "Lisa");
3415if(store != undefined) {
3416  (store as relationalStore.RdbStore).delete(predicates, (err, rows) => {
3417    if (err) {
3418      console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
3419      return;
3420    }
3421    console.info(`Delete rows: ${rows}`);
3422  })
3423}
3424```
3425
3426### delete
3427
3428delete(predicates: RdbPredicates):Promise&lt;number&gt;
3429
3430Deletes data from the RDB store based on the specified **RdbPredicates** object. This API uses a promise to return the result.
3431
3432**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3433
3434**Parameters**
3435
3436| Name    | Type                                | Mandatory| Description                                     |
3437| ---------- | ------------------------------------ | ---- | ----------------------------------------- |
3438| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Conditions specified by the **RdbPredicates** object for deleting data.|
3439
3440**Return value**
3441
3442| Type                 | Description                           |
3443| --------------------- | ------------------------------- |
3444| Promise&lt;number&gt; | Promise used to return the number of rows deleted.|
3445
3446**Error codes**
3447
3448For 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).
3449
3450| **ID**| **Error Message**                                                |
3451|-----------| ------------------------------------------------------------ |
3452| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3453| 14800000  | Inner error. |
3454| 14800011  | Database corrupted. |
3455| 14800014  | Already closed. |
3456| 14800015  | The database does not respond. |
3457| 14800021  | SQLite: Generic error. |
3458| 14800022  | SQLite: Callback routine requested an abort. |
3459| 14800023  | SQLite: Access permission denied. |
3460| 14800024  | SQLite: The database file is locked. |
3461| 14800025  | SQLite: A table in the database is locked. |
3462| 14800026  | SQLite: The database is out of memory. |
3463| 14800027  | SQLite: Attempt to write a readonly database. |
3464| 14800028  | SQLite: Some kind of disk I/O error occurred. |
3465| 14800029  | SQLite: The database is full. |
3466| 14800030  | SQLite: Unable to open the database file. |
3467| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
3468| 14800032  | SQLite: Abort due to constraint violation. |
3469| 14800033  | SQLite: Data type mismatch. |
3470| 14800034  | SQLite: Library used incorrectly. |
3471| 14800047  | The WAL file size exceeds the default limit. |
3472
3473**Example**
3474
3475```ts
3476import { BusinessError } from '@kit.BasicServicesKit';
3477
3478let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3479predicates.equalTo("NAME", "Lisa");
3480if(store != undefined) {
3481  (store as relationalStore.RdbStore).delete(predicates).then((rows: Number) => {
3482    console.info(`Delete rows: ${rows}`);
3483  }).catch((err: BusinessError) => {
3484    console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
3485  })
3486}
3487```
3488
3489### deleteSync<sup>12+</sup>
3490
3491deleteSync(predicates: RdbPredicates):number
3492
3493Deletes data from the RDB store based on the specified **RdbPredicates** object.
3494
3495**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3496
3497**Parameters**
3498
3499| Name    | Type                           | Mandatory| Description                                   |
3500| ---------- | ------------------------------- | ---- | --------------------------------------- |
3501| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Conditions specified by the **RdbPredicates** object for deleting data.|
3502
3503**Return value**
3504
3505| Type  | Description              |
3506| ------ | ------------------ |
3507| number | return the number of rows updated.|
3508
3509**Error codes**
3510
3511For 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).
3512
3513| **ID**| **Error Message**                                                |
3514| ------------ | ------------------------------------------------------------ |
3515| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3516| 14800000     | Inner error.                                                 |
3517| 14800011     | Database corrupted.                                          |
3518| 14800014     | Already closed.                                              |
3519| 14800015     | The database does not respond.                                        |
3520| 14800021     | SQLite: Generic error.                                       |
3521| 14800022     | SQLite: Callback routine requested an abort.                 |
3522| 14800023     | SQLite: Access permission denied.                            |
3523| 14800024     | SQLite: The database file is locked.                         |
3524| 14800025     | SQLite: A table in the database is locked.                   |
3525| 14800026     | SQLite: The database is out of memory.                       |
3526| 14800027     | SQLite: Attempt to write a readonly database.                |
3527| 14800028     | SQLite: Some kind of disk I/O error occurred.                |
3528| 14800029     | SQLite: The database is full.                                |
3529| 14800030     | SQLite: Unable to open the database file.                    |
3530| 14800031     | SQLite: TEXT or BLOB exceeds size limit.                     |
3531| 14800032     | SQLite: Abort due to constraint violation.                   |
3532| 14800033     | SQLite: Data type mismatch.                                  |
3533| 14800034     | SQLite: Library used incorrectly.                            |
3534| 14800047     | The WAL file size exceeds the default limit.                 |
3535
3536**Example**
3537
3538```ts
3539import { BusinessError } from '@kit.BasicServicesKit';
3540
3541let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3542predicates.equalTo("NAME", "Lisa");
3543if(store != undefined) {
3544  try {
3545    let rows: Number = (store as relationalStore.RdbStore).deleteSync(predicates)
3546    console.info(`Delete rows: ${rows}`);
3547  } catch (err) {
3548    console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
3549  }
3550}
3551```
3552
3553### query<sup>10+</sup>
3554
3555query(predicates: RdbPredicates, callback: AsyncCallback&lt;ResultSet&gt;):void
3556
3557Queries 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.
3558
3559**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3560
3561**Parameters**
3562
3563| Name    | Type                                                        | Mandatory| Description                                                       |
3564| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
3565| predicates | [RdbPredicates](#rdbpredicates)                         | Yes  | Query conditions specified by the **RdbPredicates** object.                  |
3566| callback   | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes  | Callback used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
3567
3568**Error codes**
3569
3570For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
3571
3572| **ID**| **Error Message**                                                |
3573|-----------| ------------------------------------------------------------ |
3574| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3575| 14800000  | Inner error. |
3576| 14800014  | Already closed. |
3577| 14800015  | The database does not respond. |
3578
3579**Example**
3580
3581```ts
3582let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3583predicates.equalTo("NAME", "Rose");
3584if(store != undefined) {
3585  (store as relationalStore.RdbStore).query(predicates, (err, resultSet) => {
3586    if (err) {
3587      console.error(`Query failed, code is ${err.code},message is ${err.message}`);
3588      return;
3589    }
3590    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3591    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3592    while (resultSet.goToNextRow()) {
3593      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3594      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3595      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3596      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3597      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3598    }
3599    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
3600    resultSet.close();
3601  })
3602}
3603```
3604
3605### query
3606
3607query(predicates: RdbPredicates, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;ResultSet&gt;):void
3608
3609Queries 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.
3610
3611**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3612
3613**Parameters**
3614
3615| Name    | Type                                                        | Mandatory| Description                                                       |
3616| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
3617| predicates | [RdbPredicates](#rdbpredicates)                         | Yes  | Query conditions specified by the **RdbPredicates** object.                  |
3618| columns    | Array&lt;string&gt;                                          | Yes  | Columns to query. If this parameter is not specified, the query applies to all columns.           |
3619| callback   | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes  | Callback used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
3620
3621**Error codes**
3622
3623For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
3624
3625| **ID**| **Error Message**                                                |
3626|-----------| ------------------------------------------------------------ |
3627| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3628| 14800000  | Inner error. |
3629| 14800014  | Already closed. |
3630| 14800015  | The database does not respond. |
3631
3632**Example**
3633
3634```ts
3635let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3636predicates.equalTo("NAME", "Rose");
3637if(store != undefined) {
3638  (store as relationalStore.RdbStore).query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], (err, resultSet) => {
3639    if (err) {
3640      console.error(`Query failed, code is ${err.code},message is ${err.message}`);
3641      return;
3642    }
3643    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3644    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3645    while (resultSet.goToNextRow()) {
3646      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3647      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3648      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3649      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3650      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3651    }
3652    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
3653    resultSet.close();
3654  })
3655}
3656```
3657
3658### query
3659
3660query(predicates: RdbPredicates, columns?: Array&lt;string&gt;):Promise&lt;ResultSet&gt;
3661
3662Queries 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.
3663
3664**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3665
3666**Parameters**
3667
3668| Name    | Type                                | Mandatory| Description                                            |
3669| ---------- | ------------------------------------ | ---- | ------------------------------------------------ |
3670| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Query conditions specified by the **RdbPredicates** object.       |
3671| columns    | Array&lt;string&gt;                  | No  | Columns to query. If this parameter is not specified, the query applies to all columns.|
3672
3673**Error codes**
3674
3675For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
3676
3677| **ID**| **Error Message**                                                |
3678|-----------| ------------------------------------------------------------ |
3679| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3680| 14800000  | Inner error. |
3681| 14800014  | Already closed. |
3682| 14800015  | The database does not respond. |
3683
3684**Return value**
3685
3686| Type                                                   | Description                                              |
3687| ------------------------------------------------------- | -------------------------------------------------- |
3688| Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
3689
3690**Example**
3691
3692```ts
3693import { BusinessError } from '@kit.BasicServicesKit';
3694
3695let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3696predicates.equalTo("NAME", "Rose");
3697if(store != undefined) {
3698  (store as relationalStore.RdbStore).query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet: relationalStore.ResultSet) => {
3699    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3700    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3701    while (resultSet.goToNextRow()) {
3702      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3703      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3704      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3705      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3706      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3707    }
3708    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
3709    resultSet.close();
3710  }).catch((err: BusinessError) => {
3711    console.error(`Query failed, code is ${err.code},message is ${err.message}`);
3712  })
3713}
3714```
3715
3716### querySync<sup>12+</sup>
3717
3718querySync(predicates: RdbPredicates, columns?: Array&lt;string&gt;):ResultSet
3719
3720Queries data in the RDB store based on specified conditions. This API returns the result synchronously. If complex logic and a large number of loops are involved in the operations on the **resultSet** obtained by **querySync()**, the freeze problem may occur. You are advised to perform this operation in the [taskpool](../apis-arkts/js-apis-taskpool.md) thread.
3721
3722**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3723
3724**Parameters**
3725
3726| Name    | Type                           | Mandatory| Description                                                        |
3727| ---------- | ------------------------------- | ---- | ------------------------------------------------------------ |
3728| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Query conditions specified by the **RdbPredicates** object.                     |
3729| columns    | Array&lt;string&gt;             | No  | Columns to query. If this parameter is not specified, the query applies to all columns. The default value is null.|
3730
3731**Error codes**
3732
3733For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
3734
3735| **ID**| **Error Message**                                                |
3736| ------------ | ------------------------------------------------------------ |
3737| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3738| 14800000     | Inner error.                                                 |
3739| 14800014     | Already closed.                                              |
3740| 14800015     | The database does not respond.                                        |
3741
3742**Return value**
3743
3744| Type                   | Description                               |
3745| ----------------------- | ----------------------------------- |
3746| [ResultSet](#resultset) | If the operation is successful, a **ResultSet** object will be returned.|
3747
3748**Example**
3749
3750```ts
3751import { BusinessError } from '@kit.BasicServicesKit';
3752
3753let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
3754predicates.equalTo("NAME", "Rose");
3755if(store != undefined) {
3756  try {
3757    let resultSet: relationalStore.ResultSet = (store as relationalStore.RdbStore).querySync(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]);
3758    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3759    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3760    while (resultSet.goToNextRow()) {
3761      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3762      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3763      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3764      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3765      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3766    }
3767    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
3768    resultSet.close();
3769  } catch (err) {
3770    console.error(`Query failed, code is ${err.code},message is ${err.message}`);
3771  }
3772}
3773```
3774
3775### remoteQuery
3776
3777remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array&lt;string&gt; , callback: AsyncCallback&lt;ResultSet&gt;): void
3778
3779Queries data from the RDB store of a remote device based on specified conditions. This API uses an asynchronous callback to return the result.
3780
3781> **NOTE**
3782>
3783> **device** can be obtained by [deviceManager.getAvailableDeviceListSync](../apis-distributedservice-kit/js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
3784
3785**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3786
3787**Parameters**
3788
3789| Name    | Type                                        | Mandatory| Description                                                     |
3790| ---------- | -------------------------------------------- | ---- | --------------------------------------------------------- |
3791| device     | string                                       | Yes  | ID of the remote device.                                       |
3792| table      | string                                       | Yes  | Name of the target table.                                         |
3793| predicates | [RdbPredicates](#rdbpredicates)              | Yes  | Query conditions specified by the **RdbPredicates** object.                |
3794| columns    | Array&lt;string&gt;                          | Yes  | Columns to query. If this parameter is not specified, the query applies to all columns.         |
3795| callback   | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes  | Callback used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
3796
3797**Error codes**
3798
3799For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
3800
3801| **ID**| **Error Message**                                                |
3802|-----------| ------------------------------------------------------------ |
3803| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3804| 801       | Capability not supported. |
3805| 14800000  | Inner error. |
3806| 14800014  | Already closed. |
3807
3808**Example**
3809
3810```ts
3811import { distributedDeviceManager } from '@kit.DistributedServiceKit';
3812import { BusinessError } from '@kit.BasicServicesKit';
3813
3814let dmInstance: distributedDeviceManager.DeviceManager;
3815let deviceId: string | undefined = undefined;
3816
3817try {
3818  dmInstance = distributedDeviceManager.createDeviceManager("com.example.appdatamgrverify");
3819  let devices = dmInstance.getAvailableDeviceListSync();
3820  if(deviceId != undefined) {
3821    deviceId = devices[0].networkId;
3822  }
3823} catch (err) {
3824  let code = (err as BusinessError).code;
3825  let message = (err as BusinessError).message;
3826  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
3827}
3828
3829let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
3830predicates.greaterThan("id", 0);
3831if(store != undefined && deviceId != undefined) {
3832  (store as relationalStore.RdbStore).remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet: relationalStore.ResultSet) => {
3833    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3834    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3835    while (resultSet.goToNextRow()) {
3836      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3837      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3838      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3839      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3840      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3841    }
3842    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
3843    resultSet.close();
3844  }).catch((err: BusinessError) => {
3845    console.error(`Failed to remoteQuery, code is ${err.code},message is ${err.message}`);
3846  })
3847}
3848```
3849
3850### remoteQuery
3851
3852remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array&lt;string&gt;): Promise&lt;ResultSet&gt;
3853
3854Queries data from the RDB store of a remote device based on specified conditions. This API uses a promise to return the result.
3855
3856> **NOTE**
3857>
3858> **device** can be obtained by [deviceManager.getAvailableDeviceListSync](../apis-distributedservice-kit/js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
3859
3860**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3861
3862**Parameters**
3863
3864| Name    | Type                                | Mandatory| Description                                            |
3865| ---------- | ------------------------------------ | ---- | ------------------------------------------------ |
3866| device     | string                               | Yes  | ID of the remote device.                  |
3867| table      | string                               | Yes  | Name of the target table.                                |
3868| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Query conditions specified by the **RdbPredicates** object.     |
3869| columns    | Array&lt;string&gt;                  | Yes  | Columns to query. If this parameter is not specified, the query applies to all columns.|
3870
3871**Return value**
3872
3873| Type                                                        | Description                                              |
3874| ------------------------------------------------------------ | -------------------------------------------------- |
3875| Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
3876
3877**Error codes**
3878
3879For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
3880
3881| **ID**| **Error Message**                                                |
3882|-----------| ------------------------------------------------------------ |
3883| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3884| 801       | Capability not supported. |
3885| 14800000  | Inner error. |
3886| 14800014  | Already closed. |
3887
3888**Example**
3889
3890```ts
3891import { distributedDeviceManager } from '@kit.DistributedServiceKit';
3892import { BusinessError } from '@kit.BasicServicesKit';
3893
3894let dmInstance: distributedDeviceManager.DeviceManager;
3895let deviceId: string | undefined = undefined;
3896
3897try {
3898  dmInstance = distributedDeviceManager.createDeviceManager("com.example.appdatamgrverify");
3899  let devices: Array<distributedDeviceManager.DeviceBasicInfo> = dmInstance.getAvailableDeviceListSync();
3900  if(devices != undefined) {
3901    deviceId = devices[0].networkId;
3902  }
3903} catch (err) {
3904  let code = (err as BusinessError).code;
3905  let message = (err as BusinessError).message;
3906  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
3907}
3908
3909let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
3910predicates.greaterThan("id", 0);
3911if(store != undefined && deviceId != undefined) {
3912  (store as relationalStore.RdbStore).remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet: relationalStore.ResultSet) => {
3913    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3914    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3915    while (resultSet.goToNextRow()) {
3916      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3917      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3918      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3919      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3920      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3921    }
3922    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
3923    resultSet.close();
3924  }).catch((err: BusinessError) => {
3925    console.error(`Failed to remoteQuery, code is ${err.code},message is ${err.message}`);
3926  })
3927}
3928```
3929
3930### querySql<sup>10+</sup>
3931
3932querySql(sql: string, callback: AsyncCallback&lt;ResultSet&gt;):void
3933
3934Queries data in the RDB store using the specified SQL statement. The number of relational operators between expressions and operators in the SQL statement cannot exceed 1000. This API uses an asynchronous callback to return the result.
3935
3936**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3937
3938**Parameters**
3939
3940| Name  | Type                                        | Mandatory| Description                                   |
3941| -------- | -------------------------------------------- | ---- |---------------------------------------|
3942| sql      | string                                       | Yes  | SQL statement to run.                         |
3943| callback | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes  | Callback used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
3944
3945**Error codes**
3946
3947For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
3948
3949| **ID**| **Error Message**                                                |
3950|-----------| ------------------------------------------------------------ |
3951| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
3952| 14800000  | Inner error. |
3953| 14800014  | Already closed. |
3954| 14800015  | The database does not respond. |
3955
3956**Example**
3957
3958```ts
3959if(store != undefined) {
3960  (store as relationalStore.RdbStore).querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = 'sanguo'", (err, resultSet) => {
3961    if (err) {
3962      console.error(`Query failed, code is ${err.code},message is ${err.message}`);
3963      return;
3964    }
3965    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3966    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3967    while (resultSet.goToNextRow()) {
3968      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3969      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3970      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3971      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3972      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3973    }
3974    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
3975    resultSet.close();
3976  })
3977}
3978```
3979
3980### querySql
3981
3982querySql(sql: string, bindArgs: Array&lt;ValueType&gt;, callback: AsyncCallback&lt;ResultSet&gt;):void
3983
3984Queries data in the RDB store using the specified SQL statement. The number of relational operators between expressions and operators in the SQL statement cannot exceed 1000. This API uses an asynchronous callback to return the result.
3985
3986**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3987
3988**Parameters**
3989
3990| Name  | Type                                        | Mandatory| Description                                                        |
3991| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
3992| sql      | string                                       | Yes  | SQL statement to run.                                       |
3993| 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.|
3994| callback | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes  | Callback used to return the result. If the operation is successful, a **ResultSet** object will be returned.   |
3995
3996**Error codes**
3997
3998For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
3999
4000| **ID**| **Error Message**                                                |
4001|-----------| ------------------------------------------------------------ |
4002| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4003| 14800000  | Inner error. |
4004| 14800014  | Already closed. |
4005| 14800015  | The database does not respond. |
4006
4007**Example**
4008
4009```ts
4010if(store != undefined) {
4011  (store as relationalStore.RdbStore).querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'], (err, resultSet) => {
4012    if (err) {
4013      console.error(`Query failed, code is ${err.code},message is ${err.message}`);
4014      return;
4015    }
4016    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
4017    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
4018    while (resultSet.goToNextRow()) {
4019      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
4020      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
4021      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
4022      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
4023      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
4024    }
4025    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
4026    resultSet.close();
4027  })
4028}
4029```
4030
4031### querySql
4032
4033querySql(sql: string, bindArgs?: Array&lt;ValueType&gt;):Promise&lt;ResultSet&gt;
4034
4035Queries data in the RDB store using the specified SQL statement. The number of relational operators between expressions and operators in the SQL statement cannot exceed 1000. This API uses a promise to return the result.
4036
4037**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4038
4039**Parameters**
4040
4041| Name  | Type                                | Mandatory| Description                                                        |
4042| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
4043| sql      | string                               | Yes  | SQL statement to run.                                       |
4044| 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.|
4045
4046**Return value**
4047
4048| Type                                                   | Description                                              |
4049| ------------------------------------------------------- | -------------------------------------------------- |
4050| Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
4051
4052**Error codes**
4053
4054For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
4055
4056| **ID**| **Error Message**                                                |
4057|-----------| ------------------------------------------------------------ |
4058| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4059| 14800000  | Inner error. |
4060| 14800014  | Already closed. |
4061| 14800015  | The database does not respond. |
4062
4063**Example**
4064
4065```ts
4066import { BusinessError } from '@kit.BasicServicesKit';
4067
4068if(store != undefined) {
4069  (store as relationalStore.RdbStore).querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = 'sanguo'").then((resultSet: relationalStore.ResultSet) => {
4070    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
4071    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
4072    while (resultSet.goToNextRow()) {
4073      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
4074      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
4075      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
4076      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
4077      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
4078    }
4079    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
4080    resultSet.close();
4081  }).catch((err: BusinessError) => {
4082    console.error(`Query failed, code is ${err.code},message is ${err.message}`);
4083  })
4084}
4085```
4086
4087### querySqlSync<sup>12+</sup>
4088
4089querySqlSync(sql: string, bindArgs?: Array&lt;ValueType&gt;):ResultSet
4090
4091Queries data in the RDB store using the specified SQL statement. The number of relational operators between expressions and operators in the SQL statement cannot exceed 1000. If complex logic and a large number of loops are involved in the operations on the **resultSet** obtained by **querySync()**, the freeze problem may occur. You are advised to perform this operation in the [taskpool](../apis-arkts/js-apis-taskpool.md) thread.
4092
4093**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4094
4095**Parameters**
4096
4097| Name  | Type                                | Mandatory| Description                                                        |
4098| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
4099| sql      | string                               | Yes  | SQL statement to run.                                       |
4100| 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. The default value is null.|
4101
4102**Return value**
4103
4104| Type                   | Description                               |
4105| ----------------------- | ----------------------------------- |
4106| [ResultSet](#resultset) | If the operation is successful, a **ResultSet** object will be returned.|
4107
4108**Error codes**
4109
4110For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
4111
4112| **ID**| **Error Message**                                                |
4113| ------------ | ------------------------------------------------------------ |
4114| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4115| 14800000     | Inner error.                                                 |
4116| 14800014     | Already closed.                                              |
4117| 14800015     | The database does not respond.                                        |
4118
4119**Example**
4120
4121```ts
4122import { BusinessError } from '@kit.BasicServicesKit';
4123
4124if(store != undefined) {
4125  try {
4126    let resultSet: relationalStore.ResultSet = (store as relationalStore.RdbStore).querySqlSync("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = 'sanguo'");
4127    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
4128    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
4129    while (resultSet.goToNextRow()) {
4130      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
4131      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
4132      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
4133      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
4134      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
4135    }
4136    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
4137    resultSet.close();
4138  } catch (err) {
4139    console.error(`Query failed, code is ${err.code},message is ${err.message}`);
4140  }
4141}
4142```
4143
4144### executeSql<sup>10+</sup>
4145
4146executeSql(sql: string, callback: AsyncCallback&lt;void&gt;):void
4147
4148Executes an SQL statement that contains specified arguments but returns no value. The number of relational operators between expressions and operators in the statement cannot exceed 1000. This API uses an asynchronous callback to return the result.
4149
4150This 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).
4151
4152Statements separated by semicolons (\;) are not supported.
4153
4154**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4155
4156**Parameters**
4157
4158| Name  | Type                                | Mandatory| Description                                                        |
4159| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
4160| sql      | string                               | Yes  | SQL statement to run.                                       |
4161| callback | AsyncCallback&lt;void&gt;            | Yes  | Callback used to return the result.                                      |
4162
4163**Error codes**
4164
4165For 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).
4166
4167| **ID**| **Error Message**                                                |
4168|-----------| ------------------------------------------------------------ |
4169| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4170| 801       | Capability not supported the sql(attach,begin,commit,rollback etc.). |
4171| 14800000  | Inner error. |
4172| 14800011  | Database corrupted. |
4173| 14800014  | Already closed. |
4174| 14800015  | The database does not respond. |
4175| 14800021  | SQLite: Generic error. |
4176| 14800022  | SQLite: Callback routine requested an abort. |
4177| 14800023  | SQLite: Access permission denied. |
4178| 14800024  | SQLite: The database file is locked. |
4179| 14800025  | SQLite: A table in the database is locked. |
4180| 14800026  | SQLite: The database is out of memory. |
4181| 14800027  | SQLite: Attempt to write a readonly database. |
4182| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4183| 14800029  | SQLite: The database is full. |
4184| 14800030  | SQLite: Unable to open the database file. |
4185| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4186| 14800032  | SQLite: Abort due to constraint violation. |
4187| 14800033  | SQLite: Data type mismatch. |
4188| 14800034  | SQLite: Library used incorrectly. |
4189| 14800047  | The WAL file size exceeds the default limit. |
4190
4191**Example**
4192
4193```ts
4194const SQL_DELETE_TABLE = "DELETE FROM test WHERE name = 'zhangsan'"
4195if(store != undefined) {
4196  (store as relationalStore.RdbStore).executeSql(SQL_DELETE_TABLE, (err) => {
4197    if (err) {
4198      console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`);
4199      return;
4200    }
4201    console.info('Delete table done.');
4202  })
4203}
4204```
4205
4206### executeSql
4207
4208executeSql(sql: string, bindArgs: Array&lt;ValueType&gt;, callback: AsyncCallback&lt;void&gt;):void
4209
4210Executes an SQL statement that contains specified arguments but returns no value. The number of relational operators between expressions and operators in the statement cannot exceed 1000. This API uses an asynchronous callback to return the result.
4211
4212This 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).
4213
4214Statements separated by semicolons (\;) are not supported.
4215
4216**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4217
4218**Parameters**
4219
4220| Name  | Type                                | Mandatory| Description                                                        |
4221| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
4222| sql      | string                               | Yes  | SQL statement to run.                                       |
4223| 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.|
4224| callback | AsyncCallback&lt;void&gt;            | Yes  | Callback used to return the result.                                      |
4225
4226**Error codes**
4227
4228For 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).
4229
4230| **ID**| **Error Message**                                                |
4231|-----------| ------------------------------------------------------------ |
4232| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4233| 801       | Capability not supported the sql(attach,begin,commit,rollback etc.). |
4234| 14800000  | Inner error. |
4235| 14800011  | Database corrupted. |
4236| 14800014  | Already closed. |
4237| 14800015  | The database does not respond. |
4238| 14800021  | SQLite: Generic error. |
4239| 14800022  | SQLite: Callback routine requested an abort. |
4240| 14800023  | SQLite: Access permission denied. |
4241| 14800024  | SQLite: The database file is locked. |
4242| 14800025  | SQLite: A table in the database is locked. |
4243| 14800026  | SQLite: The database is out of memory. |
4244| 14800027  | SQLite: Attempt to write a readonly database. |
4245| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4246| 14800029  | SQLite: The database is full. |
4247| 14800030  | SQLite: Unable to open the database file. |
4248| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4249| 14800032  | SQLite: Abort due to constraint violation. |
4250| 14800033  | SQLite: Data type mismatch. |
4251| 14800034  | SQLite: Library used incorrectly. |
4252| 14800047  | The WAL file size exceeds the default limit. |
4253
4254**Example**
4255
4256```ts
4257const SQL_DELETE_TABLE = "DELETE FROM test WHERE name = ?"
4258if(store != undefined) {
4259  (store as relationalStore.RdbStore).executeSql(SQL_DELETE_TABLE, ['zhangsan'], (err) => {
4260    if (err) {
4261      console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`);
4262      return;
4263    }
4264    console.info('Delete table done.');
4265  })
4266}
4267```
4268
4269### executeSql
4270
4271executeSql(sql: string, bindArgs?: Array&lt;ValueType&gt;):Promise&lt;void&gt;
4272
4273Executes an SQL statement that contains specified arguments but returns no value. The number of relational operators between expressions and operators in the statement cannot exceed 1000. This API uses a promise to return the result.
4274
4275This 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).
4276
4277Statements separated by semicolons (\;) are not supported.
4278
4279**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4280
4281**Parameters**
4282
4283| Name  | Type                                | Mandatory| Description                                                        |
4284| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
4285| sql      | string                               | Yes  | SQL statement to run.                                       |
4286| 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.|
4287
4288**Return value**
4289
4290| Type               | Description                     |
4291| ------------------- | ------------------------- |
4292| Promise&lt;void&gt; | Promise that returns no value.|
4293
4294**Error codes**
4295
4296For 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).
4297
4298| **ID**| **Error Message**                                                |
4299|-----------| ------------------------------------------------------------ |
4300| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4301| 801       | Capability not supported the sql(attach,begin,commit,rollback etc.). |
4302| 14800000  | Inner error. |
4303| 14800011  | Database corrupted. |
4304| 14800014  | Already closed. |
4305| 14800015  | The database does not respond. |
4306| 14800021  | SQLite: Generic error. |
4307| 14800022  | SQLite: Callback routine requested an abort. |
4308| 14800023  | SQLite: Access permission denied. |
4309| 14800024  | SQLite: The database file is locked. |
4310| 14800025  | SQLite: A table in the database is locked. |
4311| 14800026  | SQLite: The database is out of memory. |
4312| 14800027  | SQLite: Attempt to write a readonly database. |
4313| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4314| 14800029  | SQLite: The database is full. |
4315| 14800030  | SQLite: Unable to open the database file. |
4316| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4317| 14800032  | SQLite: Abort due to constraint violation. |
4318| 14800033  | SQLite: Data type mismatch. |
4319| 14800034  | SQLite: Library used incorrectly. |
4320| 14800047  | The WAL file size exceeds the default limit. |
4321
4322**Example**
4323
4324```ts
4325import { BusinessError } from '@kit.BasicServicesKit';
4326
4327const SQL_DELETE_TABLE = "DELETE FROM test WHERE name = 'zhangsan'"
4328if(store != undefined) {
4329  (store as relationalStore.RdbStore).executeSql(SQL_DELETE_TABLE).then(() => {
4330    console.info('Delete table done.');
4331  }).catch((err: BusinessError) => {
4332    console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`);
4333  })
4334}
4335```
4336
4337### execute<sup>12+</sup>
4338
4339execute(sql: string, args?: Array&lt;ValueType&gt;):Promise&lt;ValueType&gt;
4340
4341Executes an SQL statement that contains specified arguments. The number of relational operators between expressions and operators in the statement cannot exceed 1000. This API uses a promise to return a value of the ValueType type.
4342
4343This 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.
4344
4345This 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).
4346
4347Statements separated by semicolons (\;) are not supported.
4348
4349**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4350
4351**Parameters**
4352
4353| Name  | Type                                | Mandatory| Description                                                        |
4354| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
4355| sql      | string                               | Yes  | SQL statement to run.                                       |
4356| 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.|
4357
4358**Return value**
4359
4360| Type               | Description                     |
4361| ------------------- | ------------------------- |
4362| Promise&lt;[ValueType](#valuetype)&gt; | Promise used to return the SQL execution result.|
4363
4364**Error codes**
4365
4366For 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).
4367
4368| **ID**| **Error Message**                                                |
4369|-----------| ------------------------------------------------------------ |
4370| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4371| 801       | Capability not supported the sql(attach,begin,commit,rollback etc.). |
4372| 14800000  | Inner error. |
4373| 14800011  | Database corrupted. |
4374| 14800014  | Already closed. |
4375| 14800015  | The database does not respond. |
4376| 14800021  | SQLite: Generic error. |
4377| 14800022  | SQLite: Callback routine requested an abort. |
4378| 14800023  | SQLite: Access permission denied. |
4379| 14800024  | SQLite: The database file is locked. |
4380| 14800025  | SQLite: A table in the database is locked. |
4381| 14800026  | SQLite: The database is out of memory. |
4382| 14800027  | SQLite: Attempt to write a readonly database. |
4383| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4384| 14800029  | SQLite: The database is full. |
4385| 14800030  | SQLite: Unable to open the database file. |
4386| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4387| 14800032  | SQLite: Abort due to constraint violation. |
4388| 14800033  | SQLite: Data type mismatch. |
4389| 14800034  | SQLite: Library used incorrectly. |
4390| 14800047  | The WAL file size exceeds the default limit. |
4391
4392**Example**
4393
4394```ts
4395import { BusinessError } from '@kit.BasicServicesKit';
4396
4397// Check the RDB store integrity.
4398if(store != undefined) {
4399  const SQL_CHECK_INTEGRITY = 'PRAGMA integrity_check';
4400  (store as relationalStore.RdbStore).execute(SQL_CHECK_INTEGRITY).then((data) => {
4401    console.info(`check result: ${data}`);
4402  }).catch((err: BusinessError) => {
4403    console.error(`check failed, code is ${err.code}, message is ${err.message}`);
4404  })
4405}
4406
4407// Delete all data from the table.
4408if(store != undefined) {
4409  const SQL_DELETE_TABLE = 'DELETE FROM test';
4410  (store as relationalStore.RdbStore).execute(SQL_DELETE_TABLE).then((data) => {
4411    console.info(`delete result: ${data}`);
4412  }).catch((err: BusinessError) => {
4413    console.error(`delete failed, code is ${err.code}, message is ${err.message}`);
4414  })
4415}
4416
4417// Delete a table.
4418if(store != undefined) {
4419  const SQL_DROP_TABLE = 'DROP TABLE test';
4420  (store as relationalStore.RdbStore).execute(SQL_DROP_TABLE).then((data) => {
4421    console.info(`drop result: ${data}`);
4422  }).catch((err: BusinessError) => {
4423    console.error(`drop failed, code is ${err.code}, message is ${err.message}`);
4424  })
4425}
4426```
4427
4428### execute<sup>12+</sup>
4429
4430execute(sql: string, txId: number, args?: Array&lt;ValueType&gt;): Promise&lt;ValueType&gt;
4431
4432Executes an SQL statement that contains specified arguments. The number of relational operators between expressions and operators in the statement cannot exceed 1000. This API uses a promise to return the result.
4433
4434<!--RP1-->
4435This API is available only for a [vector database](js-apis-data-relationalStore-sys.md#storeconfig).<!--RP1End-->
4436
4437This 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).
4438
4439Statements separated by semicolons (\;) are not supported.
4440
4441**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4442
4443**Parameters**
4444
4445| Name  | Type                                | Mandatory| Description                                                        |
4446| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
4447| sql      | string                               | Yes  | SQL statement to run.                                       |
4448| 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.                                     |
4449| 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.|
4450
4451**Return value**
4452
4453| Type               | Description                     |
4454| ------------------- | ------------------------- |
4455| Promise&lt;[ValueType](#valuetype)&gt; | Promise that returns **null**.|
4456
4457**Error codes**
4458
4459For 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).
4460
4461| **ID**| **Error Message**                                                |
4462|-----------| ------------------------------------------------------------ |
4463| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4464| 801       | Capability not supported the sql(attach,begin,commit,rollback etc.). |
4465| 14800000  | Inner error. |
4466| 14800011  | Database corrupted. |
4467| 14800014  | Already closed. |
4468| 14800015  | The database does not respond. |
4469| 14800021  | SQLite: Generic error. |
4470| 14800022  | SQLite: Callback routine requested an abort. |
4471| 14800023  | SQLite: Access permission denied. |
4472| 14800024  | SQLite: The database file is locked. |
4473| 14800025  | SQLite: A table in the database is locked. |
4474| 14800026  | SQLite: The database is out of memory. |
4475| 14800027  | SQLite: Attempt to write a readonly database. |
4476| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4477| 14800029  | SQLite: The database is full. |
4478| 14800030  | SQLite: Unable to open the database file. |
4479| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4480| 14800032  | SQLite: Abort due to constraint violation. |
4481| 14800033  | SQLite: Data type mismatch. |
4482| 14800034  | SQLite: Library used incorrectly. |
4483| 14800047  | The WAL file size exceeds the default limit. |
4484
4485**Example**
4486
4487```ts
4488import { BusinessError } from '@kit.BasicServicesKit';
4489if(store != null) {
4490  let txId : number;
4491  (store as relationalStore.RdbStore).beginTrans().then((txId : number) => {
4492    (store as relationalStore.RdbStore).execute("DELETE FROM TEST WHERE age = ? OR age = ?", txId, ["18", "20"])
4493      .then(() => {
4494        (store as relationalStore.RdbStore).commit(txId);
4495    })
4496    .catch((err: BusinessError) => {
4497      (store as relationalStore.RdbStore).rollback(txId)
4498      console.error(`execute sql failed, code is ${err.code},message is ${err.message}`);
4499    });
4500  });
4501}
4502```
4503
4504### executeSync<sup>12+</sup>
4505
4506executeSync(sql: string, args?: Array&lt;ValueType&gt;): ValueType
4507
4508Executes an SQL statement that contains specified arguments. The number of relational operators between expressions and operators in the statement cannot exceed 1000. This API returns a value of the ValueType type.
4509
4510This 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.
4511
4512This 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).
4513
4514Statements separated by semicolons (\;) are not supported.
4515
4516**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4517
4518**Parameters**
4519
4520| Name| Type                                | Mandatory| Description                                                        |
4521| ------ | ------------------------------------ | ---- | ------------------------------------------------------------ |
4522| sql    | string                               | Yes  | SQL statement to run.                                       |
4523| 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. The default value is null.|
4524
4525**Return value**
4526
4527| Type                   | Description               |
4528| ----------------------- | ------------------- |
4529| [ValueType](#valuetype) | SQL execution result.|
4530
4531**Error codes**
4532
4533For 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).
4534
4535| **ID**| **Error Message**                                                |
4536| ------------ | ------------------------------------------------------------ |
4537| 401          | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4538| 14800000     | Inner error.                                                 |
4539| 14800011     | Database corrupted.                                          |
4540| 14800014     | Already closed.                                              |
4541| 14800015     | The database does not respond.                               |
4542| 14800021     | SQLite: Generic error.                                       |
4543| 14800022     | SQLite: Callback routine requested an abort.                 |
4544| 14800023     | SQLite: Access permission denied.                            |
4545| 14800024     | SQLite: The database file is locked.                         |
4546| 14800025     | SQLite: A table in the database is locked.                   |
4547| 14800026     | SQLite: The database is out of memory.                       |
4548| 14800027     | SQLite: Attempt to write a readonly database.                |
4549| 14800028     | SQLite: Some kind of disk I/O error occurred.                |
4550| 14800029     | SQLite: The database is full.                                |
4551| 14800030     | SQLite: Unable to open the database file.                    |
4552| 14800031     | SQLite: TEXT or BLOB exceeds size limit.                     |
4553| 14800032     | SQLite: Abort due to constraint violation.                   |
4554| 14800033     | SQLite: Data type mismatch.                                  |
4555| 14800034     | SQLite: Library used incorrectly.                            |
4556| 14800047     | The WAL file size exceeds the default limit.                 |
4557
4558**Example**
4559
4560```ts
4561import { BusinessError } from '@kit.BasicServicesKit';
4562
4563// Check the RDB store integrity.
4564if(store != undefined) {
4565  const SQL_CHECK_INTEGRITY = 'PRAGMA integrity_check';
4566  try {
4567    let data = (store as relationalStore.RdbStore).executeSync(SQL_CHECK_INTEGRITY)
4568    console.info(`check result: ${data}`);
4569  } catch (err) {
4570    console.error(`check failed, code is ${err.code}, message is ${err.message}`);
4571  }
4572}
4573
4574// Delete all data from the table.
4575if(store != undefined) {
4576  const SQL_DELETE_TABLE = 'DELETE FROM test';
4577  try {
4578    let data = (store as relationalStore.RdbStore).executeSync(SQL_DELETE_TABLE)
4579    console.info(`delete result: ${data}`);
4580  } catch (err) {
4581    console.error(`delete failed, code is ${err.code}, message is ${err.message}`);
4582  }
4583}
4584
4585// Delete a table.
4586if(store != undefined) {
4587  const SQL_DROP_TABLE = 'DROP TABLE test';
4588  try {
4589    let data = (store as relationalStore.RdbStore).executeSync(SQL_DROP_TABLE)
4590    console.info(`drop result: ${data}`);
4591  } catch (err) {
4592    console.error(`drop failed, code is ${err.code}, message is ${err.message}`);
4593  }
4594}
4595```
4596
4597### getModifyTime<sup>10+</sup>
4598
4599getModifyTime(table: string, columnName: string, primaryKeys: PRIKeyType[], callback: AsyncCallback&lt;ModifyTime&gt;): void
4600
4601Obtains the last modification time of the data in a table. This API uses an asynchronous callback to return the result.
4602
4603**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4604
4605**Parameters**
4606
4607| Name     | Type                                            | Mandatory| Description                                                        |
4608| ----------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ |
4609| table       | string                                           | Yes  | Name of the database table to query.                                |
4610| columnName  | string                                           | Yes  | Column name of the database table to query.                                |
4611| 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.|
4612| callback    | AsyncCallback&lt;[ModifyTime](#modifytime10)&gt; | Yes  | Callback used to return the result. If the operation is successful, the **ModifyTime** object is returned.|
4613
4614**Error codes**
4615
4616For 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).
4617
4618| **ID**| **Error Message**                                                |
4619|-----------| ------------------------------------------------------------ |
4620| 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. |
4621| 801       | Capability not supported. |
4622| 14800000  | Inner error. |
4623| 14800011  | Database corrupted. |
4624| 14800014  | Already closed. |
4625| 14800015  | The database does not respond. |
4626| 14800021  | SQLite: Generic error. |
4627| 14800022  | SQLite: Callback routine requested an abort. |
4628| 14800023  | SQLite: Access permission denied. |
4629| 14800024  | SQLite: The database file is locked. |
4630| 14800025  | SQLite: A table in the database is locked. |
4631| 14800026  | SQLite: The database is out of memory. |
4632| 14800027  | SQLite: Attempt to write a readonly database. |
4633| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4634| 14800029  | SQLite: The database is full. |
4635| 14800030  | SQLite: Unable to open the database file. |
4636| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4637| 14800032  | SQLite: Abort due to constraint violation. |
4638| 14800033  | SQLite: Data type mismatch. |
4639| 14800034  | SQLite: Library used incorrectly. |
4640
4641**Example**
4642
4643```ts
4644let PRIKey = [1, 4, 2, 3];
4645if(store != undefined) {
4646  (store as relationalStore.RdbStore).getModifyTime("EMPLOYEE", "NAME", PRIKey, (err, modifyTime: relationalStore.ModifyTime) => {
4647    if (err) {
4648      console.error(`getModifyTime failed, code is ${err.code},message is ${err.message}`);
4649      return;
4650    }
4651    let size = modifyTime.size;
4652  });
4653}
4654```
4655
4656### getModifyTime<sup>10+</sup>
4657
4658getModifyTime(table: string, columnName: string, primaryKeys: PRIKeyType[]): Promise&lt;ModifyTime&gt;
4659
4660Obtains the last modification time of the data in a table. This API uses a promise to return the result.
4661
4662**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4663
4664**Parameters**
4665
4666| Name     | Type                         | Mandatory| Description                                                        |
4667| ----------- | ----------------------------- | ---- | ------------------------------------------------------------ |
4668| table       | string                        | Yes  | Name of the database table to query.                                |
4669| columnName  | string                        | Yes  | Column name of the database table to query.                                |
4670| 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.|
4671
4672**Return value**
4673
4674| Type                                      | Description                                                     |
4675| ------------------------------------------ | --------------------------------------------------------- |
4676| Promise&lt;[ModifyTime](#modifytime10)&gt; | Promise used to return the **ModifyTime** object.|
4677
4678**Error codes**
4679
4680For 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).
4681
4682| **ID**| **Error Message**                                                |
4683|-----------| ------------------------------------------------------------ |
4684| 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. |
4685| 801       | Capability not supported. |
4686| 14800000  | Inner error. |
4687| 14800011  | Database corrupted. |
4688| 14800014  | Already closed. |
4689| 14800015  | The database does not respond. |
4690| 14800021  | SQLite: Generic error. |
4691| 14800022  | SQLite: Callback routine requested an abort. |
4692| 14800023  | SQLite: Access permission denied. |
4693| 14800024  | SQLite: The database file is locked. |
4694| 14800025  | SQLite: A table in the database is locked. |
4695| 14800026  | SQLite: The database is out of memory. |
4696| 14800027  | SQLite: Attempt to write a readonly database. |
4697| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4698| 14800029  | SQLite: The database is full. |
4699| 14800030  | SQLite: Unable to open the database file. |
4700| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4701| 14800032  | SQLite: Abort due to constraint violation. |
4702| 14800033  | SQLite: Data type mismatch. |
4703| 14800034  | SQLite: Library used incorrectly. |
4704
4705**Example**
4706
4707```ts
4708import { BusinessError } from '@kit.BasicServicesKit';
4709
4710let PRIKey = [1, 2, 3];
4711if(store != undefined) {
4712  (store as relationalStore.RdbStore).getModifyTime("EMPLOYEE", "NAME", PRIKey)
4713    .then((modifyTime: relationalStore.ModifyTime) => {
4714      let size = modifyTime.size;
4715    })
4716    .catch((err: BusinessError) => {
4717      console.error(`getModifyTime failed, code is ${err.code},message is ${err.message}`);
4718    });
4719}
4720```
4721
4722### beginTransaction
4723
4724beginTransaction():void
4725
4726Begins a transaction before executing an SQL statement.
4727This API does not allow nested transactions and cannot be used across processes or threads.
4728
4729**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4730
4731**Error codes**
4732
4733For 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).
4734
4735| **ID**| **Error Message**                                                |
4736|-----------| ------------------------------------------------------------ |
4737| 401       | Parameter error. The store must not be nullptr. |
4738| 14800000  | Inner error. |
4739| 14800011  | Database corrupted. |
4740| 14800014  | Already closed. |
4741| 14800015  | The database does not respond. |
4742| 14800021  | SQLite: Generic error. |
4743| 14800022  | SQLite: Callback routine requested an abort. |
4744| 14800023  | SQLite: Access permission denied. |
4745| 14800024  | SQLite: The database file is locked. |
4746| 14800025  | SQLite: A table in the database is locked. |
4747| 14800026  | SQLite: The database is out of memory. |
4748| 14800027  | SQLite: Attempt to write a readonly database. |
4749| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4750| 14800029  | SQLite: The database is full. |
4751| 14800030  | SQLite: Unable to open the database file. |
4752| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4753| 14800032  | SQLite: Abort due to constraint violation. |
4754| 14800033  | SQLite: Data type mismatch. |
4755| 14800034  | SQLite: Library used incorrectly. |
4756| 14800047  | The WAL file size exceeds the default limit. |
4757
4758**Example**
4759
4760```ts
4761
4762let value1 = "Lisa";
4763let value2 = 18;
4764let value3 = 100.5;
4765let value4 = new Uint8Array([1, 2, 3]);
4766
4767if(store != undefined) {
4768  (store as relationalStore.RdbStore).beginTransaction();
4769  const valueBucket: relationalStore.ValuesBucket = {
4770    'NAME': value1,
4771    'AGE': value2,
4772    'SALARY': value3,
4773    'CODES': value4,
4774  };
4775  (store as relationalStore.RdbStore).insert("test", valueBucket);
4776  (store as relationalStore.RdbStore).commit();
4777}
4778```
4779
4780### beginTrans<sup>12+</sup>
4781
4782beginTrans(): Promise&lt;number&gt;
4783
4784Begins a transaction before executing the SQL statement. This API uses a promise to return the result.
4785
4786Different from [beginTransaction](#begintransaction), this API returns a transaction ID. [execute](#execute12-1) can specify the transaction ID to isolate different transactions.
4787
4788<!--RP1-->
4789This API is available only for a [vector database](js-apis-data-relationalStore-sys.md#storeconfig).<!--RP1End-->
4790
4791**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4792
4793**Return value**
4794
4795| Type               | Description                     |
4796| ------------------- | ------------------------- |
4797| Promise&lt;number&gt; | Promise used to return the transaction ID.|
4798
4799**Error codes**
4800
4801For 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).
4802
4803| **ID**| **Error Message**                                                |
4804|-----------| ------------------------------------------------------------ |
4805| 401       | Parameter error. The store must not be nullptr. |
4806| 801       | Capability not supported the sql(attach,begin,commit,rollback etc.). |
4807| 14800000  | Inner error. |
4808| 14800011  | Database corrupted. |
4809| 14800014  | Already closed. |
4810| 14800015  | The database does not respond. |
4811| 14800021  | SQLite: Generic error. |
4812| 14800022  | SQLite: Callback routine requested an abort. |
4813| 14800023  | SQLite: Access permission denied. |
4814| 14800024  | SQLite: The database file is locked. |
4815| 14800025  | SQLite: A table in the database is locked. |
4816| 14800026  | SQLite: The database is out of memory. |
4817| 14800027  | SQLite: Attempt to write a readonly database. |
4818| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4819| 14800029  | SQLite: The database is full. |
4820| 14800030  | SQLite: Unable to open the database file. |
4821| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4822| 14800032  | SQLite: Abort due to constraint violation. |
4823| 14800033  | SQLite: Data type mismatch. |
4824| 14800034  | SQLite: Library used incorrectly. |
4825| 14800047  | The WAL file size exceeds the default limit. |
4826
4827**Example**
4828
4829```ts
4830import { BusinessError } from '@kit.BasicServicesKit';
4831if(store != null) {
4832  let txId : number;
4833  (store as relationalStore.RdbStore).beginTrans().then((txId : number) => {
4834    (store as relationalStore.RdbStore).execute("DELETE FROM TEST WHERE age = ? OR age = ?", txId, ["18", "20"])
4835      .then(() => {
4836        (store as relationalStore.RdbStore).commit(txId);
4837    })
4838    .catch((err: BusinessError) => {
4839      (store as relationalStore.RdbStore).rollback(txId)
4840      console.error(`execute sql failed, code is ${err.code},message is ${err.message}`);
4841    });
4842  });
4843}
4844```
4845
4846### commit
4847
4848commit():void
4849
4850Commits the executed SQL statement. This API must be used with [beginTransaction](#begintransaction).
4851This API does not allow nested transactions and cannot be used across processes or threads.
4852
4853**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4854
4855**Error codes**
4856
4857For 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).
4858
4859| **ID**| **Error Message**                                                |
4860|-----------| ------------------------------------------------------------ |
4861| 401       | Parameter error. The store must not be nullptr. |
4862| 14800000  | Inner error. |
4863| 14800011  | Database corrupted. |
4864| 14800014  | Already closed. |
4865| 14800015  | The database does not respond. |
4866| 14800021  | SQLite: Generic error. |
4867| 14800022  | SQLite: Callback routine requested an abort. |
4868| 14800023  | SQLite: Access permission denied. |
4869| 14800024  | SQLite: The database file is locked. |
4870| 14800025  | SQLite: A table in the database is locked. |
4871| 14800026  | SQLite: The database is out of memory. |
4872| 14800027  | SQLite: Attempt to write a readonly database. |
4873| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4874| 14800029  | SQLite: The database is full. |
4875| 14800030  | SQLite: Unable to open the database file. |
4876| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4877| 14800032  | SQLite: Abort due to constraint violation. |
4878| 14800033  | SQLite: Data type mismatch. |
4879| 14800034  | SQLite: Library used incorrectly. |
4880
4881**Example**
4882
4883```ts
4884
4885let value1 = "Lisa";
4886let value2 = 18;
4887let value3 = 100.5;
4888let value4 = new Uint8Array([1, 2, 3]);
4889
4890if(store != undefined) {
4891  (store as relationalStore.RdbStore).beginTransaction();
4892  const valueBucket: relationalStore.ValuesBucket = {
4893    'NAME': value1,
4894    'AGE': value2,
4895    'SALARY': value3,
4896    'CODES': value4,
4897  };
4898  (store as relationalStore.RdbStore).insert("test", valueBucket);
4899  (store as relationalStore.RdbStore).commit();
4900}
4901```
4902
4903### commit<sup>12+</sup>
4904
4905commit(txId : number):Promise&lt;void&gt;
4906
4907Commits the executed SQL statement. This API must be used with [beginTrans](#begintrans12).
4908
4909<!--RP1-->
4910This API is available only for a [vector database](js-apis-data-relationalStore-sys.md#storeconfig).<!--RP1End-->
4911
4912**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4913
4914**Parameters**
4915
4916| Name  | Type                                | Mandatory| Description                                                        |
4917| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
4918| txId      | number                               | Yes  | Transaction ID obtained via [beginTrans](#begintrans12).                                       |
4919
4920**Return value**
4921
4922| Type               | Description                     |
4923| ------------------- | ------------------------- |
4924| Promise&lt;void&gt; | Promise that returns no value.|
4925
4926**Error codes**
4927
4928For 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).
4929
4930| **ID**| **Error Message**                                                |
4931|-----------| ------------------------------------------------------------ |
4932| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
4933| 14800000  | Inner error. |
4934| 14800011  | Database corrupted. |
4935| 14800014  | Already closed. |
4936| 14800015  | The database does not respond. |
4937| 14800021  | SQLite: Generic error. |
4938| 14800022  | SQLite: Callback routine requested an abort. |
4939| 14800023  | SQLite: Access permission denied. |
4940| 14800024  | SQLite: The database file is locked. |
4941| 14800025  | SQLite: A table in the database is locked. |
4942| 14800026  | SQLite: The database is out of memory. |
4943| 14800027  | SQLite: Attempt to write a readonly database. |
4944| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4945| 14800029  | SQLite: The database is full. |
4946| 14800030  | SQLite: Unable to open the database file. |
4947| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
4948| 14800032  | SQLite: Abort due to constraint violation. |
4949| 14800033  | SQLite: Data type mismatch. |
4950| 14800034  | SQLite: Library used incorrectly. |
4951
4952**Example**
4953
4954```ts
4955import { BusinessError } from '@kit.BasicServicesKit';
4956if(store != null) {
4957  let txId : number;
4958  (store as relationalStore.RdbStore).beginTrans().then((txId : number) => {
4959    (store as relationalStore.RdbStore).execute("DELETE FROM TEST WHERE age = ? OR age = ?", txId, ["18", "20"])
4960      .then(() => {
4961        (store as relationalStore.RdbStore).commit(txId);
4962    })
4963    .catch((err: BusinessError) => {
4964      (store as relationalStore.RdbStore).rollback(txId)
4965      console.error(`execute sql failed, code is ${err.code},message is ${err.message}`);
4966    });
4967  });
4968}
4969```
4970
4971### rollBack
4972
4973rollBack():void
4974
4975Rolls back the executed SQL statement.
4976This API does not allow nested transactions and cannot be used across processes or threads.
4977
4978**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4979
4980**Error codes**
4981
4982For 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).
4983
4984| **ID**| **Error Message**                                                |
4985|-----------| ------------------------------------------------------------ |
4986| 401       | Parameter error. The store must not be nullptr. |
4987| 14800000  | Inner error. |
4988| 14800011  | Database corrupted. |
4989| 14800014  | Already closed. |
4990| 14800015  | The database does not respond. |
4991| 14800021  | SQLite: Generic error. |
4992| 14800022  | SQLite: Callback routine requested an abort. |
4993| 14800023  | SQLite: Access permission denied. |
4994| 14800024  | SQLite: The database file is locked. |
4995| 14800025  | SQLite: A table in the database is locked. |
4996| 14800026  | SQLite: The database is out of memory. |
4997| 14800027  | SQLite: Attempt to write a readonly database. |
4998| 14800028  | SQLite: Some kind of disk I/O error occurred. |
4999| 14800029  | SQLite: The database is full. |
5000| 14800030  | SQLite: Unable to open the database file. |
5001| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
5002| 14800032  | SQLite: Abort due to constraint violation. |
5003| 14800033  | SQLite: Data type mismatch. |
5004| 14800034  | SQLite: Library used incorrectly. |
5005
5006**Example**
5007
5008```ts
5009import { BusinessError } from '@kit.BasicServicesKit';
5010
5011let value1 = "Lisa";
5012let value2 = 18;
5013let value3 = 100.5;
5014let value4 = new Uint8Array([1, 2, 3]);
5015
5016if(store != undefined) {
5017  try {
5018    (store as relationalStore.RdbStore).beginTransaction()
5019    const valueBucket: relationalStore.ValuesBucket = {
5020      'NAME': value1,
5021      'AGE': value2,
5022      'SALARY': value3,
5023      'CODES': value4,
5024    };
5025    (store as relationalStore.RdbStore).insert("test", valueBucket);
5026    (store as relationalStore.RdbStore).commit();
5027  } catch (err) {
5028    let code = (err as BusinessError).code;
5029    let message = (err as BusinessError).message
5030    console.error(`Transaction failed, code is ${code},message is ${message}`);
5031    (store as relationalStore.RdbStore).rollBack();
5032  }
5033}
5034```
5035
5036### rollback<sup>12+</sup>
5037
5038rollback(txId : number):Promise&lt;void&gt;
5039
5040Rolls back the executed SQL statement. This API must be used with [beginTrans](#begintrans12).
5041
5042<!--RP1-->
5043This API is available only for a [vector database](js-apis-data-relationalStore-sys.md#storeconfig).<!--RP1End-->
5044
5045**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5046
5047**Parameters**
5048
5049| Name  | Type                                | Mandatory| Description                                                        |
5050| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
5051| txId      | number                               | Yes  | Transaction ID obtained via [beginTrans](#begintrans12).                                       |
5052
5053**Return value**
5054
5055| Type               | Description                     |
5056| ------------------- | ------------------------- |
5057| Promise&lt;void&gt; | Promise that returns no value.|
5058
5059**Error codes**
5060
5061For 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).
5062
5063| **ID**| **Error Message**                                                |
5064|-----------| ------------------------------------------------------------ |
5065| 401       | Parameter error. The store must not be nullptr. |
5066| 14800000  | Inner error. |
5067| 14800011  | Database corrupted. |
5068| 14800014  | Already closed. |
5069| 14800015  | The database does not respond. |
5070| 14800021  | SQLite: Generic error. |
5071| 14800022  | SQLite: Callback routine requested an abort. |
5072| 14800023  | SQLite: Access permission denied. |
5073| 14800024  | SQLite: The database file is locked. |
5074| 14800025  | SQLite: A table in the database is locked. |
5075| 14800026  | SQLite: The database is out of memory. |
5076| 14800027  | SQLite: Attempt to write a readonly database. |
5077| 14800028  | SQLite: Some kind of disk I/O error occurred. |
5078| 14800029  | SQLite: The database is full. |
5079| 14800030  | SQLite: Unable to open the database file. |
5080| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
5081| 14800032  | SQLite: Abort due to constraint violation. |
5082| 14800033  | SQLite: Data type mismatch. |
5083| 14800034  | SQLite: Library used incorrectly. |
5084
5085**Example**
5086
5087```ts
5088import { BusinessError } from '@kit.BasicServicesKit';
5089if(store != null) {
5090  let txId : number;
5091  (store as relationalStore.RdbStore).beginTrans().then((txId : number) => {
5092    (store as relationalStore.RdbStore).execute("DELETE FROM TEST WHERE age = ? OR age = ?", txId, ["18", "20"])
5093      .then(() => {
5094        (store as relationalStore.RdbStore).commit(txId);
5095    })
5096    .catch((err: BusinessError) => {
5097      (store as relationalStore.RdbStore).rollback(txId)
5098      console.error(`execute sql failed, code is ${err.code},message is ${err.message}`);
5099    });
5100  });
5101}
5102```
5103
5104### backup
5105
5106backup(destName:string, callback: AsyncCallback&lt;void&gt;):void
5107
5108Backs up an RDB store. This API uses an asynchronous callback to return the result.
5109
5110**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5111
5112**Parameters**
5113
5114| Name  | Type                     | Mandatory| Description                    |
5115| -------- | ------------------------- | ---- | ------------------------ |
5116| destName | string                    | Yes  | Name of the RDB store backup file.|
5117| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.  |
5118
5119**Error codes**
5120
5121For 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).
5122
5123| **ID**| **Error Message**                                                |
5124|-----------| ------------------------------------------------------------ |
5125| 401       | Parameter error. The store must not be nullptr. |
5126| 14800000  | Inner error. |
5127| 14800010  | Invalid database path. |
5128| 14800011  | Database corrupted. |
5129| 14800014  | Already closed. |
5130| 14800015  | The database does not respond. |
5131| 14800021  | SQLite: Generic error. |
5132| 14800022  | SQLite: Callback routine requested an abort. |
5133| 14800023  | SQLite: Access permission denied. |
5134| 14800024  | SQLite: The database file is locked. |
5135| 14800025  | SQLite: A table in the database is locked. |
5136| 14800026  | SQLite: The database is out of memory. |
5137| 14800027  | SQLite: Attempt to write a readonly database. |
5138| 14800028  | SQLite: Some kind of disk I/O error occurred. |
5139| 14800029  | SQLite: The database is full. |
5140| 14800030  | SQLite: Unable to open the database file. |
5141| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
5142| 14800032  | SQLite: Abort due to constraint violation. |
5143| 14800033  | SQLite: Data type mismatch. |
5144| 14800034  | SQLite: Library used incorrectly. |
5145
5146**Example**
5147
5148```ts
5149if(store != undefined) {
5150  (store as relationalStore.RdbStore).backup("dbBackup.db", (err) => {
5151    if (err) {
5152      console.error(`Backup failed, code is ${err.code},message is ${err.message}`);
5153      return;
5154    }
5155    console.info('Backup success.');
5156  })
5157}
5158```
5159
5160### backup
5161
5162backup(destName:string): Promise&lt;void&gt;
5163
5164Backs up an RDB store. This API uses a promise to return the result.
5165
5166**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5167
5168**Parameters**
5169
5170| Name  | Type  | Mandatory| Description                    |
5171| -------- | ------ | ---- | ------------------------ |
5172| destName | string | Yes  | Name of the RDB store backup file.|
5173
5174**Return value**
5175
5176| Type               | Description                     |
5177| ------------------- | ------------------------- |
5178| Promise&lt;void&gt; | Promise that returns no value.|
5179
5180**Error codes**
5181
5182For 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).
5183
5184| **ID**| **Error Message**                                                |
5185|-----------| ------------------------------------------------------------ |
5186| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5187| 14800000  | Inner error. |
5188| 14800011  | Database corrupted. |
5189| 14800014  | Already closed. |
5190| 14800015  | The database does not respond. |
5191| 14800021  | SQLite: Generic error. |
5192| 14800022  | SQLite: Callback routine requested an abort. |
5193| 14800023  | SQLite: Access permission denied. |
5194| 14800024  | SQLite: The database file is locked. |
5195| 14800025  | SQLite: A table in the database is locked. |
5196| 14800026  | SQLite: The database is out of memory. |
5197| 14800027  | SQLite: Attempt to write a readonly database. |
5198| 14800028  | SQLite: Some kind of disk I/O error occurred. |
5199| 14800029  | SQLite: The database is full. |
5200| 14800030  | SQLite: Unable to open the database file. |
5201| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
5202| 14800032  | SQLite: Abort due to constraint violation. |
5203| 14800033  | SQLite: Data type mismatch. |
5204| 14800034  | SQLite: Library used incorrectly. |
5205
5206**Example**
5207
5208```ts
5209import { BusinessError } from '@kit.BasicServicesKit';
5210
5211if(store != undefined) {
5212  let promiseBackup = (store as relationalStore.RdbStore).backup("dbBackup.db");
5213  promiseBackup.then(() => {
5214    console.info('Backup success.');
5215  }).catch((err: BusinessError) => {
5216    console.error(`Backup failed, code is ${err.code},message is ${err.message}`);
5217  })
5218}
5219```
5220
5221### restore
5222
5223restore(srcName:string, callback: AsyncCallback&lt;void&gt;):void
5224
5225Restores an RDB store from a backup file. This API uses an asynchronous callback to return the result.
5226
5227**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5228
5229**Parameters**
5230
5231| Name  | Type                     | Mandatory| Description                    |
5232| -------- | ------------------------- | ---- | ------------------------ |
5233| srcName  | string                    | Yes  | Name of the RDB store backup file.|
5234| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.  |
5235
5236**Error codes**
5237
5238For 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).
5239
5240| **ID**| **Error Message**                                                |
5241|-----------| ------------------------------------------------------------ |
5242| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5243| 14800000  | Inner error. |
5244| 14800011  | Database corrupted. |
5245| 14800014  | Already closed. |
5246| 14800015  | The database does not respond. |
5247| 14800021  | SQLite: Generic error. |
5248| 14800022  | SQLite: Callback routine requested an abort. |
5249| 14800023  | SQLite: Access permission denied. |
5250| 14800024  | SQLite: The database file is locked. |
5251| 14800025  | SQLite: A table in the database is locked. |
5252| 14800026  | SQLite: The database is out of memory. |
5253| 14800027  | SQLite: Attempt to write a readonly database. |
5254| 14800028  | SQLite: Some kind of disk I/O error occurred. |
5255| 14800029  | SQLite: The database is full. |
5256| 14800030  | SQLite: Unable to open the database file. |
5257| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
5258| 14800032  | SQLite: Abort due to constraint violation. |
5259| 14800033  | SQLite: Data type mismatch. |
5260| 14800034  | SQLite: Library used incorrectly. |
5261
5262**Example**
5263
5264```ts
5265if(store != undefined) {
5266  (store as relationalStore.RdbStore).restore("dbBackup.db", (err) => {
5267    if (err) {
5268      console.error(`Restore failed, code is ${err.code},message is ${err.message}`);
5269      return;
5270    }
5271    console.info('Restore success.');
5272  })
5273}
5274```
5275
5276### restore
5277
5278restore(srcName:string): Promise&lt;void&gt;
5279
5280Restores an RDB store from a backup file. This API uses a promise to return the result.
5281
5282**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5283
5284**Parameters**
5285
5286| Name | Type  | Mandatory| Description                    |
5287| ------- | ------ | ---- | ------------------------ |
5288| srcName | string | Yes  | Name of the RDB store backup file.|
5289
5290**Return value**
5291
5292| Type               | Description                     |
5293| ------------------- | ------------------------- |
5294| Promise&lt;void&gt; | Promise that returns no value.|
5295
5296**Error codes**
5297
5298For 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).
5299
5300| **ID**| **Error Message**                                                |
5301|-----------| ------------------------------------------------------------ |
5302| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5303| 14800000  | Inner error. |
5304| 14800011  | Database corrupted. |
5305| 14800014  | Already closed. |
5306| 14800015  | The database does not respond. |
5307| 14800021  | SQLite: Generic error. |
5308| 14800022  | SQLite: Callback routine requested an abort. |
5309| 14800023  | SQLite: Access permission denied. |
5310| 14800024  | SQLite: The database file is locked. |
5311| 14800025  | SQLite: A table in the database is locked. |
5312| 14800026  | SQLite: The database is out of memory. |
5313| 14800027  | SQLite: Attempt to write a readonly database. |
5314| 14800028  | SQLite: Some kind of disk I/O error occurred. |
5315| 14800029  | SQLite: The database is full. |
5316| 14800030  | SQLite: Unable to open the database file. |
5317| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
5318| 14800032  | SQLite: Abort due to constraint violation. |
5319| 14800033  | SQLite: Data type mismatch. |
5320| 14800034  | SQLite: Library used incorrectly. |
5321
5322**Example**
5323
5324```ts
5325import { BusinessError } from '@kit.BasicServicesKit';
5326
5327if(store != undefined) {
5328  let promiseRestore = (store as relationalStore.RdbStore).restore("dbBackup.db");
5329  promiseRestore.then(() => {
5330    console.info('Restore success.');
5331  }).catch((err: BusinessError) => {
5332    console.error(`Restore failed, code is ${err.code},message is ${err.message}`);
5333  })
5334}
5335```
5336
5337### setDistributedTables
5338
5339setDistributedTables(tables: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void
5340
5341Sets distributed tables. This API uses an asynchronous callback to return the result.
5342
5343**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
5344
5345**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5346
5347**Parameters**
5348
5349| Name  | Type                     | Mandatory| Description                  |
5350| -------- | ------------------------- | ---- | ---------------------- |
5351| tables   | Array&lt;string&gt;       | Yes  | Names of the distributed tables to set.|
5352| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
5353
5354**Error codes**
5355
5356For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5357
5358| **ID**| **Error Message**                                                |
5359|-----------| ------------------------------------------------------------ |
5360| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5361| 801       | Capability not supported. |
5362| 14800000  | Inner error. |
5363| 14800014  | Already closed. |
5364
5365**Example**
5366
5367```ts
5368if(store != undefined) {
5369  (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"], (err) => {
5370    if (err) {
5371      console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
5372      return;
5373    }
5374    console.info('SetDistributedTables successfully.');
5375  })
5376}
5377```
5378
5379### setDistributedTables
5380
5381 setDistributedTables(tables: Array&lt;string&gt;): Promise&lt;void&gt;
5382
5383Sets distributed tables. This API uses a promise to return the result.
5384
5385**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
5386
5387**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5388
5389**Parameters**
5390
5391| Name| Type                    | Mandatory| Description                    |
5392| ------ | ------------------------ | ---- | ------------------------ |
5393| tables | ArrayArray&lt;string&gt; | Yes  | Names of the distributed tables to set.|
5394
5395**Return value**
5396
5397| Type               | Description                     |
5398| ------------------- | ------------------------- |
5399| Promise&lt;void&gt; | Promise that returns no value.|
5400
5401**Error codes**
5402
5403For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5404
5405| **ID**| **Error Message**                                                |
5406|-----------| ------------------------------------------------------------ |
5407| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5408| 801       | Capability not supported. |
5409| 14800000  | Inner error. |
5410| 14800014  | Already closed. |
5411
5412**Example**
5413
5414```ts
5415import { BusinessError } from '@kit.BasicServicesKit';
5416
5417if(store != undefined) {
5418  (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"]).then(() => {
5419    console.info('SetDistributedTables successfully.');
5420  }).catch((err: BusinessError) => {
5421    console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
5422  })
5423}
5424```
5425
5426### setDistributedTables<sup>10+</sup>
5427
5428setDistributedTables(tables: Array&lt;string&gt;, type: DistributedType, callback: AsyncCallback&lt;void&gt;): void
5429
5430Sets distributed tables. This API uses an asynchronous callback to return the result.
5431
5432**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
5433
5434**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5435
5436**Parameters**
5437
5438| Name  | Type                                 | Mandatory| Description                        |
5439| -------- | ------------------------------------- | ---- | ---------------------------- |
5440| tables   | Array&lt;string&gt;                   | Yes  | Names of the distributed tables to set.|
5441| type     | [DistributedType](#distributedtype10) | Yes  | Distributed type of the tables.            |
5442| callback | AsyncCallback&lt;void&gt;             | Yes  | Callback used to return the result.      |
5443
5444**Error codes**
5445
5446For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5447
5448| **ID**| **Error Message**                                                |
5449|-----------| ------------------------------------------------------------ |
5450| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5451| 801       | Capability not supported. |
5452| 14800000  | Inner error. |
5453| 14800014  | Already closed. |
5454| 14800051  | The type of the distributed table does not match. |
5455
5456**Example**
5457
5458```ts
5459if(store != undefined) {
5460  (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"], relationalStore.DistributedType.DISTRIBUTED_CLOUD, (err) => {
5461    if (err) {
5462      console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
5463      return;
5464    }
5465    console.info('SetDistributedTables successfully.');
5466  })
5467}
5468```
5469
5470### setDistributedTables<sup>10+</sup>
5471
5472setDistributedTables(tables: Array&lt;string&gt;, type: DistributedType, config: DistributedConfig, callback: AsyncCallback&lt;void&gt;): void
5473
5474Sets distributed tables. This API uses an asynchronous callback to return the result.
5475
5476**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
5477
5478**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5479
5480**Parameters**
5481
5482| Name     | Type                                 | Mandatory | Description             |
5483| -------- | ----------------------------------- | --- | --------------- |
5484| tables   | Array&lt;string&gt;                 | Yes  | Names of the distributed tables to set.    |
5485| type     | [DistributedType](#distributedtype10) | Yes  | Distributed type of the tables.|
5486| config | [DistributedConfig](#distributedconfig10) | Yes| Configuration of the distributed mode.|
5487| callback | AsyncCallback&lt;void&gt;           | Yes  | Callback used to return the result.|
5488
5489**Error codes**
5490
5491For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5492
5493| **ID**| **Error Message**                                                |
5494|-----------| ------------------------------------------------------------ |
5495| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5496| 801       | Capability not supported. |
5497| 14800000  | Inner error. |
5498| 14800014  | Already closed. |
5499| 14800051  | The type of the distributed table does not match. |
5500
5501**Example**
5502
5503```ts
5504if(store != undefined) {
5505  (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"], relationalStore.DistributedType.DISTRIBUTED_CLOUD, {
5506    autoSync: true
5507  }, (err) => {
5508    if (err) {
5509      console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
5510      return;
5511    }
5512    console.info('SetDistributedTables successfully.');
5513  })
5514}
5515```
5516
5517### setDistributedTables<sup>10+</sup>
5518
5519 setDistributedTables(tables: Array&lt;string>, type?: DistributedType, config?: DistributedConfig): Promise&lt;void>
5520
5521Sets distributed tables. This API uses a promise to return the result.
5522
5523**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
5524
5525**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5526
5527**Parameters**
5528
5529| Name| Type                                     | Mandatory| Description                                                        |
5530| ------ | ----------------------------------------- | ---- | ------------------------------------------------------------ |
5531| tables | Array&lt;string&gt;                       | Yes  | Names of the distributed tables to set.                                |
5532| type   | [DistributedType](#distributedtype10)     | No  | Distributed type of the tables. The default value is **relationalStore.DistributedType.DISTRIBUTED_DEVICE**.|
5533| 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.|
5534
5535**Return value**
5536
5537| Type               | Description                     |
5538| ------------------- | ------------------------- |
5539| Promise&lt;void&gt; | Promise that returns no value.|
5540
5541**Error codes**
5542
5543For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5544
5545| **ID**| **Error Message**                                                |
5546|-----------| ------------------------------------------------------------ |
5547| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5548| 801       | Capability not supported. |
5549| 14800000  | Inner error. |
5550| 14800014  | Already closed. |
5551| 14800051  | The type of the distributed table does not match. |
5552
5553**Example**
5554
5555```ts
5556import { BusinessError } from '@kit.BasicServicesKit';
5557
5558if(store != undefined) {
5559  (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"], relationalStore.DistributedType.DISTRIBUTED_CLOUD, {
5560    autoSync: true
5561  }).then(() => {
5562    console.info('SetDistributedTables successfully.');
5563  }).catch((err: BusinessError) => {
5564    console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
5565  })
5566}
5567```
5568
5569### obtainDistributedTableName
5570
5571obtainDistributedTableName(device: string, table: string, callback: AsyncCallback&lt;string&gt;): void
5572
5573Obtains 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.
5574
5575> **NOTE**
5576>
5577> **device** can be obtained by [deviceManager.getAvailableDeviceListSync](../apis-distributedservice-kit/js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
5578
5579**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
5580
5581**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5582
5583**Parameters**
5584
5585| Name  | Type                       | Mandatory| Description                                                        |
5586| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
5587| device   | string                      | Yes  | ID of the remote device.                                               |
5588| table    | string                      | Yes  | Local table name of the remote device.                                        |
5589| 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.|
5590
5591**Error codes**
5592
5593For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5594
5595| **ID**| **Error Message**                                                |
5596|-----------| ------------------------------------------------------------ |
5597| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5598| 801       | Capability not supported. |
5599| 14800000  | Inner error. |
5600| 14800014  | Already closed. |
5601
5602**Example**
5603
5604```ts
5605import { distributedDeviceManager } from '@kit.DistributedServiceKit';
5606import { BusinessError } from '@kit.BasicServicesKit';
5607
5608let dmInstance: distributedDeviceManager.DeviceManager;
5609let deviceId: string | undefined = undefined;
5610
5611try {
5612  dmInstance = distributedDeviceManager.createDeviceManager("com.example.appdatamgrverify");
5613  let devices = dmInstance.getAvailableDeviceListSync();
5614  deviceId = devices[0].networkId;
5615} catch (err) {
5616  let code = (err as BusinessError).code;
5617  let message = (err as BusinessError).message
5618  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
5619}
5620
5621if(store != undefined && deviceId != undefined) {
5622  (store as relationalStore.RdbStore).obtainDistributedTableName(deviceId, "EMPLOYEE", (err, tableName) => {
5623    if (err) {
5624      console.error(`ObtainDistributedTableName failed, code is ${err.code},message is ${err.message}`);
5625      return;
5626    }
5627    console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`);
5628  })
5629}
5630```
5631
5632### obtainDistributedTableName
5633
5634 obtainDistributedTableName(device: string, table: string): Promise&lt;string&gt;
5635
5636Obtains 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.
5637
5638> **NOTE**
5639>
5640> **device** can be obtained by [deviceManager.getAvailableDeviceListSync](../apis-distributedservice-kit/js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
5641
5642**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
5643
5644**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5645
5646**Parameters**
5647
5648| Name| Type  | Mandatory| Description                |
5649| ------ | ------ | ---- | -------------------- |
5650| device | string | Yes  | ID of the remote device.        |
5651| table  | string | Yes  | Local table name of the remote device.|
5652
5653**Return value**
5654
5655| Type                 | Description                                                 |
5656| --------------------- | ----------------------------------------------------- |
5657| Promise&lt;string&gt; | Promise used to return the result. If the operation succeeds, the distributed table name of the remote device is returned.|
5658
5659**Error codes**
5660
5661For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5662
5663| **ID**| **Error Message**                                                |
5664|-----------| ------------------------------------------------------------ |
5665| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5666| 801       | Capability not supported. |
5667| 14800000  | Inner error. |
5668| 14800014  | Already closed. |
5669
5670**Example**
5671
5672```ts
5673import { distributedDeviceManager } from '@kit.DistributedServiceKit';
5674import { BusinessError } from '@kit.BasicServicesKit';
5675
5676let dmInstance: distributedDeviceManager.DeviceManager;
5677let deviceId: string | undefined = undefined;
5678
5679try {
5680  dmInstance = distributedDeviceManager.createDeviceManager("com.example.appdatamgrverify");
5681  let devices = dmInstance.getAvailableDeviceListSync();
5682  deviceId = devices[0].networkId;
5683} catch (err) {
5684  let code = (err as BusinessError).code;
5685  let message = (err as BusinessError).message
5686  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
5687}
5688
5689if(store != undefined && deviceId != undefined) {
5690  (store as relationalStore.RdbStore).obtainDistributedTableName(deviceId, "EMPLOYEE").then((tableName: string) => {
5691    console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`);
5692  }).catch((err: BusinessError) => {
5693    console.error(`ObtainDistributedTableName failed, code is ${err.code},message is ${err.message}`);
5694  })
5695}
5696```
5697
5698### sync
5699
5700sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback&lt;Array&lt;[string, number]&gt;&gt;): void
5701
5702Synchronizes data between devices. This API uses an asynchronous callback to return the result.
5703
5704**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
5705
5706**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5707
5708**Parameters**
5709
5710| Name    | Type                                              | Mandatory| Description                                                        |
5711| ---------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ |
5712| mode       | [SyncMode](#syncmode)                             | Yes  | Data sync mode. The value can be **relationalStore.SyncMode.SYNC_MODE_PUSH** or **relationalStore.SyncMode.SYNC_MODE_PULL**.                              |
5713| predicates | [RdbPredicates](#rdbpredicates)               | Yes  | **RdbPredicates** object that specifies the data and devices to synchronize.                                        |
5714| 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. |
5715
5716**Error codes**
5717
5718For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5719
5720| **ID**| **Error Message**                                                |
5721|-----------| ------------------------------------------------------------ |
5722| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5723| 801       | Capability not supported. |
5724| 14800000  | Inner error. |
5725| 14800014  | Already closed. |
5726
5727**Example**
5728
5729```ts
5730import { distributedDeviceManager } from '@kit.DistributedServiceKit';
5731import { BusinessError } from '@kit.BasicServicesKit';
5732
5733let dmInstance: distributedDeviceManager.DeviceManager;
5734let deviceIds: Array<string> = [];
5735
5736try {
5737  dmInstance = distributedDeviceManager.createDeviceManager("com.example.appdatamgrverify");
5738  let devices: Array<distributedDeviceManager.DeviceBasicInfo> = dmInstance.getAvailableDeviceListSync();
5739  for (let i = 0; i < devices.length; i++) {
5740    deviceIds[i] = devices[i].networkId!;
5741  }
5742} catch (err) {
5743  let code = (err as BusinessError).code;
5744  let message = (err as BusinessError).message
5745  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
5746}
5747
5748let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
5749predicates.inDevices(deviceIds);
5750if(store != undefined) {
5751  (store as relationalStore.RdbStore).sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates, (err, result) => {
5752    if (err) {
5753      console.error(`Sync failed, code is ${err.code},message is ${err.message}`);
5754      return;
5755    }
5756    console.info('Sync done.');
5757    for (let i = 0; i < result.length; i++) {
5758      console.info(`device= ${result[i][0]}, status= ${result[i][1]}`);
5759    }
5760  })
5761}
5762```
5763
5764### sync
5765
5766 sync(mode: SyncMode, predicates: RdbPredicates): Promise&lt;Array&lt;[string, number]&gt;&gt;
5767
5768Synchronizes data between devices. This API uses a promise to return the result.
5769
5770**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
5771
5772**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5773
5774**Parameters**
5775
5776| Name    | Type                                | Mandatory| Description                          |
5777| ---------- | ------------------------------------ | ---- | ------------------------------ |
5778| mode       | [SyncMode](#syncmode)               | Yes  | Data sync mode. The value can be **relationalStore.SyncMode.SYNC_MODE_PUSH** or **relationalStore.SyncMode.SYNC_MODE_PULL**.|
5779| predicates | [RdbPredicates](#rdbpredicates) | Yes  | **RdbPredicates** object that specifies the data and devices to synchronize.          |
5780
5781**Return value**
5782
5783| Type                                        | Description                                                        |
5784| -------------------------------------------- | ------------------------------------------------------------ |
5785| 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. |
5786
5787**Error codes**
5788
5789For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5790
5791| **ID**| **Error Message**                                                |
5792|-----------| ------------------------------------------------------------ |
5793| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5794| 801       | Capability not supported. |
5795| 14800000  | Inner error. |
5796| 14800014  | Already closed. |
5797
5798**Example**
5799
5800```ts
5801import { distributedDeviceManager } from '@kit.DistributedServiceKit';
5802import { BusinessError } from '@kit.BasicServicesKit';
5803
5804let dmInstance: distributedDeviceManager.DeviceManager;
5805let deviceIds: Array<string> = [];
5806
5807try {
5808  dmInstance = distributedDeviceManager.createDeviceManager("com.example.appdatamgrverify");
5809  let devices: Array<distributedDeviceManager.DeviceBasicInfo> = dmInstance.getAvailableDeviceListSync();
5810  for (let i = 0; i < devices.length; i++) {
5811    deviceIds[i] = devices[i].networkId!;
5812  }
5813} catch (err) {
5814  let code = (err as BusinessError).code;
5815  let message = (err as BusinessError).message
5816  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
5817}
5818
5819let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
5820predicates.inDevices(deviceIds);
5821if(store != undefined) {
5822  (store as relationalStore.RdbStore).sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates).then((result: Object[][]) => {
5823    console.info('Sync done.');
5824    for (let i = 0; i < result.length; i++) {
5825      console.info(`device= ${result[i][0]}, status= ${result[i][1]}`);
5826    }
5827  }).catch((err: BusinessError) => {
5828    console.error(`Sync failed, code is ${err.code},message is ${err.message}`);
5829  })
5830}
5831```
5832
5833### cloudSync<sup>10+</sup>
5834
5835cloudSync(mode: SyncMode, progress: Callback&lt;ProgressDetails&gt;, callback: AsyncCallback&lt;void&gt;): void
5836
5837Manually 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.
5838
5839**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
5840
5841**Parameters**
5842
5843| Name  | Type                                                 | Mandatory| Description                                              |
5844| -------- | ----------------------------------------------------- | ---- | -------------------------------------------------- |
5845| mode     | [SyncMode](#syncmode)                                 | Yes  | Sync mode of the database.                            |
5846| progress | Callback&lt;[ProgressDetails](#progressdetails10)&gt; | Yes  | Callback used to process database sync details.            |
5847| callback | AsyncCallback&lt;void&gt;                             | Yes  | Callback used to send the sync result to the caller.|
5848
5849**Error codes**
5850
5851For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5852
5853| **ID**| **Error Message**       |
5854|-----------|-------|
5855| 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. |
5856| 801       | Capability not supported.       |
5857| 14800014  | Already closed.        |
5858
5859**Example**
5860
5861```ts
5862if(store != undefined) {
5863  (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, (progressDetails) => {
5864    console.info(`Progess: ${progressDetails}`);
5865  }, (err) => {
5866    if (err) {
5867      console.error(`Cloud sync failed, code is ${err.code},message is ${err.message}`);
5868      return;
5869    }
5870    console.info('Cloud sync succeeded');
5871  });
5872}
5873```
5874
5875### cloudSync<sup>10+</sup>
5876
5877cloudSync(mode: SyncMode, progress: Callback&lt;ProgressDetails&gt;): Promise&lt;void&gt;
5878
5879Manually 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.
5880
5881**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
5882
5883**Parameters**
5884
5885| Name  | Type                                                 | Mandatory| Description                                  |
5886| -------- | ----------------------------------------------------- | ---- | -------------------------------------- |
5887| mode     | [SyncMode](#syncmode)                                 | Yes  | Sync mode of the database.                |
5888| progress | Callback&lt;[ProgressDetails](#progressdetails10)&gt; | Yes  | Callback used to process database sync details.|
5889
5890**Return value**
5891
5892| Type               | Description                                   |
5893| ------------------- | --------------------------------------- |
5894| Promise&lt;void&gt; | Promise used to send the sync result.|
5895
5896**Error codes**
5897
5898For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5899
5900| **ID**| **Error Message**   |
5901|-----------|------------------|
5902| 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. |
5903| 801       | Capability not supported.   |
5904| 14800014  | Already closed.           |
5905
5906**Example**
5907
5908```ts
5909import { BusinessError } from '@kit.BasicServicesKit';
5910
5911if(store != undefined) {
5912  (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, (progressDetail: relationalStore.ProgressDetails) => {
5913    console.info(`progress: ${progressDetail}`);
5914  }).then(() => {
5915    console.info('Cloud sync succeeded');
5916  }).catch((err: BusinessError) => {
5917    console.error(`cloudSync failed, code is ${err.code},message is ${err.message}`);
5918  });
5919}
5920```
5921
5922### cloudSync<sup>10+</sup>
5923
5924cloudSync(mode: SyncMode, tables: string[], progress: Callback&lt;ProgressDetails&gt;, callback: AsyncCallback&lt;void&gt;): void
5925
5926Manually 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.
5927
5928**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
5929
5930**Parameters**
5931
5932| Name  | Type                                                 | Mandatory| Description                                              |
5933| -------- | ----------------------------------------------------- | ---- | -------------------------------------------------- |
5934| mode     | [SyncMode](#syncmode)                                 | Yes  | Sync mode of the database.                            |
5935| tables   | string[]                                              | Yes  | Name of the table to synchronize.                                  |
5936| progress | Callback&lt;[ProgressDetails](#progressdetails10)&gt; | Yes  | Callback used to process database sync details.            |
5937| callback | AsyncCallback&lt;void&gt;                             | Yes  | Callback used to send the sync result to the caller.|
5938
5939**Error codes**
5940
5941For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5942
5943| **ID**| **Error Message**                                                                                                                                                                                                                 |
5944|-----------|-------|
5945| 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.|
5946| 801       | Capability not supported.   |
5947| 14800014  | Already closed.   |
5948
5949**Example**
5950
5951```ts
5952const tables = ["table1", "table2"];
5953
5954if(store != undefined) {
5955  (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, tables, (progressDetail: relationalStore.ProgressDetails) => {
5956    console.info(`Progess: ${progressDetail}`);
5957  }, (err) => {
5958    if (err) {
5959      console.error(`Cloud sync failed, code is ${err.code},message is ${err.message}`);
5960      return;
5961    }
5962    console.info('Cloud sync succeeded');
5963  });
5964};
5965```
5966
5967### cloudSync<sup>10+</sup>
5968
5969cloudSync(mode: SyncMode, tables: string[], progress: Callback&lt;ProgressDetails&gt;): Promise&lt;void&gt;
5970
5971Manually 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.
5972
5973**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
5974
5975**Parameters**
5976
5977| Name  | Type                                                 | Mandatory| Description                                  |
5978| -------- | ----------------------------------------------------- | ---- | -------------------------------------- |
5979| mode     | [SyncMode](#syncmode)                                 | Yes  | Sync mode of the database.                |
5980| tables   | string[]                                              | Yes  | Name of the table to synchronize.                      |
5981| progress | Callback&lt;[ProgressDetails](#progressdetails10)&gt; | Yes  | Callback used to process database sync details.|
5982
5983**Return value**
5984
5985| Type               | Description                                   |
5986| ------------------- | --------------------------------------- |
5987| Promise&lt;void&gt; | Promise used to send the sync result.|
5988
5989**Error codes**
5990
5991For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
5992
5993| **ID**| **Error Message**    |
5994|-----------|---------------|
5995| 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 |
5996| 801       | Capability not supported.    |
5997| 14800014  | Already closed.  |
5998
5999**Example**
6000
6001```ts
6002import { BusinessError } from '@kit.BasicServicesKit';
6003
6004const tables = ["table1", "table2"];
6005
6006if(store != undefined) {
6007  (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, tables, (progressDetail: relationalStore.ProgressDetails) => {
6008    console.info(`progress: ${progressDetail}`);
6009  }).then(() => {
6010    console.info('Cloud sync succeeded');
6011  }).catch((err: BusinessError) => {
6012    console.error(`cloudSync failed, code is ${err.code},message is ${err.message}`);
6013  });
6014};
6015```
6016
6017### on('dataChange')
6018
6019on(event: 'dataChange', type: SubscribeType, observer: Callback&lt;Array&lt;string&gt;&gt;): void
6020
6021Subscribes to data changes of specified devices. When the data of the specified devices changes, a callback is invoked to return the data change.
6022
6023**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6024
6025**Parameters**
6026
6027| Name  | Type                                                        | Mandatory| Description                                                        |
6028| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
6029| event    | string                                                       | Yes  | Event type. The value is **'dataChange'**, which indicates data changes.                          |
6030| type     | [SubscribeType](#subscribetype)                              | Yes  | Type of data change to observe.                                                  |
6031| 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.|
6032
6033**Error codes**
6034
6035For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6036
6037| **ID**| **Error Message**       |
6038|-----------|-------------|
6039| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
6040| 801       | Capability not supported. |
6041| 14800014  | Already closed.    |
6042
6043**Example**
6044
6045```ts
6046import { distributedDeviceManager } from '@kit.DistributedServiceKit';
6047import { BusinessError } from '@kit.BasicServicesKit';
6048
6049let storeObserver = (devices: Array<string>) => {
6050  if (devices != undefined) {
6051    for (let i = 0; i < devices.length; i++) {
6052      console.info(`device= ${devices[i]} data changed`);
6053    }
6054  }
6055}
6056
6057try {
6058  if (store != undefined) {
6059    (store as relationalStore.RdbStore).on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver)
6060  }
6061} catch (err) {
6062    let code = (err as BusinessError).code;
6063    let message = (err as BusinessError).message
6064    console.error(`Register observer failed, code is ${code},message is ${message}`);
6065}
6066```
6067
6068### on('dataChange')<sup>10+</sup>
6069
6070on(event: 'dataChange', type: SubscribeType, observer: Callback&lt;Array&lt;string&gt;&gt;\| Callback&lt;Array&lt;ChangeInfo&gt;&gt;): void
6071
6072Subscribes to data changes of the specified devices. The registered callback will be called when data in a distributed or local RDB store changes.
6073
6074**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6075
6076**Parameters**
6077
6078| Name  | Type                               | Mandatory| Description                                       |
6079| -------- | ----------------------------------- | ---- | ------------------------------------------- |
6080| event    | string                              | Yes  | Event type. The value is **'dataChange'**, which indicates data changes.         |
6081| type     | [SubscribeType](#subscribetype)    | Yes  | Type of data change to observe.|
6082| 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.|
6083
6084**Error codes**
6085
6086For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6087
6088| **ID**| **Error Message**       |
6089|-----------|-------------|
6090| 202       | Permission verification failed, application which is not a system application uses system API. |
6091| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
6092| 801       | Capability not supported. |
6093| 14800014  | Already closed.    |
6094
6095Example 1: **type** is **SUBSCRIBE_TYPE_REMOTE**.
6096
6097```ts
6098import { distributedDeviceManager } from '@kit.DistributedServiceKit';
6099import { BusinessError } from '@kit.BasicServicesKit';
6100
6101let storeObserver = (devices: Array<string>) => {
6102  if (devices != undefined) {
6103    for (let i = 0; i < devices.length; i++) {
6104      console.info(`device= ${devices[i]} data changed`);
6105    }
6106  }
6107}
6108
6109try {
6110  if(store != undefined) {
6111    (store as relationalStore.RdbStore).on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver);
6112  }
6113} catch (err) {
6114  let code = (err as BusinessError).code;
6115  let message = (err as BusinessError).message;
6116  console.error(`Register observer failed, code is ${code},message is ${message}`);
6117}
6118```
6119
6120Example 2: **type** is **SUBSCRIBE_TYPE_LOCAL_DETAILS**.
6121
6122```ts
6123import { BusinessError } from '@kit.BasicServicesKit';
6124
6125let changeInfos = (changeInfos: Array<relationalStore.ChangeInfo>) => {
6126  for (let i = 0; i < changeInfos.length; i++) {
6127    console.info(`changeInfos = ${changeInfos[i]}`);
6128  }
6129}
6130
6131try {
6132  if(store != undefined) {
6133    (store as relationalStore.RdbStore).on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_LOCAL_DETAILS, changeInfos);
6134  }
6135} catch (err) {
6136  let code = (err as BusinessError).code;
6137  let message = (err as BusinessError).message;
6138  console.error(`on dataChange fail, code is ${code},message is ${message}`);
6139}
6140
6141let value1 = "Lisa";
6142let value2 = 18;
6143let value3 = 100.5;
6144let value4 = new Uint8Array([1, 2, 3]);
6145
6146try {
6147  const valueBucket: relationalStore.ValuesBucket = {
6148    'name': value1,
6149    'age': value2,
6150    'salary': value3,
6151    'blobType': value4,
6152  };
6153
6154  if(store != undefined) {
6155    (store as relationalStore.RdbStore).insert('test', valueBucket);
6156  }
6157} catch (err) {
6158  let code = (err as BusinessError).code;
6159  let message = (err as BusinessError).message;
6160  console.error(`insert fail, code is ${code},message is ${message}`);
6161}
6162```
6163
6164### on<sup>10+</sup>
6165
6166on(event: string, interProcess: boolean, observer: Callback\<void>): void
6167
6168Subscribes to process events. This callback is invoked by [emit](#emit10).
6169
6170**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6171
6172**Parameters**
6173
6174| Name      | Type           | Mandatory| Description                                                        |
6175| ------------ | --------------- | ---- | ------------------------------------------------------------ |
6176| event        | string          | Yes  | Event name to observe.                                              |
6177| 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.|
6178| observer     | Callback\<void> | Yes  | Callback used to return the result.                                                  |
6179
6180**Error codes**
6181
6182For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6183
6184| **ID**| **Error Message**       |
6185|-----------|-------------|
6186| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
6187| 801       | Capability not supported. |
6188| 14800000  | Inner error.    |
6189| 14800014  | Already closed.    |
6190| 14800050  | Failed to obtain subscription service.    |
6191
6192**Example**
6193
6194```ts
6195import { BusinessError } from '@kit.BasicServicesKit';
6196
6197let storeObserver = () => {
6198  console.info(`storeObserver`);
6199}
6200
6201try {
6202  if(store != undefined) {
6203    (store as relationalStore.RdbStore).on('storeObserver', false, storeObserver);
6204  }
6205} catch (err) {
6206  let code = (err as BusinessError).code;
6207  let message = (err as BusinessError).message
6208  console.error(`Register observer failed, code is ${code},message is ${message}`);
6209}
6210```
6211
6212### on('autoSyncProgress')<sup>11+</sup>
6213
6214on(event: 'autoSyncProgress', progress: Callback&lt;ProgressDetails&gt;): void
6215
6216Subscribes 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.
6217
6218**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6219
6220**Parameters**
6221
6222| Name      | Type                             | Mandatory| Description                               |
6223| ------------ |---------------------------------| ---- |-----------------------------------|
6224| event        | string                          | Yes  | Event type. The value is **'autoSyncProgress'**, which indicates the auto sync progress.|
6225| progress     | Callback&lt;[ProgressDetails](#progressdetails10)&gt; | Yes  | Callback used to return the auto sync progress.                            |
6226
6227**Error codes**
6228
6229For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6230
6231| **ID**| **Error Message**   |
6232|-----------|--------|
6233| 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. |
6234| 801       | Capability not supported.  |
6235| 14800014  | Already closed.     |
6236
6237**Example**
6238
6239```ts
6240import { BusinessError } from '@kit.BasicServicesKit';
6241
6242let progressDetail = (progressDetail: relationalStore.ProgressDetails) => {
6243  console.info(`progress: ${progressDetail}`);
6244}
6245
6246try {
6247  if(store != undefined) {
6248    (store as relationalStore.RdbStore).on('autoSyncProgress', progressDetail)
6249  }
6250} catch (err) {
6251  let code = (err as BusinessError).code;
6252  let message = (err as BusinessError).message
6253  console.error(`Register observer failed, code is ${code},message is ${message}`);
6254}
6255```
6256
6257### on('statistics')<sup>12+</sup>
6258
6259on(event: 'statistics', observer: Callback&lt;SqlExecutionInfo&gt;): void
6260
6261Subscribes to SQL statistics.
6262
6263**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6264
6265**Parameters**
6266
6267| Name      | Type                             | Mandatory| Description                               |
6268| ------------ |---------------------------------| ---- |-----------------------------------|
6269| event        | string                          | Yes  | Event type. The value is **'statistics'**, which indicates the statistics of the SQL execution time.|
6270| observer     | Callback&lt;[SqlExecutionInfo](#sqlexecutioninfo12)&gt; | Yes  | Callback used to return the statistics about the SQL execution time in the database. |
6271
6272**Error codes**
6273
6274For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6275
6276| **ID**| **Error Message**   |
6277|-----------|--------|
6278| 401       | Parameter error. Possible causes: 1.Mandatory parameters are left unspecified; 2.Incorrect parameter types. |
6279| 801       | Capability not supported.  |
6280| 14800000  | Inner error.  |
6281| 14800014  | Already closed.     |
6282
6283**Example**
6284
6285```ts
6286import { BusinessError } from '@kit.BasicServicesKit';
6287
6288let sqlExecutionInfo = (sqlExecutionInfo: relationalStore.SqlExecutionInfo) => {
6289  console.info(`sql: ${sqlExecutionInfo.sql[0]}`);
6290  console.info(`totalTime: ${sqlExecutionInfo.totalTime}`);
6291  console.info(`waitTime: ${sqlExecutionInfo.waitTime}`);
6292  console.info(`prepareTime: ${sqlExecutionInfo.prepareTime}`);
6293  console.info(`executeTime: ${sqlExecutionInfo.executeTime}`);
6294}
6295
6296try {
6297  if(store != undefined) {
6298    (store as relationalStore.RdbStore).on('statistics', sqlExecutionInfo);
6299  }
6300} catch (err) {
6301  let code = (err as BusinessError).code;
6302  let message = (err as BusinessError).message;
6303  console.error(`Register observer failed, code is ${code},message is ${message}`);
6304}
6305
6306try {
6307  let value1 = "Lisa";
6308  let value2 = 18;
6309  let value3 = 100.5;
6310  let value4 = new Uint8Array([1, 2, 3, 4, 5]);
6311
6312  const valueBucket: relationalStore.ValuesBucket = {
6313    'NAME': value1,
6314    'AGE': value2,
6315    'SALARY': value3,
6316    'CODES': value4,
6317  };
6318  if(store != undefined) {
6319    (store as relationalStore.RdbStore).insert('test', valueBucket);
6320  }
6321} catch (err) {
6322  console.error(`insert fail, code:${err.code}, message: ${err.message}`);
6323}
6324```
6325
6326### off('dataChange')
6327
6328off(event:'dataChange', type: SubscribeType, observer: Callback&lt;Array&lt;string&gt;&gt;): void
6329
6330Unsubscribes from data changes of the specified devices.
6331
6332**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6333
6334**Parameters**
6335
6336| Name  | Type                                                        | Mandatory| Description                                                        |
6337| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
6338| event    | string                                                       | Yes  | Event type. The value is **'dataChange'**, which indicates data changes.                          |
6339| type     | [SubscribeType](#subscribetype) | Yes  | Type of data change to observe.                                                  |
6340| 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.|
6341
6342**Error codes**
6343
6344For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6345
6346| **ID**| **Error Message**       |
6347|-----------|-------------|
6348| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
6349| 801       | Capability not supported. |
6350| 14800014  | Already closed.    |
6351
6352**Example**
6353
6354```ts
6355import { BusinessError } from '@kit.BasicServicesKit';
6356
6357let storeObserver = (devices: Array<string>) => {
6358  if (devices != undefined) {
6359    for (let i = 0; i < devices.length; i++) {
6360      console.info(`device= ${devices[i]} data changed`);
6361    }
6362  }
6363}
6364
6365try {
6366  if (store != undefined) {
6367    // The Lambda expression cannot be used here.
6368    (store as relationalStore.RdbStore).on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver)
6369  }
6370} catch (err) {
6371    let code = (err as BusinessError).code;
6372    let message = (err as BusinessError).message
6373    console.error(`Register observer failed, code is ${code},message is ${message}`);
6374}
6375
6376try {
6377  if(store != undefined) {
6378    (store as relationalStore.RdbStore).off('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver);
6379  }
6380} catch (err) {
6381  let code = (err as BusinessError).code;
6382  let message = (err as BusinessError).message
6383  console.error(`Unregister observer failed, code is ${code},message is ${message}`);
6384}
6385```
6386
6387### off('dataChange')<sup>10+</sup>
6388
6389off(event:'dataChange', type: SubscribeType, observer?: Callback&lt;Array&lt;string&gt;&gt;\| Callback&lt;Array&lt;ChangeInfo&gt;&gt;): void
6390
6391Unsubscribes from data changes of this RDB store.
6392
6393**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6394
6395**Parameters**
6396
6397| Name  | Type                               | Mandatory| Description                                       |
6398| -------- | ---------------------------------- | ---- | ------------------------------------------ |
6399| event    | string                              | Yes  | Event type. The value is **'dataChange'**, which indicates data changes.         |
6400| type     | [SubscribeType](#subscribetype)     | Yes  | Type of data change to observe.                                |
6401| 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**.|
6402
6403**Error codes**
6404
6405For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6406
6407| **ID**| **Error Message**       |
6408|-----------|-------------|
6409| 202       | Permission verification failed, application which is not a system application uses system API. |
6410| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
6411| 801       | Capability not supported. |
6412| 14800014  | Already closed.    |
6413
6414**Example**
6415
6416```ts
6417import { distributedDeviceManager } from '@kit.DistributedServiceKit';
6418import { BusinessError } from '@kit.BasicServicesKit';
6419
6420let storeObserver = (devices: Array<string>) => {
6421  if (devices != undefined) {
6422    for (let i = 0; i < devices.length; i++) {
6423      console.info(`device= ${devices[i]} data changed`);
6424    }
6425  }
6426}
6427
6428try {
6429  if(store != undefined) {
6430    (store as relationalStore.RdbStore).on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver);
6431  }
6432} catch (err) {
6433  let code = (err as BusinessError).code;
6434  let message = (err as BusinessError).message;
6435  console.error(`Register observer failed, code is ${code},message is ${message}`);
6436}
6437
6438try {
6439  if(store != undefined) {
6440    (store as relationalStore.RdbStore).off('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver);
6441  }
6442} catch (err) {
6443  let code = (err as BusinessError).code;
6444  let message = (err as BusinessError).message
6445  console.error(`Unregister observer failed, code is ${code},message is ${message}`);
6446}
6447```
6448
6449### off<sup>10+</sup>
6450
6451off(event: string, interProcess: boolean, observer?: Callback\<void>): void
6452
6453Unsubscribes from process events.
6454
6455**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6456
6457**Parameters**
6458
6459| Name      | Type           | Mandatory| Description                                                        |
6460| ------------ | --------------- | ---- | ------------------------------------------------------------ |
6461| event        | string          | Yes  | Name of the event.                                          |
6462| 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.|
6463| observer     | Callback\<void> | No  | Callback to unregister. If this parameter is not specified, this API unregisters all callbacks for the specified event.|
6464
6465**Error codes**
6466
6467For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6468
6469| **ID**| **Error Message**                          |
6470| ------------ | -------------------------------------- |
6471| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
6472| 801       | Capability not supported. |
6473| 14800000     | Inner error.                           |
6474| 14800014  | Already closed.    |
6475| 14800050     | Failed to obtain subscription service. |
6476
6477**Example**
6478
6479```ts
6480import { BusinessError } from '@kit.BasicServicesKit';
6481
6482let storeObserver = () => {
6483  console.info(`storeObserver`);
6484}
6485
6486try {
6487  if(store != undefined) {
6488    (store as relationalStore.RdbStore).on('storeObserver', false, storeObserver);
6489  }
6490} catch (err) {
6491  let code = (err as BusinessError).code;
6492  let message = (err as BusinessError).message
6493  console.error(`Register observer failed, code is ${code},message is ${message}`);
6494}
6495
6496try {
6497  if(store != undefined) {
6498    (store as relationalStore.RdbStore).off('storeObserver', false, storeObserver);
6499  }
6500} catch (err) {
6501  let code = (err as BusinessError).code;
6502  let message = (err as BusinessError).message
6503  console.error(`Unregister observer failed, code is ${code},message is ${message}`);
6504}
6505```
6506
6507### off('autoSyncProgress')<sup>11+</sup>
6508
6509off(event: 'autoSyncProgress', progress?: Callback&lt;ProgressDetails&gt;): void
6510
6511Unsubscribes from the auto sync progress.
6512
6513**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6514
6515**Parameters**
6516
6517| Name      | Type                             | Mandatory| Description                                                              |
6518| ------------ |---------------------------------| ---- |------------------------------------------------------------------|
6519| event        | string                          | Yes  | Event type. The value is **'autoSyncProgress'**, which indicates the auto sync progress.                               |
6520| 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.|
6521
6522**Error codes**
6523
6524For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6525
6526| **ID**| **Error Message**        |
6527| ------------ |--------------------|
6528| 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. |
6529| 801       | Capability not supported.  |
6530| 14800014  | Already closed.       |
6531
6532**Example**
6533
6534```ts
6535import { BusinessError } from '@kit.BasicServicesKit';
6536
6537let progressDetail = (progressDetail: relationalStore.ProgressDetails) => {
6538  console.info(`progress: ${progressDetail}`);
6539}
6540
6541try {
6542  if(store != undefined) {
6543    (store as relationalStore.RdbStore).on('autoSyncProgress', progressDetail)
6544  }
6545} catch (err) {
6546  let code = (err as BusinessError).code;
6547  let message = (err as BusinessError).message
6548  console.error(`Register observer failed, code is ${code},message is ${message}`);
6549}
6550
6551try {
6552  if(store != undefined) {
6553    (store as relationalStore.RdbStore).off('autoSyncProgress', progressDetail);
6554  }
6555} catch (err) {
6556  let code = (err as BusinessError).code;
6557  let message = (err as BusinessError).message;
6558  console.error(`Unregister failed, code is ${code},message is ${message}`);
6559}
6560```
6561
6562### off('statistics')<sup>12+</sup>
6563
6564off(event: 'statistics', observer?: Callback&lt;SqlExecutionInfo&gt;): void
6565
6566Unsubscribes from SQL statistics.
6567
6568**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6569
6570**Parameters**
6571
6572| Name      | Type                             | Mandatory| Description                               |
6573| ------------ |---------------------------------| ---- |-----------------------------------|
6574| event        | string                          | Yes  | Event type. The value is **'statistics'**, which indicates the statistics of the SQL execution time.|
6575| 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. |
6576
6577
6578**Error codes**
6579
6580For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6581
6582| **ID**| **Error Message**   |
6583|-----------|--------|
6584| 401       | Parameter error.  |
6585| 801       | Capability not supported.  |
6586| 14800000  | Inner error.  |
6587| 14800014  | Already closed.     |
6588
6589```ts
6590import { BusinessError } from '@kit.BasicServicesKit';
6591
6592try {
6593  if(store != undefined) {
6594    (store as relationalStore.RdbStore).off('statistics');
6595  }
6596} catch (err) {
6597  let code = (err as BusinessError).code;
6598  let message = (err as BusinessError).message;
6599  console.error(`Unregister observer failed, code is ${code},message is ${message}`);
6600}
6601```
6602
6603### emit<sup>10+</sup>
6604
6605emit(event: string): void
6606
6607Triggers the inter-process or intra-process event listener registered in [on](#on10).
6608
6609**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6610
6611**Parameters**
6612
6613| Name| Type  | Mandatory| Description                |
6614| ------ | ------ | ---- | -------------------- |
6615| event  | string | Yes  | Name of the event.|
6616
6617**Error codes**
6618
6619For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
6620
6621| **ID**| **Error Message**                                                                                                     |
6622| --------- |---------------------------------------------------------------------------------------------------------------|
6623| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
6624| 801       | Capability not supported.     |
6625| 14800000  | Inner error.   |
6626| 14800014  | Already closed.     |
6627| 14800050  | Failed to obtain subscription service.    |
6628
6629
6630**Example**
6631
6632```ts
6633if(store != undefined) {
6634  (store as relationalStore.RdbStore).emit('storeObserver');
6635}
6636```
6637
6638### cleanDirtyData<sup>11+</sup>
6639
6640cleanDirtyData(table: string, cursor: number, callback: AsyncCallback&lt;void&gt;): void
6641
6642Clears 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.
6643
6644**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
6645
6646**Parameters**
6647
6648| Name  | Type                                                 | Mandatory| Description                                              |
6649| -------- | ----------------------------------------------------- | ---- | -------------------------------------------------- |
6650| table     | string                        | Yes  | Name of the table in the RDB store.                            |
6651| 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.    |
6652| callback  | AsyncCallback&lt;void&gt;     | Yes  | Callback used to return the result.|
6653
6654**Error codes**
6655
6656For 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).
6657
6658| **ID**| **Error Message**    |
6659|-----------|---------------|
6660| 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. |
6661| 801       | Capability not supported. |
6662| 14800000  | Inner error. |
6663| 14800011  | Database corrupted. |
6664| 14800014  | Already closed. |
6665| 14800015  | The database does not respond. |
6666| 14800021  | SQLite: Generic error. |
6667| 14800022  | SQLite: Callback routine requested an abort. |
6668| 14800023  | SQLite: Access permission denied. |
6669| 14800024  | SQLite: The database file is locked. |
6670| 14800025  | SQLite: A table in the database is locked. |
6671| 14800026  | SQLite: The database is out of memory. |
6672| 14800027  | SQLite: Attempt to write a readonly database. |
6673| 14800028  | SQLite: Some kind of disk I/O error occurred. |
6674| 14800029  | SQLite: The database is full. |
6675| 14800030  | SQLite: Unable to open the database file. |
6676| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
6677| 14800032  | SQLite: Abort due to constraint violation. |
6678| 14800033  | SQLite: Data type mismatch. |
6679| 14800034  | SQLite: Library used incorrectly. |
6680
6681**Example**
6682
6683```ts
6684if(store != undefined) {
6685 (store as relationalStore.RdbStore).cleanDirtyData('test_table', 100, (err) => {
6686    if (err) {
6687      console.error(`clean dirty data failed, code is ${err.code},message is ${err.message}`);
6688      return;
6689    }
6690    console.info('clean dirty data succeeded');
6691  })
6692}
6693```
6694
6695### cleanDirtyData<sup>11+</sup>
6696
6697cleanDirtyData(table: string, callback: AsyncCallback&lt;void&gt;): void
6698
6699Clears all dirty data from the local device. The dirty data is the data that has been deleted from the cloud.
6700
6701**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
6702
6703**Parameters**
6704
6705| Name  | Type                                                 | Mandatory| Description                                              |
6706| -------- | ----------------------------------------------------- | ---- | -------------------------------------------------- |
6707| table     | string                        | Yes  | Name of the table in the RDB store.|
6708| callback  | AsyncCallback&lt;void&gt;     | Yes  | Callback used to return the result.|
6709
6710**Error codes**
6711
6712For 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).
6713
6714| **ID**| **Error Message**      |
6715|-----------|---------|
6716| 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. |
6717| 801       | Capability not supported.    |
6718| 14800000  | Inner error.        |
6719| 14800011  | Database corrupted.   |
6720| 14800014  | Already closed.       |
6721| 14800015  | The database does not respond.      |
6722| 14800021  | SQLite: Generic error.     |
6723| 14800022  | SQLite: Callback routine requested an abort. |
6724| 14800023  | SQLite: Access permission denied.           |
6725| 14800024  | SQLite: The database file is locked.        |
6726| 14800025  | SQLite: A table in the database is locked.  |
6727| 14800026  | SQLite: The database is out of memory.      |
6728| 14800027  | SQLite: Attempt to write a readonly database.   |
6729| 14800028  | SQLite: Some kind of disk I/O error occurred.  |
6730| 14800029  | SQLite: The database is full.                |
6731| 14800030  | SQLite: Unable to open the database file.            |
6732| 14800031  | SQLite: TEXT or BLOB exceeds size limit.             |
6733| 14800032  | SQLite: Abort due to constraint violation.   |
6734| 14800033  | SQLite: Data type mismatch.                  |
6735| 14800034  | SQLite: Library used incorrectly.          |
6736
6737**Example**
6738
6739```ts
6740if(store != undefined) {
6741  (store as relationalStore.RdbStore).cleanDirtyData('test_table', (err) => {
6742    if (err) {
6743      console.error(`clean dirty data failed, code is ${err.code},message is ${err.message}`);
6744      return;
6745    }
6746    console.info('clean dirty data succeeded');
6747  })
6748}
6749```
6750
6751### cleanDirtyData<sup>11+</sup>
6752
6753cleanDirtyData(table: string, cursor?: number): Promise&lt;void&gt;
6754
6755Clears 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.
6756
6757**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
6758
6759**Parameters**
6760
6761| Name  | Type                                                 | Mandatory| Description                                              |
6762| -------- | ----------------------------------------------------- | ---- | -------------------------------------------------- |
6763| table     | string           | Yes  | Name of the table in the RDB store.          |
6764| 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.|
6765
6766**Return value**
6767| Name   | Description                                              |
6768| -------- | ------------------------------------------------- |
6769| Promise\<void> | Promise that returns no value.       |
6770
6771**Error codes**
6772
6773For 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).
6774
6775| **ID**| **Error Message**                                                                                                                                                                     |
6776|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
6777| 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. |
6778| 801       | Capability not supported. |
6779| 14800000  | Inner error.            |
6780| 14800011  | Database corrupted.   |
6781| 14800014  | Already closed. |
6782| 14800015  | The database does not respond.   |
6783| 14800021  | SQLite: Generic error.   |
6784| 14800022  | SQLite: Callback routine requested an abort. |
6785| 14800023  | SQLite: Access permission denied.          |
6786| 14800024  | SQLite: The database file is locked.      |
6787| 14800025  | SQLite: A table in the database is locked. |
6788| 14800026  | SQLite: The database is out of memory.   |
6789| 14800027  | SQLite: Attempt to write a readonly database. |
6790| 14800028  | SQLite: Some kind of disk I/O error occurred. |
6791| 14800029  | SQLite: The database is full.   |
6792| 14800030  | SQLite: Unable to open the database file. |
6793| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
6794| 14800032  | SQLite: Abort due to constraint violation. |
6795| 14800033  | SQLite: Data type mismatch. |
6796| 14800034  | SQLite: Library used incorrectly. |
6797
6798**Example**
6799
6800```ts
6801import { BusinessError } from '@kit.BasicServicesKit';
6802
6803if(store != undefined) {
6804    (store as relationalStore.RdbStore).cleanDirtyData('test_table', 100).then(() => {
6805        console.info('clean dirty data  succeeded');
6806    }).catch ((err: BusinessError) => {
6807        console.error(`clean dirty data failed, code is ${err.code},message is ${err.message}`);
6808    })
6809}
6810```
6811
6812### attach<sup>12+</sup>
6813
6814attach(fullPath: string, attachName: string, waitTime?: number) : Promise&lt;number&gt;
6815
6816Attaches an RDB store to this RDB store so that the data in the attached RDB store can be directly accessed using the SQL statement.
6817
6818The 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.
6819
6820Before 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.
6821
6822The **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.
6823
6824**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6825
6826**Parameters**
6827
6828| Name       | Type    | Mandatory | Description          |
6829| ----------- | ------ | --- | ------------ |
6830| fullPath | string | Yes  | Path of the database file to attach.|
6831| attachName | string | Yes  | Alias of the RDB store formed after the attach operation.|
6832| waitTime | number | No  | Maximum time period (in seconds) allowed for attaching the database file. <br>Value range: 1 to 300<br>Default value: 2|
6833
6834**Return value**
6835
6836| Type             | Description                          |
6837| ---------------- | ---------------------------- |
6838|  Promise&lt;number&gt; | Promise used to return the number of attached RDB stores.|
6839
6840**Error codes**
6841
6842For 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).
6843
6844| **ID**| **Error Message**                                                |
6845|-----------| ------------------------------------------------------------ |
6846| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
6847| 801       | Capability not supported. |
6848| 14800000  | Inner error. |
6849| 14800010  | Invalid database path.               |
6850| 14800011  | Database corrupted. |
6851| 14800014  | Already closed. |
6852| 14800015  | The database does not respond.                 |
6853| 14800016  | The database is already attached.                |
6854| 14800021  | SQLite: Generic error. |
6855| 14800022  | SQLite: Callback routine requested an abort. |
6856| 14800023  | SQLite: Access permission denied. |
6857| 14800024  | SQLite: The database file is locked. |
6858| 14800025  | SQLite: A table in the database is locked. |
6859| 14800026  | SQLite: The database is out of memory. |
6860| 14800027  | SQLite: Attempt to write a readonly database. |
6861| 14800028  | SQLite: Some kind of disk I/O error occurred. |
6862| 14800029  | SQLite: The database is full. |
6863| 14800030  | SQLite: Unable to open the database file. |
6864| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
6865| 14800032  | SQLite: Abort due to constraint violation. |
6866| 14800033  | SQLite: Data type mismatch. |
6867| 14800034  | SQLite: Library used incorrectly. |
6868
6869**Example**
6870
6871```ts
6872// Attach a non-encrypted RDB store to a non-encrypted RDB store.
6873import { BusinessError } from '@kit.BasicServicesKit';
6874
6875if(store != undefined) {
6876    (store as relationalStore.RdbStore).attach("/path/rdbstore1.db", "attachDB").then((number: number) => {
6877        console.info('attach succeeded');
6878    }).catch ((err: BusinessError) => {
6879        console.error(`attach failed, code is ${err.code},message is ${err.message}`);
6880    })
6881}
6882```
6883
6884### attach<sup>12+</sup>
6885
6886attach(context: Context, config: StoreConfig, attachName: string, waitTime?: number) : Promise&lt;number&gt;
6887
6888Attaches an RDB store to this RDB store so that the data in the attached RDB store can be directly accessed using the SQL statement.
6889
6890This 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.
6891
6892Before 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.
6893
6894The **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.
6895
6896**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
6897
6898**Parameters**
6899
6900| Name       | Type    | Mandatory | Description          |
6901| ----------- | ------ | --- | ------------ |
6902| 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).|
6903| config  | [StoreConfig](#storeconfig) | Yes  | Configuration of the RDB store to attach.                               |
6904| attachName | string | Yes  | Alias of the RDB store formed after the attach operation.|
6905| waitTime | number | No  | Maximum time period (in seconds) allowed for attaching the database file. <br>Value range: 1 to 300<br>Default value: 2|
6906
6907**Return value**
6908
6909| Type             | Description                          |
6910| ---------------- | ---------------------------- |
6911|  Promise&lt;number&gt; | Promise used to return the number of attached RDB stores.|
6912
6913**Error codes**
6914
6915For 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).
6916
6917| **ID**| **Error Message**                                                |
6918|-----------| ------------------------------------------------------------ |
6919| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
6920| 801       | Capability not supported. |
6921| 14800000  | Inner error. |
6922| 14800010  | Invalid database path.               |
6923| 14800011  | Database corrupted. |
6924| 14800014  | Already closed. |
6925| 14800015  | The database does not respond.                 |
6926| 14800016  | The database is already attached.                |
6927| 14801001  | Only supported in stage mode.                 |
6928| 14801002  | The data group id is not valid.                |
6929| 14800021  | SQLite: Generic error. |
6930| 14800022  | SQLite: Callback routine requested an abort. |
6931| 14800023  | SQLite: Access permission denied. |
6932| 14800024  | SQLite: The database file is locked. |
6933| 14800025  | SQLite: A table in the database is locked. |
6934| 14800026  | SQLite: The database is out of memory. |
6935| 14800027  | SQLite: Attempt to write a readonly database. |
6936| 14800028  | SQLite: Some kind of disk I/O error occurred. |
6937| 14800029  | SQLite: The database is full. |
6938| 14800030  | SQLite: Unable to open the database file. |
6939| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
6940| 14800032  | SQLite: Abort due to constraint violation. |
6941| 14800033  | SQLite: Data type mismatch. |
6942| 14800034  | SQLite: Library used incorrectly. |
6943
6944Example 1: Attach a non-encrypted RDB store to a non-encrypted RDB store.
6945
6946```ts
6947import { BusinessError } from '@kit.BasicServicesKit';
6948
6949let attachStore: relationalStore.RdbStore | undefined = undefined;
6950
6951const STORE_CONFIG1: relationalStore.StoreConfig = {
6952    name: "rdbstore1.db",
6953    securityLevel: relationalStore.SecurityLevel.S3,
6954}
6955
6956relationalStore.getRdbStore(this.context, STORE_CONFIG1).then(async (rdbStore: relationalStore.RdbStore) => {
6957    attachStore = rdbStore;
6958    console.info('Get RdbStore successfully.')
6959}).catch((err: BusinessError) => {
6960    console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
6961})
6962
6963if(store != undefined) {
6964    (store as relationalStore.RdbStore).attach(this.context, STORE_CONFIG1, "attachDB").then((number: number) => {
6965        console.info(`attach succeeded, number is ${number}`);
6966    }).catch ((err: BusinessError) => {
6967        console.error(`attach failed, code is ${err.code},message is ${err.message}`);
6968    })
6969}
6970```
6971
6972Example 2: Attach an encrypted RDB store to a non-encrypted RDB store.
6973
6974```ts
6975import { BusinessError } from '@kit.BasicServicesKit';
6976
6977let attachStore: relationalStore.RdbStore | undefined = undefined;
6978
6979
6980const STORE_CONFIG2: relationalStore.StoreConfig = {
6981    name: "rdbstore2.db",
6982    encrypt: true,
6983    securityLevel: relationalStore.SecurityLevel.S3,
6984}
6985
6986relationalStore.getRdbStore(this.context, STORE_CONFIG2).then(async (rdbStore: relationalStore.RdbStore) => {
6987    attachStore = rdbStore;
6988    console.info('Get RdbStore successfully.')
6989}).catch((err: BusinessError) => {
6990    console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
6991})
6992
6993if(store != undefined) {
6994    (store as relationalStore.RdbStore).attach(this.context, STORE_CONFIG2, "attachDB2", 10).then((number: number) => {
6995        console.info(`attach succeeded, number is ${number}`);
6996    }).catch ((err: BusinessError) => {
6997        console.error(`attach failed, code is ${err.code},message is ${err.message}`);
6998    })
6999}
7000```
7001
7002### detach<sup>12+</sup>
7003
7004detach(attachName: string, waitTime?: number) : Promise&lt;number&gt;
7005
7006Detaches an RDB store from this RDB store.
7007
7008After all attached RDB stores are detached, the RDB is switched to the WAL mode.
7009
7010Before 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.
7011
7012**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7013
7014**Parameters**
7015
7016| Name       | Type    | Mandatory | Description          |
7017| ----------- | ------ | --- | ------------ |
7018| attachName | string | Yes  | Alias of the RDB store formed after the attach operation.|
7019| waitTime | number | No  | Maximum time period (in seconds) allowed for detaching the RDB store. <br>Value range: 1 to 300<br>Default value: 2|
7020
7021**Return value**
7022
7023| Type             | Description                          |
7024| ---------------- | ---------------------------- |
7025|  Promise&lt;number&gt; | Promise used to return the number of remaining attached RDB stores.|
7026
7027**Error codes**
7028
7029For 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).
7030
7031| **ID**| **Error Message**      |
7032|-----------|------------------------|
7033| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7034| 14800000  | Inner error.            |
7035| 14800011  | Database corrupted.         |
7036| 14800014  | Already closed.        |
7037| 14800015  | The database does not respond.         |
7038| 14800021  | SQLite: Generic error.            |
7039| 14800022  | SQLite: Callback routine requested an abort.       |
7040| 14800023  | SQLite: Access permission denied.           |
7041| 14800024  | SQLite: The database file is locked.        |
7042| 14800025  | SQLite: A table in the database is locked.       |
7043| 14800026  | SQLite: The database is out of memory.     |
7044| 14800027  | SQLite: Attempt to write a readonly database.        |
7045| 14800028  | SQLite: Some kind of disk I/O error occurred.    |
7046| 14800029  | SQLite: The database is full.      |
7047| 14800030  | SQLite: Unable to open the database file.       |
7048| 14800031  | SQLite: TEXT or BLOB exceeds size limit.      |
7049| 14800032  | SQLite: Abort due to constraint violation.    |
7050| 14800033  | SQLite: Data type mismatch.       |
7051| 14800034  | SQLite: Library used incorrectly.       |
7052
7053**Example**
7054
7055```ts
7056import { BusinessError } from '@kit.BasicServicesKit';
7057
7058if(store != undefined) {
7059    (store as relationalStore.RdbStore).detach("attachDB").then((number: number) => {
7060        console.info(`detach succeeded, number is ${number}`);
7061    }).catch ((err: BusinessError) => {
7062        console.error(`detach failed, code is ${err.code},message is ${err.message}`);
7063    })
7064}
7065```
7066
7067### lockRow<sup>12+</sup>
7068
7069lockRow(predicates: RdbPredicates):Promise&lt;void&gt;
7070
7071Locks data in this RDB store. This API uses a promise to return the result. The locked data is blocked from device-cloud sync.
7072
7073This 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.
7074This 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.
7075This API cannot be used for deleted data.
7076
7077**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7078
7079**Parameters**
7080
7081| Name    | Type                                | Mandatory| Description                                     |
7082| ---------- | ------------------------------------ | ---- | ----------------------------------------- |
7083| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Conditions for locking data.|
7084
7085**Return value**
7086
7087| Type                 | Description                           |
7088| --------------------- | ------------------------------- |
7089| Promise&lt;void&gt;   | Promise that returns no value.       |
7090
7091**Error codes**
7092
7093For 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).
7094
7095| **ID**| **Error Message**                                                                                    |
7096|-----------|----------------------------------------------------------------------------------------------|
7097| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7098| 14800000  | Inner error.                                                                                 |
7099| 14800011  | Database corrupted.                                                                          |
7100| 14800014  | Already closed.                                                                              |
7101| 14800015  | The database does not respond.                                                                        |
7102| 14800018  | No data meets the condition.                                                                 |
7103| 14800021  | SQLite: Generic error.                                                                       |
7104| 14800022  | SQLite: Callback routine requested an abort.                                                 |
7105| 14800023  | SQLite: Access permission denied.                                                            |
7106| 14800024  | SQLite: The database file is locked.                                                         |
7107| 14800025  | SQLite: A table in the database is locked.                                                   |
7108| 14800026  | SQLite: The database is out of memory.                                                       |
7109| 14800027  | SQLite: Attempt to write a readonly database.                                                |
7110| 14800028  | SQLite: Some kind of disk I/O error occurred.                                                |
7111| 14800029  | SQLite: The database is full.                                                                |
7112| 14800030  | SQLite: Unable to open the database file.                                                    |
7113| 14800031  | SQLite: TEXT or BLOB exceeds size limit.                                                     |
7114| 14800032  | SQLite: Abort due to constraint violation.                                                   |
7115| 14800033  | SQLite: Data type mismatch.                                                                  |
7116| 14800034  | SQLite: Library used incorrectly.                                                            |
7117
7118**Example**
7119
7120```ts
7121import { BusinessError } from '@kit.BasicServicesKit';
7122
7123let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
7124predicates.equalTo("NAME", "Lisa");
7125if(store != undefined) {
7126  (store as relationalStore.RdbStore).lockRow(predicates).then(() => {
7127    console.info(`Lock success`);
7128  }).catch((err: BusinessError) => {
7129    console.error(`Lock failed, code is ${err.code},message is ${err.message}`);
7130  })
7131}
7132```
7133
7134### unlockRow<sup>12+</sup>
7135
7136unlockRow(predicates: RdbPredicates):Promise&lt;void&gt;
7137
7138Unlocks data in this RDB store. This API uses a promise to return the result.
7139
7140This 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.
7141This 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.
7142This API cannot be used for deleted data.
7143
7144**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7145
7146**Parameters**
7147
7148| Name    | Type                                | Mandatory| Description                                     |
7149| ---------- | ------------------------------------ | ---- | ----------------------------------------- |
7150| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Conditions for unlocking data.|
7151
7152**Return value**
7153
7154| Type                 | Description                           |
7155| --------------------- | ------------------------------- |
7156| Promise&lt;void&gt;   | Promise that returns no value.       |
7157
7158**Error codes**
7159
7160For 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).
7161
7162| **ID**| **Error Message**                                                |
7163|-----------| ------------------------------------------------------------ |
7164| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7165| 14800000  | Inner error. |
7166| 14800011  | Database corrupted. |
7167| 14800014  | Already closed. |
7168| 14800015  | The database does not respond.                 |
7169| 14800018  | No data meets the condition.                |
7170| 14800021  | SQLite: Generic error. |
7171| 14800022  | SQLite: Callback routine requested an abort. |
7172| 14800023  | SQLite: Access permission denied. |
7173| 14800024  | SQLite: The database file is locked. |
7174| 14800025  | SQLite: A table in the database is locked. |
7175| 14800026  | SQLite: The database is out of memory. |
7176| 14800027  | SQLite: Attempt to write a readonly database. |
7177| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7178| 14800029  | SQLite: The database is full. |
7179| 14800030  | SQLite: Unable to open the database file. |
7180| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7181| 14800032  | SQLite: Abort due to constraint violation. |
7182| 14800033  | SQLite: Data type mismatch. |
7183| 14800034  | SQLite: Library used incorrectly. |
7184
7185**Example**
7186
7187```ts
7188import { BusinessError } from '@kit.BasicServicesKit';
7189
7190let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
7191predicates.equalTo("NAME", "Lisa");
7192if(store != undefined) {
7193  (store as relationalStore.RdbStore).unlockRow(predicates).then(() => {
7194    console.info(`Unlock success`);
7195  }).catch((err: BusinessError) => {
7196    console.error(`Unlock failed, code is ${err.code},message is ${err.message}`);
7197  })
7198}
7199```
7200
7201### queryLockedRow<sup>12+</sup>
7202
7203queryLockedRow(predicates: RdbPredicates, columns?: Array&lt;string&gt;):Promise&lt;ResultSet&gt;
7204
7205Queries the locked data in this RDB store. This API uses a promise to return the result.
7206Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
7207
7208**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7209
7210**Parameters**
7211
7212| Name    | Type                                | Mandatory| Description                                            |
7213| ---------- | ------------------------------------ | ---- | ------------------------------------------------ |
7214| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Query conditions specified by the **RdbPredicates** object.       |
7215| columns    | Array&lt;string&gt;                  | No  | Columns to query. If this parameter is not specified, the query applies to all columns.|
7216
7217**Error codes**
7218
7219For 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).
7220
7221| **ID**| **Error Message**                                                |
7222|-----------| ------------------------------------------------------------ |
7223| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7224| 14800000  | Inner error. |
7225| 14800011  | Database corrupted. |
7226| 14800014  | Already closed. |
7227| 14800015  | The database does not respond.                 |
7228| 14800021  | SQLite: Generic error. |
7229| 14800022  | SQLite: Callback routine requested an abort. |
7230| 14800023  | SQLite: Access permission denied. |
7231| 14800024  | SQLite: The database file is locked. |
7232| 14800025  | SQLite: A table in the database is locked. |
7233| 14800026  | SQLite: The database is out of memory. |
7234| 14800027  | SQLite: Attempt to write a readonly database. |
7235| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7236| 14800029  | SQLite: The database is full. |
7237| 14800030  | SQLite: Unable to open the database file. |
7238| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7239| 14800032  | SQLite: Abort due to constraint violation. |
7240| 14800033  | SQLite: Data type mismatch. |
7241| 14800034  | SQLite: Library used incorrectly. |
7242
7243**Return value**
7244
7245| Type                                                   | Description                                              |
7246| ------------------------------------------------------- | -------------------------------------------------- |
7247| Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
7248
7249**Example**
7250
7251```ts
7252import { BusinessError } from '@kit.BasicServicesKit';
7253
7254let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
7255predicates.equalTo("NAME", "Rose");
7256if(store != undefined) {
7257  (store as relationalStore.RdbStore).queryLockedRow(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet: relationalStore.ResultSet) => {
7258    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
7259    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
7260    while (resultSet.goToNextRow()) {
7261      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
7262      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
7263      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
7264      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
7265      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
7266    }
7267    // Release the memory of resultSet. If the memory is not released, FD or memory leaks may occur.
7268    resultSet.close();
7269  }).catch((err: BusinessError) => {
7270    console.error(`Query failed, code is ${err.code},message is ${err.message}`);
7271  })
7272}
7273```
7274### close<sup>12+</sup>
7275
7276close(): Promise&lt;void&gt;
7277
7278Closes this RDB store. This API uses a promise to return the result.
7279
7280**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7281
7282**Return value**
7283
7284| Type               | Description         |
7285| ------------------- | ------------- |
7286| Promise&lt;void&gt; | Promise used to|
7287
7288**Error codes**
7289
7290For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
7291
7292| **ID**| **Error Message**                                   |
7293| ------------ | ----------------------------------------------- |
7294| 401          | Parameter error. The store must not be nullptr. |
7295| 14800000     | Inner error.                                    |
7296
7297**Example**
7298
7299```ts
7300import { BusinessError } from '@kit.BasicServicesKit';
7301
7302if(store != undefined) {
7303    (store as relationalStore.RdbStore).close().then(() => {
7304        console.info(`close succeeded`);
7305    }).catch ((err: BusinessError) => {
7306        console.error(`close failed, code is ${err.code},message is ${err.message}`);
7307    })
7308}
7309```
7310
7311## ResultSet
7312
7313Provides APIs to access the **resultSet** object returned by **query()**.
7314
7315### Usage
7316
7317Obtain the **resultSet** object first.
7318
7319**Example**
7320
7321<!--code_no_check-->
7322```ts
7323let resultSet: relationalStore.ResultSet | undefined = undefined;
7324let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
7325predicates.equalTo("AGE", 18);
7326if(store != undefined) {
7327  (store as relationalStore.RdbStore).query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((result: relationalStore.ResultSet) => {
7328    resultSet = result;
7329    console.info(`resultSet columnNames: ${resultSet.columnNames}`);
7330    console.info(`resultSet columnCount: ${resultSet.columnCount}`);
7331  });
7332}
7333```
7334
7335### Properties
7336
7337**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7338
7339| Name        | Type           | Mandatory| Description                            |
7340| ------------ | ------------------- | ---- | -------------------------------- |
7341| columnNames  | Array&lt;string&gt; | Yes  | Names of all columns in the result set.      |
7342| columnCount  | number              | Yes  | Number of columns in the result set.            |
7343| rowCount     | number              | Yes  | Number of rows in the result set.            |
7344| rowIndex     | number              | Yes  | Index of the current row in the result set.        |
7345| isAtFirstRow | boolean             | Yes  | Whether the cursor is in the first row of the result set.      |
7346| isAtLastRow  | boolean             | Yes  | Whether the cursor is in the last row of the result set.    |
7347| isEnded      | boolean             | Yes  | Whether the cursor is after the last row of the result set.|
7348| isStarted    | boolean             | Yes  | Whether the cursor has been moved.            |
7349| isClosed     | boolean             | Yes  | Whether the result set is closed.        |
7350
7351### getColumnIndex
7352
7353getColumnIndex(columnName: string): number
7354
7355Obtains the column index based on the column name.
7356
7357**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7358
7359**Parameters**
7360
7361| Name    | Type  | Mandatory| Description                      |
7362| ---------- | ------ | ---- | -------------------------- |
7363| columnName | string | Yes  | Column name.|
7364
7365**Return value**
7366
7367| Type  | Description              |
7368| ------ | ------------------ |
7369| number | Column index obtained.|
7370
7371**Error codes**
7372
7373For 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).
7374
7375| **ID**| **Error Message**                                                |
7376|-----------| ------------------------------------------------------------ |
7377| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7378| 14800000  | Inner error. |
7379| 14800011  | Database corrupted. |
7380| 14800013  | Column out of bounds. |
7381| 14800014  | Already closed. |
7382| 14800019  | The SQL must be a query statement. |
7383| 14800021  | SQLite: Generic error. |
7384| 14800022  | SQLite: Callback routine requested an abort. |
7385| 14800023  | SQLite: Access permission denied. |
7386| 14800024  | SQLite: The database file is locked. |
7387| 14800025  | SQLite: A table in the database is locked. |
7388| 14800026  | SQLite: The database is out of memory. |
7389| 14800027  | SQLite: Attempt to write a readonly database. |
7390| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7391| 14800029  | SQLite: The database is full. |
7392| 14800030  | SQLite: Unable to open the database file. |
7393| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7394| 14800032  | SQLite: Abort due to constraint violation. |
7395| 14800033  | SQLite: Data type mismatch. |
7396| 14800034  | SQLite: Library used incorrectly. |
7397
7398**Example**
7399
7400```ts
7401if(resultSet != undefined) {
7402  const id = (resultSet as relationalStore.ResultSet).getLong((resultSet as relationalStore.ResultSet).getColumnIndex("ID"));
7403  const name = (resultSet as relationalStore.ResultSet).getString((resultSet as relationalStore.ResultSet).getColumnIndex("NAME"));
7404  const age = (resultSet as relationalStore.ResultSet).getLong((resultSet as relationalStore.ResultSet).getColumnIndex("AGE"));
7405  const salary = (resultSet as relationalStore.ResultSet).getDouble((resultSet as relationalStore.ResultSet).getColumnIndex("SALARY"));
7406}
7407```
7408
7409### getColumnName
7410
7411getColumnName(columnIndex: number): string
7412
7413Obtains the column name based on the specified column index.
7414
7415**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7416
7417**Parameters**
7418
7419| Name     | Type  | Mandatory| Description                      |
7420| ----------- | ------ | ---- | -------------------------- |
7421| columnIndex | number | Yes  | Column index.|
7422
7423**Return value**
7424
7425| Type  | Description              |
7426| ------ | ------------------ |
7427| string | Column name obtained.|
7428
7429**Error codes**
7430
7431For 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).
7432
7433| **ID**| **Error Message**                                                |
7434|-----------| ------------------------------------------------------------ |
7435| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7436| 14800000  | Inner error. |
7437| 14800011  | Database corrupted. |
7438| 14800013  | Column out of bounds. |
7439| 14800014  | Already closed. |
7440| 14800019  | The SQL must be a query statement. |
7441| 14800021  | SQLite: Generic error. |
7442| 14800022  | SQLite: Callback routine requested an abort. |
7443| 14800023  | SQLite: Access permission denied. |
7444| 14800024  | SQLite: The database file is locked. |
7445| 14800025  | SQLite: A table in the database is locked. |
7446| 14800026  | SQLite: The database is out of memory. |
7447| 14800027  | SQLite: Attempt to write a readonly database. |
7448| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7449| 14800029  | SQLite: The database is full. |
7450| 14800030  | SQLite: Unable to open the database file. |
7451| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7452| 14800032  | SQLite: Abort due to constraint violation. |
7453| 14800033  | SQLite: Data type mismatch. |
7454| 14800034  | SQLite: Library used incorrectly. |
7455
7456**Example**
7457
7458```ts
7459if(resultSet != undefined) {
7460  const id = (resultSet as relationalStore.ResultSet).getColumnName(0);
7461  const name = (resultSet as relationalStore.ResultSet).getColumnName(1);
7462  const age = (resultSet as relationalStore.ResultSet).getColumnName(2);
7463}
7464```
7465
7466### goTo
7467
7468goTo(offset:number): boolean
7469
7470Moves the cursor to the row based on the specified offset.
7471
7472**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7473
7474**Parameters**
7475
7476| Name| Type  | Mandatory| Description                        |
7477| ------ | ------ | ---- | ---------------------------- |
7478| offset | number | Yes  | Offset relative to the current position.|
7479
7480**Return value**
7481
7482| Type   | Description                                         |
7483| ------- | --------------------------------------------- |
7484| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
7485
7486**Error codes**
7487
7488For 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).
7489
7490| **ID**| **Error Message**                                                |
7491|-----------| ------------------------------------------------------------ |
7492| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7493| 14800000  | Inner error. |
7494| 14800011  | Database corrupted. |
7495| 14800012  | Row out of bounds. |
7496| 14800014  | Already closed. |
7497| 14800019  | The SQL must be a query statement. |
7498| 14800021  | SQLite: Generic error. |
7499| 14800022  | SQLite: Callback routine requested an abort. |
7500| 14800023  | SQLite: Access permission denied. |
7501| 14800024  | SQLite: The database file is locked. |
7502| 14800025  | SQLite: A table in the database is locked. |
7503| 14800026  | SQLite: The database is out of memory. |
7504| 14800027  | SQLite: Attempt to write a readonly database. |
7505| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7506| 14800029  | SQLite: The database is full. |
7507| 14800030  | SQLite: Unable to open the database file. |
7508| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7509| 14800032  | SQLite: Abort due to constraint violation. |
7510| 14800033  | SQLite: Data type mismatch. |
7511| 14800034  | SQLite: Library used incorrectly. |
7512
7513**Example**
7514
7515```ts
7516if(resultSet != undefined) {
7517  (resultSet as relationalStore.ResultSet).goTo(1);
7518}
7519```
7520
7521### goToRow
7522
7523goToRow(position: number): boolean
7524
7525Moves to the specified row in the result set.
7526
7527**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7528
7529**Parameters**
7530
7531| Name  | Type  | Mandatory| Description                    |
7532| -------- | ------ | ---- | ------------------------ |
7533| position | number | Yes  | Destination position to move to.|
7534
7535**Return value**
7536
7537| Type   | Description                                         |
7538| ------- | --------------------------------------------- |
7539| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
7540
7541**Error codes**
7542
7543For 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).
7544
7545| **ID**| **Error Message**                                                |
7546|-----------| ------------------------------------------------------------ |
7547| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7548| 14800000  | Inner error. |
7549| 14800011  | Database corrupted. |
7550| 14800012  | Row out of bounds. |
7551| 14800014  | Already closed. |
7552| 14800019  | The SQL must be a query statement. |
7553| 14800021  | SQLite: Generic error. |
7554| 14800022  | SQLite: Callback routine requested an abort. |
7555| 14800023  | SQLite: Access permission denied. |
7556| 14800024  | SQLite: The database file is locked. |
7557| 14800025  | SQLite: A table in the database is locked. |
7558| 14800026  | SQLite: The database is out of memory. |
7559| 14800027  | SQLite: Attempt to write a readonly database. |
7560| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7561| 14800029  | SQLite: The database is full. |
7562| 14800030  | SQLite: Unable to open the database file. |
7563| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7564| 14800032  | SQLite: Abort due to constraint violation. |
7565| 14800033  | SQLite: Data type mismatch. |
7566| 14800034  | SQLite: Library used incorrectly. |
7567
7568**Example**
7569
7570```ts
7571if(resultSet != undefined) {
7572  (resultSet as relationalStore.ResultSet).goToRow(5);
7573}
7574```
7575
7576### goToFirstRow
7577
7578goToFirstRow(): boolean
7579
7580
7581Moves to the first row of the result set.
7582
7583**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7584
7585**Return value**
7586
7587| Type   | Description                                         |
7588| ------- | --------------------------------------------- |
7589| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
7590
7591**Error codes**
7592
7593For 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).
7594
7595| **ID**| **Error Message**                                                |
7596|-----------| ------------------------------------------------------------ |
7597| 14800000  | Inner error. |
7598| 14800011  | Database corrupted. |
7599| 14800012  | Row out of bounds. |
7600| 14800014  | Already closed. |
7601| 14800019  | The SQL must be a query statement. |
7602| 14800021  | SQLite: Generic error. |
7603| 14800022  | SQLite: Callback routine requested an abort. |
7604| 14800023  | SQLite: Access permission denied. |
7605| 14800024  | SQLite: The database file is locked. |
7606| 14800025  | SQLite: A table in the database is locked. |
7607| 14800026  | SQLite: The database is out of memory. |
7608| 14800027  | SQLite: Attempt to write a readonly database. |
7609| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7610| 14800029  | SQLite: The database is full. |
7611| 14800030  | SQLite: Unable to open the database file. |
7612| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7613| 14800032  | SQLite: Abort due to constraint violation. |
7614| 14800033  | SQLite: Data type mismatch. |
7615| 14800034  | SQLite: Library used incorrectly. |
7616
7617**Example**
7618
7619```ts
7620if(resultSet != undefined) {
7621  (resultSet as relationalStore.ResultSet).goToFirstRow();
7622}
7623```
7624
7625### goToLastRow
7626
7627goToLastRow(): boolean
7628
7629Moves to the last row of the result set.
7630
7631**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7632
7633**Return value**
7634
7635| Type   | Description                                         |
7636| ------- | --------------------------------------------- |
7637| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
7638
7639**Error codes**
7640
7641For 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).
7642
7643| **ID**| **Error Message**                                                |
7644|-----------| ------------------------------------------------------------ |
7645| 14800000  | Inner error. |
7646| 14800011  | Database corrupted. |
7647| 14800012  | Row out of bounds. |
7648| 14800014  | Already closed. |
7649| 14800019  | The SQL must be a query statement. |
7650| 14800021  | SQLite: Generic error. |
7651| 14800022  | SQLite: Callback routine requested an abort. |
7652| 14800023  | SQLite: Access permission denied. |
7653| 14800024  | SQLite: The database file is locked. |
7654| 14800025  | SQLite: A table in the database is locked. |
7655| 14800026  | SQLite: The database is out of memory. |
7656| 14800027  | SQLite: Attempt to write a readonly database. |
7657| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7658| 14800029  | SQLite: The database is full. |
7659| 14800030  | SQLite: Unable to open the database file. |
7660| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7661| 14800032  | SQLite: Abort due to constraint violation. |
7662| 14800033  | SQLite: Data type mismatch. |
7663| 14800034  | SQLite: Library used incorrectly. |
7664
7665**Example**
7666
7667```ts
7668if(resultSet != undefined) {
7669  (resultSet as relationalStore.ResultSet).goToLastRow();
7670}
7671```
7672
7673### goToNextRow
7674
7675goToNextRow(): boolean
7676
7677Moves to the next row in the result set.
7678
7679**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7680
7681**Return value**
7682
7683| Type   | Description                                         |
7684| ------- | --------------------------------------------- |
7685| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
7686
7687**Error codes**
7688
7689For 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).
7690
7691| **ID**| **Error Message**                                                |
7692|-----------| ------------------------------------------------------------ |
7693| 14800000  | Inner error. |
7694| 14800011  | Database corrupted. |
7695| 14800012  | Row out of bounds. |
7696| 14800014  | Already closed. |
7697| 14800019  | The SQL must be a query statement. |
7698| 14800021  | SQLite: Generic error. |
7699| 14800022  | SQLite: Callback routine requested an abort. |
7700| 14800023  | SQLite: Access permission denied. |
7701| 14800024  | SQLite: The database file is locked. |
7702| 14800025  | SQLite: A table in the database is locked. |
7703| 14800026  | SQLite: The database is out of memory. |
7704| 14800027  | SQLite: Attempt to write a readonly database. |
7705| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7706| 14800029  | SQLite: The database is full. |
7707| 14800030  | SQLite: Unable to open the database file. |
7708| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7709| 14800032  | SQLite: Abort due to constraint violation. |
7710| 14800033  | SQLite: Data type mismatch. |
7711| 14800034  | SQLite: Library used incorrectly. |
7712
7713**Example**
7714
7715```ts
7716if(resultSet != undefined) {
7717  (resultSet as relationalStore.ResultSet).goToNextRow();
7718}
7719```
7720
7721### goToPreviousRow
7722
7723goToPreviousRow(): boolean
7724
7725Moves to the previous row in the result set.
7726
7727**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7728
7729**Return value**
7730
7731| Type   | Description                                         |
7732| ------- | --------------------------------------------- |
7733| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
7734
7735**Error codes**
7736
7737For 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).
7738
7739| **ID**| **Error Message**                                                |
7740|-----------| ------------------------------------------------------------ |
7741| 14800000  | Inner error. |
7742| 14800011  | Database corrupted. |
7743| 14800012  | Row out of bounds. |
7744| 14800014  | Already closed. |
7745| 14800019  | The SQL must be a query statement. |
7746| 14800021  | SQLite: Generic error. |
7747| 14800022  | SQLite: Callback routine requested an abort. |
7748| 14800023  | SQLite: Access permission denied. |
7749| 14800024  | SQLite: The database file is locked. |
7750| 14800025  | SQLite: A table in the database is locked. |
7751| 14800026  | SQLite: The database is out of memory. |
7752| 14800027  | SQLite: Attempt to write a readonly database. |
7753| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7754| 14800029  | SQLite: The database is full. |
7755| 14800030  | SQLite: Unable to open the database file. |
7756| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7757| 14800032  | SQLite: Abort due to constraint violation. |
7758| 14800033  | SQLite: Data type mismatch. |
7759| 14800034  | SQLite: Library used incorrectly. |
7760
7761**Example**
7762
7763```ts
7764if(resultSet != undefined) {
7765  (resultSet as relationalStore.ResultSet).goToPreviousRow();
7766}
7767```
7768
7769### getValue<sup>12+</sup>
7770
7771getValue(columnIndex: number): ValueType
7772
7773Obtains 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.
7774
7775**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7776
7777**Parameters**
7778
7779| Name     | Type  | Mandatory| Description                   |
7780| ----------- | ------ | ---- | ----------------------- |
7781| columnIndex | number | Yes  | Index of the target column, starting from 0.|
7782
7783**Return value**
7784
7785| Type      | Description                            |
7786| ---------- | -------------------------------- |
7787| [ValueType](#valuetype) | Value obtained. |
7788
7789**Error codes**
7790
7791For 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).
7792
7793| **ID**| **Error Message**    |
7794|-----------|---------|
7795| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7796| 14800000  | Inner error.      |
7797| 14800011  | Database corrupted.        |
7798| 14800012  | Row out of bounds.       |
7799| 14800013  | Column out of bounds.   |
7800| 14800014  | Already closed.       |
7801| 14800021  | SQLite: Generic error.    |
7802| 14800022  | SQLite: Callback routine requested an abort.     |
7803| 14800023  | SQLite: Access permission denied.    |
7804| 14800024  | SQLite: The database file is locked.    |
7805| 14800025  | SQLite: A table in the database is locked.  |
7806| 14800026  | SQLite: The database is out of memory.    |
7807| 14800027  | SQLite: Attempt to write a readonly database.    |
7808| 14800028  | SQLite: Some kind of disk I/O error occurred.    |
7809| 14800029  | SQLite: The database is full.   |
7810| 14800030  | SQLite: Unable to open the database file.    |
7811| 14800031  | SQLite: TEXT or BLOB exceeds size limit.    |
7812| 14800032  | SQLite: Abort due to constraint violation.   |
7813| 14800033  | SQLite: Data type mismatch.      |
7814| 14800034  | SQLite: Library used incorrectly.    |
7815
7816**Example**
7817
7818```ts
7819if(resultSet != undefined) {
7820  const codes = (resultSet as relationalStore.ResultSet).getValue((resultSet as relationalStore.ResultSet).getColumnIndex("BIGINT_COLUMN"));
7821}
7822```
7823
7824### getBlob
7825
7826getBlob(columnIndex: number): Uint8Array
7827
7828
7829Obtains 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.
7830
7831**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7832
7833**Parameters**
7834
7835| Name     | Type  | Mandatory| Description                   |
7836| ----------- | ------ | ---- | ----------------------- |
7837| columnIndex | number | Yes  | Index of the target column, starting from 0.|
7838
7839**Return value**
7840
7841| Type      | Description                            |
7842| ---------- | -------------------------------- |
7843| Uint8Array | Value obtained.|
7844
7845**Error codes**
7846
7847For 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).
7848
7849| **ID**| **Error Message**                                                |
7850|-----------| ------------------------------------------------------------ |
7851| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7852| 14800000  | Inner error. |
7853| 14800011  | Database corrupted. |
7854| 14800012  | Row out of bounds. |
7855| 14800013  | Column out of bounds. |
7856| 14800014  | Already closed. |
7857| 14800021  | SQLite: Generic error. |
7858| 14800022  | SQLite: Callback routine requested an abort. |
7859| 14800023  | SQLite: Access permission denied. |
7860| 14800024  | SQLite: The database file is locked. |
7861| 14800025  | SQLite: A table in the database is locked. |
7862| 14800026  | SQLite: The database is out of memory. |
7863| 14800027  | SQLite: Attempt to write a readonly database. |
7864| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7865| 14800029  | SQLite: The database is full. |
7866| 14800030  | SQLite: Unable to open the database file. |
7867| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7868| 14800032  | SQLite: Abort due to constraint violation. |
7869| 14800033  | SQLite: Data type mismatch. |
7870| 14800034  | SQLite: Library used incorrectly. |
7871
7872**Example**
7873
7874```ts
7875if(resultSet != undefined) {
7876  const codes = (resultSet as relationalStore.ResultSet).getBlob((resultSet as relationalStore.ResultSet).getColumnIndex("CODES"));
7877}
7878```
7879
7880### getString
7881
7882getString(columnIndex: number): string
7883
7884Obtains 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. If the value in the current column is of the DOUBLE type, the precision may be lost. You are advised to use [getDouble](#getdouble) to obtain the value.
7885
7886**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7887
7888**Parameters**
7889
7890| Name     | Type  | Mandatory| Description                   |
7891| ----------- | ------ | ---- | ----------------------- |
7892| columnIndex | number | Yes  | Index of the target column, starting from 0.|
7893
7894**Return value**
7895
7896| Type  | Description                        |
7897| ------ | ---------------------------- |
7898| string | String obtained.|
7899
7900**Error codes**
7901
7902For 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).
7903
7904| **ID**| **Error Message**                                                |
7905|-----------| ------------------------------------------------------------ |
7906| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7907| 14800000  | Inner error. |
7908| 14800011  | Database corrupted. |
7909| 14800012  | Row out of bounds. |
7910| 14800013  | Column out of bounds. |
7911| 14800014  | Already closed. |
7912| 14800021  | SQLite: Generic error. |
7913| 14800022  | SQLite: Callback routine requested an abort. |
7914| 14800023  | SQLite: Access permission denied. |
7915| 14800024  | SQLite: The database file is locked. |
7916| 14800025  | SQLite: A table in the database is locked. |
7917| 14800026  | SQLite: The database is out of memory. |
7918| 14800027  | SQLite: Attempt to write a readonly database. |
7919| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7920| 14800029  | SQLite: The database is full. |
7921| 14800030  | SQLite: Unable to open the database file. |
7922| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7923| 14800032  | SQLite: Abort due to constraint violation. |
7924| 14800033  | SQLite: Data type mismatch. |
7925| 14800034  | SQLite: Library used incorrectly. |
7926
7927**Example**
7928
7929```ts
7930if(resultSet != undefined) {
7931  const name = (resultSet as relationalStore.ResultSet).getString((resultSet as relationalStore.ResultSet).getColumnIndex("NAME"));
7932}
7933```
7934
7935### getLong
7936
7937getLong(columnIndex: number): number
7938
7939Obtains 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.
7940
7941**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7942
7943**Parameters**
7944
7945| Name     | Type  | Mandatory| Description                   |
7946| ----------- | ------ | ---- | ----------------------- |
7947| columnIndex | number | Yes  | Index of the target column, starting from 0.|
7948
7949**Return value**
7950
7951| Type  | Description                                                        |
7952| ------ | ------------------------------------------------------------ |
7953| 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).|
7954
7955**Error codes**
7956
7957For 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).
7958
7959| **ID**| **Error Message**                                                |
7960|-----------| ------------------------------------------------------------ |
7961| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
7962| 14800000  | Inner error. |
7963| 14800011  | Database corrupted. |
7964| 14800012  | Row out of bounds. |
7965| 14800013  | Column out of bounds. |
7966| 14800014  | Already closed. |
7967| 14800021  | SQLite: Generic error. |
7968| 14800022  | SQLite: Callback routine requested an abort. |
7969| 14800023  | SQLite: Access permission denied. |
7970| 14800024  | SQLite: The database file is locked. |
7971| 14800025  | SQLite: A table in the database is locked. |
7972| 14800026  | SQLite: The database is out of memory. |
7973| 14800027  | SQLite: Attempt to write a readonly database. |
7974| 14800028  | SQLite: Some kind of disk I/O error occurred. |
7975| 14800029  | SQLite: The database is full. |
7976| 14800030  | SQLite: Unable to open the database file. |
7977| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
7978| 14800032  | SQLite: Abort due to constraint violation. |
7979| 14800033  | SQLite: Data type mismatch. |
7980| 14800034  | SQLite: Library used incorrectly. |
7981
7982**Example**
7983
7984```ts
7985if(resultSet != undefined) {
7986  const age = (resultSet as relationalStore.ResultSet).getLong((resultSet as relationalStore.ResultSet).getColumnIndex("AGE"));
7987 }
7988```
7989
7990### getDouble
7991
7992getDouble(columnIndex: number): number
7993
7994Obtains 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.
7995
7996**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
7997
7998**Parameters**
7999
8000| Name     | Type  | Mandatory| Description                   |
8001| ----------- | ------ | ---- | ----------------------- |
8002| columnIndex | number | Yes  | Index of the target column, starting from 0.|
8003
8004**Return value**
8005
8006| Type  | Description                        |
8007| ------ | ---------------------------- |
8008| number | Returns the value obtained.|
8009
8010**Error codes**
8011
8012For 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).
8013
8014| **ID**| **Error Message**                                                |
8015|-----------| ------------------------------------------------------------ |
8016| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
8017| 14800000  | Inner error. |
8018| 14800011  | Database corrupted. |
8019| 14800012  | Row out of bounds. |
8020| 14800013  | Column out of bounds. |
8021| 14800014  | Already closed. |
8022| 14800021  | SQLite: Generic error. |
8023| 14800022  | SQLite: Callback routine requested an abort. |
8024| 14800023  | SQLite: Access permission denied. |
8025| 14800024  | SQLite: The database file is locked. |
8026| 14800025  | SQLite: A table in the database is locked. |
8027| 14800026  | SQLite: The database is out of memory. |
8028| 14800027  | SQLite: Attempt to write a readonly database. |
8029| 14800028  | SQLite: Some kind of disk I/O error occurred. |
8030| 14800029  | SQLite: The database is full. |
8031| 14800030  | SQLite: Unable to open the database file. |
8032| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
8033| 14800032  | SQLite: Abort due to constraint violation. |
8034| 14800033  | SQLite: Data type mismatch. |
8035| 14800034  | SQLite: Library used incorrectly. |
8036
8037**Example**
8038
8039```ts
8040if(resultSet != undefined) {
8041  const salary = (resultSet as relationalStore.ResultSet).getDouble((resultSet as relationalStore.ResultSet).getColumnIndex("SALARY"));
8042}
8043```
8044
8045### getAsset<sup>10+</sup>
8046
8047getAsset(columnIndex: number): Asset
8048
8049Obtains 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.
8050
8051**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
8052
8053**Parameters**
8054
8055| Name        | Type    | Mandatory | Description          |
8056| ----------- | ------ | --- | ------------ |
8057| columnIndex | number | Yes  | Index of the target column, starting from 0.|
8058
8059**Return value**
8060
8061| Type             | Description                        |
8062| --------------- | -------------------------- |
8063| [Asset](#asset10) | Returns the value obtained.|
8064
8065**Error codes**
8066
8067For 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).
8068
8069| **ID**| **Error Message**                                                |
8070|-----------| ------------------------------------------------------------ |
8071| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
8072| 14800000  | Inner error. |
8073| 14800011  | Database corrupted. |
8074| 14800012  | Row out of bounds. |
8075| 14800013  | Column out of bounds. |
8076| 14800014  | Already closed. |
8077| 14800021  | SQLite: Generic error. |
8078| 14800022  | SQLite: Callback routine requested an abort. |
8079| 14800023  | SQLite: Access permission denied. |
8080| 14800024  | SQLite: The database file is locked. |
8081| 14800025  | SQLite: A table in the database is locked. |
8082| 14800026  | SQLite: The database is out of memory. |
8083| 14800027  | SQLite: Attempt to write a readonly database. |
8084| 14800028  | SQLite: Some kind of disk I/O error occurred. |
8085| 14800029  | SQLite: The database is full. |
8086| 14800030  | SQLite: Unable to open the database file. |
8087| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
8088| 14800032  | SQLite: Abort due to constraint violation. |
8089| 14800033  | SQLite: Data type mismatch. |
8090| 14800034  | SQLite: Library used incorrectly. |
8091
8092**Example**
8093
8094```ts
8095if(resultSet != undefined) {
8096  const doc = (resultSet as relationalStore.ResultSet).getAsset((resultSet as relationalStore.ResultSet).getColumnIndex("DOC"));
8097}
8098```
8099
8100### getAssets<sup>10+</sup>
8101
8102getAssets(columnIndex: number): Assets
8103
8104Obtains 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.
8105
8106**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
8107
8108**Parameters**
8109
8110| Name        | Type    | Mandatory | Description          |
8111| ----------- | ------ | --- | ------------ |
8112| columnIndex | number | Yes  | Index of the target column, starting from 0.|
8113
8114**Return value**
8115
8116| Type             | Description                          |
8117| ---------------- | ---------------------------- |
8118| [Assets](#assets10)| Returns the value obtained.|
8119
8120**Error codes**
8121
8122For 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).
8123
8124| **ID**| **Error Message**                                                |
8125|-----------| ------------------------------------------------------------ |
8126| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
8127| 14800000  | Inner error. |
8128| 14800011  | Database corrupted. |
8129| 14800012  | Row out of bounds. |
8130| 14800013  | Column out of bounds. |
8131| 14800014  | Already closed. |
8132| 14800021  | SQLite: Generic error. |
8133| 14800022  | SQLite: Callback routine requested an abort. |
8134| 14800023  | SQLite: Access permission denied. |
8135| 14800024  | SQLite: The database file is locked. |
8136| 14800025  | SQLite: A table in the database is locked. |
8137| 14800026  | SQLite: The database is out of memory. |
8138| 14800027  | SQLite: Attempt to write a readonly database. |
8139| 14800028  | SQLite: Some kind of disk I/O error occurred. |
8140| 14800029  | SQLite: The database is full. |
8141| 14800030  | SQLite: Unable to open the database file. |
8142| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
8143| 14800032  | SQLite: Abort due to constraint violation. |
8144| 14800033  | SQLite: Data type mismatch. |
8145| 14800034  | SQLite: Library used incorrectly. |
8146
8147**Example**
8148
8149```ts
8150if(resultSet != undefined) {
8151  const docs = (resultSet as relationalStore.ResultSet).getAssets((resultSet as relationalStore.ResultSet).getColumnIndex("DOCS"));
8152}
8153```
8154
8155### getRow<sup>11+</sup>
8156
8157getRow(): ValuesBucket
8158
8159Obtains the data in the current row.
8160
8161**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
8162
8163**Return value**
8164
8165| Type             | Description                          |
8166| ---------------- | ---------------------------- |
8167| [ValuesBucket](#valuesbucket) | Data obtained.|
8168
8169**Error codes**
8170
8171For 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).
8172
8173| **ID**| **Error Message**                                                |
8174|-----------| ------------------------------------------------------------ |
8175| 14800000  | Inner error. |
8176| 14800011  | Database corrupted. |
8177| 14800012  | Row out of bounds. |
8178| 14800013  | Column out of bounds. |
8179| 14800014  | Already closed. |
8180| 14800021  | SQLite: Generic error. |
8181| 14800022  | SQLite: Callback routine requested an abort. |
8182| 14800023  | SQLite: Access permission denied. |
8183| 14800024  | SQLite: The database file is locked. |
8184| 14800025  | SQLite: A table in the database is locked. |
8185| 14800026  | SQLite: The database is out of memory. |
8186| 14800027  | SQLite: Attempt to write a readonly database. |
8187| 14800028  | SQLite: Some kind of disk I/O error occurred. |
8188| 14800029  | SQLite: The database is full. |
8189| 14800030  | SQLite: Unable to open the database file. |
8190| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
8191| 14800032  | SQLite: Abort due to constraint violation. |
8192| 14800033  | SQLite: Data type mismatch. |
8193| 14800034  | SQLite: Library used incorrectly. |
8194
8195**Example**
8196
8197```ts
8198if(resultSet != undefined) {
8199  const row = (resultSet as relationalStore.ResultSet).getRow();
8200}
8201```
8202
8203### getSendableRow<sup>12+</sup>
8204
8205getSendableRow(): sendableRelationalStore.ValuesBucket
8206
8207Obtains the sendable data from the current row. The sendable data can be passed across threads.
8208
8209**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
8210
8211**Return value**
8212
8213| Type                                                                                          | Description                                          |
8214| ---------------------------------------------------------------------------------------------- | ---------------------------------------------- |
8215| [sendableRelationalStore.ValuesBucket](./js-apis-data-sendableRelationalStore.md#valuesbucket) | Sendable data obtained for cross-thread transfer.|
8216
8217**Error codes**
8218
8219For 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).
8220
8221| **ID**| **Error Message**                                 |
8222| ------------ | --------------------------------------------- |
8223| 14800000     | Inner error.                                  |
8224| 14800011     | Database corrupted.                           |
8225| 14800012     | Row out of bounds.                            |
8226| 14800013     | Column out of bounds.                         |
8227| 14800014     | Already closed.                               |
8228| 14800021     | SQLite: Generic error.                        |
8229| 14800022     | SQLite: Callback routine requested an abort.  |
8230| 14800023     | SQLite: Access permission denied.             |
8231| 14800024     | SQLite: The database file is locked.          |
8232| 14800025     | SQLite: A table in the database is locked.    |
8233| 14800026     | SQLite: The database is out of memory.        |
8234| 14800027     | SQLite: Attempt to write a readonly database. |
8235| 14800028     | SQLite: Some kind of disk I/O error occurred. |
8236| 14800029     | SQLite: The database is full.                 |
8237| 14800030     | SQLite: Unable to open the database file.     |
8238| 14800031     | SQLite: TEXT or BLOB exceeds size limit.      |
8239| 14800032     | SQLite: Abort due to constraint violation.    |
8240| 14800033     | SQLite: Data type mismatch.                   |
8241| 14800034     | SQLite: Library used incorrectly.             |
8242
8243**Example**
8244
8245```ts
8246import { taskpool } from '@kit.ArkTS';
8247import type ctx from '@ohos.app.ability.common';
8248import { sendableRelationalStore } from '@kit.ArkData';
8249
8250@Concurrent
8251async function getDataByName(name: string, context: ctx.UIAbilityContext) {
8252  const STORE_CONFIG: relationalStore.StoreConfig = {
8253    name: "RdbTest.db",
8254    securityLevel: relationalStore.SecurityLevel.S3
8255  };
8256  const store = await relationalStore.getRdbStore(context, STORE_CONFIG);
8257  const predicates = new relationalStore.RdbPredicates("EMPLOYEE");
8258  predicates.equalTo("NAME", name);
8259  const resultSet = store.querySync(predicates);
8260
8261  if (resultSet.rowCount > 0) {
8262    resultSet.goToFirstRow();
8263    const sendableValuesBucket = resultSet.getSendableRow();
8264    return sendableValuesBucket;
8265  } else {
8266    return null;
8267  }
8268}
8269
8270const task = new taskpool.Task(getDataByName, 'Lisa', this.context);
8271const sendableValuesBucket  = await taskpool.execute(task) as sendableRelationalStore.ValuesBucket;
8272
8273if (sendableValuesBucket) {
8274  const columnCount = sendableValuesBucket.size;
8275  const age = sendableValuesBucket.get('age');
8276  const name = sendableValuesBucket.get('name');
8277  console.info(`Query data in taskpool succeeded, name is "${name}", age is "${age}"`)
8278}
8279```
8280
8281### isColumnNull
8282
8283isColumnNull(columnIndex: number): boolean
8284
8285Checks whether the value in the specified column is null.
8286
8287**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
8288
8289**Parameters**
8290
8291| Name     | Type  | Mandatory| Description                   |
8292| ----------- | ------ | ---- | ----------------------- |
8293| columnIndex | number | Yes  | Index of the target column, starting from 0.|
8294
8295**Return value**
8296
8297| Type   | Description                                                     |
8298| ------- | --------------------------------------------------------- |
8299| boolean | Returns **true** if the value is null; returns **false** otherwise.|
8300
8301**Error codes**
8302
8303For 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).
8304
8305| **ID**| **Error Message**                                                |
8306|-----------| ------------------------------------------------------- |
8307| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
8308| 14800000  | Inner error. |
8309| 14800011  | Database corrupted. |
8310| 14800012  | Row out of bounds. |
8311| 14800013  | Column out of bounds. |
8312| 14800014  | Already closed. |
8313| 14800021  | SQLite: Generic error. |
8314| 14800022  | SQLite: Callback routine requested an abort. |
8315| 14800023  | SQLite: Access permission denied. |
8316| 14800024  | SQLite: The database file is locked. |
8317| 14800025  | SQLite: A table in the database is locked. |
8318| 14800026  | SQLite: The database is out of memory. |
8319| 14800027  | SQLite: Attempt to write a readonly database. |
8320| 14800028  | SQLite: Some kind of disk I/O error occurred. |
8321| 14800029  | SQLite: The database is full. |
8322| 14800030  | SQLite: Unable to open the database file. |
8323| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
8324| 14800032  | SQLite: Abort due to constraint violation. |
8325| 14800033  | SQLite: Data type mismatch. |
8326| 14800034  | SQLite: Library used incorrectly. |
8327
8328**Example**
8329
8330```ts
8331if(resultSet != undefined) {
8332  const isColumnNull = (resultSet as relationalStore.ResultSet).isColumnNull((resultSet as relationalStore.ResultSet).getColumnIndex("CODES"));
8333}
8334```
8335
8336### close
8337
8338close(): void
8339
8340Closes this **resultSet** to release memory. If the **resultSet** is not closed, FD or memory leaks may occur.
8341
8342**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
8343
8344**Example**
8345
8346```ts
8347if(resultSet != undefined) {
8348  (resultSet as relationalStore.ResultSet).close();
8349}
8350```
8351
8352**Error codes**
8353
8354For details about the error codes, see [RDB Error Codes](errorcode-data-rdb.md).
8355
8356| **ID**| **Error Message**                                                |
8357|-----------| ------------------------------------------------------------ |
8358| 14800000  | Inner error. |
8359| 14800012  | Row out of bounds. |
8360
8361<!--no_check-->