• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.data.relationalStore (RDB Store) (System API)
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.
4ArkTS supports the following basic data types: number, string, binary data, and boolean. The maximum size of a data record is 2 MB. If a data record exceeds 2 MB, it can be inserted successfully but cannot be read.
5
6The **relationalStore** module provides the following functions:
7
8- [RdbPredicates](arkts-apis-data-relationalStore-RdbPredicates.md): 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.
9- [RdbStore](arkts-apis-data-relationalStore-RdbStore.md): provides APIs for managing data in an RDB store.
10- [ResultSet](arkts-apis-data-relationalStore-ResultSet.md): provides APIs for accessing the result set obtained from the RDB store.
11
12> **NOTE**
13>
14> - 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.
15>
16> - This topic describes only the system APIs provided by the module. For details about its public APIs, see [@ohos.data.relationalStore](arkts-apis-data-relationalStore.md).
17
18## Modules to Import
19
20```ts
21import { relationalStore } from '@kit.ArkData';
22```
23
24## StoreConfig
25
26Defines the configuration of an RDB store.
27
28**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
29
30| Name       | Type         | Mandatory| Description                                                     |
31| ------------- | ------------- | ---- | --------------------------------------------------------- |
32| isSearchable<sup>11+</sup> | boolean | No| Whether the RDB store is searchable. The value **true** means the RDB store is searchable; the value **false** means the opposite. The default value is **false**.<br>**System API**: This is a system API.<br>This parameter is supported since API version 11. |
33| haMode<sup>12+</sup> | [HAMode](#hamode12) | No| High availability (HA) mode.<br>The value **SINGLE** means data can be written only to a single RDB store. The value **MAIN_REPLICA** means data can be written to the main and replica RDB stores to ensure HA. However, this mode is not supported in encryption and attach scenarios. The default value is **SINGLE**. The value **MAIN_REPLICA** may affect the database write performance.<br>**System API**: This is a system API.<br>This parameter is supported since API version 12. |
34
35## HAMode<sup>12+</sup>
36
37Enumerates the HA modes of an RDB store.
38
39**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
40
41| Name                             | Value  | Description            |
42| ------------------------------- | --- | -------------- |
43| SINGLE      | 0 | Allows data to be written to a single RDB store.     |
44| MAIN_REPLICA | 1 | Allows data to be written to the main and replica RDB stores for HA. This mode is not supported in encryption and attach scenarios.|
45
46## Reference<sup>11+</sup>
47
48Represents the reference between tables by field. If table **b** references table **a**, table **a** is the source table and **b** is the target table.
49
50**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
51
52**System API**: This is a system API.
53
54| Name      | Type  | Mandatory| Description                                    |
55| ---------- | ------ | ---- | ---------------------------------------- |
56| sourceTable | string | Yes  | Name of the table referenced.  |
57| targetTable | string | Yes  | Name of the table that references the source table.  |
58| refFields   | Record<string, string> | Yes  | Fields referenced. In a KV pair, the key indicates the field in the source table, and the value indicates the field in the target table.      |
59
60## DistributedConfig<sup>10+</sup>
61
62Defines the configuration of the distributed mode of tables.
63
64**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
65
66| Name    | Type   | Mandatory| Description                                                        |
67| -------- | ------- | ---- | ------------------------------------------------------------ |
68| references<sup>11+</sup> | Array&lt;[Reference](#reference11)&gt; | No  | References between tables. You can reference multiple fields, and their values must be the same in the source and target tables. By default, database tables are not referenced with each other.<br>**System API**: This is a system API.<br>This parameter is supported since API version 11.|
69
70## RdbStore
71
72Provides APIs for managing data in an RDB store.
73
74Before using the following APIs, you should obtain a **RdbStore** instance by calling the [getRdbStore](arkts-apis-data-relationalStore-f.md#relationalstoregetrdbstore-1) method and then call the corresponding method through the instance.
75
76In addition, use [execute](arkts-apis-data-relationalStore-RdbStore.md#execute12) to initialize the database table structure and related data first, ensuring that the prerequisites for related API calls are met.
77
78### update
79
80update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback&lt;number&gt;):void
81
82Updates data based on the specified **DataSharePredicates** object. This API uses an asynchronous callback to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
83
84**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
85
86**Model restriction**: This API can be used only in the stage model.
87
88**System API**: This is a system API.
89
90**Parameters**
91
92| Name    | Type                                                        | Mandatory| Description                                                        |
93| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
94| table      | string                                                       | Yes  | Name of the target table.                                            |
95| values     | [ValuesBucket](arkts-apis-data-relationalStore-t.md#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.|
96| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes  | Update conditions specified by the **DataSharePredicates** object.               |
97| callback   | AsyncCallback&lt;number&gt;                                  | Yes  | Callback used to return the number of rows updated.                  |
98
99**Error codes**
100
101For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
102
103| **ID**| **Error Message**                                                |
104|-----------| ------------------------------------------------------------ |
105| 202       | Permission verification failed, application which is not a system application uses system API. |
106| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
107| 14800000  | Inner error. |
108| 14800011  | Failed to open the database because it is corrupted. |
109| 14800014  | The RdbStore or ResultSet is already closed. |
110| 14800015  | The database does not respond. |
111| 14800021  | SQLite: Generic error. Possible causes: Insert failed or the updated data does not exist. |
112| 14800022  | SQLite: Callback routine requested an abort. |
113| 14800023  | SQLite: Access permission denied. |
114| 14800024  | SQLite: The database file is locked. |
115| 14800025  | SQLite: A table in the database is locked. |
116| 14800026  | SQLite: The database is out of memory. |
117| 14800027  | SQLite: Attempt to write a readonly database. |
118| 14800028  | SQLite: Some kind of disk I/O error occurred. |
119| 14800029  | SQLite: The database is full. |
120| 14800030  | SQLite: Unable to open the database file. |
121| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
122| 14800032  | SQLite: Abort due to constraint violation. |
123| 14800033  | SQLite: Data type mismatch. |
124| 14800034  | SQLite: Library used incorrectly. |
125| 14800047  | The WAL file size exceeds the default limit. |
126
127**Example**
128
129```ts
130import { dataSharePredicates } from '@kit.ArkData';
131import { ValuesBucket } from '@kit.ArkData';
132
133let value1 = "Rose";
134let value2 = 22;
135let value3 = 200.5;
136let value4 = new Uint8Array([1, 2, 3, 4, 5]);
137
138// You can use either of the following:
139const valueBucket1: ValuesBucket = {
140  'NAME': value1,
141  'AGE': value2,
142  'SALARY': value3,
143  'CODES': value4,
144};
145const valueBucket2: ValuesBucket = {
146  NAME: value1,
147  AGE: value2,
148  SALARY: value3,
149  CODES: value4,
150};
151const valueBucket3: ValuesBucket = {
152  "NAME": value1,
153  "AGE": value2,
154  "SALARY": value3,
155  "CODES": value4,
156};
157
158let predicates = new dataSharePredicates.DataSharePredicates();
159predicates.equalTo("NAME", "Lisa");
160if (store != undefined) {
161  (store as relationalStore.RdbStore).update("EMPLOYEE", valueBucket1, predicates, (err, rows) => {
162    if (err) {
163      console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
164      return;
165    }
166    console.info(`Updated row count: ${rows}`);
167  });
168}
169```
170
171### update
172
173update(table: string, values: ValuesBucket, predicates: dataSharePredicates.DataSharePredicates):Promise&lt;number&gt;
174
175Updates data based on the specified **DataSharePredicates** object. This API uses a promise to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
176
177**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
178
179**Model restriction**: This API can be used only in the stage model.
180
181**System API**: This is a system API.
182
183**Parameters**
184
185| Name    | Type                                                        | Mandatory| Description                                                        |
186| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
187| table      | string                                                       | Yes  | Name of the target table.                                            |
188| values     | [ValuesBucket](arkts-apis-data-relationalStore-t.md#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.|
189| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes  | Update conditions specified by the **DataSharePredicates** object.               |
190
191**Return value**
192
193| Type                 | Description                                     |
194| --------------------- | ----------------------------------------- |
195| Promise&lt;number&gt; | Promise used to return the number of rows updated.|
196
197**Error codes**
198
199For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
200
201| **ID**| **Error Message**                                                |
202|-----------| ------------------------------------------------------------ |
203| 202       | Permission verification failed, application which is not a system application uses system API. |
204| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
205| 14800000  | Inner error. |
206| 14800011  | Failed to open the database because it is corrupted. |
207| 14800014  | The RdbStore or ResultSet is already closed. |
208| 14800015  | The database does not respond. |
209| 14800021  | SQLite: Generic error. Possible causes: Insert failed or the updated data does not exist. |
210| 14800022  | SQLite: Callback routine requested an abort. |
211| 14800023  | SQLite: Access permission denied. |
212| 14800024  | SQLite: The database file is locked. |
213| 14800025  | SQLite: A table in the database is locked. |
214| 14800026  | SQLite: The database is out of memory. |
215| 14800027  | SQLite: Attempt to write a readonly database. |
216| 14800028  | SQLite: Some kind of disk I/O error occurred. |
217| 14800029  | SQLite: The database is full. |
218| 14800030  | SQLite: Unable to open the database file. |
219| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
220| 14800032  | SQLite: Abort due to constraint violation. |
221| 14800033  | SQLite: Data type mismatch. |
222| 14800034  | SQLite: Library used incorrectly. |
223| 14800047  | The WAL file size exceeds the default limit. |
224
225**Example**
226
227```ts
228import { dataSharePredicates } from '@kit.ArkData';
229import { ValuesBucket } from '@kit.ArkData';
230import { BusinessError } from '@kit.BasicServicesKit';
231
232let value1 = "Rose";
233let value2 = 22;
234let value3 = 200.5;
235let value4 = new Uint8Array([1, 2, 3, 4, 5]);
236
237// You can use either of the following:
238const valueBucket1: ValuesBucket = {
239  'NAME': value1,
240  'AGE': value2,
241  'SALARY': value3,
242  'CODES': value4,
243};
244const valueBucket2: ValuesBucket = {
245  NAME: value1,
246  AGE: value2,
247  SALARY: value3,
248  CODES: value4,
249};
250const valueBucket3: ValuesBucket = {
251  "NAME": value1,
252  "AGE": value2,
253  "SALARY": value3,
254  "CODES": value4,
255};
256
257let predicates = new dataSharePredicates.DataSharePredicates();
258predicates.equalTo("NAME", "Lisa");
259if (store != undefined) {
260  (store as relationalStore.RdbStore).update("EMPLOYEE", valueBucket1, predicates).then(async (rows: Number) => {
261    console.info(`Updated row count: ${rows}`);
262  }).catch((err: BusinessError) => {
263    console.error(`Updated failed, code is ${err.code},message is ${err.message}`);
264  });
265}
266```
267
268### delete
269
270delete(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback&lt;number&gt;):void
271
272Deletes data from the RDB store based on the specified **DataSharePredicates** object. This API uses an asynchronous callback to return the result.
273
274**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
275
276**Model restriction**: This API can be used only in the stage model.
277
278**System API**: This is a system API.
279
280**Parameters**
281
282| Name    | Type                                                        | Mandatory| Description                                         |
283| ---------- | ------------------------------------------------------------ | ---- | --------------------------------------------- |
284| table      | string                                                       | Yes  | Name of the target table, which cannot be an empty string.             |
285| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes  | Deletion conditions specified by the **DataSharePredicates** object.|
286| callback   | AsyncCallback&lt;number&gt;                                  | Yes  | Callback used to return the number of rows deleted.|
287
288**Error codes**
289
290For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
291
292| **ID**| **Error Message**                                                |
293|-----------| ------------------------------------------------------------ |
294| 202       | Permission verification failed, application which is not a system application uses system API. |
295| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
296| 14800000  | Inner error. |
297| 14800011  | Failed to open the database because it is corrupted. |
298| 14800014  | The RdbStore or ResultSet is already closed. |
299| 14800015  | The database does not respond. |
300| 14800021  | SQLite: Generic error. Possible causes: Insert failed or the updated data does not exist. |
301| 14800022  | SQLite: Callback routine requested an abort. |
302| 14800023  | SQLite: Access permission denied. |
303| 14800024  | SQLite: The database file is locked. |
304| 14800025  | SQLite: A table in the database is locked. |
305| 14800026  | SQLite: The database is out of memory. |
306| 14800027  | SQLite: Attempt to write a readonly database. |
307| 14800028  | SQLite: Some kind of disk I/O error occurred. |
308| 14800029  | SQLite: The database is full. |
309| 14800030  | SQLite: Unable to open the database file. |
310| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
311| 14800032  | SQLite: Abort due to constraint violation. |
312| 14800033  | SQLite: Data type mismatch. |
313| 14800034  | SQLite: Library used incorrectly. |
314| 14800047  | The WAL file size exceeds the default limit. |
315
316**Example**
317
318```ts
319import { dataSharePredicates } from '@kit.ArkData';
320
321let predicates = new dataSharePredicates.DataSharePredicates();
322predicates.equalTo("NAME", "Lisa");
323if (store != undefined) {
324  (store as relationalStore.RdbStore).delete("EMPLOYEE", predicates, (err, rows) => {
325    if (err) {
326      console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
327      return;
328    }
329    console.info(`Delete rows: ${rows}`);
330  });
331}
332```
333
334### delete
335
336delete(table: string, predicates: dataSharePredicates.DataSharePredicates):Promise&lt;number&gt;
337
338Deletes data from the RDB store based on the specified **DataSharePredicates** object. This API uses a promise to return the result.
339
340**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
341
342**Model restriction**: This API can be used only in the stage model.
343
344**System API**: This is a system API.
345
346**Parameters**
347
348| Name    | Type                                                        | Mandatory| Description                                         |
349| ---------- | ------------------------------------------------------------ | ---- | --------------------------------------------- |
350| table      | string                                                       | Yes  | Name of the target table.                             |
351| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes  | Deletion conditions specified by the **DataSharePredicates** object.|
352
353**Return value**
354
355| Type                 | Description                           |
356| --------------------- | ------------------------------- |
357| Promise&lt;number&gt; | Promise used to return the number of rows deleted.|
358
359**Error codes**
360
361For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
362
363| **ID**| **Error Message**     |
364|-----------| --------------------- |
365| 202       | Permission verification failed, application which is not a system application uses system API. |
366| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
367| 14800000  | Inner error. |
368| 14800011  | Failed to open the database because it is corrupted. |
369| 14800014  | The RdbStore or ResultSet is already closed. |
370| 14800015  | The database does not respond. |
371| 14800021  | SQLite: Generic error. Possible causes: Insert failed or the updated data does not exist. |
372| 14800022  | SQLite: Callback routine requested an abort. |
373| 14800023  | SQLite: Access permission denied. |
374| 14800024  | SQLite: The database file is locked. |
375| 14800025  | SQLite: A table in the database is locked. |
376| 14800026  | SQLite: The database is out of memory. |
377| 14800027  | SQLite: Attempt to write a readonly database. |
378| 14800028  | SQLite: Some kind of disk I/O error occurred. |
379| 14800029  | SQLite: The database is full. |
380| 14800030  | SQLite: Unable to open the database file. |
381| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
382| 14800032  | SQLite: Abort due to constraint violation. |
383| 14800033  | SQLite: Data type mismatch. |
384| 14800034  | SQLite: Library used incorrectly. |
385| 14800047  | The WAL file size exceeds the default limit. |
386
387**Example**
388
389```ts
390import { dataSharePredicates } from '@kit.ArkData';
391import { BusinessError } from '@kit.BasicServicesKit';
392
393let predicates = new dataSharePredicates.DataSharePredicates();
394predicates.equalTo("NAME", "Lisa");
395if (store != undefined) {
396  (store as relationalStore.RdbStore).delete("EMPLOYEE", predicates).then((rows: Number) => {
397    console.info(`Delete rows: ${rows}`);
398  }).catch((err: BusinessError) => {
399    console.error(`Delete failed, code is ${err.code},message is ${err.message}`);
400  });
401}
402```
403
404### query<sup>10+</sup>
405
406query(table: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback&lt;ResultSet&gt;):void
407
408Queries data from the RDB store based on specified conditions. This API uses an asynchronous callback to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
409
410**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
411
412**Model restriction**: This API can be used only in the stage model.
413
414**System API**: This is a system API.
415
416**Parameters**
417
418| Name    | Type                                                        | Mandatory| Description                                                       |
419| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
420| table      | string                                                       | Yes  | Name of the target table.                                           |
421| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes  | Query conditions specified by the **DataSharePredicates** object.              |
422| callback   | AsyncCallback&lt;[ResultSet](arkts-apis-data-relationalStore-ResultSet.md)&gt; | Yes  | Callback used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
423
424**Error codes**
425
426For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
427
428| **ID**| **Error Message**          |
429|-----------| ------------------ |
430| 202       | Permission verification failed, application which is not a system application uses system API. |
431| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
432| 14800000  | Inner error. |
433| 14800014  | The RdbStore or ResultSet is already closed. |
434| 14800015  | The database does not respond. |
435
436**Example**
437
438```ts
439import { dataSharePredicates } from '@kit.ArkData';
440
441let predicates = new dataSharePredicates.DataSharePredicates();
442predicates.equalTo("NAME", "Rose");
443if (store != undefined) {
444  (store as relationalStore.RdbStore).query("EMPLOYEE", predicates, (err, resultSet) => {
445    if (err) {
446      console.error(`Query failed, code is ${err.code},message is ${err.message}`);
447      return;
448    }
449    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
450    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
451    while (resultSet.goToNextRow()) {
452      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
453      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
454      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
455      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
456      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
457    }
458    // Release the dataset memory.
459    resultSet.close();
460  });
461}
462```
463
464### query
465
466query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;ResultSet&gt;):void
467
468Queries data from the RDB store based on specified conditions. This API uses an asynchronous callback to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
469
470**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
471
472**Model restriction**: This API can be used only in the stage model.
473
474**System API**: This is a system API.
475
476**Parameters**
477
478| Name    | Type                                                        | Mandatory| Description                                                       |
479| ---------- | ------------------------------------------------------------ | ---- | ----------------------------------------------------------- |
480| table      | string                                                       | Yes  | Name of the target table.                                           |
481| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes  | Query conditions specified by the **DataSharePredicates** object.              |
482| columns    | Array&lt;string&gt;                                          | Yes  | Columns to query. If this parameter is not specified, the query applies to all columns.           |
483| callback   | AsyncCallback&lt;[ResultSet](arkts-apis-data-relationalStore-ResultSet.md)&gt; | Yes  | Callback used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
484
485**Error codes**
486
487For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
488
489| **ID**| **Error Message**     |
490|-----------| --------------- |
491| 202       | Permission verification failed, application which is not a system application uses system API. |
492| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
493| 14800000  | Inner error. |
494| 14800014  | The RdbStore or ResultSet is already closed. |
495| 14800015  | The database does not respond. |
496
497**Example**
498
499```ts
500import { dataSharePredicates } from '@kit.ArkData';
501
502let predicates = new dataSharePredicates.DataSharePredicates();
503predicates.equalTo("NAME", "Rose");
504if (store != undefined) {
505  (store as relationalStore.RdbStore).query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], (err, resultSet) => {
506    if (err) {
507      console.error(`Query failed, code is ${err.code},message is ${err.message}`);
508      return;
509    }
510    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
511    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
512    while (resultSet.goToNextRow()) {
513      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
514      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
515      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
516      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
517      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
518    }
519    // Release the dataset memory.
520    resultSet.close();
521  });
522}
523```
524
525### query
526
527query(table: string, predicates: dataSharePredicates.DataSharePredicates, columns?: Array&lt;string&gt;):Promise&lt;ResultSet&gt;
528
529Queries data from the RDB store based on specified conditions. This API uses a promise to return the result. Due to the limit of the shared memory (max. 2 MB), a single data record cannot exceed 2 MB. Otherwise, the query operation will fail.
530
531**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
532
533**Model restriction**: This API can be used only in the stage model.
534
535**System API**: This is a system API.
536
537**Parameters**
538
539| Name    | Type                                                        | Mandatory| Description                                            |
540| ---------- | ------------------------------------------------------------ | ---- | ------------------------------------------------ |
541| table      | string                                                       | Yes  | Name of the target table.                                |
542| predicates | [dataSharePredicates.DataSharePredicates](js-apis-data-dataSharePredicates.md#datasharepredicates) | Yes  | Query conditions specified by the **DataSharePredicates** object.   |
543| columns    | Array&lt;string&gt;                                          | No  | Columns to query. If this parameter is not specified, the query applies to all columns.|
544
545**Return value**
546
547| Type                                                   | Description                                              |
548| ------------------------------------------------------- | -------------------------------------------------- |
549| Promise&lt;[ResultSet](arkts-apis-data-relationalStore-ResultSet.md)&gt; | Promise used to return the result. If the operation is successful, a **ResultSet** object will be returned.|
550
551**Error codes**
552
553For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
554
555| **ID**| **Error Message**        |
556|-----------| ----------- |
557| 202       | Permission verification failed, application which is not a system application uses system API. |
558| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
559| 14800000  | Inner error. |
560| 14800014  | The RdbStore or ResultSet is already closed. |
561| 14800015  | The database does not respond. |
562
563**Example**
564
565```ts
566import { dataSharePredicates } from '@kit.ArkData';
567import { BusinessError } from '@kit.BasicServicesKit';
568
569let predicates = new dataSharePredicates.DataSharePredicates();
570predicates.equalTo("NAME", "Rose");
571if (store != undefined) {
572  (store as relationalStore.RdbStore).query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet: relationalStore.ResultSet) => {
573    console.info(`ResultSet column names: ${resultSet.columnNames}, column count: ${resultSet.columnCount}`);
574    // resultSet is a cursor of a data set. By default, the cursor points to the -1st record. Valid data starts from 0.
575    while (resultSet.goToNextRow()) {
576      const id = resultSet.getLong(resultSet.getColumnIndex("ID"));
577      const name = resultSet.getString(resultSet.getColumnIndex("NAME"));
578      const age = resultSet.getLong(resultSet.getColumnIndex("AGE"));
579      const salary = resultSet.getDouble(resultSet.getColumnIndex("SALARY"));
580      console.info(`id=${id}, name=${name}, age=${age}, salary=${salary}`);
581    }
582    // Release the dataset memory.
583    resultSet.close();
584  }).catch((err: BusinessError) => {
585    console.error(`Query failed, code is ${err.code},message is ${err.message}`);
586  });
587}
588```
589
590### cloudSync<sup>11+</sup>
591
592cloudSync(mode: SyncMode, predicates: RdbPredicates, progress: Callback&lt;ProgressDetails&gt;, callback: AsyncCallback&lt;void&gt;): void
593
594Manually performs device-cloud sync based on specified conditions. This API uses an asynchronous callback to return the result. The cloud sync function must be implemented. Otherwise, this API cannot be used.
595
596> **NOTE**
597>
598> Since API version 18, you can specify assets in predicates when performing manual device-cloud sync. In this case, the sync mode must be **relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST**.
599>
600> When specifying the predicates, you can use the primary key (mandatory) and asset (optional) as sync conditions. If assets are specified, the predicate supports only [equalTo](arkts-apis-data-relationalStore-RdbPredicates.md#equalto), with a limit of 50 assets. If more assets are involved, you are advised to use only the primary key as the sync condition.
601
602**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
603
604**System API**: This is a system API.
605
606**Parameters**
607
608| Name        | Type                            | Mandatory| Description                           |
609|-------------|--------------------------------| ---- |-------------------------------|
610| mode        | [SyncMode](arkts-apis-data-relationalStore-e.md#syncmode)          | Yes  | Sync mode of the database.                  |
611| predicates  | [RdbPredicates](arkts-apis-data-relationalStore-RdbPredicates.md)                  | Yes  | Conditions for data sync.                 |
612| progress    | Callback&lt;[ProgressDetails](arkts-apis-data-relationalStore-i.md#progressdetails10)&gt; | Yes  | Callback used to process database sync details.          |
613| callback    | AsyncCallback&lt;void&gt;      | Yes  | Callback used to return the sync result to the caller.|
614
615**Error codes**
616
617For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
618
619| **ID**| **Error Message**    |
620|-----------|--------------|
621| 202       | if permission verification failed, application which is not a system application uses system API. |
622| 401       | Parameter error. Possible causes: 1. Need 2 - 4  parameter(s). 2. The RdbStore must be not nullptr. 3. The mode must be a SyncMode of cloud. 4. The tablesNames must be not empty. 5. The progress must be a callback type. 6.The callback must be a function.|
623| 801       | Capability not supported.  |
624| 14800014  | The RdbStore or ResultSet is already closed.      |
625
626**Example 1**: Manually sync data on the local device with the cloud.
627
628```ts
629let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
630predicates.in("id", ["id1", "id2"]);
631
632if (store != undefined) {
633  (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, predicates, (progressDetail: relationalStore.ProgressDetails) => {
634    console.info(`progress: ${progressDetail}`);
635  }, (err) => {
636    if (err) {
637      console.error(`cloudSync failed, code is ${err.code},message is ${err.message}}`);
638      return;
639    }
640    console.info('Cloud sync succeeded');
641  });
642};
643```
644**Example 2**: Download the specified asset.
645```ts
646import { BusinessError } from '@kit.BasicServicesKit';
647
648let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
649let asset: relationalStore.Asset = {
650  name: "name",
651  uri: "uri",
652  path: "path",
653  createTime: new Date().getTime().toString(),
654  modifyTime: new Date().getTime().toString(),
655  size: "1024"
656};
657// Specify the primary key and asset (asset column in the database) in the predicates.
658predicates.beginWrap().equalTo("id", "id1").and().equalTo("asset", asset).endWrap();
659
660if (store != undefined) {
661  (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, predicates, (progressDetail: relationalStore.ProgressDetails) => {
662    console.info(`progress: ${progressDetail}`);
663  }, (err) => {
664    if (err) {
665      console.error(`cloud sync failed, code is ${err.code},message is ${err.message}}`);
666      return;
667    }
668    console.info('cloud sync succeeded');
669  });
670};
671```
672
673### cloudSync<sup>11+</sup>
674
675cloudSync(mode: SyncMode, predicates: RdbPredicates, progress: Callback&lt;ProgressDetails&gt;): Promise&lt;void&gt;
676
677Manually performs device-cloud sync based on specified conditions. This API uses a promise to return the result. The cloud sync function must be implemented. Otherwise, this API cannot be used.
678
679> **NOTE**
680>
681> Since API version 18, you can specify assets in predicates when performing manual device-cloud sync. In this case, the sync mode must be **relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST**.
682>
683> When specifying the predicates, you can use the primary key (mandatory) and asset (optional) as sync conditions. If assets are specified, the predicate supports only [equalTo](arkts-apis-data-relationalStore-RdbPredicates.md#equalto), with a limit of 50 assets. If more assets are involved, you are advised to use only the primary key as the sync condition.
684
685**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
686
687**System API**: This is a system API.
688
689**Parameters**
690
691| Name       | Type                             | Mandatory| Description                 |
692|------------|---------------------------------| ---- |---------------------|
693| mode       | [SyncMode](arkts-apis-data-relationalStore-e.md#syncmode)           | Yes  | Sync mode of the database.        |
694| predicates | [RdbPredicates](arkts-apis-data-relationalStore-RdbPredicates.md)                   | Yes  | Conditions for data sync.               |
695| progress   | Callback&lt;[ProgressDetails](arkts-apis-data-relationalStore-i.md#progressdetails10)&gt; | Yes  | Callback used to process database sync details.|
696
697**Return value**
698
699| Type               | Description                                   |
700| ------------------- | --------------------------------------- |
701| Promise&lt;void&gt; | Promise used to return the sync result.|
702
703**Error codes**
704
705For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
706
707| **ID**| **Error Message**           |
708|-----------|---------------------------|
709| 202       | if permission verification failed, application which is not a system application uses system API.  |
710| 401       | Parameter error. Possible causes: 1. Need 2 - 4  parameter(s). 2. The RdbStore must be not nullptr. 3. The mode must be a SyncMode of cloud. 4. The tablesNames must be not empty. 5. The progress must be a callback type. |
711| 801       | Capability not supported.       |
712| 14800014  | The RdbStore or ResultSet is already closed.      |
713
714**Example 1**: Manually sync data on the local device with the cloud.
715
716```ts
717import { BusinessError } from '@kit.BasicServicesKit';
718
719let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
720predicates.in("id", ["id1", "id2"]);
721
722if (store != undefined) {
723  (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, predicates, (progressDetail: relationalStore.ProgressDetails) => {
724    console.info(`progress: ${progressDetail}`);
725  }).then(() => {
726    console.info('cloud sync succeeded');
727  }).catch((err: BusinessError) => {
728    console.error(`cloud sync failed, code is ${err.code},message is ${err.message}}`);
729  });
730};
731```
732**Example 2**: Download the specified asset.
733```ts
734import { BusinessError } from '@kit.BasicServicesKit';
735
736let predicates = new relationalStore.RdbPredicates("EMPLOYEE");
737let asset: relationalStore.Asset = {
738  name: "name",
739  uri: "uri",
740  path: "path",
741  createTime: new Date().getTime().toString(),
742  modifyTime: new Date().getTime().toString(),
743  size: "1024"
744};
745// Specify the primary key and asset (asset column in the database) in the predicates.
746predicates.beginWrap().equalTo("id", "id1").and().equalTo("asset", asset).endWrap();
747
748if (store != undefined) {
749  (store as relationalStore.RdbStore).cloudSync(relationalStore.SyncMode.SYNC_MODE_CLOUD_FIRST, predicates, (progressDetail: relationalStore.ProgressDetails) => {
750    console.info(`progress: ${progressDetail}`);
751  }).then(() => {
752    console.info('Cloud sync succeeded');
753  }).catch((err: BusinessError) => {
754    console.error(`cloudSync failed, code is ${err.code},message is ${err.message}}`);
755  });
756};
757```
758
759### querySharingResource<sup>11+</sup>
760
761querySharingResource(predicates: RdbPredicates, columns?: Array&lt;string&gt;): Promise&lt;ResultSet&gt;
762
763Queries the shared resource of the data matching the specified conditions. This API uses a promise to return the result set, which includes the shared resource ID and the column names if the column names are specified.
764
765**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
766
767**System API**: This is a system API.
768
769**Parameters**
770
771| Name  | Type                                                 | Mandatory| Description                                              |
772| -------- | ----------------------------------------------------- | ---- | -------------------------------------------------- |
773| predicates | [RdbPredicates](arkts-apis-data-relationalStore-RdbPredicates.md) | Yes  | Query conditions.   |
774| columns    | Array&lt;string&gt;      | No  | Columns to be searched for. If this parameter is not specified, the returned result set contains only the shared resource ID.|
775
776**Return value**
777
778| Name   | Description                                              |
779| -------- | ------------------------------------------------- |
780| Promise&lt;[ResultSet](arkts-apis-data-relationalStore-ResultSet.md)&gt; | Promise used to return the result set.  |
781
782**Error codes**
783
784For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
785
786| **ID**| **Error Message**          |
787|-----------|-------------|
788| 401       | Parameter error. Possible causes: 1. Need 1 - 3  parameter(s)! 2. The RdbStore must be not nullptr. 3. The predicates must be an RdbPredicates. 4. The columns must be a string array. |
789| 801       | Capability not supported.       |
790| 14800000  | Inner error.                      |
791| 14800011  | Failed to open the database because it is corrupted.           |
792| 14800014  | The RdbStore or ResultSet is already closed.                        |
793| 14800015  | The database does not respond.          |
794| 14800021  | SQLite: Generic error. Possible causes: Insert failed or the updated data does not exist.             |
795| 14800022  | SQLite: Callback routine requested an abort.          |
796| 14800023  | SQLite: Access permission denied.         |
797| 14800024  | SQLite: The database file is locked.         |
798| 14800025  | SQLite: A table in the database is locked.           |
799| 14800026  | SQLite: The database is out of memory.            |
800| 14800027  | SQLite: Attempt to write a readonly database.         |
801| 14800028  | SQLite: Some kind of disk I/O error occurred.             |
802| 14800029  | SQLite: The database is full.           |
803| 14800030  | SQLite: Unable to open the database file.        |
804| 14800031  | SQLite: TEXT or BLOB exceeds size limit.           |
805| 14800032  | SQLite: Abort due to constraint violation.        |
806| 14800033  | SQLite: Data type mismatch.             |
807| 14800034  | SQLite: Library used incorrectly.          |
808
809**Example**
810
811```ts
812import { BusinessError } from '@kit.BasicServicesKit';
813
814let sharingResource: string;
815let predicates = new relationalStore.RdbPredicates('test_table');
816predicates.equalTo('data', 'data_test');
817if (store != undefined) {
818  (store as relationalStore.RdbStore).querySharingResource(predicates, ['uuid', 'data']).then((resultSet) => {
819    if (!resultSet.goToFirstRow()) {
820      console.error(`resultSet error`);
821      return;
822    }
823    const res = resultSet.getString(resultSet.getColumnIndex(relationalStore.Field.SHARING_RESOURCE_FIELD));
824    console.info(`sharing resource: ${res}`);
825    sharingResource = res;
826  }).catch((err: BusinessError) => {
827    console.error(`query sharing resource failed, code is ${err.code},message is ${err.message}`);
828  });
829}
830```
831
832### querySharingResource<sup>11+</sup>
833
834querySharingResource(predicates: RdbPredicates, callback: AsyncCallback&lt;ResultSet&gt;): void
835
836Queries the shared resource of the data matching the specified conditions. This API uses an asynchronous callback to return the result set.
837
838**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
839
840**System API**: This is a system API.
841
842**Parameters**
843
844| Name  | Type                                                 | Mandatory| Description                                              |
845| -------- | ----------------------------------------------------- | ---- | -------------------------------------------------- |
846| predicates | [RdbPredicates](arkts-apis-data-relationalStore-RdbPredicates.md)              | Yes  | Query conditions.          |
847| callback   | AsyncCallback&lt;[ResultSet](arkts-apis-data-relationalStore-ResultSet.md)&gt; | Yes  | Callback used to return the result set.|
848
849**Error codes**
850
851For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
852
853| **ID**| **Error Message**     |
854|-----------|------|
855| 401       | Parameter error. Possible causes: 1. Need 1 - 3  parameter(s)! 2. The RdbStore must be not nullptr. 3. The predicates must be an RdbPredicates. 4. The columns must be a string array. |
856| 801       | Capability not supported.                 |
857| 14800000  | Inner error.          |
858| 14800011  | Failed to open the database because it is corrupted.       |
859| 14800014  | The RdbStore or ResultSet is already closed.      |
860| 14800015  | The database does not respond.        |
861| 14800021  | SQLite: Generic error. Possible causes: Insert failed or the updated data does not exist.        |
862| 14800022  | SQLite: Callback routine requested an abort.         |
863| 14800023  | SQLite: Access permission denied.                    |
864| 14800024  | SQLite: The database file is locked.            |
865| 14800025  | SQLite: A table in the database is locked.           |
866| 14800026  | SQLite: The database is out of memory.           |
867| 14800027  | SQLite: Attempt to write a readonly database.            |
868| 14800028  | SQLite: Some kind of disk I/O error occurred.         |
869| 14800029  | SQLite: The database is full.       |
870| 14800030  | SQLite: Unable to open the database file.       |
871| 14800031  | SQLite: TEXT or BLOB exceeds size limit.         |
872| 14800032  | SQLite: Abort due to constraint violation.      |
873| 14800033  | SQLite: Data type mismatch.         |
874| 14800034  | SQLite: Library used incorrectly.     |
875
876
877**Example**
878
879```ts
880let sharingResource: string;
881let predicates = new relationalStore.RdbPredicates('test_table');
882predicates.equalTo('data', 'data_test');
883if (store != undefined) {
884  (store as relationalStore.RdbStore).querySharingResource(predicates, (err, resultSet) => {
885    if (err) {
886      console.error(`sharing resource failed, code is ${err.code},message is ${err.message}`);
887      return;
888    }
889    if (!resultSet.goToFirstRow()) {
890      console.error(`resultSet error`);
891      return;
892    }
893    const res = resultSet.getString(resultSet.getColumnIndex(relationalStore.Field.SHARING_RESOURCE_FIELD));
894    console.info(`sharing resource: ${res}`);
895    sharingResource = res;
896  });
897}
898```
899
900### querySharingResource<sup>11+</sup>
901
902querySharingResource(predicates: RdbPredicates, columns: Array&lt;string&gt;, callback: AsyncCallback&lt;ResultSet&gt;): void
903
904Queries the shared resource of the data matching the specified conditions. This API uses an asynchronous callback to return the shared resource ID and the column names specified.
905
906**System capability**: SystemCapability.DistributedDataManager.CloudSync.Client
907
908**System API**: This is a system API.
909
910**Parameters**
911
912| Name  | Type                                                 | Mandatory| Description                                              |
913| -------- | ----------------------------------------------------- | ---- | -------------------------------------------------- |
914| predicates | [RdbPredicates](arkts-apis-data-relationalStore-RdbPredicates.md) | Yes  | Query conditions.          |
915| columns    | Array&lt;string&gt;              | Yes  | Columns to be searched for.          |
916| callback   | AsyncCallback&lt;[ResultSet](arkts-apis-data-relationalStore-ResultSet.md)&gt;  | Yes  | Callback used to return the result set.|
917
918**Error codes**
919
920For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
921
922| **ID**| **Error Message**      |
923|-----------|--------------|
924| 401       | Parameter error. Possible causes: 1. Need 1 - 3  parameter(s)! 2. The RdbStore must be not nullptr. 3. The predicates must be an RdbPredicates. 4. The columns must be a string array. |
925| 801       | Capability not supported.       |
926| 14800000  | Inner error.            |
927| 14800011  | Failed to open the database because it is corrupted.         |
928| 14800014  | The RdbStore or ResultSet is already closed.          |
929| 14800015  | The database does not respond.          |
930| 14800021  | SQLite: Generic error. Possible causes: Insert failed or the updated data does not exist.           |
931| 14800022  | SQLite: Callback routine requested an abort.    |
932| 14800023  | SQLite: Access permission denied.     |
933| 14800024  | SQLite: The database file is locked.     |
934| 14800025  | SQLite: A table in the database is locked.       |
935| 14800026  | SQLite: The database is out of memory.      |
936| 14800027  | SQLite: Attempt to write a readonly database.    |
937| 14800028  | SQLite: Some kind of disk I/O error occurred.       |
938| 14800029  | SQLite: The database is full.       |
939| 14800030  | SQLite: Unable to open the database file.       |
940| 14800031  | SQLite: TEXT or BLOB exceeds size limit.      |
941| 14800032  | SQLite: Abort due to constraint violation.       |
942| 14800033  | SQLite: Data type mismatch.        |
943| 14800034  | SQLite: Library used incorrectly.          |
944
945
946**Example**
947
948```ts
949let sharingResource: string;
950let predicates = new relationalStore.RdbPredicates('test_table');
951predicates.equalTo('data', 'data_test');
952if (store != undefined) {
953  (store as relationalStore.RdbStore).querySharingResource(predicates, ['uuid', 'data'], (err, resultSet) => {
954    if (err) {
955      console.error(`sharing resource failed, code is ${err.code},message is ${err.message}`);
956      return;
957    }
958    if (!resultSet.goToFirstRow()) {
959      console.error(`resultSet error`);
960      return;
961    }
962    const res = resultSet.getString(resultSet.getColumnIndex(relationalStore.Field.SHARING_RESOURCE_FIELD));
963    console.info(`sharing resource: ${res}`);
964    sharingResource = res;
965  });
966}
967```
968
969
970### lockCloudContainer<sup>12+</sup>
971
972lockCloudContainer(): Promise&lt;number&gt;
973
974Manually locks the cloud database of an application. This API uses a promise to return the result.
975
976> **NOTE**
977>
978> After the cloud database is locked, data of the same application logged in with the same account on other devices cannot be synced to the cloud. The cloud sync function must be implemented. Otherwise, this API cannot be used.
979
980**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
981
982**System API**: This is a system API.
983
984**Return value**
985
986| Type               | Description                                   |
987| ------------------- | ---------------------------------------|
988| Promise&lt;number&gt; | Promise used to return the lock validity period (in ms) if the operation is successful. If the operation fails, **0** is returned.|
989
990**Error codes**
991
992For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
993
994| **ID**| **Error Message**           |
995|-----------|---------------------------|
996| 202       | Permission verification failed, application which is not a system application uses system API.  |
997
998**Example**
999
1000```ts
1001import { BusinessError } from '@kit.BasicServicesKit';
1002
1003if (store != undefined) {
1004  (store as relationalStore.RdbStore).lockCloudContainer().then((time: Number) => {
1005    console.info('lockCloudContainer succeeded time:' + time);
1006  }).catch((err: BusinessError) => {
1007    console.error(`lockCloudContainer failed, code is ${err.code},message is ${err.message}`);
1008  });
1009}
1010```
1011
1012### unlockCloudContainer<sup>12+</sup>
1013
1014unlockCloudContainer(): Promise&lt;void&gt;
1015
1016Manually unlocks the cloud database of an application. This API uses a promise to return the result. The cloud sync function must be implemented. Otherwise, this API cannot be used.
1017
1018**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1019
1020**System API**: This is a system API.
1021
1022**Return value**
1023
1024| Type               | Description                                   |
1025| ------------------- | --------------------------------------- |
1026| Promise&lt;void&gt; | Promise that returns no value.|
1027
1028**Error codes**
1029
1030For details about the error codes, see [Universal Error Codes](../errorcode-universal.md).
1031
1032| **ID**| **Error Message**           |
1033|-----------|---------------------------|
1034| 202       | Permission verification failed, application which is not a system application uses system API.  |
1035
1036**Example**
1037
1038```ts
1039import { BusinessError } from '@kit.BasicServicesKit';
1040
1041if (store != undefined) {
1042  (store as relationalStore.RdbStore).unlockCloudContainer().then(() => {
1043    console.info('unlockCloudContainer succeeded');
1044  }).catch((err: BusinessError) => {
1045    console.error(`unlockCloudContainer failed, code is ${err.code},message is ${err.message}`);
1046  });
1047}
1048```
1049
1050### restore<sup>12+</sup>
1051
1052restore(): Promise&lt;void&gt;
1053
1054Restores data from a replica RDB store file. This API uses a promise to return the result. This API can be used only when [HAMode](#hamode12) is **MAIN_REPLICA**, and cannot be used in transactions.
1055
1056**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1057
1058**System API**: This is a system API.
1059
1060**Return value**
1061
1062| Type               | Description                     |
1063| ------------------- | ------------------------- |
1064| Promise&lt;void&gt; | Promise that returns no value.|
1065
1066**Error codes**
1067
1068For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
1069
1070| **ID**| **Error Message**                                                |
1071|-----------| ------------------------------------------------------------ |
1072| 202       | Permission verification failed, application which is not a system application uses system API. |
1073| 14800000  | Inner error. |
1074| 14800010  | Failed to open or delete the database by an invalid database path. |
1075| 14800011  | Failed to open the database because it is corrupted. |
1076| 14800014  | The RdbStore or ResultSet is already closed. |
1077| 14800015  | The database does not respond. |
1078| 14800021  | SQLite: Generic error. Possible causes: Insert failed or the updated data does not exist. |
1079| 14800022  | SQLite: Callback routine requested an abort. |
1080| 14800023  | SQLite: Access permission denied. |
1081| 14800024  | SQLite: The database file is locked. |
1082| 14800025  | SQLite: A table in the database is locked. |
1083| 14800026  | SQLite: The database is out of memory. |
1084| 14800027  | SQLite: Attempt to write a readonly database. |
1085| 14800028  | SQLite: Some kind of disk I/O error occurred. |
1086| 14800029  | SQLite: The database is full. |
1087| 14800030  | SQLite: Unable to open the database file. |
1088| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
1089| 14800032  | SQLite: Abort due to constraint violation. |
1090| 14800033  | SQLite: Data type mismatch. |
1091| 14800034  | SQLite: Library used incorrectly. |
1092
1093**Example**
1094
1095```ts
1096import { BusinessError } from '@kit.BasicServicesKit';
1097
1098if (store != undefined) {
1099  let promiseRestore = (store as relationalStore.RdbStore).restore();
1100  promiseRestore.then(() => {
1101    console.info('Succeeded in restoring.');
1102  }).catch((err: BusinessError) => {
1103    console.error(`Failed to restore, code is ${err.code},message is ${err.message}`);
1104  });
1105}
1106```
1107
1108## ResultSet
1109
1110Provides APIs to access the **resultSet** object returned by **query()**.
1111
1112### getFloat32Array<sup>12+</sup>
1113
1114getFloat32Array(columnIndex: number): Float32Array
1115
1116Obtains the value from the specified column in the current row and outputs it in a Float32Array (array of 32-bit floating-point numbers). This API is available only for a [vector database](#storeconfig).
1117
1118**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core
1119
1120**Parameters**
1121
1122| Name     | Type  | Mandatory| Description                   |
1123| ----------- | ------ | ---- | ----------------------- |
1124| columnIndex | number | Yes  | Index of the target column, starting from 0.|
1125
1126**Return value**
1127
1128| Type      | Description                            |
1129| ---------- | -------------------------------- |
1130| Float32Array | Value obtained, in a Float32Array.|
1131
1132**Error codes**
1133
1134For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [RDB Store Error Codes](errorcode-data-rdb.md).
1135
1136| **ID**| **Error Message**         |
1137|-----------| ------------ |
1138| 401       | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
1139| 801       | The capability is not supported because the database is not a vector DB. |
1140| 14800011  | Failed to open the database because it is corrupted. |
1141| 14800013  | Resultset is empty or column index is out of bounds. |
1142| 14800014  | The RdbStore or ResultSet is already closed. |
1143| 14800021  | SQLite: Generic error. Possible causes: Insert failed or the updated data does not exist. |
1144| 14800022  | SQLite: Callback routine requested an abort. |
1145| 14800023  | SQLite: Access permission denied. |
1146| 14800024  | SQLite: The database file is locked. |
1147| 14800025  | SQLite: A table in the database is locked. |
1148| 14800026  | SQLite: The database is out of memory. |
1149| 14800027  | SQLite: Attempt to write a readonly database. |
1150| 14800028  | SQLite: Some kind of disk I/O error occurred. |
1151| 14800029  | SQLite: The database is full. |
1152| 14800030  | SQLite: Unable to open the database file. |
1153| 14800031  | SQLite: TEXT or BLOB exceeds size limit. |
1154| 14800032  | SQLite: Abort due to constraint violation. |
1155| 14800033  | SQLite: Data type mismatch. |
1156| 14800034  | SQLite: Library used incorrectly. |
1157
1158**Example**
1159
1160```ts
1161let resultSet: relationalStore.ResultSet | undefined;
1162if (resultSet != undefined) {
1163  const id = (resultSet as relationalStore.ResultSet).getFloat32Array(0);
1164}
1165```
1166