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