• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.data.relationalStore (RDB Store)
2
3The relational database (RDB) store manages data based on relational models. It provides a complete mechanism for managing local databases based on the underlying SQLite. To satisfy different needs in complicated scenarios, the RDB store offers a series of APIs for performing operations such as adding, deleting, modifying, and querying data, and supports direct execution of SQL statements. The worker threads are not supported.
4
5ArkTS supports the following basic data types: number, string, binary data, and boolean. The 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
7The **relationalStore** module provides the following functions:
8
9- [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.
10- [RdbStore](#rdbstore): provides APIs for managing data in an RDB store.
11- [Resultset](#resultset): provides APIs for accessing the result set obtained from the RDB store.
12
13> **NOTE**
14>
15> 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.
16
17## Modules to Import
18
19```ts
20import relationalStore from '@ohos.data.relationalStore';
21```
22
23## relationalStore.getRdbStore
24
25getRdbStore(context: Context, config: StoreConfig, callback: AsyncCallback<RdbStore>): void
26
27Obtains 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.
28
29**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
30
31**Parameters**
32
33| Name  | Type                                          | Mandatory| Description                                                        |
34| -------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ |
35| context  | Context                                        | Yes  | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).|
36| config   | [StoreConfig](#storeconfig)               | Yes  | Configuration of the RDB store.                               |
37| callback | AsyncCallback&lt;[RdbStore](#rdbstore)&gt; | Yes  | Callback invoked to return the RDB store obtained.                  |
38
39**Error codes**
40
41For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
42
43| **ID**| **Error Message**                                               |
44| ------------ | ----------------------------------------------------------- |
45| 14800010     | Failed to open or delete database by invalid database path. |
46| 14800011     | Failed to open database by database corrupted.              |
47| 14800000     | Inner error.                                                |
48| 14801001     | Only supported in stage mode.                               |
49| 14801002     | The data group id is not valid.                             |
50
51**Example**
52
53FA model:
54
55```js
56import featureAbility from '@ohos.ability.featureAbility';
57import { BusinessError } from "@ohos.base";
58
59let store: relationalStore.RdbStore | undefined = undefined;
60let context = getContext(this);
61
62const STORE_CONFIG: relationalStore.StoreConfig = {
63  name: "RdbTest.db",
64  securityLevel: relationalStore.SecurityLevel.S1
65};
66
67relationalStore.getRdbStore(context, STORE_CONFIG, (err: BusinessError, rdbStore: relationalStore.RdbStore) => {
68  store = rdbStore;
69  if (err) {
70    console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
71    return;
72  }
73  console.info('Get RdbStore successfully.');
74})
75```
76
77Stage model:
78
79```ts
80import UIAbility from '@ohos.app.ability.UIAbility';
81import window from '@ohos.window';
82import { BusinessError } from "@ohos.base";
83
84let store: relationalStore.RdbStore | undefined = undefined;
85
86class EntryAbility extends UIAbility {
87  onWindowStageCreate(windowStage: window.WindowStage) {
88    const STORE_CONFIG: relationalStore.StoreConfig = {
89      name: "RdbTest.db",
90      securityLevel: relationalStore.SecurityLevel.S1
91    };
92
93    relationalStore.getRdbStore(this.context, STORE_CONFIG, (err: BusinessError, rdbStore: relationalStore.RdbStore) => {
94      store = rdbStore;
95      if (err) {
96        console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
97        return;
98      }
99      console.info('Get RdbStore successfully.');
100    })
101  }
102}
103```
104
105## relationalStore.getRdbStore
106
107getRdbStore(context: Context, config: StoreConfig): Promise&lt;RdbStore&gt;
108
109Obtains 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.
110
111**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
112
113**Parameters**
114
115| Name | Type                            | Mandatory| Description                                                        |
116| ------- | -------------------------------- | ---- | ------------------------------------------------------------ |
117| context | Context                          | Yes  | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).|
118| config  | [StoreConfig](#storeconfig) | Yes  | Configuration of the RDB store.                               |
119
120**Return value**
121
122| Type                                     | Description                             |
123| ----------------------------------------- | --------------------------------- |
124| Promise&lt;[RdbStore](#rdbstore)&gt; | Promise used to return the **RdbStore** object.|
125
126**Error codes**
127
128For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
129
130| **ID**| **Error Message**                                               |
131| ------------ | ----------------------------------------------------------- |
132| 14800010     | Failed to open or delete database by invalid database path. |
133| 14800011     | Failed to open database by database corrupted.              |
134| 14800000     | Inner error.                                                |
135| 14801001     | Only supported in stage mode.                               |
136| 14801002     | The data group id is not valid.                             |
137
138**Example**
139
140FA model:
141
142```js
143import featureAbility from '@ohos.ability.featureAbility';
144import { BusinessError } from "@ohos.base";
145
146let store: relationalStore.RdbStore | undefined = undefined;
147let context = getContext(this);
148
149const STORE_CONFIG: relationalStore.StoreConfig = {
150  name: "RdbTest.db",
151  securityLevel: relationalStore.SecurityLevel.S1
152};
153
154relationalStore.getRdbStore(context, STORE_CONFIG).then(async (rdbStore: relationalStore.RdbStore) => {
155  store = rdbStore;
156  console.info('Get RdbStore successfully.')
157}).catch((err: BusinessError) => {
158  console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
159})
160```
161
162Stage model:
163
164```ts
165import UIAbility from '@ohos.app.ability.UIAbility';
166import window from '@ohos.window';
167import { BusinessError } from "@ohos.base";
168
169let store: relationalStore.RdbStore | undefined = undefined;
170
171class EntryAbility extends UIAbility {
172  onWindowStageCreate(windowStage: window.WindowStage) {
173    const STORE_CONFIG: relationalStore.StoreConfig = {
174      name: "RdbTest.db",
175      securityLevel: relationalStore.SecurityLevel.S1
176    };
177
178    relationalStore.getRdbStore(this.context, STORE_CONFIG).then(async (rdbStore: relationalStore.RdbStore) => {
179      store = rdbStore;
180      console.info('Get RdbStore successfully.')
181    }).catch((err: BusinessError) => {
182      console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`);
183    })
184  }
185}
186```
187
188## relationalStore.deleteRdbStore
189
190deleteRdbStore(context: Context, name: string, callback: AsyncCallback&lt;void&gt;): void
191
192Deletes an RDB store. This API uses an asynchronous callback to return the result.
193
194After the deletion, you are advised to set the database object to null.
195
196**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
197
198**Parameters**
199
200| Name  | Type                     | Mandatory| Description                                                        |
201| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
202| context  | Context                   | Yes  | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).|
203| name     | string                    | Yes  | Name of the RDB store to delete.                                                |
204| callback | AsyncCallback&lt;void&gt; | Yes  | Callback invoked to return the result.                                      |
205
206**Error codes**
207
208For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
209
210| **ID**| **Error Message**                                               |
211| ------------ | ----------------------------------------------------------- |
212| 14800010     | Failed to open or delete database by invalid database path. |
213| 14800000     | Inner error.                                                |
214
215**Example**
216
217FA model:
218
219```js
220import featureAbility from '@ohos.ability.featureAbility';
221import { BusinessError } from "@ohos.base";
222
223let store: relationalStore.RdbStore | undefined = undefined;
224let context = getContext(this);
225
226relationalStore.deleteRdbStore(context, "RdbTest.db", (err: BusinessError) => {
227  if (err) {
228    console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
229    return;
230  }
231  store = undefined;
232  console.info('Delete RdbStore successfully.');
233})
234```
235
236Stage model:
237
238```ts
239import UIAbility from '@ohos.app.ability.UIAbility';
240import window from '@ohos.window';
241import { BusinessError } from "@ohos.base";
242
243let store: relationalStore.RdbStore | undefined = undefined;
244
245class EntryAbility extends UIAbility {
246  onWindowStageCreate(windowStage: window.WindowStage){
247    relationalStore.deleteRdbStore(this.context, "RdbTest.db", (err: BusinessError) => {
248      if (err) {
249        console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
250        return;
251      }
252      store = undefined;
253      console.info('Delete RdbStore successfully.');
254    })
255  }
256}
257```
258
259## relationalStore.deleteRdbStore
260
261deleteRdbStore(context: Context, name: string): Promise&lt;void&gt;
262
263Deletes an RDB store. This API uses a promise to return the result.
264
265After the deletion, you are advised to set the database object to null.
266
267**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
268
269**Parameters**
270
271| Name | Type   | Mandatory| Description                                                        |
272| ------- | ------- | ---- | ------------------------------------------------------------ |
273| context | Context | Yes  | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).|
274| name    | string  | Yes  | Name of the RDB store to delete.                                                |
275
276**Return value**
277
278| Type               | Description                     |
279| ------------------- | ------------------------- |
280| Promise&lt;void&gt; | Promise that returns no value.|
281
282**Error codes**
283
284For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
285
286| **ID**| **Error Message**                                               |
287| ------------ | ----------------------------------------------------------- |
288| 14800010     | Failed to open or delete database by invalid database path. |
289| 14800000     | Inner error.                                                |
290
291**Example**
292
293FA model:
294
295```js
296import featureAbility from '@ohos.ability.featureAbility';
297import { BusinessError } from "@ohos.base";
298
299let store: relationalStore.RdbStore | undefined = undefined;
300let context = getContext(this);
301
302relationalStore.deleteRdbStore(context, "RdbTest.db").then(()=>{
303  store = undefined;
304  console.info('Delete RdbStore successfully.');
305}).catch((err: BusinessError) => {
306  console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
307})
308```
309
310Stage model:
311
312```ts
313import UIAbility from '@ohos.app.ability.UIAbility';
314import window from '@ohos.window';
315import { BusinessError } from "@ohos.base";
316
317let store: relationalStore.RdbStore | undefined = undefined;
318
319class EntryAbility extends UIAbility {
320  onWindowStageCreate(windowStage: window.WindowStage){
321    relationalStore.deleteRdbStore(this.context, "RdbTest.db").then(()=>{
322      store = undefined;
323      console.info('Delete RdbStore successfully.');
324    }).catch((err: BusinessError) => {
325      console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
326    })
327  }
328}
329```
330
331## relationalStore.deleteRdbStore<sup>10+</sup>
332
333deleteRdbStore(context: Context, config: StoreConfig, callback: AsyncCallback\<void>): void
334
335Deletes an RDB store. This API uses an asynchronous callback to return the result.
336
337After 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.
338
339**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
340
341**Parameters**
342
343| Name  | Type                       | Mandatory| Description                                                        |
344| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
345| context  | Context                     | Yes  | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).|
346| config   | [StoreConfig](#storeconfig) | Yes  | Configuration of the RDB store.                               |
347| callback | AsyncCallback&lt;void&gt;   | Yes  | Callback invoked to return the result.                                      |
348
349**Error codes**
350
351For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
352
353| **ID**| **Error Message**                                               |
354| ------------ | ----------------------------------------------------------- |
355| 14800010     | Failed to open or delete database by invalid database path. |
356| 14800000     | Inner error.                                                |
357| 14801001     | Only supported in stage mode.                               |
358| 14801002     | The data group id is not valid.                             |
359
360**Example**
361
362FA model:
363
364```js
365import featureAbility from '@ohos.ability.featureAbility';
366import { BusinessError } from "@ohos.base";
367
368let store: relationalStore.RdbStore | undefined = undefined;
369let context = getContext(this);
370
371const STORE_CONFIG: relationalStore.StoreConfig = {
372  name: "RdbTest.db",
373  securityLevel: relationalStore.SecurityLevel.S1
374};
375
376relationalStore.deleteRdbStore(context, STORE_CONFIG, (err: BusinessError) => {
377  if (err) {
378    console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
379    return;
380  }
381  store = undefined;
382  console.info('Delete RdbStore successfully.');
383})
384```
385
386Stage model:
387
388```ts
389import UIAbility from '@ohos.app.ability.UIAbility';
390import window from '@ohos.window';
391import { BusinessError } from "@ohos.base";
392
393let store: relationalStore.RdbStore | undefined = undefined;
394
395class EntryAbility extends UIAbility {
396  onWindowStageCreate(windowStage: window.WindowStage){
397    const STORE_CONFIG: relationalStore.StoreConfig = {
398      name: "RdbTest.db",
399      securityLevel: relationalStore.SecurityLevel.S1
400    };
401    relationalStore.deleteRdbStore(this.context, STORE_CONFIG, (err: BusinessError) => {
402      if (err) {
403        console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
404        return;
405      }
406      store = undefined;
407      console.info('Delete RdbStore successfully.');
408    })
409  }
410}
411
412```
413
414## relationalStore.deleteRdbStore<sup>10+</sup>
415
416deleteRdbStore(context: Context, config: StoreConfig): Promise\<void>
417
418Deletes an RDB store. This API uses a promise to return the result.
419
420After 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.
421
422**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
423
424**Parameters**
425
426| Name | Type                       | Mandatory| Description                                                        |
427| ------- | --------------------------- | ---- | ------------------------------------------------------------ |
428| context | Context                     | Yes  | Application context.<br>For details about the application context of the FA model, see [Context](js-apis-inner-app-context.md).<br>For details about the application context of the stage model, see [Context](js-apis-inner-application-uiAbilityContext.md).|
429| config  | [StoreConfig](#storeconfig) | Yes  | Configuration of the RDB store.                               |
430
431**Return value**
432
433| Type               | Description                     |
434| ------------------- | ------------------------- |
435| Promise&lt;void&gt; | Promise that returns no value.|
436
437**Error codes**
438
439For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
440
441| **ID**| **Error Message**                                               |
442| ------------ | ----------------------------------------------------------- |
443| 14800010     | Failed to open or delete database by invalid database path. |
444| 14800000     | Inner error.                                                |
445| 14801001     | Only supported in stage mode.                               |
446| 14801002     | The data group id is not valid.                             |
447
448**Example**
449
450FA model:
451
452```js
453import featureAbility from '@ohos.ability.featureAbility';
454import { BusinessError } from "@ohos.base";
455
456let store: relationalStore.RdbStore | undefined = undefined;
457let context = getContext(this);
458
459const STORE_CONFIG: relationalStore.StoreConfig = {
460  name: "RdbTest.db",
461  securityLevel: relationalStore.SecurityLevel.S1
462};
463
464relationalStore.deleteRdbStore(context, STORE_CONFIG).then(()=>{
465  store = undefined;
466  console.info('Delete RdbStore successfully.');
467}).catch((err: BusinessError) => {
468  console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
469})
470```
471
472Stage model:
473
474```ts
475import UIAbility from '@ohos.app.ability.UIAbility';
476import window from '@ohos.window';
477import { BusinessError } from "@ohos.base";
478
479let store: relationalStore.RdbStore | undefined = undefined;
480
481class EntryAbility extends UIAbility {
482  onWindowStageCreate(windowStage: window.WindowStage){
483    const STORE_CONFIG: relationalStore.StoreConfig = {
484      name: "RdbTest.db",
485      securityLevel: relationalStore.SecurityLevel.S1
486    };
487    relationalStore.deleteRdbStore(this.context, STORE_CONFIG).then(()=>{
488      store = undefined;
489      console.info('Delete RdbStore successfully.');
490    }).catch((err: BusinessError) => {
491      console.error(`Delete RdbStore failed, code is ${err.code},message is ${err.message}`);
492    })
493  }
494}
495```
496
497## StoreConfig
498
499Defines the RDB store configuration.
500
501**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
502
503| Name       | Type         | Mandatory| Description                                                     |
504| ------------- | ------------- | ---- | --------------------------------------------------------- |
505| name          | string        | Yes  | Database file name, which is the unique identifier of the database.|
506| securityLevel | [SecurityLevel](#securitylevel) | Yes  | Security level of the RDB store.                                       |
507| 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.|
508| dataGroupId<sup>10+</sup> | string | No| Application group ID, which needs to be obtained from AppGallery.<br>**Model restriction**: This attribute can be used only in the stage model.<br>This parameter is supported since API version 10. It specifies the **relationalStore** instance created in the sandbox directory corresponding to **dataGroupId**. If this parameter is not specified, the **relationalStore** instance is created in the sandbox directory of the application.|
509
510## SecurityLevel
511
512Enumerates the RDB store security levels. Use the enum name rather than the enum value.
513
514> **NOTE**
515>
516> To perform data synchronization operations, the RDB store security level must be lower than or equal to that of the peer device. For details, see the [Access Control Mechanism in Cross-Device Synchronization](../../database/access-control-by-device-and-data-level.md#access-control-mechanism-in-cross-device-synchronization).
517
518**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
519
520| Name| Value  | Description                                                        |
521| ---- | ---- | ------------------------------------------------------------ |
522| 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.|
523| 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.|
524| 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.|
525| 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.|
526
527## AssetStatus<sup>10+</sup>
528
529Enumerates the asset statuses. Use the enum name rather than the enum value.
530
531**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
532
533| Name                             | Value  | Description            |
534| ------------------------------- | --- | -------------- |
535| ASSET_NORMAL     | 1  | The asset is in normal status.     |
536| ASSET_INSERT | 2 | The asset is to be inserted to the cloud.|
537| ASSET_UPDATE | 3 | The asset is to be updated to the cloud.|
538| ASSET_DELETE | 4 | The asset is to be deleted from the cloud.|
539| ASSET_ABNORMAL    | 5   | The asset is in abnormal status.     |
540| ASSET_DOWNLOADING | 6   | The asset is being downloaded to a local device.|
541
542## Asset<sup>10+</sup>
543
544Defines information about an asset (such as a document, image, and video). The asset APIs do not support **Datashare**.
545
546**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
547
548| Name         | Type                         | Mandatory | Description          |
549| ----------- | --------------------------- | --- | ------------ |
550| name        | string                      | Yes  | Asset name.      |
551| uri         | string                      | Yes  | Asset URI, which is an absolute path in the system.      |
552| path        | string                      | Yes  | Application sandbox path of the asset.      |
553| createTime  | string                      | Yes  | Time when the asset was created.  |
554| modifyTime  | string                      | Yes  | Time when the asset was last modified.|
555| size        | string                      | Yes  | Size of the asset.   |
556| status      | [AssetStatus](#assetstatus10) | No  | Asset status. The default value is **ASSET_NORMAL**.       |
557
558## Assets<sup>10+</sup>
559
560Defines an array of the [Asset](#asset10) type.
561
562**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
563
564| Type   | Description                |
565| ------- | -------------------- |
566| [Asset](#asset10)[] | Array of assets.  |
567
568## ValueType
569
570Enumerates the types of the value in a KV pair. The type varies with the parameter function.
571
572**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
573
574| Type   | Description                |
575| ------- | -------------------- |
576| null<sup>10+</sup>    | Null.  |
577| number  | Number.  |
578| string  | String.  |
579| boolean | Boolean.|
580| Uint8Array<sup>10+</sup>           | Uint8 array.           |
581| Asset<sup>10+</sup>  | [Asset](#asset10).    |
582| Assets<sup>10+</sup> | [Assets](#assets10).|
583
584## ValuesBucket
585
586Enumerates the types of the key in a KV pair. This type is not multi-thread safe. If a **ValuesBucket** instance is operated by multiple threads at the same time in an application, use a lock for the instance.
587
588**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
589
590| Key Type| Value Type                  |
591| ------ | ----------------------- |
592| number | The primary key is a number.|
593| string | The primary key is a string.|
594
595## PRIKeyType<sup>10+</sup>
596
597Enumerates the types of the primary key in a row of a database table.
598
599**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
600
601| Type            | Description                              |
602| ---------------- | ---------------------------------- |
603| number | The primary key is a number.|
604| string | The primary key is a string.|
605
606## UTCTime<sup>10+</sup>
607
608Represents the data type of the UTC time.
609
610**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
611
612| Type| Description           |
613| ---- | --------------- |
614| Date | UTC time.|
615
616## ModifyTime<sup>10+</sup>
617
618Represents the data type of the primary key and modification time of a database table.
619
620**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
621
622| Type                                                   | Description                                                        |
623| ------------------------------------------------------- | ------------------------------------------------------------ |
624| 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.|
625
626## SyncMode
627
628Enumerates the database synchronization modes. Use the enum name rather than the enum value.
629
630| Name          | Value  | Description                              |
631| -------------- | ---- | ---------------------------------- |
632| SYNC_MODE_PUSH                       | 0   | Push data from a local device to a remote device.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
633| SYNC_MODE_PULL                       | 1   | Pull data from a remote device to a local device.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
634| SYNC_MODE_TIME_FIRST<sup>10+</sup>   | 4   | Synchronize with the data with the latest modification time.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
635| SYNC_MODE_NATIVE_FIRST<sup>10+</sup> | 5   | Synchronize data from a local device to the cloud.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
636| SYNC_MODE_CLOUD_FIRST<sup>10+</sup>  | 6   | Synchronize data from the cloud to a local device.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
637
638## SubscribeType
639
640Enumerates the subscription types. Use the enum name rather than the enum value.
641
642**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
643
644| Name                 | Value  | Description              |
645| --------------------- | ---- | ------------------ |
646| SUBSCRIBE_TYPE_REMOTE | 0    | Subscribe to remote data changes.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core|
647| SUBSCRIBE_TYPE_CLOUD<sup>10+</sup> | 1  | Subscribe to cloud data changes.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
648| SUBSCRIBE_TYPE_CLOUD_DETAILS<sup>10+</sup> | 2  | Subscribe to cloud data change details.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
649
650## ChangeType<sup>10+</sup>
651
652Enumerates data change types. Use the enum name rather than the enum value.
653
654**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
655
656**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
657
658| Name                        | Value  | Description                        |
659| -------------------------- | --- | -------------------------- |
660| DATA_CHANGE  | 0   | Data change.  |
661| ASSET_CHANGE | 1   | Asset change.|
662
663## ChangeInfo<sup>10+</sup>
664
665Defines the details about the device-cloud synchronization process.
666
667**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
668
669| Name    | Type                              | Mandatory| Description                                                        |
670| -------- | ---------------------------------- | ---- | ------------------------------------------------------------ |
671| table    | string                             | Yes  | Name of the table with data changes.                                    |
672| type     | [ChangeType](#changetype10)        | Yes  | Type of the data changed, which can be data or asset.        |
673| 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.|
674| 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.|
675| 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.|
676
677## DistributedType<sup>10+</sup>
678
679Enumerates the distributed table types. Use the enum name rather than the enum value.
680
681**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
682
683| Name               | Value  | Description                                                                                                |
684| ------------------ | --- | -------------------------------------------------------------------------------------------------- |
685| DISTRIBUTED_DEVICE | 0  | Distributed database table synchronized between devices.<br>**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core              |
686| DISTRIBUTED_CLOUD  | 1   | Distributed database table synchronized between the device and the cloud.<br>**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client|
687
688## DistributedConfig<sup>10+</sup>
689
690Defines the configuration of the distributed mode of tables.
691
692**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
693
694| Name    | Type   | Mandatory| Description                                                        |
695| -------- | ------- | ---- | ------------------------------------------------------------ |
696| autoSync | boolean | Yes  | The value **true** means both automatic synchronization and manual synchronization are supported for the table. The value **false** means only manual synchronization is supported for the table.|
697
698## ConflictResolution<sup>10+</sup>
699
700Defines the resolution to use when **insert()** and **update()** conflict. Use the enum name rather than the enum value.
701
702**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
703
704| Name                | Value  | Description                                                        |
705| -------------------- | ---- | ------------------------------------------------------------ |
706| ON_CONFLICT_NONE | 0 | No operation is performed.|
707| ON_CONFLICT_ROLLBACK | 1    | Abort the SQL statement and roll back the current transaction.               |
708| 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.|
709| 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.|
710| ON_CONFLICT_IGNORE   | 4    | Skip the rows that contain constraint violations and continue to process the subsequent rows of the SQL statement.|
711| 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.|
712
713## Progress<sup>10+</sup>
714
715Enumerates the device-cloud synchronization processes. Use the enum name rather than the enum value.
716
717**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
718
719| Name            | Value  | Description                    |
720| ---------------- | ---- | ------------------------ |
721| SYNC_BEGIN       | 0    | The device-cloud synchronization starts.  |
722| SYNC_IN_PROGRESS | 1    | The device-cloud synchronization is in progress.|
723| SYNC_FINISH      | 2    | The device-cloud synchronization is complete.|
724
725## Statistic<sup>10+</sup>
726
727Represents the device-cloud synchronization statistics information.
728
729**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
730
731| Name      | Type  | Mandatory| Description                                    |
732| ---------- | ------ | ---- | ---------------------------------------- |
733| total      | number | Yes  | Total number of rows to be synchronized between the device and cloud in the database table.    |
734| successful | number | Yes  | Number of rows that are successfully synchronized between the device and cloud in the database table.      |
735| failed     | number | Yes  | Number of rows that failed to be synchronized between the device and cloud in the database table.      |
736| remained   | number | Yes  | Number of rows that are not executed for device-cloud synchronization in the database table.|
737
738## TableDetails<sup>10+</sup>
739
740Represents the upload and download statistics of device-cloud synchronization tasks.
741
742**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
743
744| Name    | Type                     | Mandatory| Description                                      |
745| -------- | ------------------------- | ---- | ------------------------------------------ |
746| upload   | [Statistic](#statistic10) | Yes  | Statistics of the device-cloud upload tasks.|
747| download | [Statistic](#statistic10) | Yes  | Statistics of the device-cloud download tasks.|
748
749## ProgressCode<sup>10+</sup>
750
751Enumerates the device-cloud synchronization states. Use the enum name rather than the enum value.
752
753**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
754
755| Name                 | Value  | Description                                                        |
756| --------------------- | ---- | ------------------------------------------------------------ |
757| SUCCESS               | 0    | The device-cloud synchronization is successful.                                      |
758| UNKNOWN_ERROR         | 1    | An unknown error occurs during device-cloud synchronization.                              |
759| NETWORK_ERROR         | 2    | A network error occurs during device-cloud synchronization.                              |
760| CLOUD_DISABLED        | 3    | The cloud is unavailable.                                            |
761| LOCKED_BY_OTHERS      | 4    | The device-cloud synchronization of another device is being performed.<br>Start device-cloud synchronization after checking that cloud resources are not occupied by other devices.|
762| 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.|
763| NO_SPACE_FOR_ASSET    | 6    | The remaining cloud space is less than the size of the data to be synchronized.                    |
764
765## ProgressDetails<sup>10+</sup>
766
767Represents the statistics of the overall device-cloud synchronization (upload and download) tasks.
768
769**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
770
771| Name    | Type                                             | Mandatory| Description                                                        |
772| -------- | ------------------------------------------------- | ---- | ------------------------------------------------------------ |
773| schedule | [Progress](#progress10)                           | Yes  | Device-cloud synchronization process.                                          |
774| code     | [ProgressCode](#progresscode10)                   | Yes  | Device-cloud synchronization state.                                    |
775| details  | [table: string] : [TableDetails](#tabledetails10) | Yes  | Statistics of each table.<br>The key indicates the table name, and the value indicates the device-cloud synchronization statistics of the table.|
776
777## RdbPredicates
778
779Defines the predicates for an RDB store. This class determines whether the conditional expression for the RDB store is true or false. This type is not multi-thread safe. If an **RdbPredicates** instance is operated by multiple threads at the same time in an application, use a lock for the instance.
780
781### constructor
782
783constructor(name: string)
784
785A constructor used to create an **RdbPredicates** object.
786
787**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
788
789**Parameters**
790
791| Name| Type  | Mandatory| Description        |
792| ------ | ------ | ---- | ------------ |
793| name   | string | Yes  | Database table name.|
794
795**Example**
796
797```ts
798let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
799```
800
801### inDevices
802
803inDevices(devices: Array&lt;string&gt;): RdbPredicates
804
805Sets an **RdbPredicates** to specify the remote devices to connect on the network during distributed database synchronization.
806
807> **NOTE**
808>
809> The value of **devices** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
810If **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.
811
812**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
813
814**Parameters**
815
816| Name | Type               | Mandatory| Description                      |
817| ------- | ------------------- | ---- | -------------------------- |
818| devices | Array&lt;string&gt; | Yes  | IDs of the remote devices in the same network.|
819
820**Return value**
821
822| Type                                | Description                      |
823| ------------------------------------ | -------------------------- |
824| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
825
826**Example**
827
828```ts
829import deviceManager from '@ohos.distributedDeviceManager';
830
831let dmInstance: deviceManager.DeviceManager;
832let deviceIds: Array<string> = [];
833
834try {
835  dmInstance = deviceManager.createDeviceManager("com.example.appdatamgrverify");
836  let devices: Array<deviceManager.DeviceBasicInfo> = dmInstance.getAvailableDeviceListSync();
837  for (let i = 0; i < devices.length; i++) {
838    deviceIds[i] = devices[i].networkId!;
839  }
840} catch (err) {
841  let code = (err as BusinessError).code;
842  let message = (err as BusinessError).message
843  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
844}
845
846let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
847predicates.inDevices(deviceIds);
848```
849
850### inAllDevices
851
852inAllDevices(): RdbPredicates
853
854
855Sets an **RdbPredicates** to specify all remote devices on the network to connect during distributed database synchronization.
856
857
858**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
859
860**Return value**
861
862| Type                                | Description                      |
863| ------------------------------------ | -------------------------- |
864| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
865
866**Example**
867
868```ts
869let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
870predicates.inAllDevices();
871```
872
873### equalTo
874
875equalTo(field: string, value: ValueType): RdbPredicates
876
877
878Sets an **RdbPredicates** object to match the fields in the specified column that are equal to the given value.
879
880**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
881
882**Parameters**
883
884| Name| Type                   | Mandatory| Description                  |
885| ------ | ----------------------- | ---- | ---------------------- |
886| field  | string                  | Yes  | Column name in the database table.    |
887| value  | [ValueType](#valuetype) | Yes  | Value to match the **RdbPredicates**.|
888
889**Return value**
890
891| Type                                | Description                      |
892| ------------------------------------ | -------------------------- |
893| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
894
895**Example**
896
897```ts
898// Locate data of Lisa in the EMPLOYEE table.
899let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
900predicates.equalTo("NAME", "Lisa");
901```
902
903
904### notEqualTo
905
906notEqualTo(field: string, value: ValueType): RdbPredicates
907
908Sets an **RdbPredicates** object to match the fields in the specified column that are not equal to the given value.
909
910**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
911
912**Parameters**
913
914| Name| Type                   | Mandatory| Description                  |
915| ------ | ----------------------- | ---- | ---------------------- |
916| field  | string                  | Yes  | Column name in the database table.    |
917| value  | [ValueType](#valuetype) | Yes  | Value to match the **RdbPredicates**.|
918
919**Return value**
920
921| Type                                | Description                      |
922| ------------------------------------ | -------------------------- |
923| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
924
925**Example**
926
927```ts
928// Locate data of the employees whose name is not Lisa in the table.
929let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
930predicates.notEqualTo("NAME", "Lisa");
931```
932
933
934### beginWrap
935
936beginWrap(): RdbPredicates
937
938
939Adds a left parenthesis to the **RdbPredicates**.
940
941**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
942
943**Return value**
944
945| Type                                | Description                     |
946| ------------------------------------ | ------------------------- |
947| [RdbPredicates](#rdbpredicates) | **RdbPredicates** with a left parenthesis.|
948
949**Example**
950
951```ts
952let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
953predicates.equalTo("NAME", "Lisa")
954    .beginWrap()
955    .equalTo("AGE", 18)
956    .or()
957    .equalTo("SALARY", 200.5)
958    .endWrap()
959```
960
961### endWrap
962
963endWrap(): RdbPredicates
964
965Adds a right parenthesis to the **RdbPredicates**.
966
967**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
968
969**Return value**
970
971| Type                                | Description                     |
972| ------------------------------------ | ------------------------- |
973| [RdbPredicates](#rdbpredicates) | **RdbPredicates** with a right parenthesis.|
974
975**Example**
976
977```ts
978let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
979predicates.equalTo("NAME", "Lisa")
980    .beginWrap()
981    .equalTo("AGE", 18)
982    .or()
983    .equalTo("SALARY", 200.5)
984    .endWrap()
985```
986
987### or
988
989or(): RdbPredicates
990
991Adds the OR condition to the **RdbPredicates**.
992
993**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
994
995**Return value**
996
997| Type                                | Description                     |
998| ------------------------------------ | ------------------------- |
999| [RdbPredicates](#rdbpredicates) | **RdbPredicates** with the OR condition.|
1000
1001**Example**
1002
1003```ts
1004// Locate the employees named Lisa or Rose in the table.
1005let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1006predicates.equalTo("NAME", "Lisa")
1007    .or()
1008    .equalTo("NAME", "Rose")
1009```
1010
1011### and
1012
1013and(): RdbPredicates
1014
1015Adds the AND condition to the **RdbPredicates**.
1016
1017**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1018
1019**Return value**
1020
1021| Type                                | Description                     |
1022| ------------------------------------ | ------------------------- |
1023| [RdbPredicates](#rdbpredicates) | **RdbPredicates** with the AND condition.|
1024
1025**Example**
1026
1027```ts
1028// Locate the field with name of Lisa and salary of 200.5 in the table.
1029let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1030predicates.equalTo("NAME", "Lisa")
1031    .and()
1032    .equalTo("SALARY", 200.5)
1033```
1034
1035### contains
1036
1037contains(field: string, value: string): RdbPredicates
1038
1039Sets an **RdbPredicates** object to match the fields in the specified column that contain the given value.
1040
1041**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1042
1043**Parameters**
1044
1045| Name| Type  | Mandatory| Description                  |
1046| ------ | ------ | ---- | ---------------------- |
1047| field  | string | Yes  | Column name in the database table.    |
1048| value  | string | Yes  | Value to match the **RdbPredicates**.|
1049
1050**Return value**
1051
1052| Type                                | Description                      |
1053| ------------------------------------ | -------------------------- |
1054| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1055
1056**Example**
1057
1058```ts
1059// Locate data of the employees whose name contains os, for example, Rose, in the table.
1060let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1061predicates.contains("NAME", "os");
1062```
1063
1064### beginsWith
1065
1066beginsWith(field: string, value: string): RdbPredicates
1067
1068Sets an **RdbPredicates** object to match the fields in the specified column that begin with the given value.
1069
1070**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1071
1072**Parameters**
1073
1074| Name| Type  | Mandatory| Description                  |
1075| ------ | ------ | ---- | ---------------------- |
1076| field  | string | Yes  | Column name in the database table.    |
1077| value  | string | Yes  | Value to match the **RdbPredicates**.|
1078
1079**Return value**
1080
1081| Type                                | Description                      |
1082| ------------------------------------ | -------------------------- |
1083| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1084
1085**Example**
1086
1087```ts
1088// Locate data of the employees whose name begins with Li, for example, Lisa, in the table.
1089let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1090predicates.beginsWith("NAME", "Li");
1091```
1092
1093### endsWith
1094
1095endsWith(field: string, value: string): RdbPredicates
1096
1097Sets an **RdbPredicates** object to match the fields in the specified column that end with the given value.
1098
1099**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1100
1101**Parameters**
1102
1103| Name| Type  | Mandatory| Description                  |
1104| ------ | ------ | ---- | ---------------------- |
1105| field  | string | Yes  | Column name in the database table.    |
1106| value  | string | Yes  | Value to match the **RdbPredicates**.|
1107
1108**Return value**
1109
1110| Type                                | Description                      |
1111| ------------------------------------ | -------------------------- |
1112| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1113
1114**Example**
1115
1116```ts
1117// Locate data of the employees whose name ends with se, for example, Rose, in the table.
1118let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1119predicates.endsWith("NAME", "se");
1120```
1121
1122### isNull
1123
1124isNull(field: string): RdbPredicates
1125
1126Sets an **RdbPredicates** object to match the fields in the specified column that are **null**.
1127
1128**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1129
1130**Parameters**
1131
1132| Name| Type  | Mandatory| Description              |
1133| ------ | ------ | ---- | ------------------ |
1134| field  | string | Yes  | Column name in the database table.|
1135
1136**Return value**
1137
1138| Type                                | Description                      |
1139| ------------------------------------ | -------------------------- |
1140| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1141
1142**Example**
1143
1144```ts
1145let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1146predicates.isNull("NAME");
1147```
1148
1149### isNotNull
1150
1151isNotNull(field: string): RdbPredicates
1152
1153Sets an **RdbPredicates** object to match the fields in the specified column that are not **null**.
1154
1155**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1156
1157**Parameters**
1158
1159| Name| Type  | Mandatory| Description              |
1160| ------ | ------ | ---- | ------------------ |
1161| field  | string | Yes  | Column name in the database table.|
1162
1163**Return value**
1164
1165| Type                                | Description                      |
1166| ------------------------------------ | -------------------------- |
1167| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1168
1169**Example**
1170
1171```ts
1172let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1173predicates.isNotNull("NAME");
1174```
1175
1176### like
1177
1178like(field: string, value: string): RdbPredicates
1179
1180Sets an **RdbPredicates** object to match the fields in the specified column that are similar to the given value.
1181
1182**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1183
1184**Parameters**
1185
1186| Name| Type  | Mandatory| Description                  |
1187| ------ | ------ | ---- | ---------------------- |
1188| field  | string | Yes  | Column name in the database table.    |
1189| value  | string | Yes  | Value to match the **RdbPredicates**.|
1190
1191**Return value**
1192
1193| Type                                | Description                      |
1194| ------------------------------------ | -------------------------- |
1195| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1196
1197**Example**
1198
1199```ts
1200// Locate data of the employees whose name is similar to os in the table, for example, Rose.
1201let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1202predicates.like("NAME", "%os%");
1203```
1204
1205### glob
1206
1207glob(field: string, value: string): RdbPredicates
1208
1209Sets an **RdbPredicates** object to locate the fields in the specified column that match the given string.
1210
1211**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1212
1213**Parameters**
1214
1215| Name| Type  | Mandatory| Description                                                        |
1216| ------ | ------ | ---- | ------------------------------------------------------------ |
1217| field  | string | Yes  | Column name in the database table.                                          |
1218| 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.|
1219
1220**Return value**
1221
1222| Type                                | Description                      |
1223| ------------------------------------ | -------------------------- |
1224| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1225
1226**Example**
1227
1228```ts
1229// Locate data of the employees whose name matches the "?h*g" string in the table.
1230let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1231predicates.glob("NAME", "?h*g");
1232```
1233
1234### between
1235
1236between(field: string, low: ValueType, high: ValueType): RdbPredicates
1237
1238Sets an **RdbPredicates** object to match the fields in the specified column that are within the given range (including the min. and max. values).
1239
1240**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1241
1242**Parameters**
1243
1244| Name| Type                   | Mandatory| Description                      |
1245| ------ | ----------------------- | ---- | -------------------------- |
1246| field  | string                  | Yes  | Column name in the database table.        |
1247| low    | [ValueType](#valuetype) | Yes  | Minimum value to match.  |
1248| high   | [ValueType](#valuetype) | Yes  | Maximum value to match.|
1249
1250**Return value**
1251
1252| Type                                | Description                      |
1253| ------------------------------------ | -------------------------- |
1254| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1255
1256**Example**
1257
1258```ts
1259// Locate data of the employees with age between 10 and 50 (including 10 and 50) in the table.
1260let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1261predicates.between("AGE", 10, 50);
1262```
1263
1264### notBetween
1265
1266notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates
1267
1268Sets an **RdbPredicates** object to match the fields in the specified column that are out of the given range (excluding the min. and max. values).
1269
1270**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1271
1272**Parameters**
1273
1274| Name| Type                   | Mandatory| Description                      |
1275| ------ | ----------------------- | ---- | -------------------------- |
1276| field  | string                  | Yes  | Column name in the database table.        |
1277| low    | [ValueType](#valuetype) | Yes  | Minimum value to match.  |
1278| high   | [ValueType](#valuetype) | Yes  | Maximum value to match.|
1279
1280**Return value**
1281
1282| Type                                | Description                      |
1283| ------------------------------------ | -------------------------- |
1284| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1285
1286**Example**
1287
1288```ts
1289// Locate data of the employees who are younger than 10 or older than 50 in the table.
1290let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1291predicates.notBetween("AGE", 10, 50);
1292```
1293
1294### greaterThan
1295
1296greaterThan(field: string, value: ValueType): RdbPredicates
1297
1298Sets an **RdbPredicates** object to match the fields in the specified column that are greater than the given value.
1299
1300**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1301
1302**Parameters**
1303
1304| Name| Type                   | Mandatory| Description                  |
1305| ------ | ----------------------- | ---- | ---------------------- |
1306| field  | string                  | Yes  | Column name in the database table.    |
1307| value  | [ValueType](#valuetype) | Yes  | Value to match the **RdbPredicates**.|
1308
1309**Return value**
1310
1311| Type                                | Description                      |
1312| ------------------------------------ | -------------------------- |
1313| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1314
1315**Example**
1316
1317```ts
1318// Locate data of the employees who are older than 18 in the table.
1319let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1320predicates.greaterThan("AGE", 18);
1321```
1322
1323### lessThan
1324
1325lessThan(field: string, value: ValueType): RdbPredicates
1326
1327Sets an **RdbPredicates** object to match the fields in the specified column that are less than the given value.
1328
1329**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1330
1331**Parameters**
1332
1333| Name| Type                   | Mandatory| Description                  |
1334| ------ | ----------------------- | ---- | ---------------------- |
1335| field  | string                  | Yes  | Column name in the database table.    |
1336| value  | [ValueType](#valuetype) | Yes  | Value to match the **RdbPredicates**.|
1337
1338**Return value**
1339
1340| Type                                | Description                      |
1341| ------------------------------------ | -------------------------- |
1342| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1343
1344**Example**
1345
1346```ts
1347// Locate data of the employees who are younger than 20 in the table.
1348let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1349predicates.lessThan("AGE", 20);
1350```
1351
1352### greaterThanOrEqualTo
1353
1354greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates
1355
1356Sets an **RdbPredicates** object to match the fields in the specified column that are greater than or equal to the given value.
1357
1358**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1359
1360**Parameters**
1361
1362| Name| Type                   | Mandatory| Description                  |
1363| ------ | ----------------------- | ---- | ---------------------- |
1364| field  | string                  | Yes  | Column name in the database table.    |
1365| value  | [ValueType](#valuetype) | Yes  | Value to match the **RdbPredicates**.|
1366
1367**Return value**
1368
1369| Type                                | Description                      |
1370| ------------------------------------ | -------------------------- |
1371| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1372
1373**Example**
1374
1375```ts
1376// Locate data of the employees who are 18 or older in the table.
1377let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1378predicates.greaterThanOrEqualTo("AGE", 18);
1379```
1380
1381### lessThanOrEqualTo
1382
1383lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates
1384
1385Sets an **RdbPredicates** object to match the fields in the specified column that are less than or equal to the given value.
1386
1387**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1388
1389**Parameters**
1390
1391| Name| Type                   | Mandatory| Description                  |
1392| ------ | ----------------------- | ---- | ---------------------- |
1393| field  | string                  | Yes  | Column name in the database table.    |
1394| value  | [ValueType](#valuetype) | Yes  | Value to match the **RdbPredicates**.|
1395
1396**Return value**
1397
1398| Type                                | Description                      |
1399| ------------------------------------ | -------------------------- |
1400| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1401
1402**Example**
1403
1404```ts
1405// Locate data of the employees who are 20 or younger in the table.
1406let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1407predicates.lessThanOrEqualTo("AGE", 20);
1408```
1409
1410### orderByAsc
1411
1412orderByAsc(field: string): RdbPredicates
1413
1414Sets an **RdbPredicates** object to sort the fields in the specified column in ascending order.
1415
1416**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1417
1418**Parameters**
1419
1420| Name| Type  | Mandatory| Description              |
1421| ------ | ------ | ---- | ------------------ |
1422| field  | string | Yes  | Column name in the database table.|
1423
1424**Return value**
1425
1426| Type                                | Description                      |
1427| ------------------------------------ | -------------------------- |
1428| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1429
1430**Example**
1431
1432```ts
1433let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1434predicates.orderByAsc("NAME");
1435```
1436
1437### orderByDesc
1438
1439orderByDesc(field: string): RdbPredicates
1440
1441Sets an **RdbPredicates** object to sort the fields in the specified column in descending order.
1442
1443**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1444
1445**Parameters**
1446
1447| Name| Type  | Mandatory| Description              |
1448| ------ | ------ | ---- | ------------------ |
1449| field  | string | Yes  | Column name in the database table.|
1450
1451**Return value**
1452
1453| Type                                | Description                      |
1454| ------------------------------------ | -------------------------- |
1455| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1456
1457**Example**
1458
1459```ts
1460let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1461predicates.orderByDesc("AGE");
1462```
1463
1464### distinct
1465
1466distinct(): RdbPredicates
1467
1468Sets an **RdbPredicates** object to filter out duplicate records.
1469
1470**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1471
1472**Return value**
1473
1474| Type                                | Description                          |
1475| ------------------------------------ | ------------------------------ |
1476| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that can filter out duplicate records.|
1477
1478**Example**
1479
1480```ts
1481let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1482predicates.equalTo("NAME", "Rose").distinct();
1483```
1484
1485### limitAs
1486
1487limitAs(value: number): RdbPredicates
1488
1489Sets an **RdbPredicates** object to specify the maximum number of records.
1490
1491**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1492
1493**Parameters**
1494
1495| Name| Type  | Mandatory| Description            |
1496| ------ | ------ | ---- | ---------------- |
1497| value  | number | Yes  | Maximum number of records.|
1498
1499**Return value**
1500
1501| Type                                | Description                                |
1502| ------------------------------------ | ------------------------------------ |
1503| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the maximum number of records.|
1504
1505**Example**
1506
1507```ts
1508let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1509predicates.equalTo("NAME", "Rose").limitAs(3);
1510```
1511
1512### offsetAs
1513
1514offsetAs(rowOffset: number): RdbPredicates
1515
1516Sets an **RdbPredicates** object to specify the start position of the returned result.
1517
1518**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1519
1520**Parameters**
1521
1522| Name   | Type  | Mandatory| Description                              |
1523| --------- | ------ | ---- | ---------------------------------- |
1524| rowOffset | number | Yes  | Number of rows to offset from the beginning. The value is a positive integer.|
1525
1526**Return value**
1527
1528| Type                                | Description                                |
1529| ------------------------------------ | ------------------------------------ |
1530| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the start position of the returned result.|
1531
1532**Example**
1533
1534```ts
1535let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1536predicates.equalTo("NAME", "Rose").offsetAs(3);
1537```
1538
1539### groupBy
1540
1541groupBy(fields: Array&lt;string&gt;): RdbPredicates
1542
1543Sets an **RdbPredicates** object to group rows that have the same value into summary rows.
1544
1545**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1546
1547**Parameters**
1548
1549| Name| Type               | Mandatory| Description                |
1550| ------ | ------------------- | ---- | -------------------- |
1551| fields | Array&lt;string&gt; | Yes  | Names of columns to group.|
1552
1553**Return value**
1554
1555| Type                                | Description                  |
1556| ------------------------------------ | ---------------------- |
1557| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that groups rows with the same value.|
1558
1559**Example**
1560
1561```ts
1562let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1563predicates.groupBy(["AGE", "NAME"]);
1564```
1565
1566### indexedBy
1567
1568indexedBy(field: string): RdbPredicates
1569
1570Sets an **RdbPredicates** object to specify the index column.
1571
1572**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1573
1574**Parameters**
1575
1576| Name| Type  | Mandatory| Description          |
1577| ------ | ------ | ---- | -------------- |
1578| field  | string | Yes  | Name of the index column.|
1579
1580**Return value**
1581
1582
1583| Type                                | Description                                 |
1584| ------------------------------------ | ------------------------------------- |
1585| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object that specifies the index column.|
1586
1587**Example**
1588
1589```ts
1590let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1591predicates.indexedBy("SALARY");
1592```
1593
1594### in
1595
1596in(field: string, value: Array&lt;ValueType&gt;): RdbPredicates
1597
1598Sets an **RdbPredicates** object to match the fields in the specified column that are in the given range.
1599
1600**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1601
1602**Parameters**
1603
1604| Name| Type                                | Mandatory| Description                                   |
1605| ------ | ------------------------------------ | ---- | --------------------------------------- |
1606| field  | string                               | Yes  | Column name in the database table.                     |
1607| value  | Array&lt;[ValueType](#valuetype)&gt; | Yes  | Array of **ValueType**s to match.|
1608
1609**Return value**
1610
1611| Type                                | Description                      |
1612| ------------------------------------ | -------------------------- |
1613| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1614
1615**Example**
1616
1617```ts
1618// Locate data of the employees with age of [18, 20] in the table.
1619let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1620predicates.in("AGE", [18, 20]);
1621```
1622
1623### notIn
1624
1625notIn(field: string, value: Array&lt;ValueType&gt;): RdbPredicates
1626
1627Sets an **RdbPredicates** object to match the fields in the specified column that are out of the given range.
1628
1629**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1630
1631**Parameters**
1632
1633| Name| Type                                | Mandatory| Description                                 |
1634| ------ | ------------------------------------ | ---- | ------------------------------------- |
1635| field  | string                               | Yes  | Column name in the database table.                   |
1636| value  | Array&lt;[ValueType](#valuetype)&gt; | Yes  | Array of **ValueType**s to match.|
1637
1638**Return value**
1639
1640| Type                                | Description                      |
1641| ------------------------------------ | -------------------------- |
1642| [RdbPredicates](#rdbpredicates) | **RdbPredicates** object created.|
1643
1644**Example**
1645
1646```ts
1647// Locate data of all the employees except Lisa and Rose in the table.
1648let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
1649predicates.notIn("NAME", ["Lisa", "Rose"]);
1650```
1651
1652## RdbStore
1653
1654Provides APIs to manage an RDB store.
1655
1656Before using the APIs of this class, use [executeSql](#executesql) to initialize the database table structure and related data.
1657
1658### Attributes<sup>10+</sup>
1659
1660**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1661
1662| Name        | Type           | Mandatory| Description                            |
1663| ------------ | ----------- | ---- | -------------------------------- |
1664| version<sup>10+</sup>  | number | Yes  | RDB store version, which is an integer greater than 0.      |
1665
1666**Example**
1667
1668```ts
1669// Set the RDB store version.
1670if(store != undefined) {
1671  (store as relationalStore.RdbStore).version = 3;
1672  // Obtain the RDB store version.
1673  console.info(`RdbStore version is ${store.version}`);
1674}
1675```
1676
1677### insert
1678
1679insert(table: string, values: ValuesBucket, callback: AsyncCallback&lt;number&gt;):void
1680
1681Inserts 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.
1682
1683**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1684
1685**Parameters**
1686
1687| Name  | Type                         | Mandatory| Description                                                      |
1688| -------- | ----------------------------- | ---- | ---------------------------------------------------------- |
1689| table    | string                        | Yes  | Name of the target table.                                          |
1690| values   | [ValuesBucket](#valuesbucket) | Yes  | Row of data to insert.                                |
1691| callback | AsyncCallback&lt;number&gt;   | Yes  | Callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
1692
1693**Error codes**
1694
1695For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
1696
1697| **ID**| **Error Message**                                |
1698| ------------ | -------------------------------------------- |
1699| 14800047     | The WAL file size exceeds the default limit. |
1700| 14800000     | Inner error.                                 |
1701
1702**Example**
1703
1704```ts
1705import { ValuesBucket } from '@ohos.data.ValuesBucket';
1706
1707let value1 = "Lisa";
1708let value2 = 18;
1709let value3 = 100.5;
1710let value4 = new Uint8Array([1, 2, 3, 4, 5]);
1711
1712// You can use either of the following:
1713const valueBucket1: ValuesBucket = {
1714  'NAME': value1,
1715  'AGE': value2,
1716  'SALARY': value3,
1717  'CODES': value4,
1718};
1719const valueBucket2: ValuesBucket = {
1720  NAME: value1,
1721  AGE: value2,
1722  SALARY: value3,
1723  CODES: value4,
1724};
1725const valueBucket3: ValuesBucket = {
1726  "NAME": value1,
1727  "AGE": value2,
1728  "SALARY": value3,
1729  "CODES": value4,
1730};
1731
1732if(store != undefined) {
1733  (store as relationalStore.RdbStore).insert("EMPLOYEE", valueBucket1, (err: BusinessError, rowId: number) => {
1734    if (err) {
1735      console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
1736      return;
1737    }
1738    console.info(`Insert is successful, rowId = ${rowId}`);
1739  })
1740}
1741```
1742
1743### insert<sup>10+</sup>
1744
1745insert(table: string, values: ValuesBucket,  conflict: ConflictResolution, callback: AsyncCallback&lt;number&gt;):void
1746
1747Inserts 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.
1748
1749**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1750
1751**Parameters**
1752
1753| Name  | Type                                       | Mandatory| Description                                                      |
1754| -------- | ------------------------------------------- | ---- | ---------------------------------------------------------- |
1755| table    | string                                      | Yes  | Name of the target table.                                          |
1756| values   | [ValuesBucket](#valuesbucket)               | Yes  | Row of data to insert.                                |
1757| conflict | [ConflictResolution](#conflictresolution10) | Yes  | Resolution used to resolve the conflict.                                        |
1758| callback | AsyncCallback&lt;number&gt;                 | Yes  | Callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
1759
1760**Error codes**
1761
1762For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
1763
1764| **ID**| **Error Message**                                |
1765| ------------ | -------------------------------------------- |
1766| 14800047     | The WAL file size exceeds the default limit. |
1767| 14800000     | Inner error.                                 |
1768
1769**Example**
1770
1771```ts
1772import { ValuesBucket } from '@ohos.data.ValuesBucket';
1773
1774let value1 = "Lisa";
1775let value2 = 18;
1776let value3 = 100.5;
1777let value4 = new Uint8Array([1, 2, 3, 4, 5]);
1778
1779// You can use either of the following:
1780const valueBucket1: ValuesBucket = {
1781  'NAME': value1,
1782  'AGE': value2,
1783  'SALARY': value3,
1784  'CODES': value4,
1785};
1786const valueBucket2: ValuesBucket = {
1787  NAME: value1,
1788  AGE: value2,
1789  SALARY: value3,
1790  CODES: value4,
1791};
1792const valueBucket3: ValuesBucket = {
1793  "NAME": value1,
1794  "AGE": value2,
1795  "SALARY": value3,
1796  "CODES": value4,
1797};
1798
1799if(store != undefined) {
1800  (store as relationalStore.RdbStore).insert("EMPLOYEE", valueBucket1, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE,
1801    (err: BusinessError, rowId: number) => {
1802      if (err) {
1803        console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
1804        return;
1805      }
1806      console.info(`Insert is successful, rowId = ${rowId}`);
1807  })
1808}
1809```
1810
1811### insert
1812
1813insert(table: string, values: ValuesBucket):Promise&lt;number&gt;
1814
1815Inserts 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.
1816
1817**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1818
1819**Parameters**
1820
1821| Name| Type                         | Mandatory| Description                      |
1822| ------ | ----------------------------- | ---- | -------------------------- |
1823| table  | string                        | Yes  | Name of the target table.          |
1824| values | [ValuesBucket](#valuesbucket) | Yes  | Row of data to insert.|
1825
1826**Return value**
1827
1828| Type                 | Description                                             |
1829| --------------------- | ------------------------------------------------- |
1830| 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.|
1831
1832**Error codes**
1833
1834For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
1835
1836| **ID**| **Error Message**                                |
1837| ------------ | -------------------------------------------- |
1838| 14800047     | The WAL file size exceeds the default limit. |
1839| 14800000     | Inner error.                                 |
1840
1841**Example**
1842
1843```ts
1844import { ValuesBucket } from '@ohos.data.ValuesBucket';
1845import { BusinessError } from "@ohos.base";
1846
1847let value1 = "Lisa";
1848let value2 = 18;
1849let value3 = 100.5;
1850let value4 = new Uint8Array([1, 2, 3, 4, 5]);
1851
1852// You can use either of the following:
1853const valueBucket1: ValuesBucket = {
1854  'NAME': value1,
1855  'AGE': value2,
1856  'SALARY': value3,
1857  'CODES': value4,
1858};
1859const valueBucket2: ValuesBucket = {
1860  NAME: value1,
1861  AGE: value2,
1862  SALARY: value3,
1863  CODES: value4,
1864};
1865const valueBucket3: ValuesBucket = {
1866  "NAME": value1,
1867  "AGE": value2,
1868  "SALARY": value3,
1869  "CODES": value4,
1870};
1871
1872if(store != undefined) {
1873  (store as relationalStore.RdbStore).insert("EMPLOYEE", valueBucket1).then((rowId: number) => {
1874    console.info(`Insert is successful, rowId = ${rowId}`);
1875  }).catch((err: BusinessError) => {
1876    console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
1877  })
1878}
1879```
1880
1881### insert<sup>10+</sup>
1882
1883insert(table: string, values: ValuesBucket,  conflict: ConflictResolution):Promise&lt;number&gt;
1884
1885Inserts 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.
1886
1887**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1888
1889**Parameters**
1890
1891| Name  | Type                                       | Mandatory| Description                      |
1892| -------- | ------------------------------------------- | ---- | -------------------------- |
1893| table    | string                                      | Yes  | Name of the target table.          |
1894| values   | [ValuesBucket](#valuesbucket)               | Yes  | Row of data to insert.|
1895| conflict | [ConflictResolution](#conflictresolution10) | Yes  | Resolution used to resolve the conflict.        |
1896
1897**Return value**
1898
1899| Type                 | Description                                             |
1900| --------------------- | ------------------------------------------------- |
1901| 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.|
1902
1903**Error codes**
1904
1905For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
1906
1907| **ID**| **Error Message**                                |
1908| ------------ | -------------------------------------------- |
1909| 14800047     | The WAL file size exceeds the default limit. |
1910| 14800000     | Inner error.                                 |
1911
1912**Example**
1913
1914```ts
1915import { ValuesBucket } from '@ohos.data.ValuesBucket';
1916import { BusinessError } from "@ohos.base";
1917
1918let value1 = "Lisa";
1919let value2 = 18;
1920let value3 = 100.5;
1921let value4 = new Uint8Array([1, 2, 3, 4, 5]);
1922
1923// You can use either of the following:
1924const valueBucket1: ValuesBucket = {
1925  'NAME': value1,
1926  'AGE': value2,
1927  'SALARY': value3,
1928  'CODES': value4,
1929};
1930const valueBucket2: ValuesBucket = {
1931  NAME: value1,
1932  AGE: value2,
1933  SALARY: value3,
1934  CODES: value4,
1935};
1936const valueBucket3: ValuesBucket = {
1937  "NAME": value1,
1938  "AGE": value2,
1939  "SALARY": value3,
1940  "CODES": value4,
1941};
1942
1943if(store != undefined) {
1944  (store as relationalStore.RdbStore).insert("EMPLOYEE", valueBucket1, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE).then((rowId: number) => {
1945    console.info(`Insert is successful, rowId = ${rowId}`);
1946  }).catch((err: BusinessError) => {
1947    console.error(`Insert is failed, code is ${err.code},message is ${err.message}`);
1948  })
1949}
1950```
1951
1952### batchInsert
1953
1954batchInsert(table: string, values: Array&lt;ValuesBucket&gt;, callback: AsyncCallback&lt;number&gt;):void
1955
1956Batch inserts data into a table. This API uses an asynchronous callback to return the result.
1957
1958**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1959
1960**Parameters**
1961
1962| Name  | Type                                      | Mandatory| Description                                                        |
1963| -------- | ------------------------------------------ | ---- | ------------------------------------------------------------ |
1964| table    | string                                     | Yes  | Name of the target table.                                            |
1965| values   | Array&lt;[ValuesBucket](#valuesbucket)&gt; | Yes  | An array of data to insert.                                |
1966| callback | AsyncCallback&lt;number&gt;                | Yes  | Callback invoked to return the result. If the operation is successful, the number of inserted data records is returned. Otherwise, **-1** is returned.|
1967
1968**Error codes**
1969
1970For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
1971
1972| **ID**| **Error Message**                                |
1973| ------------ | -------------------------------------------- |
1974| 14800047     | The WAL file size exceeds the default limit. |
1975| 14800000     | Inner error.                                 |
1976
1977**Example**
1978
1979```ts
1980import { ValuesBucket } from '@ohos.data.ValuesBucket';
1981
1982let value1 = "Lisa";
1983let value2 = 18;
1984let value3 = 100.5;
1985let value4 = new Uint8Array([1, 2, 3, 4, 5]);
1986let value5 = "Jack";
1987let value6 = 19;
1988let value7 = 101.5;
1989let value8 = new Uint8Array([6, 7, 8, 9, 10]);
1990let value9 = "Tom";
1991let value10 = 20;
1992let value11 = 102.5;
1993let value12 = new Uint8Array([11, 12, 13, 14, 15]);
1994
1995const valueBucket1: ValuesBucket = {
1996  'NAME': value1,
1997  'AGE': value2,
1998  'SALARY': value3,
1999  'CODES': value4,
2000};
2001const valueBucket2: ValuesBucket = {
2002  'NAME': value5,
2003  'AGE': value6,
2004  'SALARY': value7,
2005  'CODES': value8,
2006};
2007const valueBucket3: ValuesBucket = {
2008  'NAME': value9,
2009  'AGE': value10,
2010  'SALARY': value11,
2011  'CODES': value12,
2012};
2013
2014let valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3);
2015if(store != undefined) {
2016  (store as relationalStore.RdbStore).batchInsert("EMPLOYEE", valueBuckets, (err, insertNum) => {
2017    if (err) {
2018      console.error(`batchInsert is failed, code is ${err.code},message is ${err.message}`);
2019      return;
2020    }
2021    console.info(`batchInsert is successful, the number of values that were inserted = ${insertNum}`);
2022  })
2023}
2024```
2025
2026### batchInsert
2027
2028batchInsert(table: string, values: Array&lt;ValuesBucket&gt;):Promise&lt;number&gt;
2029
2030Batch inserts data into a table. This API uses a promise to return the result.
2031
2032**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2033
2034**Parameters**
2035
2036| Name| Type                                      | Mandatory| Description                        |
2037| ------ | ------------------------------------------ | ---- | ---------------------------- |
2038| table  | string                                     | Yes  | Name of the target table.            |
2039| values | Array&lt;[ValuesBucket](#valuesbucket)&gt; | Yes  | An array of data to insert.|
2040
2041**Return value**
2042
2043| Type                 | Description                                                       |
2044| --------------------- | ----------------------------------------------------------- |
2045| 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.|
2046
2047**Error codes**
2048
2049For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
2050
2051| **ID**| **Error Message**                                |
2052| ------------ | -------------------------------------------- |
2053| 14800047     | The WAL file size exceeds the default limit. |
2054| 14800000     | Inner error.                                 |
2055
2056**Example**
2057
2058```ts
2059import { ValuesBucket } from '@ohos.data.ValuesBucket';
2060import { BusinessError } from "@ohos.base";
2061
2062let value1 = "Lisa";
2063let value2 = 18;
2064let value3 = 100.5;
2065let value4 = new Uint8Array([1, 2, 3, 4, 5]);
2066let value5 = "Jack";
2067let value6 = 19;
2068let value7 = 101.5;
2069let value8 = new Uint8Array([6, 7, 8, 9, 10]);
2070let value9 = "Tom";
2071let value10 = 20;
2072let value11 = 102.5;
2073let value12 = new Uint8Array([11, 12, 13, 14, 15]);
2074
2075const valueBucket1: ValuesBucket = {
2076  'NAME': value1,
2077  'AGE': value2,
2078  'SALARY': value3,
2079  'CODES': value4,
2080};
2081const valueBucket2: ValuesBucket = {
2082  'NAME': value5,
2083  'AGE': value6,
2084  'SALARY': value7,
2085  'CODES': value8,
2086};
2087const valueBucket3: ValuesBucket = {
2088  'NAME': value9,
2089  'AGE': value10,
2090  'SALARY': value11,
2091  'CODES': value12,
2092};
2093
2094let valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3);
2095if(store != undefined) {
2096  (store as relationalStore.RdbStore).batchInsert("EMPLOYEE", valueBuckets).then((insertNum: number) => {
2097    console.info(`batchInsert is successful, the number of values that were inserted = ${insertNum}`);
2098  }).catch((err: BusinessError) => {
2099    console.error(`batchInsert is failed, code is ${err.code},message is ${err.message}`);
2100  })
2101}
2102```
2103
2104### update
2105
2106update(values: ValuesBucket, predicates: RdbPredicates, callback: AsyncCallback&lt;number&gt;):void
2107
2108Updates 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.
2109
2110**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2111
2112**Parameters**
2113
2114| Name    | Type                                | Mandatory| Description                                                        |
2115| ---------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
2116| 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.|
2117| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Update conditions specified by the **RdbPredicates** object.                   |
2118| callback   | AsyncCallback&lt;number&gt;          | Yes  | Callback invoked to return the number of rows updated.                  |
2119
2120**Error codes**
2121
2122For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
2123
2124| **ID**| **Error Message**                                |
2125| ------------ | -------------------------------------------- |
2126| 14800047     | The WAL file size exceeds the default limit. |
2127| 14800000     | Inner error.                                 |
2128
2129**Example**
2130
2131```ts
2132import { ValuesBucket } from '@ohos.data.ValuesBucket';
2133
2134let value1 = "Rose";
2135let value2 = 22;
2136let value3 = 200.5;
2137let value4 = new Uint8Array([1, 2, 3, 4, 5]);
2138
2139// You can use either of the following:
2140const valueBucket1: ValuesBucket = {
2141  'NAME': value1,
2142  'AGE': value2,
2143  'SALARY': value3,
2144  'CODES': value4,
2145};
2146const valueBucket2: ValuesBucket = {
2147  NAME: value1,
2148  AGE: value2,
2149  SALARY: value3,
2150  CODES: value4,
2151};
2152const valueBucket3: ValuesBucket = {
2153  "NAME": value1,
2154  "AGE": value2,
2155  "SALARY": value3,
2156  "CODES": value4,
2157};
2158
2159let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
2160predicates.equalTo("NAME", "Lisa");
2161if(store != undefined) {
2162  (store as relationalStore.RdbStore).update(valueBucket1, predicates,(err, rows) => {
2163    if (err) {
2164      console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
2165      return;
2166    }
2167    console.info(`Updated row count: ${rows}`);
2168  })
2169}
2170```
2171
2172### update<sup>10+</sup>
2173
2174update(values: ValuesBucket, predicates: RdbPredicates, conflict: ConflictResolution, callback: AsyncCallback&lt;number&gt;):void
2175
2176Updates 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.
2177
2178**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2179
2180**Parameters**
2181
2182| Name    | Type                                       | Mandatory| Description                                                        |
2183| ---------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
2184| 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.|
2185| predicates | [RdbPredicates](#rdbpredicates)            | Yes  | Update conditions specified by the **RdbPredicates** object.                     |
2186| conflict   | [ConflictResolution](#conflictresolution10) | Yes  | Resolution used to resolve the conflict.                                          |
2187| callback   | AsyncCallback&lt;number&gt;                 | Yes  | Callback invoked to return the number of rows updated.                  |
2188
2189**Error codes**
2190
2191For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
2192
2193| **ID**| **Error Message**                                |
2194| ------------ | -------------------------------------------- |
2195| 14800047     | The WAL file size exceeds the default limit. |
2196| 14800000     | Inner error.                                 |
2197
2198**Example**
2199
2200```ts
2201import { ValuesBucket } from '@ohos.data.ValuesBucket';
2202
2203let value1 = "Rose";
2204let value2 = 22;
2205let value3 = 200.5;
2206let value4 = new Uint8Array([1, 2, 3, 4, 5]);
2207
2208// You can use either of the following:
2209const valueBucket1: ValuesBucket = {
2210  'NAME': value1,
2211  'AGE': value2,
2212  'SALARY': value3,
2213  'CODES': value4,
2214};
2215const valueBucket2: ValuesBucket = {
2216  NAME: value1,
2217  AGE: value2,
2218  SALARY: value3,
2219  CODES: value4,
2220};
2221const valueBucket3: ValuesBucket = {
2222  "NAME": value1,
2223  "AGE": value2,
2224  "SALARY": value3,
2225  "CODES": value4,
2226};
2227
2228let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
2229predicates.equalTo("NAME", "Lisa");
2230if(store != undefined) {
2231  (store as relationalStore.RdbStore).update(valueBucket1, predicates, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE, (err, rows) => {
2232    if (err) {
2233      console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
2234      return;
2235    }
2236    console.info(`Updated row count: ${rows}`);
2237  })
2238}
2239```
2240
2241### update
2242
2243update(values: ValuesBucket, predicates: RdbPredicates):Promise&lt;number&gt;
2244
2245Updates 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.
2246
2247**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2248
2249**Parameters**
2250
2251| Name      | Type                                | Mandatory| Description                                                        |
2252| ------------ | ------------------------------------ | ---- | ------------------------------------------------------------ |
2253| 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.|
2254| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Update conditions specified by the **RdbPredicates** object.                   |
2255
2256**Return value**
2257
2258| Type                 | Description                                     |
2259| --------------------- | ----------------------------------------- |
2260| Promise&lt;number&gt; | Promise used to return the number of rows updated.|
2261
2262**Error codes**
2263
2264For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
2265
2266| **ID**| **Error Message**                                |
2267| ------------ | -------------------------------------------- |
2268| 14800047     | The WAL file size exceeds the default limit. |
2269| 14800000     | Inner error.                                 |
2270
2271**Example**
2272
2273```ts
2274import { ValuesBucket } from '@ohos.data.ValuesBucket';
2275import { BusinessError } from "@ohos.base";
2276
2277let value1 = "Rose";
2278let value2 = 22;
2279let value3 = 200.5;
2280let value4 = new Uint8Array([1, 2, 3, 4, 5]);
2281
2282// You can use either of the following:
2283const valueBucket1: ValuesBucket = {
2284  'NAME': value1,
2285  'AGE': value2,
2286  'SALARY': value3,
2287  'CODES': value4,
2288};
2289const valueBucket2: ValuesBucket = {
2290  NAME: value1,
2291  AGE: value2,
2292  SALARY: value3,
2293  CODES: value4,
2294};
2295const valueBucket3: ValuesBucket = {
2296  "NAME": value1,
2297  "AGE": value2,
2298  "SALARY": value3,
2299  "CODES": value4,
2300};
2301
2302let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
2303predicates.equalTo("NAME", "Lisa");
2304if(store != undefined) {
2305  (store as relationalStore.RdbStore).update(valueBucket1, predicates).then(async (rows: Number) => {
2306    console.info(`Updated row count: ${rows}`);
2307  }).catch((err: BusinessError) => {
2308    console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
2309  })
2310}
2311```
2312
2313### update<sup>10+</sup>
2314
2315update(values: ValuesBucket, predicates: RdbPredicates, conflict: ConflictResolution):Promise&lt;number&gt;
2316
2317Updates 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.
2318
2319**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2320
2321**Parameters**
2322
2323| Name    | Type                                       | Mandatory| Description                                                        |
2324| ---------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
2325| 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.|
2326| predicates | [RdbPredicates](#rdbpredicates)            | Yes  | Update conditions specified by the **RdbPredicates** object.                     |
2327| conflict   | [ConflictResolution](#conflictresolution10) | Yes  | Resolution used to resolve the conflict.                                          |
2328
2329**Return value**
2330
2331| Type                 | Description                                     |
2332| --------------------- | ----------------------------------------- |
2333| Promise&lt;number&gt; | Promise used to return the number of rows updated.|
2334
2335**Error codes**
2336
2337For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
2338
2339| **ID**| **Error Message**                                |
2340| ------------ | -------------------------------------------- |
2341| 14800047     | The WAL file size exceeds the default limit. |
2342| 14800000     | Inner error.                                 |
2343
2344**Example**
2345
2346```ts
2347import { ValuesBucket } from '@ohos.data.ValuesBucket';
2348import { BusinessError } from "@ohos.base";
2349
2350let value1 = "Rose";
2351let value2 = 22;
2352let value3 = 200.5;
2353let value4 = new Uint8Array([1, 2, 3, 4, 5]);
2354
2355// You can use either of the following:
2356const valueBucket1: ValuesBucket = {
2357  'NAME': value1,
2358  'AGE': value2,
2359  'SALARY': value3,
2360  'CODES': value4,
2361};
2362const valueBucket2: ValuesBucket = {
2363  NAME: value1,
2364  AGE: value2,
2365  SALARY: value3,
2366  CODES: value4,
2367};
2368const valueBucket3: ValuesBucket = {
2369  "NAME": value1,
2370  "AGE": value2,
2371  "SALARY": value3,
2372  "CODES": value4,
2373};
2374
2375let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
2376predicates.equalTo("NAME", "Lisa");
2377if(store != undefined) {
2378  (store as relationalStore.RdbStore).update(valueBucket1, predicates, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE).then(async (rows: Number) => {
2379    console.info(`Updated row count: ${rows}`);
2380  }).catch((err: BusinessError) => {
2381    console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
2382  })
2383}
2384```
2385
2386### update
2387
2388update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback&lt;number&gt;):void
2389
2390Updates data based on the specified **DataSharePredicates** 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.
2391
2392**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2393
2394**Model restriction**: This API can be used only in the stage model.
2395
2396**System API**: This is a system API.
2397
2398**Parameters**
2399
2400| Name    | Type                                                        | Mandatory| Description                                                        |
2401| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
2402| table      | string                                                       | Yes  | Name of the target table.                                            |
2403| 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.|
2404| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes  | Update conditions specified by the **DataSharePredicates** object.               |
2405| callback   | AsyncCallback&lt;number&gt;                                  | Yes  | Callback invoked to return the number of rows updated.                  |
2406
2407**Error codes**
2408
2409For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
2410
2411| **ID**| **Error Message**                                |
2412| ------------ | -------------------------------------------- |
2413| 14800047     | The WAL file size exceeds the default limit. |
2414| 14800000     | Inner error.                                 |
2415
2416**Example**
2417
2418```ts
2419import dataSharePredicates from '@ohos.data.dataSharePredicates'
2420import { ValuesBucket } from '@ohos.data.ValuesBucket';
2421
2422let value1 = "Rose";
2423let value2 = 22;
2424let value3 = 200.5;
2425let value4 = new Uint8Array([1, 2, 3, 4, 5]);
2426
2427// You can use either of the following:
2428const valueBucket1: ValuesBucket = {
2429  'NAME': value1,
2430  'AGE': value2,
2431  'SALARY': value3,
2432  'CODES': value4,
2433};
2434const valueBucket2: ValuesBucket = {
2435  NAME: value1,
2436  AGE: value2,
2437  SALARY: value3,
2438  CODES: value4,
2439};
2440const valueBucket3: ValuesBucket = {
2441  "NAME": value1,
2442  "AGE": value2,
2443  "SALARY": value3,
2444  "CODES": value4,
2445};
2446
2447let predicates = new dataSharePredicates.DataSharePredicates();
2448predicates.equalTo("NAME", "Lisa");
2449if(store != undefined) {
2450  (store as relationalStore.RdbStore).update("EMPLOYEE", valueBucket1, predicates, (err, rows) => {
2451    if (err) {
2452      console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
2453      return;
2454    }
2455    console.info(`Updated row count: ${rows}`);
2456  })
2457}
2458```
2459
2460### update
2461
2462update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates):Promise&lt;number&gt;
2463
2464Updates data based on the specified **DataSharePredicates** 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.
2465
2466**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2467
2468**Model restriction**: This API can be used only in the stage model.
2469
2470**System API**: This is a system API.
2471
2472**Parameters**
2473
2474| Name    | Type                                                        | Mandatory| Description                                                        |
2475| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
2476| table      | string                                                       | Yes  | Name of the target table.                                            |
2477| 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.|
2478| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes  | Update conditions specified by the **DataSharePredicates** object.               |
2479
2480**Return value**
2481
2482| Type                 | Description                                     |
2483| --------------------- | ----------------------------------------- |
2484| Promise&lt;number&gt; | Promise used to return the number of rows updated.|
2485
2486**Error codes**
2487
2488For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
2489
2490| **ID**| **Error Message**                                |
2491| ------------ | -------------------------------------------- |
2492| 14800047     | The WAL file size exceeds the default limit. |
2493| 14800000     | Inner error.                                 |
2494
2495**Example**
2496
2497```ts
2498import dataSharePredicates from '@ohos.data.dataSharePredicates';
2499import { ValuesBucket } from '@ohos.data.ValuesBucket';
2500import { BusinessError } from "@ohos.base";
2501
2502let value1 = "Rose";
2503let value2 = 22;
2504let value3 = 200.5;
2505let value4 = new Uint8Array([1, 2, 3, 4, 5]);
2506
2507// You can use either of the following:
2508const valueBucket1: ValuesBucket = {
2509  'NAME': value1,
2510  'AGE': value2,
2511  'SALARY': value3,
2512  'CODES': value4,
2513};
2514const valueBucket2: ValuesBucket = {
2515  NAME: value1,
2516  AGE: value2,
2517  SALARY: value3,
2518  CODES: value4,
2519};
2520const valueBucket3: ValuesBucket = {
2521  "NAME": value1,
2522  "AGE": value2,
2523  "SALARY": value3,
2524  "CODES": value4,
2525};
2526
2527let predicates = new dataSharePredicates.DataSharePredicates();
2528predicates.equalTo("NAME", "Lisa");
2529if(store != undefined) {
2530  (store as relationalStore.RdbStore).update("EMPLOYEE", valueBucket1, predicates).then(async (rows: Number) => {
2531    console.info(`Updated row count: ${rows}`);
2532  }).catch((err: BusinessError) => {
2533    console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
2534  })
2535}
2536```
2537
2538### delete
2539
2540delete(predicates: RdbPredicates, callback: AsyncCallback&lt;number&gt;):void
2541
2542Deletes data from the RDB store based on the specified **RdbPredicates** object. This API uses an asynchronous callback to return the result.
2543
2544**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2545
2546**Parameters**
2547
2548| Name    | Type                                | Mandatory| Description                                     |
2549| ---------- | ------------------------------------ | ---- | ----------------------------------------- |
2550| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Conditions specified by the **RdbPredicates** object for deleting data.|
2551| callback   | AsyncCallback&lt;number&gt;          | Yes  | Callback invoked to return the number of rows deleted. |
2552
2553**Error codes**
2554
2555For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
2556
2557| **ID**| **Error Message**                                |
2558| ------------ | -------------------------------------------- |
2559| 14800047     | The WAL file size exceeds the default limit. |
2560| 14800000     | Inner error.                                 |
2561
2562**Example**
2563
2564```ts
2565let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
2566predicates.equalTo("NAME", "Lisa");
2567if(store != undefined) {
2568  (store as relationalStore.RdbStore).delete(predicates, (err, rows) => {
2569    if (err) {
2570      console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
2571      return;
2572    }
2573    console.info(`Delete rows: ${rows}`);
2574  })
2575}
2576```
2577
2578### delete
2579
2580delete(predicates: RdbPredicates):Promise&lt;number&gt;
2581
2582Deletes data from the RDB store based on the specified **RdbPredicates** object. This API uses a promise to return the result.
2583
2584**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2585
2586**Parameters**
2587
2588| Name    | Type                                | Mandatory| Description                                     |
2589| ---------- | ------------------------------------ | ---- | ----------------------------------------- |
2590| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Conditions specified by the **RdbPredicates** object for deleting data.|
2591
2592**Return value**
2593
2594| Type                 | Description                           |
2595| --------------------- | ------------------------------- |
2596| Promise&lt;number&gt; | Promise used to return the number of rows deleted.|
2597
2598**Error codes**
2599
2600For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
2601
2602| **ID**| **Error Message**                                |
2603| ------------ | -------------------------------------------- |
2604| 14800047     | The WAL file size exceeds the default limit. |
2605| 14800000     | Inner error.                                 |
2606
2607**Example**
2608
2609```ts
2610import { BusinessError } from "@ohos.base";
2611
2612let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
2613predicates.equalTo("NAME", "Lisa");
2614if(store != undefined) {
2615  (store as relationalStore.RdbStore).delete(predicates).then((rows: Number) => {
2616    console.info(`Delete rows: ${rows}`);
2617  }).catch((err: BusinessError) => {
2618    console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
2619  })
2620}
2621```
2622
2623### delete
2624
2625delete(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback&lt;number&gt;):void
2626
2627Deletes data from the RDB store based on the specified **DataSharePredicates** object. This API uses an asynchronous callback to return the result.
2628
2629**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2630
2631**Model restriction**: This API can be used only in the stage model.
2632
2633**System API**: This is a system API.
2634
2635**Parameters**
2636
2637| Name    | Type                                                        | Mandatory| Description                                         |
2638| ---------- | ------------------------------------------------------------ | ---- | --------------------------------------------- |
2639| table      | string                                                       | Yes  | Name of the target table.                             |
2640| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes  | Conditions specified by the **DataSharePredicates** object for deleting data.|
2641| callback   | AsyncCallback&lt;number&gt;                                  | Yes  | Callback invoked to return the number of rows deleted.     |
2642
2643**Error codes**
2644
2645For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
2646
2647| **ID**| **Error Message**                                |
2648| ------------ | -------------------------------------------- |
2649| 14800047     | The WAL file size exceeds the default limit. |
2650| 14800000     | Inner error.                                 |
2651
2652**Example**
2653
2654```ts
2655import dataSharePredicates from '@ohos.data.dataSharePredicates';
2656
2657let predicates = new dataSharePredicates.DataSharePredicates();
2658predicates.equalTo("NAME", "Lisa");
2659if(store != undefined) {
2660  (store as relationalStore.RdbStore).delete("EMPLOYEE", predicates, (err, rows) => {
2661    if (err) {
2662      console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
2663      return;
2664    }
2665    console.info(`Delete rows: ${rows}`);
2666  })
2667}
2668```
2669
2670### delete
2671
2672delete(table: string, predicates: dataSharePredicates.DataSharePredicates):Promise&lt;number&gt;
2673
2674Deletes data from the RDB store based on the specified **DataSharePredicates** object. This API uses a promise to return the result.
2675
2676**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2677
2678**Model restriction**: This API can be used only in the stage model.
2679
2680**System API**: This is a system API.
2681
2682**Parameters**
2683
2684| Name    | Type                                                        | Mandatory| Description                                         |
2685| ---------- | ------------------------------------------------------------ | ---- | --------------------------------------------- |
2686| table      | string                                                       | Yes  | Name of the target table.                             |
2687| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes  | Conditions specified by the **DataSharePredicates** object for deleting data.|
2688
2689**Return value**
2690
2691| Type                 | Description                           |
2692| --------------------- | ------------------------------- |
2693| Promise&lt;number&gt; | Promise used to return the number of rows deleted.|
2694
2695**Error codes**
2696
2697For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
2698
2699| **ID**| **Error Message**                                |
2700| ------------ | -------------------------------------------- |
2701| 14800047     | The WAL file size exceeds the default limit. |
2702| 14800000     | Inner error.                                 |
2703
2704**Example**
2705
2706```ts
2707import dataSharePredicates from '@ohos.data.dataSharePredicates';
2708import { BusinessError } from "@ohos.base";
2709
2710let predicates = new dataSharePredicates.DataSharePredicates();
2711predicates.equalTo("NAME", "Lisa");
2712if(store != undefined) {
2713  (store as relationalStore.RdbStore).delete("EMPLOYEE", predicates).then((rows: Number) => {
2714    console.info(`Delete rows: ${rows}`);
2715  }).catch((err: BusinessError) => {
2716    console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
2717  })
2718}
2719```
2720
2721### query<sup>10+</sup>
2722
2723query(predicates: RdbPredicates, callback: AsyncCallback&lt;ResultSet&gt;):void
2724
2725Queries 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.
2726
2727**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2728
2729**Parameters**
2730
2731| Name    | Type                                                        | Mandatory| Description                                                       |
2732| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
2733| predicates | [RdbPredicates](#rdbpredicates)                         | Yes  | Query conditions specified by the **RdbPredicates** object.                  |
2734| callback   | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes  | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
2735
2736**Error codes**
2737
2738For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
2739
2740| **ID**| **Error Message**                |
2741| ------------ | ---------------------------- |
2742| 14800000     | Inner error.                 |
2743
2744**Example**
2745
2746```ts
2747let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
2748predicates.equalTo("NAME", "Rose");
2749if(store != undefined) {
2750  (store as relationalStore.RdbStore).query(predicates, (err, resultSet) => {
2751    if (err) {
2752      console.error(`Query failed, code is ${err.code},message is ${err.message}`);
2753      return;
2754    }
2755    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
2756    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
2757    while (resultSet.goToNextRow()) {
2758      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
2759      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
2760      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
2761      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
2762      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
2763    }
2764    // Release the dataset memory.
2765    resultSet.close();
2766  })
2767}
2768```
2769
2770### query
2771
2772query(predicates: RdbPredicates, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;ResultSet&gt;):void
2773
2774Queries 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.
2775
2776**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2777
2778**Parameters**
2779
2780| Name    | Type                                                        | Mandatory| Description                                                       |
2781| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
2782| predicates | [RdbPredicates](#rdbpredicates)                         | Yes  | Query conditions specified by the **RdbPredicates** object.                  |
2783| columns    | Array&lt;string&gt;                                          | Yes  | Columns to query. If this parameter is not specified, the query applies to all columns.           |
2784| callback   | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes  | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
2785
2786**Error codes**
2787
2788For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
2789
2790| **ID**| **Error Message**                |
2791| ------------ | ---------------------------- |
2792| 14800000     | Inner error.                 |
2793
2794**Example**
2795
2796```ts
2797let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
2798predicates.equalTo("NAME", "Rose");
2799if(store != undefined) {
2800  (store as relationalStore.RdbStore).query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], (err, resultSet) => {
2801    if (err) {
2802      console.error(`Query failed, code is ${err.code},message is ${err.message}`);
2803      return;
2804    }
2805    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
2806    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
2807    while (resultSet.goToNextRow()) {
2808      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
2809      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
2810      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
2811      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
2812      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
2813    }
2814    // Release the dataset memory.
2815    resultSet.close();
2816  })
2817}
2818```
2819
2820### query
2821
2822query(predicates: RdbPredicates, columns?: Array&lt;string&gt;):Promise&lt;ResultSet&gt;
2823
2824Queries 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.
2825
2826**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2827
2828**Parameters**
2829
2830| Name    | Type                                | Mandatory| Description                                            |
2831| ---------- | ------------------------------------ | ---- | ------------------------------------------------ |
2832| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Query conditions specified by the **RdbPredicates** object.       |
2833| columns    | Array&lt;string&gt;                  | No  | Columns to query. If this parameter is not specified, the query applies to all columns.|
2834
2835**Error codes**
2836
2837For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
2838
2839| **ID**| **Error Message**                |
2840| ------------ | ---------------------------- |
2841| 14800000     | Inner error.                 |
2842
2843**Return value**
2844
2845| Type                                                   | Description                                              |
2846| ------------------------------------------------------- | -------------------------------------------------- |
2847| Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
2848
2849**Example**
2850
2851```ts
2852import { BusinessError } from "@ohos.base";
2853
2854let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
2855predicates.equalTo("NAME", "Rose");
2856if(store != undefined) {
2857  (store as relationalStore.RdbStore).query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet: relationalStore.ResultSet) => {
2858    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
2859    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
2860    while (resultSet.goToNextRow()) {
2861      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
2862      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
2863      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
2864      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
2865      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
2866    }
2867    // Release the dataset memory.
2868    resultSet.close();
2869  }).catch((err: BusinessError) => {
2870    console.error(`Query failed, code is ${err.code},message is ${err.message}`);
2871  })
2872}
2873```
2874
2875### query<sup>10+</sup>
2876
2877query(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback&lt;ResultSet&gt;):void
2878
2879Queries 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.
2880
2881**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2882
2883**Model restriction**: This API can be used only in the stage model.
2884
2885**System API**: This is a system API.
2886
2887**Parameters**
2888
2889| Name    | Type                                                        | Mandatory| Description                                                       |
2890| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
2891| table      | string                                                       | Yes  | Name of the target table.                                           |
2892| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes  | Query conditions specified by the **DataSharePredicates** object.              |
2893| callback   | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes  | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
2894
2895**Error codes**
2896
2897For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
2898
2899| **ID**| **Error Message**                |
2900| ------------ | ---------------------------- |
2901| 14800000     | Inner error.                 |
2902
2903**Example**
2904
2905```ts
2906import dataSharePredicates from '@ohos.data.dataSharePredicates';
2907
2908let predicates = new dataSharePredicates.DataSharePredicates();
2909predicates.equalTo("NAME", "Rose");
2910if(store != undefined) {
2911  (store as relationalStore.RdbStore).query("EMPLOYEE", predicates, (err, resultSet) => {
2912    if (err) {
2913      console.error(`Query failed, code is ${err.code},message is ${err.message}`);
2914      return;
2915    }
2916    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
2917    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
2918    while (resultSet.goToNextRow()) {
2919      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
2920      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
2921      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
2922      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
2923      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
2924    }
2925    // Release the dataset memory.
2926    resultSet.close();
2927  })
2928}
2929```
2930
2931### query
2932
2933query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;ResultSet&gt;):void
2934
2935Queries 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.
2936
2937**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2938
2939**Model restriction**: This API can be used only in the stage model.
2940
2941**System API**: This is a system API.
2942
2943**Parameters**
2944
2945| Name    | Type                                                        | Mandatory| Description                                                       |
2946| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
2947| table      | string                                                       | Yes  | Name of the target table.                                           |
2948| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes  | Query conditions specified by the **DataSharePredicates** object.              |
2949| columns    | Array&lt;string&gt;                                          | Yes  | Columns to query. If this parameter is not specified, the query applies to all columns.           |
2950| callback   | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes  | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
2951
2952**Error codes**
2953
2954For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
2955
2956| **ID**| **Error Message**                |
2957| ------------ | ---------------------------- |
2958| 14800000     | Inner error.                 |
2959
2960**Example**
2961
2962```ts
2963import dataSharePredicates from '@ohos.data.dataSharePredicates';
2964
2965let predicates = new dataSharePredicates.DataSharePredicates();
2966predicates.equalTo("NAME", "Rose");
2967if(store != undefined) {
2968  (store as relationalStore.RdbStore).query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], (err, resultSet) => {
2969    if (err) {
2970      console.error(`Query failed, code is ${err.code},message is ${err.message}`);
2971      return;
2972    }
2973    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
2974    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
2975    while (resultSet.goToNextRow()) {
2976      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
2977      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
2978      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
2979      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
2980      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
2981    }
2982    // Release the dataset memory.
2983    resultSet.close();
2984  })
2985}
2986```
2987
2988### query
2989
2990query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns?: Array&lt;string&gt;):Promise&lt;ResultSet&gt;
2991
2992Queries 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.
2993
2994**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
2995
2996**Model restriction**: This API can be used only in the stage model.
2997
2998**System API**: This is a system API.
2999
3000**Parameters**
3001
3002| Name    | Type                                                        | Mandatory| Description                                            |
3003| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------ |
3004| table      | string                                                       | Yes  | Name of the target table.                                |
3005| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes  | Query conditions specified by the **DataSharePredicates** object.   |
3006| columns    | Array&lt;string&gt;                                          | No  | Columns to query. If this parameter is not specified, the query applies to all columns.|
3007
3008**Return value**
3009
3010| Type                                                   | Description                                              |
3011| ------------------------------------------------------- | -------------------------------------------------- |
3012| Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
3013
3014**Error codes**
3015
3016For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3017
3018| **ID**| **Error Message**                |
3019| ------------ | ---------------------------- |
3020| 14800000     | Inner error.                 |
3021
3022**Example**
3023
3024```ts
3025import dataSharePredicates from '@ohos.data.dataSharePredicates';
3026import { BusinessError } from "@ohos.base";
3027
3028let predicates = new dataSharePredicates.DataSharePredicates();
3029predicates.equalTo("NAME", "Rose");
3030if(store != undefined) {
3031  (store as relationalStore.RdbStore).query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet: relationalStore.ResultSet) => {
3032    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3033    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3034    while (resultSet.goToNextRow()) {
3035      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3036      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3037      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3038      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3039      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3040    }
3041    // Release the dataset memory.
3042    resultSet.close();
3043  }).catch((err: BusinessError) => {
3044    console.error(`Query failed, code is ${err.code},message is ${err.message}`);
3045  })
3046}
3047```
3048
3049### remoteQuery
3050
3051remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array&lt;string&gt; , callback: AsyncCallback&lt;ResultSet&gt;): void
3052
3053Queries data from the RDB store of a remote device based on specified conditions. This API uses an asynchronous callback to return the result.
3054
3055> **NOTE**
3056>
3057> The value of **device** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
3058
3059**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3060
3061**Parameters**
3062
3063| Name    | Type                                        | Mandatory| Description                                                     |
3064| ---------- | -------------------------------------------- | ---- | --------------------------------------------------------- |
3065| device     | string                                       | Yes  | ID of the remote device.                                       |
3066| table      | string                                       | Yes  | Name of the target table.                                         |
3067| predicates | [RdbPredicates](#rdbpredicates)              | Yes  | Query conditions specified by the **RdbPredicates** object.                |
3068| columns    | Array&lt;string&gt;                          | Yes  | Columns to query. If this parameter is not specified, the query applies to all columns.         |
3069| callback   | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes  | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
3070
3071**Error codes**
3072
3073For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3074
3075| **ID**| **Error Message**                |
3076| ------------ | ---------------------------- |
3077| 14800000     | Inner error.                 |
3078
3079**Example**
3080
3081```ts
3082import deviceManager from '@ohos.distributedDeviceManager';
3083import { BusinessError } from "@ohos.base";
3084
3085let dmInstance: deviceManager.DeviceManager;
3086let deviceId: string | undefined = undefined;
3087
3088try {
3089  dmInstance = deviceManager.createDeviceManager("com.example.appdatamgrverify");
3090  let devices = dmInstance.getAvailableDeviceListSync();
3091  if(deviceId != undefined) {
3092    deviceId = devices[0].networkId;
3093  }
3094} catch (err) {
3095  let code = (err as BusinessError).code;
3096  let message = (err as BusinessError).message;
3097  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
3098}
3099
3100let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
3101predicates.greaterThan("id", 0);
3102if(store != undefined && deviceId != undefined) {
3103  (store as relationalStore.RdbStore).remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet: relationalStore.ResultSet) => {
3104    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3105    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3106    while (resultSet.goToNextRow()) {
3107      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3108      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3109      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3110      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3111      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3112    }
3113    // Release the dataset memory.
3114    resultSet.close();
3115  }).catch((err: BusinessError) => {
3116    console.error(`Failed to remoteQuery, code is ${err.code},message is ${err.message}`);
3117  })
3118}
3119```
3120
3121### remoteQuery
3122
3123remoteQuery(device: string, table: string, predicates: RdbPredicates, columns: Array&lt;string&gt;): Promise&lt;ResultSet&gt;
3124
3125Queries data from the RDB store of a remote device based on specified conditions. This API uses a promise to return the result.
3126
3127> **NOTE**
3128>
3129> The value of **device** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
3130
3131**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3132
3133**Parameters**
3134
3135| Name    | Type                                | Mandatory| Description                                            |
3136| ---------- | ------------------------------------ | ---- | ------------------------------------------------ |
3137| device     | string                               | Yes  | ID of the remote device.                  |
3138| table      | string                               | Yes  | Name of the target table.                                |
3139| predicates | [RdbPredicates](#rdbpredicates) | Yes  | Query conditions specified by the **RdbPredicates** object.     |
3140| columns    | Array&lt;string&gt;                  | Yes  | Columns to query. If this parameter is not specified, the query applies to all columns.|
3141
3142**Return value**
3143
3144| Type                                                        | Description                                              |
3145| ------------------------------------------------------------ | -------------------------------------------------- |
3146| Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
3147
3148**Error codes**
3149
3150For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3151
3152| **ID**| **Error Message**                |
3153| ------------ | ---------------------------- |
3154| 14800000     | Inner error.                 |
3155
3156**Example**
3157
3158```ts
3159import deviceManager from '@ohos.distributedDeviceManager';
3160import { BusinessError } from "@ohos.base";
3161
3162let dmInstance: deviceManager.DeviceManager;
3163let deviceId: string | undefined = undefined;
3164
3165try {
3166  dmInstance = deviceManager.createDeviceManager("com.example.appdatamgrverify");
3167  let devices: Array<deviceManager.DeviceBasicInfo> = dmInstance.getAvailableDeviceListSync();
3168  if(devices != undefined) {
3169    deviceId = devices[0].networkId;
3170  }
3171} catch (err) {
3172  let code = (err as BusinessError).code;
3173  let message = (err as BusinessError).message;
3174  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
3175}
3176
3177let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
3178predicates.greaterThan("id", 0);
3179if(store != undefined && deviceId != undefined) {
3180  (store as relationalStore.RdbStore).remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet: relationalStore.ResultSet) => {
3181    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3182    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3183    while (resultSet.goToNextRow()) {
3184      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3185      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3186      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3187      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3188      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3189    }
3190    // Release the dataset memory.
3191    resultSet.close();
3192  }).catch((err: BusinessError) => {
3193    console.error(`Failed to remoteQuery, code is ${err.code},message is ${err.message}`);
3194  })
3195}
3196```
3197
3198### querySql<sup>10+</sup>
3199
3200querySql(sql: string, callback: AsyncCallback&lt;ResultSet&gt;):void
3201
3202Queries data using the specified SQL statement. This API uses an asynchronous callback to return the result.
3203
3204**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3205
3206**Parameters**
3207
3208| Name  | Type                                        | Mandatory| Description                                                        |
3209| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
3210| sql      | string                                       | Yes  | SQL statement to run.                                       |
3211| callback | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes  | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.   |
3212
3213**Error codes**
3214
3215For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3216
3217| **ID**| **Error Message**                |
3218| ------------ | ---------------------------- |
3219| 14800000     | Inner error.                 |
3220
3221**Example**
3222
3223```ts
3224if(store != undefined) {
3225  (store as relationalStore.RdbStore).querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = 'sanguo'", (err, resultSet) => {
3226    if (err) {
3227      console.error(`Query failed, code is ${err.code},message is ${err.message}`);
3228      return;
3229    }
3230    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3231    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3232    while (resultSet.goToNextRow()) {
3233      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3234      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3235      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3236      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3237      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3238    }
3239    // Release the dataset memory.
3240    resultSet.close();
3241  })
3242}
3243```
3244
3245### querySql
3246
3247querySql(sql: string, bindArgs: Array&lt;ValueType&gt;, callback: AsyncCallback&lt;ResultSet&gt;):void
3248
3249Queries data using the specified SQL statement. This API uses an asynchronous callback to return the result.
3250
3251**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3252
3253**Parameters**
3254
3255| Name  | Type                                        | Mandatory| Description                                                        |
3256| -------- | -------------------------------------------- | ---- | ------------------------------------------------------------ |
3257| sql      | string                                       | Yes  | SQL statement to run.                                       |
3258| 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.|
3259| callback | AsyncCallback&lt;[ResultSet](#resultset)&gt; | Yes  | Callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.   |
3260
3261**Error codes**
3262
3263For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3264
3265| **ID**| **Error Message**                |
3266| ------------ | ---------------------------- |
3267| 14800000     | Inner error.                 |
3268
3269**Example**
3270
3271```ts
3272if(store != undefined) {
3273  (store as relationalStore.RdbStore).querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'], (err, resultSet) => {
3274    if (err) {
3275      console.error(`Query failed, code is ${err.code},message is ${err.message}`);
3276      return;
3277    }
3278    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3279    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3280    while (resultSet.goToNextRow()) {
3281      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3282      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3283      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3284      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3285      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3286    }
3287    // Release the dataset memory.
3288    resultSet.close();
3289  })
3290}
3291```
3292
3293### querySql
3294
3295querySql(sql: string, bindArgs?: Array&lt;ValueType&gt;):Promise&lt;ResultSet&gt;
3296
3297Queries data using the specified SQL statement. This API uses a promise to return the result.
3298
3299**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3300
3301**Parameters**
3302
3303| Name  | Type                                | Mandatory| Description                                                        |
3304| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
3305| sql      | string                               | Yes  | SQL statement to run.                                       |
3306| 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.|
3307
3308**Return value**
3309
3310| Type                                                   | Description                                              |
3311| ------------------------------------------------------- | -------------------------------------------------- |
3312| Promise&lt;[ResultSet](#resultset)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
3313
3314**Error codes**
3315
3316For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3317
3318| **ID**| **Error Message**                |
3319| ------------ | ---------------------------- |
3320| 14800000     | Inner error.                 |
3321
3322**Example**
3323
3324```ts
3325import { BusinessError } from "@ohos.base";
3326
3327if(store != undefined) {
3328  (store as relationalStore.RdbStore).querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = 'sanguo'").then((resultSet: relationalStore.ResultSet) => {
3329    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
3330    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
3331    while (resultSet.goToNextRow()) {
3332      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
3333      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
3334      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
3335      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
3336      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
3337    }
3338    // Release the dataset memory.
3339    resultSet.close();
3340  }).catch((err: BusinessError) => {
3341    console.error(`Query failed, code is ${err.code},message is ${err.message}`);
3342  })
3343}
3344```
3345
3346### executeSql<sup>10+</sup>
3347
3348executeSql(sql: string, callback: AsyncCallback&lt;void&gt;):void
3349
3350Executes an SQL statement that contains specified arguments but returns no value. This API uses an asynchronous callback to return the result.
3351
3352**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3353
3354**Parameters**
3355
3356| Name  | Type                                | Mandatory| Description                                                        |
3357| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
3358| sql      | string                               | Yes  | SQL statement to run.                                       |
3359| callback | AsyncCallback&lt;void&gt;            | Yes  | Callback invoked to return the result.                                      |
3360
3361**Error codes**
3362
3363For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3364
3365| **ID**| **Error Message**                                |
3366| ------------ | -------------------------------------------- |
3367| 14800047     | The WAL file size exceeds the default limit. |
3368| 14800000     | Inner error.                                 |
3369
3370**Example**
3371
3372```ts
3373const SQL_DELETE_TABLE = "DELETE FROM test WHERE name = 'zhangsan'"
3374if(store != undefined) {
3375  (store as relationalStore.RdbStore).executeSql(SQL_DELETE_TABLE, (err) => {
3376    if (err) {
3377      console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`);
3378      return;
3379    }
3380    console.info('Delete table done.');
3381  })
3382}
3383```
3384
3385### executeSql
3386
3387executeSql(sql: string, bindArgs: Array&lt;ValueType&gt;, callback: AsyncCallback&lt;void&gt;):void
3388
3389Executes an SQL statement that contains specified arguments but returns no value. This API uses an asynchronous callback to return the result.
3390
3391**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3392
3393**Parameters**
3394
3395| Name  | Type                                | Mandatory| Description                                                        |
3396| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
3397| sql      | string                               | Yes  | SQL statement to run.                                       |
3398| 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.|
3399| callback | AsyncCallback&lt;void&gt;            | Yes  | Callback invoked to return the result.                                      |
3400
3401**Error codes**
3402
3403For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3404
3405| **ID**| **Error Message**                                |
3406| ------------ | -------------------------------------------- |
3407| 14800047     | The WAL file size exceeds the default limit. |
3408| 14800000     | Inner error.                                 |
3409
3410**Example**
3411
3412```ts
3413const SQL_DELETE_TABLE = "DELETE FROM test WHERE name = ?"
3414if(store != undefined) {
3415  (store as relationalStore.RdbStore).executeSql(SQL_DELETE_TABLE, ['zhangsan'], (err) => {
3416    if (err) {
3417      console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`);
3418      return;
3419    }
3420    console.info('Delete table done.');
3421  })
3422}
3423```
3424
3425### executeSql
3426
3427executeSql(sql: string, bindArgs?: Array&lt;ValueType&gt;):Promise&lt;void&gt;
3428
3429Executes an SQL statement that contains specified arguments but returns no value. This API uses a promise to return the result.
3430
3431**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3432
3433**Parameters**
3434
3435| Name  | Type                                | Mandatory| Description                                                        |
3436| -------- | ------------------------------------ | ---- | ------------------------------------------------------------ |
3437| sql      | string                               | Yes  | SQL statement to run.                                       |
3438| 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.|
3439
3440**Return value**
3441
3442| Type               | Description                     |
3443| ------------------- | ------------------------- |
3444| Promise&lt;void&gt; | Promise that returns no value.|
3445
3446**Error codes**
3447
3448For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3449
3450| **ID**| **Error Message**                                |
3451| ------------ | -------------------------------------------- |
3452| 14800047     | The WAL file size exceeds the default limit. |
3453| 14800000     | Inner error.                                 |
3454
3455**Example**
3456
3457```ts
3458import { BusinessError } from "@ohos.base";
3459
3460const SQL_DELETE_TABLE = "DELETE FROM test WHERE name = 'zhangsan'"
3461if(store != undefined) {
3462  (store as relationalStore.RdbStore).executeSql(SQL_DELETE_TABLE).then(() => {
3463    console.info('Delete table done.');
3464  }).catch((err: BusinessError) => {
3465    console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`);
3466  })
3467}
3468```
3469
3470### getModifyTime<sup>10+</sup>
3471
3472getModifyTime(table: string, columnName: string, primaryKeys: PRIKeyType[], callback: AsyncCallback&lt;ModifyTime&gt;): void
3473
3474Obtains the last modification time of the data in a table. This API uses an asynchronous callback to return the result.
3475
3476**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3477
3478**Parameters**
3479
3480| Name     | Type                                            | Mandatory| Description                                                        |
3481| ----------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ |
3482| table       | string                                           | Yes  | Name of the database table to query.                                |
3483| columnName  | string                                           | Yes  | Column name of the database table to query.                                |
3484| 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.|
3485| callback    | AsyncCallback&lt;[ModifyTime](#modifytime10)&gt; | Yes  | Callback invoked to return the result. If the operation is successful, the **ModifyTime** object is returned.|
3486
3487**Error codes**
3488
3489For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3490
3491| **ID**| **Error Message**|
3492| ------------ | ------------ |
3493| 14800000     | Inner error. |
3494
3495**Example**
3496
3497```ts
3498let PRIKey = [1, 4, 2, 3];
3499if(store != undefined) {
3500  (store as relationalStore.RdbStore).getModifyTime("EMPLOYEE", "NAME", PRIKey, (err, modifyTime: relationalStore.ModifyTime) => {
3501    if (err) {
3502      console.error(`getModifyTime failed, code is ${err.code},message is ${err.message}`);
3503      return;
3504    }
3505    let size = modifyTime.size;
3506  });
3507}
3508```
3509
3510### getModifyTime<sup>10+</sup>
3511
3512getModifyTime(table: string, columnName: string, primaryKeys: PRIKeyType[]): Promise&lt;ModifyTime&gt;
3513
3514Obtains the last modification time of the data in a table. This API uses a promise to return the result.
3515
3516**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3517
3518**Parameters**
3519
3520| Name     | Type                         | Mandatory| Description                                                        |
3521| ----------- | ----------------------------- | ---- | ------------------------------------------------------------ |
3522| table       | string                        | Yes  | Name of the database table to query.                                |
3523| columnName  | string                        | Yes  | Column name of the database table to query.                                |
3524| 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.|
3525
3526**Return value**
3527
3528| Type                                      | Description                                                     |
3529| ------------------------------------------ | --------------------------------------------------------- |
3530| Promise&lt;[ModifyTime](#modifytime10)&gt; | Promise used to return the **ModifyTime** object.|
3531
3532**Error codes**
3533
3534For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3535
3536| **ID**| **Error Message**|
3537| ------------ | ------------ |
3538| 14800000     | Inner error. |
3539
3540**Example**
3541
3542```ts
3543import { BusinessError } from "@ohos.base";
3544
3545let PRIKey = [1, 2, 3];
3546if(store != undefined) {
3547  (store as relationalStore.RdbStore).getModifyTime("EMPLOYEE", "NAME", PRIKey)
3548    .then((modifyTime: relationalStore.ModifyTime) => {
3549      let size = modifyTime.size;
3550    })
3551    .catch((err: BusinessError) => {
3552      console.error(`getModifyTime failed, code is ${err.code},message is ${err.message}`);
3553    });
3554}
3555```
3556
3557### beginTransaction
3558
3559beginTransaction():void
3560
3561Starts the transaction before executing an SQL statement.
3562This API cannot be used in multi-process or multi-thread scenarios.
3563
3564**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3565
3566**Error codes**
3567
3568For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3569
3570| **ID**| **Error Message**                                |
3571| ------------ | -------------------------------------------- |
3572| 14800047     | The WAL file size exceeds the default limit. |
3573| 14800000     | Inner error.                                 |
3574
3575**Example**
3576
3577```ts
3578import featureAbility from '@ohos.ability.featureAbility'
3579import { ValuesBucket } from '@ohos.data.ValuesBucket';
3580
3581let value1 = "Lisa";
3582let value2 = 18;
3583let value3 = 100.5;
3584let value4 = new Uint8Array([1, 2, 3]);
3585
3586store.beginTransaction();
3587const valueBucket: ValuesBucket = {
3588  'NAME': value1,
3589  'AGE': value2,
3590  'SALARY': value3,
3591  'CODES': value4,
3592};
3593store.insert("test", valueBucket);
3594store.commit();
3595```
3596
3597### commit
3598
3599commit():void
3600
3601Commits the executed SQL statements.
3602This API cannot be used in multi-process or multi-thread scenarios.
3603
3604**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3605
3606**Example**
3607
3608```ts
3609import { ValuesBucket } from '@ohos.data.ValuesBucket';
3610
3611let value1 = "Lisa";
3612let value2 = 18;
3613let value3 = 100.5;
3614let value4 = new Uint8Array([1, 2, 3]);
3615
3616store.beginTransaction();
3617const valueBucket: ValuesBucket = {
3618  'NAME': value1,
3619  'AGE': value2,
3620  'SALARY': value3,
3621  'CODES': value4,
3622};
3623store.insert("test", valueBucket);
3624store.commit();
3625```
3626
3627### rollBack
3628
3629rollBack():void
3630
3631Rolls back the SQL statements that have been executed.
3632This API cannot be used in multi-process or multi-thread scenarios.
3633
3634**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3635
3636**Example**
3637
3638```ts
3639import { ValuesBucket } from '@ohos.data.ValuesBucket';
3640
3641let value1 = "Lisa";
3642let value2 = 18;
3643let value3 = 100.5;
3644let value4 = new Uint8Array([1, 2, 3]);
3645
3646try {
3647  store.beginTransaction()
3648  const valueBucket: ValuesBucket = {
3649    'NAME': value1,
3650    'AGE': value2,
3651    'SALARY': value3,
3652    'CODES': value4,
3653  };
3654  store.insert("test", valueBucket);
3655  store.commit();
3656} catch (err) {
3657  let code = (err as BusinessError).code;
3658  let message = (err as BusinessError).message
3659  console.error(`Transaction failed, code is ${code},message is ${message}`);
3660  store.rollBack();
3661}
3662```
3663
3664### backup
3665
3666backup(destName:string, callback: AsyncCallback&lt;void&gt;):void
3667
3668Backs up an RDB store. This API uses an asynchronous callback to return the result.
3669
3670**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3671
3672**Parameters**
3673
3674| Name  | Type                     | Mandatory| Description                    |
3675| -------- | ------------------------- | ---- | ------------------------ |
3676| destName | string                    | Yes  | Name of the RDB store backup file.|
3677| callback | AsyncCallback&lt;void&gt; | Yes  | Callback invoked to return the result.  |
3678
3679**Error codes**
3680
3681For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3682
3683| **ID**| **Error Message**                |
3684| ------------ | ---------------------------- |
3685| 14800000     | Inner error.                 |
3686
3687**Example**
3688
3689```ts
3690if(store != undefined) {
3691  (store as relationalStore.RdbStore).backup("dbBackup.db", (err) => {
3692    if (err) {
3693      console.error(`Backup failed, code is ${err.code},message is ${err.message}`);
3694      return;
3695    }
3696    console.info('Backup success.');
3697  })
3698}
3699```
3700
3701### backup
3702
3703backup(destName:string): Promise&lt;void&gt;
3704
3705Backs up an RDB store. This API uses a promise to return the result.
3706
3707**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3708
3709**Parameters**
3710
3711| Name  | Type  | Mandatory| Description                    |
3712| -------- | ------ | ---- | ------------------------ |
3713| destName | string | Yes  | Name of the RDB store backup file.|
3714
3715**Return value**
3716
3717| Type               | Description                     |
3718| ------------------- | ------------------------- |
3719| Promise&lt;void&gt; | Promise that returns no value.|
3720
3721**Error codes**
3722
3723For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3724
3725| **ID**| **Error Message**                |
3726| ------------ | ---------------------------- |
3727| 14800000     | Inner error.                 |
3728
3729**Example**
3730
3731```ts
3732import { BusinessError } from "@ohos.base";
3733
3734if(store != undefined) {
3735  let promiseBackup = (store as relationalStore.RdbStore).backup("dbBackup.db");
3736  promiseBackup.then(() => {
3737    console.info('Backup success.');
3738  }).catch((err: BusinessError) => {
3739    console.error(`Backup failed, code is ${err.code},message is ${err.message}`);
3740  })
3741}
3742```
3743
3744### restore
3745
3746restore(srcName:string, callback: AsyncCallback&lt;void&gt;):void
3747
3748Restores an RDB store from a backup file. This API uses an asynchronous callback to return the result.
3749
3750**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3751
3752**Parameters**
3753
3754| Name  | Type                     | Mandatory| Description                    |
3755| -------- | ------------------------- | ---- | ------------------------ |
3756| srcName  | string                    | Yes  | Name of the RDB store backup file.|
3757| callback | AsyncCallback&lt;void&gt; | Yes  | Callback invoked to return the result.  |
3758
3759**Error codes**
3760
3761For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3762
3763| **ID**| **Error Message**                |
3764| ------------ | ---------------------------- |
3765| 14800000     | Inner error.                 |
3766
3767**Example**
3768
3769```ts
3770if(store != undefined) {
3771  (store as relationalStore.RdbStore).restore("dbBackup.db", (err) => {
3772    if (err) {
3773      console.error(`Restore failed, code is ${err.code},message is ${err.message}`);
3774      return;
3775    }
3776    console.info('Restore success.');
3777  })
3778}
3779```
3780
3781### restore
3782
3783restore(srcName:string): Promise&lt;void&gt;
3784
3785Restores an RDB store from a backup file. This API uses a promise to return the result.
3786
3787**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3788
3789**Parameters**
3790
3791| Name | Type  | Mandatory| Description                    |
3792| ------- | ------ | ---- | ------------------------ |
3793| srcName | string | Yes  | Name of the RDB store backup file.|
3794
3795**Return value**
3796
3797| Type               | Description                     |
3798| ------------------- | ------------------------- |
3799| Promise&lt;void&gt; | Promise that returns no value.|
3800
3801**Error codes**
3802
3803For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3804
3805| **ID**| **Error Message**                |
3806| ------------ | ---------------------------- |
3807| 14800000     | Inner error.                 |
3808
3809**Example**
3810
3811```ts
3812import { BusinessError } from "@ohos.base";
3813
3814if(store != undefined) {
3815  let promiseRestore = (store as relationalStore.RdbStore).restore("dbBackup.db");
3816  promiseRestore.then(() => {
3817    console.info('Restore success.');
3818  }).catch((err: BusinessError) => {
3819    console.error(`Restore failed, code is ${err.code},message is ${err.message}`);
3820  })
3821}
3822```
3823
3824### setDistributedTables
3825
3826setDistributedTables(tables: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;): void
3827
3828Sets distributed tables. This API uses an asynchronous callback to return the result.
3829
3830**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
3831
3832**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3833
3834**Parameters**
3835
3836| Name  | Type                     | Mandatory| Description                  |
3837| -------- | ------------------------- | ---- | ---------------------- |
3838| tables   | Array&lt;string&gt;       | Yes  | Names of the distributed tables to set.|
3839| callback | AsyncCallback&lt;void&gt; | Yes  | Callback invoked to return the result.|
3840
3841**Error codes**
3842
3843For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3844
3845| **ID**| **Error Message**                |
3846| ------------ | ---------------------------- |
3847| 14800000     | Inner error.                 |
3848
3849**Example**
3850
3851```ts
3852if(store != undefined) {
3853  (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"], (err) => {
3854    if (err) {
3855      console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
3856      return;
3857    }
3858    console.info('SetDistributedTables successfully.');
3859  })
3860}
3861```
3862
3863### setDistributedTables
3864
3865 setDistributedTables(tables: Array&lt;string&gt;): Promise&lt;void&gt;
3866
3867Sets distributed tables. This API uses a promise to return the result.
3868
3869**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
3870
3871**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3872
3873**Parameters**
3874
3875| Name| Type                    | Mandatory| Description                    |
3876| ------ | ------------------------ | ---- | ------------------------ |
3877| tables | ArrayArray&lt;string&gt; | Yes  | Names of the distributed tables to set.|
3878
3879**Return value**
3880
3881| Type               | Description                     |
3882| ------------------- | ------------------------- |
3883| Promise&lt;void&gt; | Promise that returns no value.|
3884
3885**Error codes**
3886
3887For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3888
3889| **ID**| **Error Message**|
3890| ------------ | ------------ |
3891| 14800000     | Inner error. |
3892
3893**Example**
3894
3895```ts
3896import { BusinessError } from "@ohos.base";
3897
3898if(store != undefined) {
3899  (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"]).then(() => {
3900    console.info('SetDistributedTables successfully.');
3901  }).catch((err: BusinessError) => {
3902    console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
3903  })
3904}
3905```
3906
3907### setDistributedTables<sup>10+</sup>
3908
3909setDistributedTables(tables: Array&lt;string&gt;, type: DistributedType, callback: AsyncCallback&lt;void&gt;): void
3910
3911Sets distributed tables. This API uses an asynchronous callback to return the result.
3912
3913**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
3914
3915**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3916
3917**Parameters**
3918
3919| Name  | Type                                 | Mandatory| Description                        |
3920| -------- | ------------------------------------- | ---- | ---------------------------- |
3921| tables   | Array&lt;string&gt;                   | Yes  | Names of the distributed tables to set.|
3922| type     | [DistributedType](#distributedtype10) | Yes  | Distributed type of the tables.            |
3923| callback | AsyncCallback&lt;void&gt;             | Yes  | Callback invoked to return the result.      |
3924
3925**Error codes**
3926
3927For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3928
3929| **ID**| **Error Message**|
3930| ------------ | ------------ |
3931| 14800000     | Inner error. |
3932| 14800051     |The type of the distributed table does not match.|
3933
3934**Example**
3935
3936```ts
3937if(store != undefined) {
3938  (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"], relationalStore.DistributedType.DISTRIBUTED_CLOUD, (err) => {
3939    if (err) {
3940      console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
3941      return;
3942    }
3943    console.info('SetDistributedTables successfully.');
3944  })
3945}
3946```
3947
3948
3949
3950### setDistributedTables<sup>10+</sup>
3951
3952setDistributedTables(tables: Array&lt;string&gt;, type: DistributedType, config: DistributedConfig, callback: AsyncCallback&lt;void&gt;): void
3953
3954Sets distributed tables. This API uses an asynchronous callback to return the result.
3955
3956**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
3957
3958**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
3959
3960**Parameters**
3961
3962| Name     | Type                                 | Mandatory | Description             |
3963| -------- | ----------------------------------- | --- | --------------- |
3964| tables   | Array&lt;string&gt;                 | Yes  | Names of the distributed tables to set.    |
3965| type     | [DistributedType](#distributedtype10) | Yes  | Distributed type of the tables.|
3966| config | [DistributedConfig](#distributedconfig10) | Yes| Configuration of the distributed mode.|
3967| callback | AsyncCallback&lt;void&gt;           | Yes  | Callback invoked to return the result.|
3968
3969**Error codes**
3970
3971For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
3972
3973| **ID**| **Error Message**                                     |
3974| ------------ | ------------------------------------------------- |
3975| 14800000     | Inner error.                                      |
3976| 14800051     | The type of the distributed table does not match. |
3977
3978**Example**
3979
3980```ts
3981if(store != undefined) {
3982  (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"], relationalStore.DistributedType.DISTRIBUTED_CLOUD, {
3983    autoSync: true
3984  }, (err) => {
3985    if (err) {
3986      console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
3987      return;
3988    }
3989    console.info('SetDistributedTables successfully.');
3990  })
3991}
3992```
3993
3994### setDistributedTables<sup>10+</sup>
3995
3996 setDistributedTables(tables: Array&lt;string>, type?: DistributedType, config?: DistributedConfig): Promise&lt;void>
3997
3998Sets distributed tables. This API uses a promise to return the result.
3999
4000**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
4001
4002**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4003
4004**Parameters**
4005
4006| Name| Type                                     | Mandatory| Description                                                        |
4007| ------ | ----------------------------------------- | ---- | ------------------------------------------------------------ |
4008| tables | Array&lt;string&gt;                       | Yes  | Names of the distributed tables to set.                                |
4009| type   | [DistributedType](#distributedtype10)     | No  | Distributed type of the tables. The default value is **relationalStore.DistributedType.DISTRIBUTED_DEVICE**.|
4010| 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 synchronization is supported.|
4011
4012**Return value**
4013
4014| Type               | Description                     |
4015| ------------------- | ------------------------- |
4016| Promise&lt;void&gt; | Promise that returns no value.|
4017
4018**Error codes**
4019
4020For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
4021
4022| **ID**| **Error Message**                                     |
4023| ------------ | ------------------------------------------------- |
4024| 14800000     | Inner error.                                      |
4025| 14800051     | The type of the distributed table does not match. |
4026
4027**Example**
4028
4029```ts
4030import { BusinessError } from "@ohos.base";
4031
4032if(store != undefined) {
4033  (store as relationalStore.RdbStore).setDistributedTables(["EMPLOYEE"], relationalStore.DistributedType.DISTRIBUTED_CLOUD, {
4034    autoSync: true
4035  }).then(() => {
4036    console.info('SetDistributedTables successfully.');
4037  }).catch((err: BusinessError) => {
4038    console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`);
4039  })
4040}
4041```
4042
4043### obtainDistributedTableName
4044
4045obtainDistributedTableName(device: string, table: string, callback: AsyncCallback&lt;string&gt;): void
4046
4047Obtains 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.
4048
4049> **NOTE**
4050>
4051> The value of **device** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
4052
4053**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
4054
4055**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4056
4057**Parameters**
4058
4059| Name  | Type                       | Mandatory| Description                                                        |
4060| -------- | --------------------------- | ---- | ------------------------------------------------------------ |
4061| device   | string                      | Yes  | ID of the remote device.                                               |
4062| table    | string                      | Yes  | Local table name of the remote device.                                        |
4063| callback | AsyncCallback&lt;string&gt; | Yes  | Callback invoked to return the result. If the operation succeeds, the distributed table name of the remote device is returned.|
4064
4065**Error codes**
4066
4067For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
4068
4069| **ID**| **Error Message**                |
4070| ------------ | ---------------------------- |
4071| 14800000     | Inner error.                 |
4072
4073**Example**
4074
4075```ts
4076import deviceManager from '@ohos.distributedDeviceManager';
4077
4078let dmInstance: deviceManager.DeviceManager;
4079let deviceId: string | undefined = undefined;
4080
4081try {
4082  dmInstance = deviceManager.createDeviceManager("com.example.appdatamgrverify");
4083  let devices = dmInstance.getAvailableDeviceListSync();
4084  deviceId = devices[0].networkId;
4085} catch (err) {
4086  let code = (err as BusinessError).code;
4087  let message = (err as BusinessError).message
4088  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
4089}
4090
4091if(store != undefined && deviceId != undefined) {
4092  (store as relationalStore.RdbStore).obtainDistributedTableName(deviceId, "EMPLOYEE", (err, tableName) => {
4093    if (err) {
4094      console.error(`ObtainDistributedTableName failed, code is ${err.code},message is ${err.message}`);
4095      return;
4096    }
4097    console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`);
4098  })
4099}
4100```
4101
4102### obtainDistributedTableName
4103
4104 obtainDistributedTableName(device: string, table: string): Promise&lt;string&gt;
4105
4106Obtains 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.
4107
4108> **NOTE**
4109>
4110> The value of **device** can be obtained by [deviceManager.getAvailableDeviceListSync](js-apis-distributedDeviceManager.md#getavailabledevicelistsync).
4111
4112**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
4113
4114**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4115
4116**Parameters**
4117
4118| Name| Type  | Mandatory| Description                |
4119| ------ | ------ | ---- | -------------------- |
4120| device | string | Yes  | ID of the remote device.        |
4121| table  | string | Yes  | Local table name of the remote device.|
4122
4123**Return value**
4124
4125| Type                 | Description                                                 |
4126| --------------------- | ----------------------------------------------------- |
4127| Promise&lt;string&gt; | Promise used to return the result. If the operation succeeds, the distributed table name of the remote device is returned.|
4128
4129**Error codes**
4130
4131For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
4132
4133| **ID**| **Error Message**                |
4134| ------------ | ---------------------------- |
4135| 14800000     | Inner error.                 |
4136
4137**Example**
4138
4139```ts
4140import deviceManager from '@ohos.distributedDeviceManager';
4141import { BusinessError } from "@ohos.base";
4142
4143let dmInstance: deviceManager.DeviceManager;
4144let deviceId: string | undefined = undefined;
4145
4146try {
4147  dmInstance = deviceManager.createDeviceManager("com.example.appdatamgrverify");
4148  let devices = dmInstance.getAvailableDeviceListSync();
4149  deviceId = devices[0].networkId;
4150} catch (err) {
4151  let code = (err as BusinessError).code;
4152  let message = (err as BusinessError).message
4153  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
4154}
4155
4156if(store != undefined && deviceId != undefined) {
4157  (store as relationalStore.RdbStore).obtainDistributedTableName(deviceId, "EMPLOYEE").then((tableName: string) => {
4158    console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`);
4159  }).catch((err: BusinessError) => {
4160    console.error(`ObtainDistributedTableName failed, code is ${err.code},message is ${err.message}`);
4161  })
4162}
4163```
4164
4165### sync
4166
4167sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback&lt;Array&lt;[string, number]&gt;&gt;): void
4168
4169Synchronizes data between devices. This API uses an asynchronous callback to return the result.
4170
4171**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
4172
4173**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4174
4175**Parameters**
4176
4177| Name    | Type                                              | Mandatory| Description                                                        |
4178| ---------- | -------------------------------------------------- | ---- | ------------------------------------------------------------ |
4179| mode       | [SyncMode](#syncmode)                             | Yes  | Data synchronization mode. The value can be **relationalStore.SyncMode.SYNC_MODE_PUSH** or **relationalStore.SyncMode.SYNC_MODE_PULL**.                              |
4180| predicates | [RdbPredicates](#rdbpredicates)               | Yes  | **RdbPredicates** object that specifies the data and devices to synchronize.                                        |
4181| callback   | AsyncCallback&lt;Array&lt;[string, number]&gt;&gt; | Yes  | Callback invoked to send the synchronization result to the caller. <br>**string** indicates the device ID. <br>**number** indicates the synchronization status of that device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. |
4182
4183**Error codes**
4184
4185For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
4186
4187| **ID**| **Error Message**                |
4188| ------------ | ---------------------------- |
4189| 14800000     | Inner error.                 |
4190
4191**Example**
4192
4193```ts
4194import deviceManager from '@ohos.distributedDeviceManager';
4195
4196let dmInstance: deviceManager.DeviceManager;
4197let deviceIds: Array<string> = [];
4198
4199try {
4200  dmInstance = deviceManager.createDeviceManager("com.example.appdatamgrverify");
4201  let devices: Array<deviceManager.DeviceBasicInfo> = dmInstance.getAvailableDeviceListSync();
4202  for (let i = 0; i < devices.length; i++) {
4203    deviceIds[i] = devices[i].networkId!;
4204  }
4205} catch (err) {
4206  let code = (err as BusinessError).code;
4207  let message = (err as BusinessError).message
4208  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
4209}
4210
4211let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
4212predicates.inDevices(deviceIds);
4213if(store != undefined) {
4214  (store as relationalStore.RdbStore).sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates, (err, result) => {
4215    if (err) {
4216      console.error(`Sync failed, code is ${err.code},message is ${err.message}`);
4217      return;
4218    }
4219    console.info('Sync done.');
4220    for (let i = 0; i < result.length; i++) {
4221      console.info(`device= ${result[i][0]}, status= ${result[i][1]}`);
4222    }
4223  })
4224}
4225```
4226
4227### sync
4228
4229 sync(mode: SyncMode, predicates: RdbPredicates): Promise&lt;Array&lt;[string, number]&gt;&gt;
4230
4231Synchronizes data between devices. This API uses a promise to return the result.
4232
4233**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
4234
4235**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4236
4237**Parameters**
4238
4239| Name    | Type                                | Mandatory| Description                          |
4240| ---------- | ------------------------------------ | ---- | ------------------------------ |
4241| mode       | [SyncMode](#syncmode)               | Yes  | Data synchronization mode. The value can be **relationalStore.SyncMode.SYNC_MODE_PUSH** or **relationalStore.SyncMode.SYNC_MODE_PULL**.|
4242| predicates | [RdbPredicates](#rdbpredicates) | Yes  | **RdbPredicates** object that specifies the data and devices to synchronize.          |
4243
4244**Return value**
4245
4246| Type                                        | Description                                                        |
4247| -------------------------------------------- | ------------------------------------------------------------ |
4248| Promise&lt;Array&lt;[string, number]&gt;&gt; | Promise used to send the synchronization result. <br>**string** indicates the device ID. <br>**number** indicates the synchronization status of that device. The value **0** indicates a successful synchronization. Other values indicate a synchronization failure. |
4249
4250**Error codes**
4251
4252For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
4253
4254| **ID**| **Error Message**                |
4255| ------------ | ---------------------------- |
4256| 14800000     | Inner error.                 |
4257
4258**Example**
4259
4260```ts
4261import deviceManager from '@ohos.distributedDeviceManager';
4262import { BusinessError } from "@ohos.base";
4263
4264let dmInstance: deviceManager.DeviceManager;
4265let deviceIds: Array<string> = [];
4266
4267try {
4268  dmInstance = deviceManager.createDeviceManager("com.example.appdatamgrverify");
4269  let devices: Array<deviceManager.DeviceBasicInfo> = dmInstance.getAvailableDeviceListSync();
4270  for (let i = 0; i < devices.length; i++) {
4271    deviceIds[i] = devices[i].networkId!;
4272  }
4273} catch (err) {
4274  let code = (err as BusinessError).code;
4275  let message = (err as BusinessError).message
4276  console.error("createDeviceManager errCode:" + code + ",errMessage:" + message);
4277}
4278
4279let predicates = new relationalStore.RdbPredicates('EMPLOYEE');
4280predicates.inDevices(deviceIds);
4281if(store != undefined) {
4282  (store as relationalStore.RdbStore).sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates).then((result: Object[][]) => {
4283    console.info('Sync done.');
4284    for (let i = 0; i < result.length; i++) {
4285      console.info(`device= ${result[i][0]}, status= ${result[i][1]}`);
4286    }
4287  }).catch((err: BusinessError) => {
4288    console.error(`Sync failed, code is ${err.code},message is ${err.message}`);
4289  })
4290}
4291```
4292
4293### cloudSync<sup>10+</sup>
4294
4295cloudSync(mode: SyncMode, progress: Callback&lt;ProgressDetails&gt;, callback: AsyncCallback&lt;void&gt;): void
4296
4297Manually starts device-cloud synchronization 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.
4298
4299**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
4300
4301**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
4302
4303**Parameters**
4304
4305| Name  | Type                                                 | Mandatory| Description                                              |
4306| -------- | ----------------------------------------------------- | ---- | -------------------------------------------------- |
4307| mode     | [SyncMode](#syncmode)                                 | Yes  | Synchronization mode of the database.                            |
4308| progress | Callback&lt;[ProgressDetails](#progressdetails10)&gt; | Yes  | Callback used to process database synchronization details.            |
4309| callback | AsyncCallback&lt;void&gt;                             | Yes  | Callback invoked to send the synchronization result to the caller.|
4310
4311**Example**
4312
4313```ts
4314if(store != undefined) {
4315  (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, (progressDetails) => {
4316    console.info(`Progess: ${progressDetails}`);
4317  }, (err) => {
4318    if (err) {
4319      console.error(`Cloud sync failed, code is ${err.code},message is ${err.message}`);
4320      return;
4321    }
4322    console.info('Cloud sync succeeded');
4323  });
4324}
4325```
4326
4327### cloudSync<sup>10+</sup>
4328
4329cloudSync(mode: SyncMode, progress: Callback&lt;ProgressDetails&gt;): Promise&lt;void&gt;
4330
4331Manually starts device-cloud synchronization 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.
4332
4333**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
4334
4335**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
4336
4337**Parameters**
4338
4339| Name  | Type                                                 | Mandatory| Description                                  |
4340| -------- | ----------------------------------------------------- | ---- | -------------------------------------- |
4341| mode     | [SyncMode](#syncmode)                                 | Yes  | Synchronization mode of the database.                |
4342| progress | Callback&lt;[ProgressDetails](#progressdetails10)&gt; | Yes  | Callback used to process database synchronization details.|
4343
4344**Return value**
4345
4346| Type               | Description                                   |
4347| ------------------- | --------------------------------------- |
4348| Promise&lt;void&gt; | Promise used to send the synchronization result.|
4349
4350**Example**
4351
4352```ts
4353import { BusinessError } from "@ohos.base";
4354
4355if(store != undefined) {
4356  (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, (progressDetail: relationalStore.ProgressDetails) => {
4357    console.info(`progress: ${progressDetail}`);
4358  }).then(() => {
4359    console.info('Cloud sync succeeded');
4360  }).catch((err: BusinessError) => {
4361    console.error(`cloudSync failed, code is ${err.code},message is ${err.message}`);
4362  });
4363}
4364```
4365
4366### cloudSync<sup>10+</sup>
4367
4368cloudSync(mode: SyncMode, tables: string[], progress: Callback&lt;ProgressDetails&gt;, callback: AsyncCallback&lt;void&gt;): void
4369
4370Manually starts device-cloud synchronization 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.
4371
4372**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
4373
4374**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
4375
4376**Parameters**
4377
4378| Name  | Type                                                 | Mandatory| Description                                              |
4379| -------- | ----------------------------------------------------- | ---- | -------------------------------------------------- |
4380| mode     | [SyncMode](#syncmode)                                 | Yes  | Synchronization mode of the database.                            |
4381| tables   | string[]                                              | Yes  | Name of the table to synchronize.                                  |
4382| progress | Callback&lt;[ProgressDetails](#progressdetails10)&gt; | Yes  | Callback used to process database synchronization details.            |
4383| callback | AsyncCallback&lt;void&gt;                             | Yes  | Callback invoked to send the synchronization result to the caller.|
4384
4385**Example**
4386
4387```ts
4388const tables = ["table1", "table2"];
4389
4390if(store != undefined) {
4391  (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, tables, (progressDetail: relationalStore.ProgressDetails) => {
4392    console.info(`Progess: ${progressDetail}`);
4393  }, (err) => {
4394    if (err) {
4395      console.error(`Cloud sync failed, code is ${err.code},message is ${err.message}`);
4396      return;
4397    }
4398    console.info('Cloud sync succeeded');
4399  });
4400};
4401```
4402
4403### cloudSync<sup>10+</sup>
4404
4405cloudSync(mode: SyncMode, tables: string[], progress: Callback&lt;ProgressDetails&gt;): Promise&lt;void&gt;
4406
4407Manually starts device-cloud synchronization 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.
4408
4409**Required permissions**: ohos.permission.DISTRIBUTED_DATASYNC
4410
4411**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
4412
4413**Parameters**
4414
4415| Name  | Type                                                 | Mandatory| Description                                  |
4416| -------- | ----------------------------------------------------- | ---- | -------------------------------------- |
4417| mode     | [SyncMode](#syncmode)                                 | Yes  | Synchronization mode of the database.                |
4418| tables   | string[]                                              | Yes  | Name of the table to synchronize.                      |
4419| progress | Callback&lt;[ProgressDetails](#progressdetails10)&gt; | Yes  | Callback used to process database synchronization details.|
4420
4421**Return value**
4422
4423| Type               | Description                                   |
4424| ------------------- | --------------------------------------- |
4425| Promise&lt;void&gt; | Promise used to send the synchronization result.|
4426
4427**Example**
4428
4429```ts
4430import { BusinessError } from "@ohos.base";
4431
4432const tables = ["table1", "table2"];
4433
4434if(store != undefined) {
4435  (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, (progressDetail: relationalStore.ProgressDetails) => {
4436    console.info(`progress: ${progressDetail}`);
4437  }).then(() => {
4438    console.info('Cloud sync succeeded');
4439  }).catch((err: BusinessError) => {
4440    console.error(`cloudSync failed, code is ${err.code},message is ${err.message}`);
4441  });
4442};
4443```
4444
4445### on('dataChange')
4446
4447on(event: 'dataChange', type: SubscribeType, observer: Callback&lt;Array&lt;string&gt;&gt;): void
4448
4449Subscribes to data changes of the specified devices. When the data in the RDB store changes, a callback is invoked to return the data changes.
4450
4451**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4452
4453**Parameters**
4454
4455| Name  | Type                                                        | Mandatory| Description                                                        |
4456| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
4457| event    | string                                                       | Yes  | Event type. The value is **dataChange**, which indicates data changes.                     |
4458| type     | [SubscribeType](#subscribetype) | Yes  | Type of data change to observe.                   |
4459| observer | Callback&lt;Array&lt;string&gt;&gt;                          | Yes  | Callback invoked to return the data change. **Array<string>** indicates the IDs of the peer devices whose data in the database is changed.|
4460
4461**Example**
4462
4463```ts
4464import deviceManager from '@ohos.distributedHardware.deviceManager';
4465
4466let devices: string | undefined = undefined;
4467
4468try {
4469  if (store != undefined) {
4470    (store as relationalStore.RdbStore).on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, (storeObserver) => {
4471      if (devices != undefined) {
4472        for (let i = 0; i < devices.length; i++) {
4473          console.info(`device= ${devices[i]} data changed`);
4474        }
4475      }
4476    })
4477  }
4478} catch (err) {
4479    let code = (err as BusinessError).code;
4480    let message = (err as BusinessError).message
4481    console.error(`Register observer failed, code is ${code},message is ${message}`);
4482}
4483```
4484
4485### on('dataChange')<sup>10+</sup>
4486
4487on(event: 'dataChange', type: SubscribeType, observer: Callback&lt;Array&lt;string&gt;&gt;\| Callback&lt;Array&lt;ChangeInfo&gt;&gt;): void
4488
4489Subscribes to data changes of this RDB store. When the data in the RDB store changes, a callback is invoked to return the data changes.
4490
4491**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4492
4493**Parameters**
4494
4495| Name  | Type                               | Mandatory| Description                                       |
4496| -------- | ----------------------------------- | ---- | ------------------------------------------- |
4497| event    | string                              | Yes  | Event type. The value is **dataChange**, which indicates data changes.     |
4498| type     | [SubscribeType](#subscribetype)    | Yes  | Type of data change to observe. |
4499| observer | Callback&lt;Array&lt;string&gt;&gt; \| Callback&lt;Array&lt;[ChangeInfo](#changeinfo10)&gt;&gt; | Yes  | Callback invoked 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;** specifies 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;** specifies 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;** specifies the details about the device-cloud synchronization.|
4500
4501**Example**
4502
4503```ts
4504import deviceManager from '@ohos.distributedHardware.deviceManager';
4505
4506let devices: string | undefined = undefined;
4507
4508try {
4509  if(store != undefined) {
4510    (store as relationalStore.RdbStore).on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver => {
4511      if (devices != undefined) {
4512        for (let i = 0; i < devices.length; i++) {
4513          console.info(`device= ${devices[i]} data changed`);
4514        }
4515      }
4516    });
4517  }
4518} catch (err) {
4519  let code = (err as BusinessError).code;
4520  let message = (err as BusinessError).message
4521  console.error(`Register observer failed, code is ${code},message is ${message}`);
4522}
4523```
4524
4525### on<sup>10+</sup>
4526
4527on(event: string, interProcess: boolean, observer: Callback\<void>): void
4528
4529Subscribes to intra-process or inter-process events for this RDB store. This callback is invoked by [emit](#emit10).
4530
4531**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4532
4533**Parameters**
4534
4535| Name      | Type           | Mandatory| Description                                                        |
4536| ------------ | --------------- | ---- | ------------------------------------------------------------ |
4537| event        | string          | Yes  | Event name to observe.                                              |
4538| interProcess | boolean         | Yes  | Type of the event to observe.<br>The value **true** means inter-process events.<br>The value **false** means intra-process events. |
4539| observer     | Callback\<void> | Yes  | Callback invoked to return the result.                                                  |
4540
4541**Error codes**
4542
4543For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
4544
4545| **ID**| **Error Message**                          |
4546| ------------ | -------------------------------------- |
4547| 14800000     | Inner error.                           |
4548| 14800050     | Failed to obtain subscription service. |
4549
4550**Example**
4551
4552```ts
4553try {
4554  if(store != undefined) {
4555    (store as relationalStore.RdbStore).on('storeObserver', false, (storeObserver) => {
4556      console.info(`storeObserver`);
4557    });
4558  }
4559} catch (err) {
4560  let code = (err as BusinessError).code;
4561  let message = (err as BusinessError).message
4562  console.error(`Register observer failed, code is ${code},message is ${message}`);
4563}
4564```
4565
4566### off('dataChange')
4567
4568off(event:'dataChange', type: SubscribeType, observer: Callback&lt;Array&lt;string&gt;&gt;): void
4569
4570Unsubscribes from data changes of the specified devices.
4571
4572**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4573
4574**Parameters**
4575
4576| Name  | Type                                                        | Mandatory| Description                                                        |
4577| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
4578| event    | string                                                       | Yes  | Event type. The value is **dataChange**, which indicates data changes.                     |
4579| type     | [SubscribeType](#subscribetype) | Yes  | Type of data change to observe.                 |
4580| observer | Callback&lt;Array&lt;string&gt;&gt;                          | Yes  | Callback to unregister. **Array<string>** indicates the IDs of the peer devices whose data change is unsubscribed from. |
4581
4582**Example**
4583
4584```ts
4585let devices: string | undefined = undefined;
4586
4587try {
4588  if(store != undefined) {
4589    (store as relationalStore.RdbStore).off('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, (storeObserver) => {
4590      if (devices != undefined){
4591        for (let i = 0; i < devices.length; i++) {
4592          console.info(`device= ${devices[i]} data changed`);
4593        }
4594      }
4595    });
4596  }
4597} catch (err) {
4598  let code = (err as BusinessError).code;
4599  let message = (err as BusinessError).message
4600  console.error(`Unregister observer failed, code is ${code},message is ${message}`);
4601}
4602```
4603
4604### off('dataChange')<sup>10+</sup>
4605
4606off(event:'dataChange', type: SubscribeType, observer?: Callback&lt;Array&lt;string&gt;&gt;\| Callback&lt;Array&lt;ChangeInfo&gt;&gt;): void
4607
4608Unsubscribes from data changes of this RDB store.
4609
4610**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4611
4612**Parameters**
4613
4614| Name  | Type                               | Mandatory| Description                                       |
4615| -------- | ---------------------------------- | ---- | ------------------------------------------ |
4616| event    | string                              | Yes  | Event type. The value is **dataChange**, which indicates data changes.     |
4617| type     | [SubscribeType](#subscribetype)     | Yes  | Type of data change to observe. |
4618| 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;** specifies 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;** specifies 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;** specifies the details about the device-cloud synchronization.<br>If **observer** is not specified, listening for all data change events of the specified **type** will be canceled. |
4619
4620**Example**
4621
4622```ts
4623import deviceManager from '@ohos.distributedHardware.deviceManager';
4624
4625let devices: string | undefined = undefined;
4626
4627try {
4628  if(store != undefined) {
4629    (store as relationalStore.RdbStore).off('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, (storeObserver) => {
4630      if (devices !=  undefined) {
4631        for (let i = 0; i < devices.length; i++) {
4632          console.info(`device= ${devices[i]} data changed`);
4633        }
4634      }
4635    });
4636  }
4637} catch (err) {
4638  let code = (err as BusinessError).code;
4639  let message = (err as BusinessError).message
4640  console.error(`Unregister observer failed, code is ${code},message is ${message}`);
4641}
4642```
4643
4644### off<sup>10+</sup>
4645
4646off(event: string, interProcess: boolean, observer?: Callback\<void>): void
4647
4648Unsubscribes from inter-process or intra-process events.
4649
4650**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4651
4652**Parameters**
4653
4654| Name      | Type           | Mandatory| Description                                                        |
4655| ------------ | --------------- | ---- | ------------------------------------------------------------ |
4656| event        | string          | Yes  | Name of the event.                                          |
4657| interProcess | boolean         | Yes  | Type of the event.<br>The value **true** means inter-process events.<br>The value **false** means intra-process events. |
4658| observer     | Callback\<void> | No  | Callback to unregister.<br/>If this parameter is not specified, all callbacks of the specified event will be unregistered. |
4659
4660**Error codes**
4661
4662For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
4663
4664| **ID**| **Error Message**                          |
4665| ------------ | -------------------------------------- |
4666| 14800000     | Inner error.                           |
4667| 14800050     | Failed to obtain subscription service. |
4668
4669**Example**
4670
4671```ts
4672try {
4673  if(store != undefined) {
4674    (store as relationalStore.RdbStore).off('storeObserver', false, (storeObserver) => {
4675      console.info(`storeObserver`);
4676    });
4677  }
4678} catch (err) {
4679  let code = (err as BusinessError).code;
4680  let message = (err as BusinessError).message
4681  console.error(`Register observer failed, code is ${code},message is ${message}`);
4682}
4683```
4684
4685### emit<sup>10+</sup>
4686
4687emit(event: string): void
4688
4689Triggers the inter-process or intra-process event listener registered through [on](#on10).
4690
4691**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4692
4693**Parameters**
4694
4695| Name| Type  | Mandatory| Description                |
4696| ------ | ------ | ---- | -------------------- |
4697| event  | string | Yes  | Name of the event.|
4698
4699**Error codes**
4700
4701For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
4702
4703| **ID**| **Error Message**                          |
4704| ------------ | -------------------------------------- |
4705| 14800000     | Inner error.                           |
4706| 14800050     | Failed to obtain subscription service. |
4707
4708**Example**
4709
4710```ts
4711if(store != undefined) {
4712  (store as relationalStore.RdbStore).emit('storeObserver');
4713}
4714```
4715
4716## ResultSet
4717
4718Provides APIs to access the **resultSet** object returned by **query()**.
4719
4720### Usage
4721
4722Obtain the **resultSet** object first.
4723
4724**Example**
4725
4726```ts
4727let resultSet: relationalStore.ResultSet | undefined = undefined;
4728let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
4729predicates.equalTo("AGE", 18);
4730if(store != undefined) {
4731  (store as relationalStore.RdbStore).query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((result: relationalStore.ResultSet) => {
4732    resultSet = result;
4733    console.info(`resultSet columnNames: ${resultSet.columnNames}`);
4734    console.info(`resultSet columnCount: ${resultSet.columnCount}`);
4735  });
4736}
4737```
4738
4739### Attributes
4740
4741**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4742
4743| Name        | Type           | Mandatory| Description                            |
4744| ------------ | ------------------- | ---- | -------------------------------- |
4745| columnNames  | Array&lt;string&gt; | Yes  | Names of all columns in the result set.      |
4746| columnCount  | number              | Yes  | Number of columns in the result set.            |
4747| rowCount     | number              | Yes  | Number of rows in the result set.            |
4748| rowIndex     | number              | Yes  | Index of the current row in the result set.        |
4749| isAtFirstRow | boolean             | Yes  | Whether the cursor is in the first row of the result set.      |
4750| isAtLastRow  | boolean             | Yes  | Whether the cursor is in the last row of the result set.    |
4751| isEnded      | boolean             | Yes  | Whether the cursor is after the last row of the result set.|
4752| isStarted    | boolean             | Yes  | Whether the cursor has been moved.            |
4753| isClosed     | boolean             | Yes  | Whether the result set is closed.        |
4754
4755### getColumnIndex
4756
4757getColumnIndex(columnName: string): number
4758
4759Obtains the column index based on the column name.
4760
4761**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4762
4763**Parameters**
4764
4765| Name    | Type  | Mandatory| Description                      |
4766| ---------- | ------ | ---- | -------------------------- |
4767| columnName | string | Yes  | Column name.|
4768
4769**Return value**
4770
4771| Type  | Description              |
4772| ------ | ------------------ |
4773| number | Column index obtained.|
4774
4775**Error codes**
4776
4777For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
4778
4779| **ID**| **Error Message**                                                |
4780| ------------ | ------------------------------------------------------------ |
4781| 14800013     | The column value is null or the column type is incompatible. |
4782
4783**Example**
4784
4785```ts
4786if(resultSet != undefined) {
4787  const id = (resultSet as relationalStore.ResultSet).getLong((resultSet as relationalStore.ResultSet).getColumnIndex("ID"));
4788  const name = (resultSet as relationalStore.ResultSet).getString((resultSet as relationalStore.ResultSet).getColumnIndex("NAME"));
4789  const age = (resultSet as relationalStore.ResultSet).getLong((resultSet as relationalStore.ResultSet).getColumnIndex("AGE"));
4790  const salary = (resultSet as relationalStore.ResultSet).getDouble((resultSet as relationalStore.ResultSet).getColumnIndex("SALARY"));
4791}
4792```
4793
4794### getColumnName
4795
4796getColumnName(columnIndex: number): string
4797
4798Obtains the column name based on the specified column index.
4799
4800**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4801
4802**Parameters**
4803
4804| Name     | Type  | Mandatory| Description                      |
4805| ----------- | ------ | ---- | -------------------------- |
4806| columnIndex | number | Yes  | Column index.|
4807
4808**Return value**
4809
4810| Type  | Description              |
4811| ------ | ------------------ |
4812| string | Column name obtained.|
4813
4814**Error codes**
4815
4816For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
4817
4818| **ID**| **Error Message**                                                |
4819| ------------ | ------------------------------------------------------------ |
4820| 14800013     | The column value is null or the column type is incompatible. |
4821
4822**Example**
4823
4824```ts
4825if(resultSet != undefined) {
4826  const id = (resultSet as relationalStore.ResultSet).getColumnName(0);
4827  const name = (resultSet as relationalStore.ResultSet).getColumnName(1);
4828  const age = (resultSet as relationalStore.ResultSet).getColumnName(2);
4829}
4830```
4831
4832### goTo
4833
4834goTo(offset:number): boolean
4835
4836Moves the cursor to the row based on the specified offset.
4837
4838**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4839
4840**Parameters**
4841
4842| Name| Type  | Mandatory| Description                        |
4843| ------ | ------ | ---- | ---------------------------- |
4844| offset | number | Yes  | Offset relative to the current position.|
4845
4846**Return value**
4847
4848| Type   | Description                                         |
4849| ------- | --------------------------------------------- |
4850| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
4851
4852**Error codes**
4853
4854For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
4855
4856| **ID**| **Error Message**                                                |
4857| ------------ | ------------------------------------------------------------ |
4858| 14800012     | The result set is empty or the specified location is invalid. |
4859
4860**Example**
4861
4862```ts
4863if(resultSet != undefined) {
4864  (resultSet as relationalStore.ResultSet).goTo(1);
4865}
4866```
4867
4868### goToRow
4869
4870goToRow(position: number): boolean
4871
4872Moves to the specified row in the result set.
4873
4874**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4875
4876**Parameters**
4877
4878| Name  | Type  | Mandatory| Description                    |
4879| -------- | ------ | ---- | ------------------------ |
4880| position | number | Yes  | Destination position to move to.|
4881
4882**Return value**
4883
4884| Type   | Description                                         |
4885| ------- | --------------------------------------------- |
4886| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
4887
4888**Error codes**
4889
4890For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
4891
4892| **ID**| **Error Message**                                                |
4893| ------------ | ------------------------------------------------------------ |
4894| 14800012     | The result set is empty or the specified location is invalid. |
4895
4896**Example**
4897
4898```ts
4899if(resultSet != undefined) {
4900  (resultSet as relationalStore.ResultSet).goToRow(5);
4901}
4902```
4903
4904### goToFirstRow
4905
4906goToFirstRow(): boolean
4907
4908
4909Moves to the first row of the result set.
4910
4911**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4912
4913**Return value**
4914
4915| Type   | Description                                         |
4916| ------- | --------------------------------------------- |
4917| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
4918
4919**Error codes**
4920
4921For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
4922
4923| **ID**| **Error Message**                                                |
4924| ------------ | ------------------------------------------------------------ |
4925| 14800012     | The result set is empty or the specified location is invalid. |
4926
4927**Example**
4928
4929```ts
4930if(resultSet != undefined) {
4931  (resultSet as relationalStore.ResultSet).goToFirstRow();
4932}
4933```
4934
4935### goToLastRow
4936
4937goToLastRow(): boolean
4938
4939Moves to the last row of the result set.
4940
4941**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4942
4943**Return value**
4944
4945| Type   | Description                                         |
4946| ------- | --------------------------------------------- |
4947| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
4948
4949**Error codes**
4950
4951For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
4952
4953| **ID**| **Error Message**                                                |
4954| ------------ | ------------------------------------------------------------ |
4955| 14800012     | The result set is empty or the specified location is invalid. |
4956
4957**Example**
4958
4959```ts
4960if(resultSet != undefined) {
4961  (resultSet as relationalStore.ResultSet).goToLastRow();
4962}
4963```
4964
4965### goToNextRow
4966
4967goToNextRow(): boolean
4968
4969Moves to the next row in the result set.
4970
4971**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
4972
4973**Return value**
4974
4975| Type   | Description                                         |
4976| ------- | --------------------------------------------- |
4977| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
4978
4979**Error codes**
4980
4981For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
4982
4983| **ID**| **Error Message**                                                |
4984| ------------ | ------------------------------------------------------------ |
4985| 14800012     | The result set is empty or the specified location is invalid. |
4986
4987**Example**
4988
4989```ts
4990if(resultSet != undefined) {
4991  (resultSet as relationalStore.ResultSet).goToNextRow();
4992}
4993```
4994
4995### goToPreviousRow
4996
4997goToPreviousRow(): boolean
4998
4999Moves to the previous row in the result set.
5000
5001**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5002
5003**Return value**
5004
5005| Type   | Description                                         |
5006| ------- | --------------------------------------------- |
5007| boolean | Returns **true** if the operation is successful; returns **false** otherwise.|
5008
5009**Error codes**
5010
5011For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
5012
5013| **ID**| **Error Message**                                                |
5014| ------------ | ------------------------------------------------------------ |
5015| 14800012     | The result set is empty or the specified location is invalid. |
5016
5017**Example**
5018
5019```ts
5020if(resultSet != undefined) {
5021  (resultSet as relationalStore.ResultSet).goToPreviousRow();
5022}
5023```
5024
5025### getBlob
5026
5027getBlob(columnIndex: number): Uint8Array
5028
5029Obtains the value in the form of a byte array based on the specified column and the current row.
5030
5031**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5032
5033**Parameters**
5034
5035| Name     | Type  | Mandatory| Description                   |
5036| ----------- | ------ | ---- | ----------------------- |
5037| columnIndex | number | Yes  | Index of the target column, starting from 0.|
5038
5039**Return value**
5040
5041| Type      | Description                            |
5042| ---------- | -------------------------------- |
5043| Uint8Array | Value obtained.|
5044
5045**Error codes**
5046
5047For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
5048
5049| **ID**| **Error Message**                                                |
5050| ------------ | ------------------------------------------------------------ |
5051| 14800013     | The column value is null or the column type is incompatible. |
5052
5053**Example**
5054
5055```ts
5056if(resultSet != undefined) {
5057  const codes = (resultSet as relationalStore.ResultSet).getBlob((resultSet as relationalStore.ResultSet).getColumnIndex("CODES"));
5058}
5059```
5060
5061### getString
5062
5063getString(columnIndex: number): string
5064
5065Obtains the value in the form of a string based on the specified column and the current row.
5066
5067**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5068
5069**Parameters**
5070
5071| Name     | Type  | Mandatory| Description                   |
5072| ----------- | ------ | ---- | ----------------------- |
5073| columnIndex | number | Yes  | Index of the target column, starting from 0.|
5074
5075**Return value**
5076
5077| Type  | Description                        |
5078| ------ | ---------------------------- |
5079| string | String obtained.|
5080
5081**Error codes**
5082
5083For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
5084
5085| **ID**| **Error Message**                                                |
5086| ------------ | ------------------------------------------------------------ |
5087| 14800013     | The column value is null or the column type is incompatible. |
5088
5089**Example**
5090
5091```ts
5092if(resultSet != undefined) {
5093  const name = (resultSet as relationalStore.ResultSet).getString((resultSet as relationalStore.ResultSet).getColumnIndex("NAME"));
5094}
5095```
5096
5097### getLong
5098
5099getLong(columnIndex: number): number
5100
5101Obtains the value of the Long type based on the specified column and the current row.
5102
5103**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5104
5105**Parameters**
5106
5107| Name     | Type  | Mandatory| Description                   |
5108| ----------- | ------ | ---- | ----------------------- |
5109| columnIndex | number | Yes  | Index of the target column, starting from 0.|
5110
5111**Return value**
5112
5113| Type  | Description                                                        |
5114| ------ | ------------------------------------------------------------ |
5115| 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).|
5116
5117**Error codes**
5118
5119For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
5120
5121| **ID**| **Error Message**                                                |
5122| ------------ | ------------------------------------------------------------ |
5123| 14800013     | The column value is null or the column type is incompatible. |
5124
5125**Example**
5126
5127```ts
5128if(resultSet != undefined) {
5129  const age = (resultSet as relationalStore.ResultSet).getLong((resultSet as relationalStore.ResultSet).getColumnIndex("AGE"));
5130 }
5131```
5132
5133### getDouble
5134
5135getDouble(columnIndex: number): number
5136
5137Obtains the value of the double type based on the specified column and the current row.
5138
5139**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5140
5141**Parameters**
5142
5143| Name     | Type  | Mandatory| Description                   |
5144| ----------- | ------ | ---- | ----------------------- |
5145| columnIndex | number | Yes  | Index of the target column, starting from 0.|
5146
5147**Return value**
5148
5149| Type  | Description                        |
5150| ------ | ---------------------------- |
5151| number | Returns the value obtained.|
5152
5153**Error codes**
5154
5155For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
5156
5157| **ID**| **Error Message**                                                |
5158| ------------ | ------------------------------------------------------------ |
5159| 14800013     | The column value is null or the column type is incompatible. |
5160
5161**Example**
5162
5163```ts
5164if(resultSet != undefined) {
5165  const salary = (resultSet as relationalStore.ResultSet).getDouble((resultSet as relationalStore.ResultSet).getColumnIndex("SALARY"));
5166}
5167```
5168
5169### getAsset<sup>10+</sup>
5170
5171getAsset(columnIndex: number): Asset
5172
5173Obtains the value in the [Asset](#asset10) format based on the specified column and current row.
5174
5175**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5176
5177**Parameters**
5178
5179| Name        | Type    | Mandatory | Description          |
5180| ----------- | ------ | --- | ------------ |
5181| columnIndex | number | Yes  | Index of the target column, starting from 0.|
5182
5183**Return value**
5184
5185| Type             | Description                        |
5186| --------------- | -------------------------- |
5187| [Asset](#asset10) | Returns the value obtained.|
5188
5189**Error codes**
5190
5191For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
5192
5193| **ID**| **Error Message**                                                    |
5194| --------- | ------------------------------------------------------------ |
5195| 14800013  | The column value is null or the column type is incompatible. |
5196
5197**Example**
5198
5199```ts
5200if(resultSet != undefined) {
5201  const doc = (resultSet as relationalStore.ResultSet).getAsset((resultSet as relationalStore.ResultSet).getColumnIndex("DOC"));
5202}
5203```
5204
5205### getAssets<sup>10+</sup>
5206
5207getAssets(columnIndex: number): Assets
5208
5209Obtains the value in the [Assets](#assets10) format based on the specified column and current row.
5210
5211**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5212
5213**Parameters**
5214
5215| Name        | Type    | Mandatory | Description          |
5216| ----------- | ------ | --- | ------------ |
5217| columnIndex | number | Yes  | Index of the target column, starting from 0.|
5218
5219**Return value**
5220
5221| Type             | Description                          |
5222| ---------------- | ---------------------------- |
5223| [Assets](#assets10)| Returns the value obtained.|
5224
5225**Error codes**
5226
5227For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
5228
5229| **ID**| **Error Message**                                                |
5230| ------------ | ------------------------------------------------------------ |
5231| 14800013     | The column value is null or the column type is incompatible. |
5232
5233**Example**
5234
5235```ts
5236if(resultSet != undefined) {
5237  const docs = (resultSet as relationalStore.ResultSet).getAssets((resultSet as relationalStore.ResultSet).getColumnIndex("DOCS"));
5238}
5239```
5240
5241
5242### isColumnNull
5243
5244isColumnNull(columnIndex: number): boolean
5245
5246Checks whether the value in the specified column is null.
5247
5248**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5249
5250**Parameters**
5251
5252| Name     | Type  | Mandatory| Description                   |
5253| ----------- | ------ | ---- | ----------------------- |
5254| columnIndex | number | Yes  | Index of the target column, starting from 0.|
5255
5256**Return value**
5257
5258| Type   | Description                                                     |
5259| ------- | --------------------------------------------------------- |
5260| boolean | Returns **true** if the value is null; returns **false** otherwise.|
5261
5262**Error codes**
5263
5264For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
5265
5266| **ID**| **Error Message**                                                |
5267| ------------ | ------------------------------------------------------------ |
5268| 14800013     | The column value is null or the column type is incompatible. |
5269
5270**Example**
5271
5272```ts
5273if(resultSet != undefined) {
5274  const isColumnNull = (resultSet as relationalStore.ResultSet).isColumnNull((resultSet as relationalStore.ResultSet).getColumnIndex("CODES"));
5275}
5276```
5277
5278### close
5279
5280close(): void
5281
5282Closes this result set.
5283
5284**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
5285
5286**Example**
5287
5288```ts
5289if(resultSet != undefined) {
5290  (resultSet as relationalStore.ResultSet).close();
5291}
5292```
5293
5294**Error codes**
5295
5296For details about the error codes, see [RDB Error Codes](../errorcodes/errorcode-data-rdb.md).
5297
5298| **ID**| **Error Message**                                                |
5299| ------------ | ------------------------------------------------------------ |
5300| 14800012     | The result set is empty or the specified location is invalid. |
5301