1# relational_store.h 2 3## Overview 4 5Provides APIs for managing data in an RDB store. The APIs not marked as supporting vector stores are available only to RDB stores. 6 7**File to include**: <database/rdb/relational_store.h> 8 9**Library**: libnative_rdb_ndk.z.so 10 11**System capability**: SystemCapability.DistributedDataManager.RelationalStore.Core 12 13**Since**: 10 14 15**Related module**: [RDB](capi-rdb.md) 16 17## Summary 18 19### Structs 20 21| Name | typedef Keyword| Description | 22|---------------------------------------------------------| -- |-------------------------------------------------------------------------| 23| [OH_Rdb_Config](capi-rdb-oh-rdb-config.md) | - | Defines the configuration of an RDB store. | 24| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) | OH_Rdb_Store | Defines the RDB store type. | 25| [Rdb_DistributedConfig](capi-rdb-rdb-distributedconfig.md) | Rdb_DistributedConfig | Defines a struct for distributed configuration of a table. | 26| [Rdb_KeyInfo](capi-rdb-rdb-keyinfo.md) | Rdb_KeyInfo | Defines a struct for the primary key or number of the row that changes. | 27| [Rdb_KeyData](capi-rdb-rdb-keydata.md) | - | Holds the changed data. | 28| [Rdb_ChangeInfo](capi-rdb-rdb-changeinfo.md) | Rdb_ChangeInfo | Defines a struct for the details about the device-cloud sync process. | 29| [Rdb_SubscribeCallback](capi-rdb-rdb-subscribecallback.md) | Rdb_SubscribeCallback | Defines a callback used to return the subscribed event. | 30| [Rdb_DataObserver](capi-rdb-rdb-dataobserver.md) | Rdb_DataObserver | Defines a struct for the data observer. | 31| [Rdb_Statistic](capi-rdb-rdb-statistic.md) | Rdb_Statistic | Defines a struct for the device-cloud sync statistics of a database table. | 32| [Rdb_TableDetails](capi-rdb-rdb-tabledetails.md) | Rdb_TableDetails | Defines a struct for statistics of device-cloud upload and download tasks of a database table. | 33| [Rdb_ProgressDetails](capi-rdb-rdb-progressdetails.md) | Rdb_ProgressDetails | Defines a struct for statistics of the overall device-cloud sync (upload and download) tasks of an RDB store. | 34| [Rdb_ProgressObserver](capi-rdb-rdb-progressobserver.md) | Rdb_ProgressObserver | Defines the observer of the device-cloud sync progress. | 35| [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) | OH_Rdb_ConfigV2 | Defines a struct for the RDB store configuration. Different from [OH_Rdb_Config](capi-rdb-oh-rdb-config.md), this struct does not expose its member variables externally. Methods are used to configure the properties of this struct. It supports vector stores.| 36 37### Enums 38 39| Name| typedef Keyword| Description| 40| -- | -- | -- | 41| [OH_Rdb_SecurityLevel](#oh_rdb_securitylevel) | OH_Rdb_SecurityLevel | Enumerates the RDB store security levels.| 42| [Rdb_SecurityArea](#rdb_securityarea) | Rdb_SecurityArea | Enumerates the encryption levels of database files.| 43| [Rdb_DBType](#rdb_dbtype) | Rdb_DBType | Enumerates the database kernel types.| 44| [Rdb_Tokenizer](#rdb_tokenizer) | Rdb_Tokenizer | Enumerates the database tokenizer types.| 45| [Rdb_DistributedType](#rdb_distributedtype) | Rdb_DistributedType | Enumerates the distributed types.| 46| [Rdb_ChangeType](#rdb_changetype) | Rdb_ChangeType | Enumerates the data change types.| 47| [Rdb_SubscribeType](#rdb_subscribetype) | Rdb_SubscribeType | Enumerates the subscription types.| 48| [Rdb_SyncMode](#rdb_syncmode) | Rdb_SyncMode | Enumerates the RDB sync modes.| 49| [Rdb_Progress](#rdb_progress) | Rdb_Progress | Enumerates the device-cloud sync progress states.| 50| [Rdb_ProgressCode](#rdb_progresscode) | Rdb_ProgressCode | Enumerates the device-cloud sync states.| 51 52### Functions 53 54| Name| typedef Keyword| Description| 55| -- | -- | -- | 56| [OH_Rdb_ConfigV2 *OH_Rdb_CreateConfig()](#oh_rdb_createconfig) | - | Creates an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance.| 57| [int OH_Rdb_DestroyConfig(OH_Rdb_ConfigV2 *config)](#oh_rdb_destroyconfig) | - | Destroys an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance created by [OH_Rdb_CreateConfig](capi-relational-store-h.md#oh_rdb_createconfig).| 58| [int OH_Rdb_SetDatabaseDir(OH_Rdb_ConfigV2 *config, const char *databaseDir)](#oh_rdb_setdatabasedir) | - | Sets the database file path for an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance.| 59| [int OH_Rdb_SetStoreName(OH_Rdb_ConfigV2 *config, const char *storeName)](#oh_rdb_setstorename) | - | Sets the database name for an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance.| 60| [int OH_Rdb_SetBundleName(OH_Rdb_ConfigV2 *config, const char *bundleName)](#oh_rdb_setbundlename) | - | Sets the bundle name for an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance.| 61| [int OH_Rdb_SetModuleName(OH_Rdb_ConfigV2 *config, const char *moduleName)](#oh_rdb_setmodulename) | - | Sets the module name for an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance.| 62| [int OH_Rdb_SetEncrypted(OH_Rdb_ConfigV2 *config, bool isEncrypted)](#oh_rdb_setencrypted) | - | Sets whether to encrypt the database for an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance.| 63| [int OH_Rdb_SetSecurityLevel(OH_Rdb_ConfigV2 *config, int securityLevel)](#oh_rdb_setsecuritylevel) | - | Sets the database security level ([OH_Rdb_SecurityLevel](capi-relational-store-h.md#oh_rdb_securitylevel)) for an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance.| 64| [int OH_Rdb_SetArea(OH_Rdb_ConfigV2 *config, int area)](#oh_rdb_setarea) | - | Sets the security area level ([Rdb_SecurityArea](capi-relational-store-h.md#rdb_securityarea)) for an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance.| 65| [int OH_Rdb_SetDbType(OH_Rdb_ConfigV2 *config, int dbType)](#oh_rdb_setdbtype) | - | Sets the database type ([Rdb_DBType](capi-relational-store-h.md#rdb_dbtype)) for an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance.| 66| [int OH_Rdb_SetCustomDir(OH_Rdb_ConfigV2 *config, const char *customDir)](#oh_rdb_setcustomdir) | - | Sets the custom directory of the database.| 67| [int OH_Rdb_SetReadOnly(OH_Rdb_ConfigV2 *config, bool readOnly)](#oh_rdb_setreadonly) | - | Sets whether the RDB store is in read-only mode.| 68| [int OH_Rdb_SetPlugins(OH_Rdb_ConfigV2 *config, const char **plugins, int32_t length)](#oh_rdb_setplugins) | - | Sets the dynamic library with specific capabilities (such as full-text search).| 69| [int OH_Rdb_SetCryptoParam(OH_Rdb_ConfigV2 *config, const OH_Rdb_CryptoParam *cryptoParam)](#oh_rdb_setcryptoparam) | - | Sets custom encryption parameters.| 70| [int OH_Rdb_IsTokenizerSupported(Rdb_Tokenizer tokenizer, bool *isSupported)](#oh_rdb_istokenizersupported) | - | Checks whether the specified tokenizer is supported.| 71| [int OH_Rdb_SetTokenizer(OH_Rdb_ConfigV2 *config, Rdb_Tokenizer tokenizer)](#oh_rdb_settokenizer) | - | Sets the tokenizer type.| 72| [int OH_Rdb_SetPersistent(OH_Rdb_ConfigV2 *config, bool isPersistent)](#oh_rdb_setpersistent) | - | Sets whether to persist an RDB store.| 73| [const int *OH_Rdb_GetSupportedDbType(int *typeCount)](#oh_rdb_getsupporteddbtype) | - | Obtains the supported database type ([Rdb_DBType](capi-relational-store-h.md#rdb_dbtype)).| 74| [OH_VObject *OH_Rdb_CreateValueObject()](#oh_rdb_createvalueobject) | - | Creates an [OH_VObject](capi-rdb-oh-vobject.md) instance.| 75| [OH_VBucket *OH_Rdb_CreateValuesBucket()](#oh_rdb_createvaluesbucket) | - | Creates an [OH_VBucket](capi-rdb-oh-vbucket.md) instance.| 76| [OH_Predicates *OH_Rdb_CreatePredicates(const char *table)](#oh_rdb_createpredicates) | - | Creates an [OH_Predicates](capi-rdb-oh-predicates.md) instance.| 77| [OH_Rdb_Store *OH_Rdb_GetOrOpen(const OH_Rdb_Config *config, int *errCode)](#oh_rdb_getoropen) | - | Obtains a related [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance to operate the RDB store.| 78| [OH_Rdb_Store *OH_Rdb_CreateOrOpen(const OH_Rdb_ConfigV2 *config, int *errCode)](#oh_rdb_createoropen) | - | Creates or opens an [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance based on the given [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md).| 79| [int OH_Rdb_CloseStore(OH_Rdb_Store *store)](#oh_rdb_closestore) | - | Closes an [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) object and reclaims the memory occupied by the object.| 80| [int OH_Rdb_DeleteStore(const OH_Rdb_Config *config)](#oh_rdb_deletestore) | - | Deletes a graph store.| 81| [int OH_Rdb_DeleteStoreV2(const OH_Rdb_ConfigV2 *config)](#oh_rdb_deletestorev2) | - | Deletes an RDB store based on the given [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md).<br>Before calling **DeleteStoreV2**, ensure that the **OH_Rdb_Store** and **OH_Cursor** of the vector store have been closed.| 82| [int OH_Rdb_Insert(OH_Rdb_Store *store, const char *table, OH_VBucket *valuesBucket)](#oh_rdb_insert) | - | Inserts a row of data into a table.| 83| [int OH_Rdb_InsertWithConflictResolution(OH_Rdb_Store *store, const char *table, OH_VBucket *row,Rdb_ConflictResolution resolution, int64_t *rowId)](#oh_rdb_insertwithconflictresolution) | - | Inserts a row of data into the target table and supports conflict resolution.| 84| [int OH_Rdb_BatchInsert(OH_Rdb_Store *store, const char *table,const OH_Data_VBuckets *rows, Rdb_ConflictResolution resolution, int64_t *changes)](#oh_rdb_batchinsert) | - | Inserts a batch of data into a table.| 85| [int OH_Rdb_Update(OH_Rdb_Store *store, OH_VBucket *valuesBucket, OH_Predicates *predicates)](#oh_rdb_update) | - | Updates data in an RDB store based on specified conditions.| 86| [int OH_Rdb_UpdateWithConflictResolution(OH_Rdb_Store *store, OH_VBucket *row, OH_Predicates *predicates,Rdb_ConflictResolution resolution, int64_t *changes)](#oh_rdb_updatewithconflictresolution) | - | Updates data in the database based on specified conditions and supports conflict resolution.| 87| [int OH_Rdb_Delete(OH_Rdb_Store *store, OH_Predicates *predicates)](#oh_rdb_delete) | - | Deletes data from an RDB store based on specified conditions.| 88| [OH_Cursor *OH_Rdb_Query(OH_Rdb_Store *store, OH_Predicates *predicates, const char *const *columnNames, int length)](#oh_rdb_query) | - | Queries data in an RDB store based on specified conditions.| 89| [int OH_Rdb_Execute(OH_Rdb_Store *store, const char *sql)](#oh_rdb_execute) | - | Executes an SQL statement that returns no value.| 90| [int OH_Rdb_ExecuteV2(OH_Rdb_Store *store, const char *sql, const OH_Data_Values *args, OH_Data_Value **result)](#oh_rdb_executev2) | - | Executes an SQL statement with a return value. This API supports vector stores.| 91| [int OH_Rdb_ExecuteByTrxId(OH_Rdb_Store *store, int64_t trxId, const char *sql)](#oh_rdb_executebytrxid) | - | Executes an SQL statement that returns no value based on the specified transaction ID. This API supports only vector stores.| 92| [OH_Cursor *OH_Rdb_ExecuteQuery(OH_Rdb_Store *store, const char *sql)](#oh_rdb_executequery) | - | Queries data in the database using the specified SQL statement. This API supports vector stores.| 93| [OH_Cursor *OH_Rdb_ExecuteQueryV2(OH_Rdb_Store *store, const char *sql, const OH_Data_Values *args)](#oh_rdb_executequeryv2) | - | Queries data in the database using the specified SQL statement. This API supports vector stores.| 94| [int OH_Rdb_BeginTransaction(OH_Rdb_Store *store)](#oh_rdb_begintransaction) | - | Begins the transaction before executing SQL statements.| 95| [int OH_Rdb_RollBack(OH_Rdb_Store *store)](#oh_rdb_rollback) | - | Rolls back the SQL statements executed.| 96| [int OH_Rdb_Commit(OH_Rdb_Store *store)](#oh_rdb_commit) | - | Commits the executed SQL statements.| 97| [int OH_Rdb_BeginTransWithTrxId(OH_Rdb_Store *store, int64_t *trxId)](#oh_rdb_begintranswithtrxid) | - | Begins a transaction. This API returns a transaction ID API and supports only vector stores.| 98| [int OH_Rdb_RollBackByTrxId(OH_Rdb_Store *store, int64_t trxId)](#oh_rdb_rollbackbytrxid) | - | Rolls back the executed SQL statements based on the specified transaction ID. This API supports only vector stores.| 99| [int OH_Rdb_CommitByTrxId(OH_Rdb_Store *store, int64_t trxId)](#oh_rdb_commitbytrxid) | - | Commits the executed SQL statements based on the specified transaction ID. This API supports only vector stores.| 100| [int OH_Rdb_Backup(OH_Rdb_Store *store, const char *databasePath)](#oh_rdb_backup) | - | Backs up an RDB store using the backup file of the specified path. This API supports vector stores.| 101| [int OH_Rdb_Restore(OH_Rdb_Store *store, const char *databasePath)](#oh_rdb_restore) | - | Restores a database from a specified database backup file. This API supports vector stores.| 102| [int OH_Rdb_GetVersion(OH_Rdb_Store *store, int *version)](#oh_rdb_getversion) | - | Obtains the RDB store version.| 103| [int OH_Rdb_SetVersion(OH_Rdb_Store *store, int version)](#oh_rdb_setversion) | - | Sets the RDB store version.| 104| [int OH_Rdb_SetDistributedTables(OH_Rdb_Store *store, const char *tables[], uint32_t count, Rdb_DistributedType type,const Rdb_DistributedConfig *config)](#oh_rdb_setdistributedtables) | - | Sets distributed database tables.| 105| [OH_Cursor *OH_Rdb_FindModifyTime(OH_Rdb_Store *store, const char *tableName, const char *columnName,OH_VObject *values)](#oh_rdb_findmodifytime) | - | Obtains the last modification time of a table in an RDB store.| 106| [typedef void (\*Rdb_BriefObserver)(void *context, const char *values[], uint32_t count)](#rdb_briefobserver) | Rdb_BriefObserver | Defines a callback used to return the device-cloud data change event. | 107| [typedef void (\*Rdb_DetailsObserver)(void *context, const Rdb_ChangeInfo **changeInfo, uint32_t count)](#rdb_detailsobserver) | Rdb_DetailsObserver | Defines a callback used to return the details about the device-cloud data change. | 108| [int OH_Rdb_Subscribe(OH_Rdb_Store *store, Rdb_SubscribeType type, const Rdb_DataObserver *observer)](#oh_rdb_subscribe) | - | Registers an observer for an RDB store. The registered callback will be invoked when data in a distributed or local RDB store changes.| 109| [int OH_Rdb_Unsubscribe(OH_Rdb_Store *store, Rdb_SubscribeType type, const Rdb_DataObserver *observer)](#oh_rdb_unsubscribe) | - | Unregisters the observer of the specified type.| 110| [Rdb_TableDetails *OH_Rdb_GetTableDetails(Rdb_ProgressDetails *progress, int32_t version)](#oh_rdb_gettabledetails) | - | Obtains the device-cloud sync statistics of a table.| 111| [typedef void (\*Rdb_ProgressCallback)(void *context, Rdb_ProgressDetails *progressDetails)](#rdb_progresscallback) | Rdb_ProgressCallback | Defines a callback used to return the device-cloud sync progress.| 112| [typedef void (\*Rdb_SyncCallback)(Rdb_ProgressDetails *progressDetails)](#rdb_synccallback) | Rdb_SyncCallback | Defines a callback for device-cloud sync.| 113| [int OH_Rdb_CloudSync(OH_Rdb_Store *store, Rdb_SyncMode mode, const char *tables[], uint32_t count,const Rdb_ProgressObserver *observer)](#oh_rdb_cloudsync) | - | Performs device-cloud sync.| 114| [int OH_Rdb_SubscribeAutoSyncProgress(OH_Rdb_Store *store, const Rdb_ProgressObserver *observer)](#oh_rdb_subscribeautosyncprogress) | - | Subscribes to the auto sync progress of an RDB store.<br>The registered callback will be invoked to return the auto sync progress.| 115| [int OH_Rdb_UnsubscribeAutoSyncProgress(OH_Rdb_Store *store, const Rdb_ProgressObserver *observer)](#oh_rdb_unsubscribeautosyncprogress) | - | Unsubscribes from the auto sync process of an RDB store.| 116| [int OH_Rdb_LockRow(OH_Rdb_Store *store, OH_Predicates *predicates)](#oh_rdb_lockrow) | - | Locks data in an RDB store based on specified conditions. The locked data will be blocked from the device-cloud sync.| 117| [int OH_Rdb_UnlockRow(OH_Rdb_Store *store, OH_Predicates *predicates)](#oh_rdb_unlockrow) | - | Unlocks data in an RDB store based on the specified conditions.| 118| [OH_Cursor *OH_Rdb_QueryLockedRow(OH_Rdb_Store *store, OH_Predicates *predicates, const char *const *columnNames, int length)](#oh_rdb_querylockedrow) | - | Queries the locked data in an RDB store.| 119| [int OH_Rdb_CreateTransaction(OH_Rdb_Store *store, const OH_RDB_TransOptions *options, OH_Rdb_Transaction **trans)](#oh_rdb_createtransaction) | - | Creates a transaction object.| 120| [int OH_Rdb_Attach(OH_Rdb_Store *store, const OH_Rdb_ConfigV2 *config, const char *attachName, int64_t waitTime,size_t *attachedNumber)](#oh_rdb_attach) | - | Attaches a database file to the database that is currently connected.| 121| [int OH_Rdb_Detach(OH_Rdb_Store *store, const char *attachName, int64_t waitTime, size_t *attachedNumber)](#oh_rdb_detach) | - | Detaches a specified store from the current database.| 122| [int OH_Rdb_SetLocale(OH_Rdb_Store *store, const char *locale)](#oh_rdb_setlocale) | - | Sets locale.| 123| [int OH_Rdb_SetSemanticIndex(OH_Rdb_ConfigV2 *config, bool enabled)](#oh_rdb_setsemanticindex) | - | Sets whether to enable knowledge processing based on semantic indexes.| 124 125## Enum Description 126 127### OH_Rdb_SecurityLevel 128 129``` 130enum OH_Rdb_SecurityLevel 131``` 132 133**Description** 134 135Enumerates the RDB store security levels. 136 137**Since**: 10 138 139| Enum Item| Description| 140| -- | -- | 141| S1 = 1 | Low security level. If data leakage occurs, minor impact will be caused.| 142| S2 | Medium security level. If data leakage occurs, moderate impact will be caused.| 143| S3 | High security level. If data leakage occurs, major impact will be caused.| 144| S4 | Critical security level. If data leakage occurs, critical impact will be caused.| 145 146### Rdb_SecurityArea 147 148``` 149enum Rdb_SecurityArea 150``` 151 152**Description** 153 154Enumerates the encryption levels of database files. 155 156**Since**: 11 157 158| Enum Item| Description| 159| -- | -- | 160| RDB_SECURITY_AREA_EL1 = 1 | Encryption level 1.| 161| RDB_SECURITY_AREA_EL2 | Encryption level 2.| 162| RDB_SECURITY_AREA_EL3 | Encryption level 3.| 163| RDB_SECURITY_AREA_EL4 | Encryption level 4.| 164| RDB_SECURITY_AREA_EL5 | Encryption level 5.<br>**Since**: 12| 165 166### Rdb_DBType 167 168``` 169enum Rdb_DBType 170``` 171 172**Description** 173 174Enumerates the database kernel types. 175 176**Since**: 14 177 178| Enum Item| Description| 179| -- | -- | 180| RDB_SQLITE = 1 | SQLite is used as the database kernel.| 181| RDB_CAYLEY = 2 | Cayley is used as the database kernel.| 182| DBTYPE_BUTT = 64 | Maximum value of the database kernel type, which is an invalid value.| 183 184### Rdb_Tokenizer 185 186``` 187enum Rdb_Tokenizer 188``` 189 190**Description** 191 192Enumerates the database tokenizer types. 193 194**Since**: 17 195 196| Enum Item| Description| 197| -- | -- | 198| RDB_NONE_TOKENIZER = 1 | No tokenizer is used.| 199| RDB_ICU_TOKENIZER = 2 | ICU tokenizer.| 200| RDB_CUSTOM_TOKENIZER = 3 | Custom tokenizer. <br>**Since**: 18| 201 202### Rdb_DistributedType 203 204``` 205enum Rdb_DistributedType 206``` 207 208**Description** 209 210Enumerates the distributed types. 211 212**Since**: 11 213 214| Enum Item| Description| 215| -- | -- | 216| RDB_DISTRIBUTED_CLOUD | Distributed database tables for device-cloud sync.| 217 218### Rdb_ChangeType 219 220``` 221enum Rdb_ChangeType 222``` 223 224**Description** 225 226Enumerates the data change types. 227 228**Since**: 11 229 230| Enum Item| Description| 231| -- | -- | 232| RDB_DATA_CHANGE | Data change.| 233| RDB_ASSET_CHANGE | Asset change.| 234 235### Rdb_SubscribeType 236 237``` 238enum Rdb_SubscribeType 239``` 240 241**Description** 242 243Enumerates the subscription types. 244 245**Since**: 11 246 247| Enum Item| Description| 248| -- | -- | 249| RDB_SUBSCRIBE_TYPE_CLOUD | Subscribe to cloud data changes.| 250| RDB_SUBSCRIBE_TYPE_CLOUD_DETAILS | Subscribe to details of the cloud data change.| 251| RDB_SUBSCRIBE_TYPE_LOCAL_DETAILS | Subscribe to details of the local data change.| 252 253### Rdb_SyncMode 254 255``` 256enum Rdb_SyncMode 257``` 258 259**Description** 260 261Enumerates the RDB sync modes. 262 263**Since**: 11 264 265| Enum Item| Description| 266| -- | -- | 267| RDB_SYNC_MODE_TIME_FIRST | Synchronize with the data with the latest modification time.| 268| RDB_SYNC_MODE_NATIVE_FIRST | Synchronize data from a local device to the cloud.| 269| RDB_SYNC_MODE_CLOUD_FIRST | Synchronize data from the cloud to a local device.| 270 271### Rdb_Progress 272 273``` 274enum Rdb_Progress 275``` 276 277**Description** 278 279| Enum Item| Description| 280| -- | -- | 281| RDB_SYNC_BEGIN | The device-cloud sync starts.| 282| RDB_SYNC_IN_PROGRESS | The device-cloud sync is in progress.| 283| RDB_SYNC_FINISH | The device-cloud sync is finished.| 284 285### Rdb_ProgressCode 286 287``` 288enum Rdb_ProgressCode 289``` 290 291**Description** 292 293| Enum Item| Description| 294| -- | -- | 295| RDB_SUCCESS | The device-cloud sync is successful.| 296| RDB_UNKNOWN_ERROR | An unknown error occurs during the device-cloud sync.| 297| RDB_NETWORK_ERROR | A network error occurs during the device-cloud sync.| 298| RDB_CLOUD_DISABLED | The cloud is unavailable.| 299| RDB_LOCKED_BY_OTHERS | The device-cloud sync of another device is being performed.| 300| RDB_RECORD_LIMIT_EXCEEDED | The number of records or size of the data to be synced exceeds the maximum. The maximum value is configured on the cloud.| 301| RDB_NO_SPACE_FOR_ASSET | The remaining cloud space is less than the size of the data to be synced.| 302 303 304## Function Description 305 306### OH_Rdb_SetSemanticIndex() 307 308``` 309int OH_Rdb_SetSemanticIndex(OH_Rdb_ConfigV2 *config, bool enabled) 310``` 311 312**Description** 313 314Sets whether to enable knowledge processing based on semantic indexes. 315 316**Since**: 20 317 318**Parameters** 319 320| Parameter| Description| 321| -- | -- | 322| [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance.| 323| bool enabled | Whether to enable knowledge processing based on semantic indexes.<br>The value **true** indicates that the function is enabled; the value **false** indicates the opposite.| 324 325**Returns** 326 327| Type| Description| 328| -- | -- | 329| int | Returns an error code. For details about the error code, see [OH_Rdb_ErrCode](capi-relational-store-error-code-h.md#oh_rdb_errcode).<br>**ERR_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 330 331### OH_Rdb_CreateConfig() 332 333``` 334OH_Rdb_ConfigV2 *OH_Rdb_CreateConfig() 335``` 336 337**Description** 338 339Creates an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance. 340 341**Since**: 14 342 343**Returns** 344 345| Type| Description| 346| -- | -- | 347| [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) | Pointer to the [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance.| 348 349**See** 350 351OH_Rdb_ConfigV2 352 353### OH_Rdb_DestroyConfig() 354 355``` 356int OH_Rdb_DestroyConfig(OH_Rdb_ConfigV2 *config) 357``` 358 359**Description** 360 361Destroys an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance created by [OH_Rdb_CreateConfig](capi-relational-store-h.md#oh_rdb_createconfig). 362 363**Since**: 14 364 365 366**Parameters** 367 368| Parameter| Description| 369| -- | -- | 370| [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance, which is the configuration of the RDB store.| 371 372**Returns** 373 374| Type| Description| 375| -- | -- | 376| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 377 378### OH_Rdb_SetDatabaseDir() 379 380``` 381int OH_Rdb_SetDatabaseDir(OH_Rdb_ConfigV2 *config, const char *databaseDir) 382``` 383 384**Description** 385 386Sets the database file path for an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance. 387 388**Since**: 14 389 390 391**Parameters** 392 393| Parameter| Description| 394| -- | -- | 395| [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance, which is the configuration of the RDB store.| 396| const char *dataBaseDir | Pointer to the database file path to set. The full path, including the RDB store name, cannot exceed a maximum of 1024 characters.| 397 398**Returns** 399 400| Type| Description| 401| -- | -- | 402| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 403 404### OH_Rdb_SetStoreName() 405 406``` 407int OH_Rdb_SetStoreName(OH_Rdb_ConfigV2 *config, const char *storeName) 408``` 409 410**Description** 411 412Sets the database name for an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance. 413 414**Since**: 14 415 416 417**Parameters** 418 419| Parameter| Description| 420| -- | -- | 421| [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance, which is the configuration of the RDB store.| 422| const char *storeName | Pointer to the RDB store name to set.| 423 424**Returns** 425 426| Type| Description| 427| -- | -- | 428| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 429 430### OH_Rdb_SetBundleName() 431 432``` 433int OH_Rdb_SetBundleName(OH_Rdb_ConfigV2 *config, const char *bundleName) 434``` 435 436**Description** 437 438Sets the bundle name for an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance. 439 440**Since**: 14 441 442 443**Parameters** 444 445| Parameter| Description| 446| -- | -- | 447| [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance, which is the configuration of the RDB store.| 448| const char *bundleName | Pointer to the application bundle name to set.| 449 450**Returns** 451 452| Type| Description| 453| -- | -- | 454| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 455 456### OH_Rdb_SetModuleName() 457 458``` 459int OH_Rdb_SetModuleName(OH_Rdb_ConfigV2 *config, const char *moduleName) 460``` 461 462**Description** 463 464Sets the module name for an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance. 465 466**Since**: 14 467 468 469**Parameters** 470 471| Parameter| Description| 472| -- | -- | 473| [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance, which is the configuration of the RDB store.| 474| const char *moduleName | Pointer to the module name to set.| 475 476**Returns** 477 478| Type| Description| 479| -- | -- | 480| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 481 482### OH_Rdb_SetEncrypted() 483 484``` 485int OH_Rdb_SetEncrypted(OH_Rdb_ConfigV2 *config, bool isEncrypted) 486``` 487 488**Description** 489 490Sets whether to encrypt the database for an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance. 491 492**Since**: 14 493 494 495**Parameters** 496 497| Parameter| Description| 498| -- | -- | 499| [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance, which is the configuration of the RDB store.| 500| bool isEncrypted | Whether to encrypt the RDB store. The value **true** means to encrypt the database; the value **false** means the opposite.| 501 502**Returns** 503 504| Type| Description| 505| -- | -- | 506| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 507 508### OH_Rdb_SetSecurityLevel() 509 510``` 511int OH_Rdb_SetSecurityLevel(OH_Rdb_ConfigV2 *config, int securityLevel) 512``` 513 514**Description** 515 516Sets the database security level ([OH_Rdb_SecurityLevel](capi-relational-store-h.md#oh_rdb_securitylevel)) for an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance. 517 518**Since**: 14 519 520 521**Parameters** 522 523| Parameter| Description| 524| -- | -- | 525| [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance, which is the configuration of the RDB store.| 526| int securityLevel | Database security level ([OH_Rdb_SecurityLevel](capi-relational-store-h.md#oh_rdb_securitylevel)).| 527 528**Returns** 529 530| Type| Description| 531| -- | -- | 532| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 533 534### OH_Rdb_SetArea() 535 536``` 537int OH_Rdb_SetArea(OH_Rdb_ConfigV2 *config, int area) 538``` 539 540**Description** 541 542Sets the security area level ([Rdb_SecurityArea](capi-relational-store-h.md#rdb_securityarea)) for an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance. 543 544**Since**: 14 545 546 547**Parameters** 548 549| Parameter| Description| 550| -- | -- | 551| [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance, which is the configuration of the RDB store.| 552| int area | Database security area level ([Rdb_SecurityArea](capi-relational-store-h.md#rdb_securityarea)).| 553 554**Returns** 555 556| Type| Description| 557| -- | -- | 558| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 559 560### OH_Rdb_SetDbType() 561 562``` 563int OH_Rdb_SetDbType(OH_Rdb_ConfigV2 *config, int dbType) 564``` 565 566**Description** 567 568Sets the database type ([Rdb_DBType](capi-relational-store-h.md#rdb_dbtype)) for an [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance. 569 570**Since**: 14 571 572 573**Parameters** 574 575| Parameter| Description| 576| -- | -- | 577| [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance, which is the configuration of the RDB store.| 578| int dbType | Database type ([Rdb_DBType](capi-relational-store-h.md#rdb_dbtype)).| 579 580**Returns** 581 582| Type| Description| 583| -- | -- | 584| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_NOT_SUPPORTED** indicates that the current operation is not supported.| 585 586### OH_Rdb_SetCustomDir() 587 588``` 589int OH_Rdb_SetCustomDir(OH_Rdb_ConfigV2 *config, const char *customDir) 590``` 591 592**Description** 593 594Sets the custom directory of the database. 595 596**Since**: 20 597 598 599**Parameters** 600 601| Parameter| Description| 602| -- | -- | 603| [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance.| 604| const char *customDir | Custom directory of the database, with a maximum length of 128 bytes.| 605 606**Returns** 607 608| Type| Description| 609| -- | -- | 610| int | Returns the execution result.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 611 612### OH_Rdb_SetReadOnly() 613 614``` 615int OH_Rdb_SetReadOnly(OH_Rdb_ConfigV2 *config, bool readOnly) 616``` 617 618**Description** 619 620Sets whether the RDB store is in read-only mode. 621 622**Since**: 20 623 624 625**Parameters** 626 627| Parameter| Description| 628| -- | -- | 629| [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance.| 630| bool readOnly | Whether the RDB store is in read-only mode. The value **true** indicates that the RDB store is in read-only mode; the value **false** indicates that the RDB store is in read/write mode.| 631 632**Returns** 633 634| Type| Description| 635| -- | -- | 636| int | Returns the execution result.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 637 638### OH_Rdb_SetPlugins() 639 640``` 641int OH_Rdb_SetPlugins(OH_Rdb_ConfigV2 *config, const char **plugins, int32_t length) 642``` 643 644**Description** 645 646Sets the dynamic library with specific capabilities (such as full-text search). 647 648**Since**: 20 649 650 651**Parameters** 652 653| Parameter| Description| 654| -- | -- | 655| [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance.| 656| const char **plugins | Name array of the dynamic library.| 657| int32_t length | Size of the plugin array. The maximum value is **16**.| 658 659**Returns** 660 661| Type| Description| 662| -- | -- | 663| int | Returns the execution result.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 664 665### OH_Rdb_SetCryptoParam() 666 667``` 668int OH_Rdb_SetCryptoParam(OH_Rdb_ConfigV2 *config, const OH_Rdb_CryptoParam *cryptoParam) 669``` 670 671**Description** 672 673Sets custom encryption parameters. 674 675**Since**: 20 676 677 678**Parameters** 679 680| Parameter| Description| 681| -- | -- | 682| [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance.| 683| const [OH_Rdb_CryptoParam](capi-rdb-oh-rdb-cryptoparam.md) *cryptoParam | Custom encryption parameters.| 684 685**Returns** 686 687| Type| Description| 688| -- | -- | 689| int | Returns the execution result.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 690 691### OH_Rdb_IsTokenizerSupported() 692 693``` 694int OH_Rdb_IsTokenizerSupported(Rdb_Tokenizer tokenizer, bool *isSupported) 695``` 696 697**Description** 698 699Checks whether the specified tokenizer is supported. 700 701**Since**: 18 702 703 704**Parameters** 705 706| Parameter| Description| 707| -- | -- | 708| [Rdb_Tokenizer](#rdb_tokenizer) tokenizer | Tokenizer to check.| 709| bool *isSupported | Pointer to the check result. The value **true** means the tokenizer is supported; the value **false** means the opposite.| 710 711**Returns** 712 713| Type| Description| 714| -- | -- | 715| int | Returns operation status code.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 716 717### OH_Rdb_SetTokenizer() 718 719``` 720int OH_Rdb_SetTokenizer(OH_Rdb_ConfigV2 *config, Rdb_Tokenizer tokenizer) 721``` 722 723**Description** 724 725Sets the tokenizer type. 726 727**Since**: 17 728 729 730**Parameters** 731 732| Parameter| Description| 733| -- | -- | 734| [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the target database configuration.| 735| [Rdb_Tokenizer](#rdb_tokenizer) tokenizer | Tokenizer type to set.| 736 737**Returns** 738 739| Type| Description| 740| -- | -- | 741| int | Returns operation status code.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_NOT_SUPPORTED** indicates that the current operation is not supported.| 742 743### OH_Rdb_SetPersistent() 744 745``` 746int OH_Rdb_SetPersistent(OH_Rdb_ConfigV2 *config, bool isPersistent) 747``` 748 749**Description** 750 751Sets whether to persist an RDB store. 752 753**Since**: 18 754 755 756**Parameters** 757 758| Parameter| Description| 759| -- | -- | 760| [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance.<br>which specifies the database configuration.| 761| bool isPersistent | Whether to persist the database data.| 762 763**Returns** 764 765| Type| Description| 766| -- | -- | 767| int | Returns operation status code.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 768 769### OH_Rdb_GetSupportedDbType() 770 771``` 772const int *OH_Rdb_GetSupportedDbType(int *typeCount) 773``` 774 775**Description** 776 777Obtains the supported database type ([Rdb_DBType](capi-relational-store-h.md#rdb_dbtype)). 778 779**Since**: 14 780 781 782**Parameters** 783 784| Parameter| Description| 785| -- | -- | 786| int *typeCount | Pointer to the length of the array of the supported database types obtained.| 787 788**Returns** 789 790| Type | Description| 791|------------| -- | 792| const int * | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 793 794### OH_Rdb_CreateValueObject() 795 796``` 797OH_VObject *OH_Rdb_CreateValueObject() 798``` 799 800**Description** 801 802Creates an [OH_VObject](capi-rdb-oh-vobject.md) instance. 803 804**Since**: 10 805 806**Returns** 807 808| Type| Description| 809| -- | -- | 810| [OH_VObject](capi-rdb-oh-vobject.md) | Returns the pointer to the [OH_VObject](capi-rdb-oh-vobject.md) instance created if the operation is successful; returns null otherwise.| 811 812**See** 813 814OH_VObject 815 816### OH_Rdb_CreateValuesBucket() 817 818``` 819OH_VBucket *OH_Rdb_CreateValuesBucket() 820``` 821 822**Description** 823 824Creates an [OH_VBucket](capi-rdb-oh-vbucket.md) instance. 825 826**Since**: 10 827 828**Returns** 829 830| Type| Description| 831| -- | -- | 832| [OH_VBucket](capi-rdb-oh-vbucket.md) | Returns the pointer to the [OH_VBucket](capi-rdb-oh-vbucket.md) instance created if the operation is successful; returns null otherwise.| 833 834**See** 835 836OH_VBucket 837 838### OH_Rdb_CreatePredicates() 839 840``` 841OH_Predicates *OH_Rdb_CreatePredicates(const char *table) 842``` 843 844**Description** 845 846Creates an [OH_Predicates](capi-rdb-oh-predicates.md) instance. 847 848**Since**: 10 849 850 851**Parameters** 852 853| Parameter| Description| 854| -- | -- | 855| const char *table | Pointer to the name of the database table.| 856 857**Returns** 858 859| Type| Description| 860| -- | -- | 861| [OH_Predicates](capi-rdb-oh-predicates.md) | Returns the pointer to the [OH_Predicates](capi-rdb-oh-predicates.md) instance created if the operation is successful; returns null otherwise.| 862 863**See** 864 865OH_Predicates 866 867### OH_Rdb_GetOrOpen() 868 869``` 870OH_Rdb_Store *OH_Rdb_GetOrOpen(const OH_Rdb_Config *config, int *errCode) 871``` 872 873**Description** 874 875Obtains a related [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance to operate the RDB store. 876 877**Since**: 10 878 879 880**Parameters** 881 882| Parameter| Description| 883| -- | -- | 884| const [OH_Rdb_Config](capi-rdb-oh-rdb-config.md) *config | Pointer to the [OH_Rdb_Config](capi-rdb-oh-rdb-config.md) instance, which is the configuration of the RDB store.| 885| int *errCode | Pointer to the execution result of this API.| 886 887**Returns** 888 889| Type| Description| 890| -- | -- | 891| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) | Returns the pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance created if the operation is successful; returns null otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 892 893### OH_Rdb_CreateOrOpen() 894 895``` 896OH_Rdb_Store *OH_Rdb_CreateOrOpen(const OH_Rdb_ConfigV2 *config, int *errCode) 897``` 898 899**Description** 900 901Creates or opens an [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance based on the given [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md). 902 903**Since**: 14 904 905 906**Parameters** 907 908| Parameter| Description| 909| -- | -- | 910| const [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance, which is the configuration of the RDB store.| 911| int *errCode | Pointer to the execution result of this API.| 912 913**Returns** 914 915| Type| Description| 916| -- | -- | 917| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) | Returns the pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance created if the operation is successful; returns null otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 918 919### OH_Rdb_CloseStore() 920 921``` 922int OH_Rdb_CloseStore(OH_Rdb_Store *store) 923``` 924 925**Description** 926 927Closes an [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) object and reclaims the memory occupied by the object. 928 929**Since**: 10 930 931 932**Parameters** 933 934| Parameter| Description| 935| -- | -- | 936| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 937 938**Returns** 939 940| Type| Description| 941| -- | -- | 942| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 943 944### OH_Rdb_DeleteStore() 945 946``` 947int OH_Rdb_DeleteStore(const OH_Rdb_Config *config) 948``` 949 950**Description** 951 952Deletes an RDB store with the specified configuration. 953 954**Since**: 10 955 956 957**Parameters** 958 959| Parameter| Description| 960| -- | -- | 961| const [OH_Rdb_Config](capi-rdb-oh-rdb-config.md) *config | Pointer to the database configuration.| 962 963**Returns** 964 965| Type| Description| 966| -- | -- | 967| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 968 969### OH_Rdb_DeleteStoreV2() 970 971``` 972int OH_Rdb_DeleteStoreV2(const OH_Rdb_ConfigV2 *config) 973``` 974 975**Description** 976 977Deletes an RDB store based on the given [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md).<br>Before calling **DeleteStoreV2**, ensure that the **OH_Rdb_Store** and **OH_Cursor** of the vector store have been closed. 978 979**Since**: 14 980 981 982**Parameters** 983 984| Parameter| Description| 985| -- | -- | 986| const [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the database configuration.| 987 988**Returns** 989 990| Type| Description| 991| -- | -- | 992| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 993 994### OH_Rdb_Insert() 995 996``` 997int OH_Rdb_Insert(OH_Rdb_Store *store, const char *table, OH_VBucket *valuesBucket) 998``` 999 1000**Description** 1001 1002Inserts a row of data into a table. 1003 1004**Since**: 10 1005 1006 1007**Parameters** 1008 1009| Parameter| Description| 1010| -- | -- | 1011| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1012| const char *table | Pointer to the target table.| 1013| [OH_VBucket](capi-rdb-oh-vbucket.md) *valuesBucket | Pointer to the data [OH_VBucket](capi-rdb-oh-vbucket.md) to insert.| 1014 1015**Returns** 1016 1017| Type| Description| 1018| -- | -- | 1019| int | Returns **rowID** if the operation is successful; returns a number less than **0** otherwise.<br>**RDB_ERR** indicates that the operation fails.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1020 1021### OH_Rdb_InsertWithConflictResolution() 1022 1023``` 1024int OH_Rdb_InsertWithConflictResolution(OH_Rdb_Store *store, const char *table, OH_VBucket *row,Rdb_ConflictResolution resolution, int64_t *rowId) 1025``` 1026 1027**Description** 1028 1029Inserts a row of data into the target table and supports conflict resolution. 1030 1031**Since**: 20 1032 1033 1034**Parameters** 1035 1036| Parameter | Description| 1037|------------------------------------------------------------------------------------| -- | 1038| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1039| const char *table | Name of the target table.| 1040| [OH_VBucket](capi-rdb-oh-vbucket.md) *row | Pointer to the row of data to insert.| 1041| [Rdb_ConflictResolution](capi-oh-rdb-types-h.md#rdb_conflictresolution) resolution | Policy used to resolve file conflicts.| 1042| int64_t *rowId | Pointer to the row number returned.| 1043 1044**Returns** 1045 1046| Type| Description| 1047| -- | -- | 1048| int | Returns the execution result.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_ERROR** indicates a common database error.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_ALREADY_CLOSED** indicates that the database is already closed.<br>**RDB_E_WAL_SIZE_OVER_LIMIT** indicates that the size of the WAL log file exceeds the default value.<br>**RDB_E_SQLITE_FULL** indicates an SQLite error: the database is full.<br>**RDB_E_SQLITE_CORRUPT** indicates that the database is corrupted.<br>**RDB_E_SQLITE_PERM** indicates an SQLite error: access denied.<br>**RDB_E_SQLITE_BUSY** indicates an SQLite error: database file locked.<br>**RDB_E_SQLITE_LOCKED** indicates an SQLite error: database table locked.<br>**RDB_E_SQLITE_NOMEM** indicates an SQLite: insufficient database memory.<br>**RDB_E_SQLITE_READONLY** indicates an SQLite error: attempt to write a read-only database.<br>**RDB_E_SQLITE_IOERR** indicates an SQLite: disk I/O error.<br>**RDB_E_SQLITE_TOO_BIG** indicates an SQLite error: TEXT or BLOB exceeds the limit.<br>**RDB_E_SQLITE_MISMATCH** indicates an SQLite error: data types mismatch.<br>**RDB_E_SQLITE_CONSTRAINT** indicates an SQLite error code: SQLite constraint.| 1049 1050### OH_Rdb_BatchInsert() 1051 1052``` 1053int OH_Rdb_BatchInsert(OH_Rdb_Store *store, const char *table,const OH_Data_VBuckets *rows, Rdb_ConflictResolution resolution, int64_t *changes) 1054``` 1055 1056**Description** 1057 1058Inserts a batch of data into a table. 1059 1060**Since**: 18 1061 1062 1063**Parameters** 1064 1065| Parameter | Description| 1066|------------------------------------------------------------------------------------| -- | 1067| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1068| const char *tables | Pointer to the names of the distributed tables to set.| 1069| const [OH_Data_VBuckets *rows](capi-rdb-oh-data-vbuckets.md) | An array of data to insert.| 1070| [Rdb_ConflictResolution](capi-oh-rdb-types-h.md#rdb_conflictresolution) resolution | Policy used to resolve file conflicts.| 1071| int64_t *changes | Pointer to the number of successful insertions.| 1072 1073**Returns** 1074 1075| Type| Description| 1076| -- | -- | 1077| int | Returns the execution result.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_ERROR** indicates a common database error.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_ALREADY_CLOSED** indicates that the database is already closed.<br>**RDB_E_WAL_SIZE_OVER_LIMIT** indicates that the size of the WAL log file exceeds the default value.<br>**RDB_E_SQLITE_FULL** indicates an SQLite error: the database is full.<br>**RDB_E_SQLITE_CORRUPT** indicates that the database is corrupted.<br>**RDB_E_SQLITE_PERM** indicates an SQLite error: access denied.<br>**RDB_E_SQLITE_BUSY** indicates an SQLite error: database file locked.<br>**RDB_E_SQLITE_LOCKED** indicates an SQLite error: database table locked.<br>**RDB_E_SQLITE_NOMEM** indicates an SQLite: insufficient database memory.<br>**RDB_E_SQLITE_READONLY** indicates an SQLite error: attempt to write a read-only database.<br>**RDB_E_SQLITE_IOERR** indicates an SQLite: disk I/O error.<br>**RDB_E_SQLITE_TOO_BIG** indicates an SQLite error: TEXT or BLOB exceeds the limit.<br>**RDB_E_SQLITE_MISMATCH** indicates an SQLite error: data types mismatch.<br>**RDB_E_SQLITE_CONSTRAINT** indicates an SQLite error code: SQLite constraint.| 1078 1079### OH_Rdb_Update() 1080 1081``` 1082int OH_Rdb_Update(OH_Rdb_Store *store, OH_VBucket *valuesBucket, OH_Predicates *predicates) 1083``` 1084 1085**Description** 1086 1087Updates data in an RDB store based on specified conditions. 1088 1089**Since**: 10 1090 1091 1092**Parameters** 1093 1094| Parameter| Description| 1095| -- | -- | 1096| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1097| [OH_VBucket](capi-rdb-oh-vbucket.md) *valuesBucket | Pointer to the data [OH_VBucket](capi-rdb-oh-vbucket.md) to update.| 1098| [OH_Predicates](capi-rdb-oh-predicates.md) *predicates | Pointer to the [OH_Predicates](capi-rdb-oh-predicates.md) instance, specifying the update conditions.| 1099 1100**Returns** 1101 1102| Type| Description| 1103| -- | -- | 1104| int | Returns the number of updated rows if the operation is successful; returns a number less than **0** otherwise.<br>**RDB_ERR** indicates that the operation fails.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1105 1106### OH_Rdb_UpdateWithConflictResolution() 1107 1108``` 1109int OH_Rdb_UpdateWithConflictResolution(OH_Rdb_Store *store, OH_VBucket *row, OH_Predicates *predicates,Rdb_ConflictResolution resolution, int64_t *changes) 1110``` 1111 1112**Description** 1113 1114Updates data in the database based on specified conditions and supports conflict resolution. 1115 1116**Since**: 20 1117 1118 1119**Parameters** 1120 1121| Parameter | Description| 1122|------------------------------------------------------------------------------------| -- | 1123| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1124| [OH_VBucket](capi-rdb-oh-vbucket.md) *row | Pointer to the row of data to update.| 1125| [OH_Predicates](capi-rdb-oh-predicates.md) *predicates | Pointer to the [OH_Predicates](capi-rdb-oh-predicates.md) instance, specifying the update conditions.| 1126| [Rdb_ConflictResolution](capi-oh-rdb-types-h.md#rdb_conflictresolution) resolution | Policy used to resolve file conflicts.| 1127| int64_t *changes | Pointer to the number of rows that are successfully updated.| 1128 1129**Returns** 1130 1131| Type| Description| 1132| -- | -- | 1133| int | Returns the execution result.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_ERROR** indicates a common database error.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_ALREADY_CLOSED** indicates that the database is already closed.<br>**RDB_E_WAL_SIZE_OVER_LIMIT** indicates that the size of the WAL log file exceeds the default value.<br>**RDB_E_SQLITE_FULL** indicates an SQLite error: the database is full.<br>**RDB_E_SQLITE_CORRUPT** indicates that the database is corrupted.<br>**RDB_E_SQLITE_PERM** indicates an SQLite error: access denied.<br>**RDB_E_SQLITE_BUSY** indicates an SQLite error: database file locked.<br>**RDB_E_SQLITE_LOCKED** indicates an SQLite error: database table locked.<br>**RDB_E_SQLITE_NOMEM** indicates an SQLite: insufficient database memory.<br>**RDB_E_SQLITE_READONLY** indicates an SQLite error: attempt to write a read-only database.<br>**RDB_E_SQLITE_IOERR** indicates an SQLite: disk I/O error.<br>**RDB_E_SQLITE_TOO_BIG** indicates an SQLite error: TEXT or BLOB exceeds the limit.<br>**RDB_E_SQLITE_MISMATCH** indicates an SQLite error: data types mismatch.<br>**RDB_E_SQLITE_CONSTRAINT** indicates an SQLite error code: SQLite constraint.| 1134 1135### OH_Rdb_Delete() 1136 1137``` 1138int OH_Rdb_Delete(OH_Rdb_Store *store, OH_Predicates *predicates) 1139``` 1140 1141**Description** 1142 1143Deletes data from an RDB store based on specified conditions. 1144 1145**Since**: 10 1146 1147 1148**Parameters** 1149 1150| Parameter| Description| 1151| -- | -- | 1152| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1153| [OH_Predicates](capi-rdb-oh-predicates.md) *predicates | Pointer to the [OH_Predicates](capi-rdb-oh-predicates.md) instance, specifying the deletion conditions.| 1154 1155**Returns** 1156 1157| Type| Description| 1158| -- | -- | 1159| int | Returns the number of deleted rows if the operation is successful; returns a number less than **0** otherwise.<br>**RDB_ERR** indicates that the operation fails.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1160 1161### OH_Rdb_Query() 1162 1163``` 1164OH_Cursor *OH_Rdb_Query(OH_Rdb_Store *store, OH_Predicates *predicates, const char *const *columnNames, int length) 1165``` 1166 1167**Description** 1168 1169Queries data in an RDB store based on specified conditions. 1170 1171**Since**: 10 1172 1173 1174**Parameters** 1175 1176| Parameter| Description| 1177| -- | -- | 1178| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1179| [OH_Predicates](capi-rdb-oh-predicates.md) *predicates | Pointer to the [OH_Predicates](capi-rdb-oh-predicates.md) instance, specifying the query conditions.| 1180| const char *const *columnNames | Columns to query. If this parameter is not specified, the query applies to all columns.| 1181| int length | Length of **columnNames**. If **length** is greater than the length of **columnNames** array, out-of-bounds access occurs.| 1182 1183**Returns** 1184 1185| Type | Description| 1186|----------------------------------| -- | 1187| [OH_Cursor](capi-rdb-oh-cursor.md) * | Returns the pointer to the [OH_Cursor](capi-rdb-oh-cursor.md) instance if the operation is successful; returns null otherwise.| 1188 1189### OH_Rdb_Execute() 1190 1191``` 1192int OH_Rdb_Execute(OH_Rdb_Store *store, const char *sql) 1193``` 1194 1195**Description** 1196 1197Executes an SQL statement that returns no value. 1198 1199**Since**: 10 1200 1201 1202**Parameters** 1203 1204| Parameter| Description| 1205| -- | -- | 1206| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1207| const char *sql | SQL statement to run.| 1208 1209**Returns** 1210 1211| Type| Description| 1212| -- | -- | 1213| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1214 1215**See** 1216 1217OH_Rdb_Store 1218 1219### OH_Rdb_ExecuteV2() 1220 1221``` 1222int OH_Rdb_ExecuteV2(OH_Rdb_Store *store, const char *sql, const OH_Data_Values *args, OH_Data_Value **result) 1223``` 1224 1225**Description** 1226 1227Executes an SQL statement with a return value. This API supports vector stores. 1228 1229**Since**: 18 1230 1231 1232**Parameters** 1233 1234| Parameter | Description | 1235|------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------| 1236| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance. | 1237| const char *sql | SQL statement to run. | 1238| const [OH_Data_Values](capi-rdb-oh-data-values.md) *args | (Optional) Pointer to the [OH_Data_Values](capi-rdb-oh-data-values.md) instance. | 1239| [OH_Data_Value](capi-rdb-oh-data-value.md) **result | Pointer to the [OH_Data_Value](capi-rdb-oh-data-value.md) instance when the execution is successful. Use [OH_Value_Destroy](capi-oh-data-value-h.md#oh_value_destroy) to release the memory in time.| 1240 1241**Returns** 1242 1243| Type| Description| 1244| -- | -- | 1245| int | Returns the execution result.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_ERROR** indicates a common database error.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_ALREADY_CLOSED** indicates that the database is already closed.<br>**RDB_E_WAL_SIZE_OVER_LIMIT** indicates that the size of the WAL log file exceeds the default value.<br>**RDB_E_SQLITE_FULL** indicates an SQLite error: the database is full.<br>**RDB_E_SQLITE_CORRUPT** indicates that the database is corrupted.<br>**RDB_E_SQLITE_PERM** indicates an SQLite error: access denied.<br>**RDB_E_SQLITE_BUSY** indicates an SQLite error: database file locked.<br>**RDB_E_SQLITE_LOCKED** indicates an SQLite error: database table locked.<br>**RDB_E_SQLITE_NOMEM** indicates an SQLite: insufficient database memory.<br>**RDB_E_SQLITE_READONLY** indicates an SQLite error: attempt to write a read-only database.<br>**RDB_E_SQLITE_IOERR** indicates an SQLite: disk I/O error.<br>**RDB_E_SQLITE_TOO_BIG** indicates an SQLite error: TEXT or BLOB exceeds the limit.<br>**RDB_E_SQLITE_MISMATCH** indicates an SQLite error: data types mismatch.| 1246 1247**See** 1248 1249OH_Value_Destroy 1250 1251### OH_Rdb_ExecuteByTrxId() 1252 1253``` 1254int OH_Rdb_ExecuteByTrxId(OH_Rdb_Store *store, int64_t trxId, const char *sql) 1255``` 1256 1257**Description** 1258 1259Executes an SQL statement that returns no value based on the specified transaction ID. This API supports only vector stores. 1260 1261**Since**: 14 1262 1263 1264**Parameters** 1265 1266| Parameter| Description| 1267| -- | -- | 1268| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1269| int64_t trxId | Transaction ID returned by [OH_Rdb_BeginTransWithTrxId](capi-relational-store-h.md#oh_rdb_begintranswithtrxid). The value **0** indicates that no transaction is enabled.| 1270| const char *sql | SQL statement to run.| 1271 1272**Returns** 1273 1274| Type| Description| 1275| -- | -- | 1276| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates invalid parameters. The possible causes are as follows:<br>The input parameter is a null pointer.<br>The current transaction ID is not obtained by calling [OH_Rdb_BeginTransWithTrxId](capi-relational-store-h.md#oh_rdb_begintranswithtrxid).<br>The current transaction ID has been submitted by calling [OH_Rdb_CommitByTrxId](capi-relational-store-h.md#oh_rdb_commitbytrxid).<br>The current transaction ID has been rolled back by calling [OH_Rdb_RollBackByTrxId](capi-relational-store-h.md#oh_rdb_rollbackbytrxid).<br>**store** or **sql** is **NULL**.<br>**RDB_E_NOT_SUPPORTED** indicates that the current operation is not supported.| 1277 1278**See** 1279 1280OH_Rdb_Store 1281 1282### OH_Rdb_ExecuteQuery() 1283 1284``` 1285OH_Cursor *OH_Rdb_ExecuteQuery(OH_Rdb_Store *store, const char *sql) 1286``` 1287 1288**Description** 1289 1290Queries data in the database using the specified SQL statement. This API supports vector stores. 1291 1292**Since**: 10 1293 1294 1295**Parameters** 1296 1297| Parameter| Description| 1298| -- | -- | 1299| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1300| const char *sql | SQL statement to run.| 1301 1302**Returns** 1303 1304| Type| Description| 1305| -- | -- | 1306| [OH_Cursor](capi-rdb-oh-cursor.md) | Returns the pointer to the [OH_Cursor](capi-rdb-oh-cursor.md) instance if the operation is successful; returns null otherwise.| 1307 1308**See** 1309 1310OH_Rdb_Store 1311 1312### OH_Rdb_ExecuteQueryV2() 1313 1314``` 1315OH_Cursor *OH_Rdb_ExecuteQueryV2(OH_Rdb_Store *store, const char *sql, const OH_Data_Values *args) 1316``` 1317 1318**Description** 1319 1320Queries data in the database using the specified SQL statement. This API supports vector stores. 1321 1322**Since**: 18 1323 1324 1325**Parameters** 1326 1327| Parameter| Description| 1328| -- | -- | 1329| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1330| const char *sql | SQL statement to run.| 1331| const OH_Data_Values *args | (Optional) Pointer to the [OH_Data_Values](capi-rdb-oh-data-values.md) instance.| 1332 1333**Returns** 1334 1335| Type | Description | 1336| -------------------------------- | ------------------------------------------------------------ | 1337| [OH_Cursor](capi-rdb-oh-cursor.md) * | Returns a pointer to the [OH_Cursor](capi-rdb-oh-cursor.md) instance if the operation is successful. The [OH_Cursor](capi-rdb-oh-cursor.md) instance is released if it is no longer required in time.<br>Returns **NULL** if the SQL statement is invalid or the memory allocation fails.| 1338 1339**See** 1340 1341OH_Rdb_Store 1342 1343### OH_Rdb_BeginTransaction() 1344 1345``` 1346int OH_Rdb_BeginTransaction(OH_Rdb_Store *store) 1347``` 1348 1349**Description** 1350 1351Begins the transaction before executing SQL statements. 1352 1353**Since**: 10 1354 1355 1356**Parameters** 1357 1358| Parameter| Description| 1359| -- | -- | 1360| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1361 1362**Returns** 1363 1364| Type| Description| 1365| -- | -- | 1366| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1367 1368### OH_Rdb_RollBack() 1369 1370``` 1371int OH_Rdb_RollBack(OH_Rdb_Store *store) 1372``` 1373 1374**Description** 1375 1376Rolls back the SQL statements executed. 1377 1378**Since**: 10 1379 1380 1381**Parameters** 1382 1383| Parameter| Description| 1384| -- | -- | 1385| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1386 1387**Returns** 1388 1389| Type| Description| 1390| -- | -- | 1391| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1392 1393### OH_Rdb_Commit() 1394 1395``` 1396int OH_Rdb_Commit(OH_Rdb_Store *store) 1397``` 1398 1399**Description** 1400 1401Commits the executed SQL statement. 1402 1403**Since**: 10 1404 1405 1406**Parameters** 1407 1408| Parameter| Description| 1409| -- | -- | 1410| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1411 1412**Returns** 1413 1414| Type| Description| 1415| -- | -- | 1416| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1417 1418### OH_Rdb_BeginTransWithTrxId() 1419 1420``` 1421int OH_Rdb_BeginTransWithTrxId(OH_Rdb_Store *store, int64_t *trxId) 1422``` 1423 1424**Description** 1425 1426Begins a transaction. This API returns a transaction ID and supports only vector stores. 1427 1428**Since**: 14 1429 1430 1431**Parameters** 1432 1433| Parameter| Description| 1434| -- | -- | 1435| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1436| int64_t *trxId | Pointer to the transaction ID returned.| 1437 1438**Returns** 1439 1440| Type| Description| 1441| -- | -- | 1442| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_NOT_SUPPORTED** indicates that the current operation is not supported.| 1443 1444### OH_Rdb_RollBackByTrxId() 1445 1446``` 1447int OH_Rdb_RollBackByTrxId(OH_Rdb_Store *store, int64_t trxId) 1448``` 1449 1450**Description** 1451 1452Rolls back the executed SQL statements based on the specified transaction ID. This API supports only vector stores. 1453 1454**Since**: 14 1455 1456 1457**Parameters** 1458 1459| Parameter| Description| 1460| -- | -- | 1461| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1462| int64_t trxId | ID of the transaction to be rolled back.| 1463 1464**Returns** 1465 1466| Type| Description| 1467| -- | -- | 1468| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates invalid parameters. The possible causes are as follows:<br>The input parameter is a null pointer.<br>The current transaction ID is not obtained by calling [OH_Rdb_BeginTransWithTrxId](capi-relational-store-h.md#oh_rdb_begintranswithtrxid).<br>The current transaction ID has been submitted by calling [OH_Rdb_CommitByTrxId](capi-relational-store-h.md#oh_rdb_commitbytrxid).<br>The current transaction ID has been rolled back by calling [OH_Rdb_RollBackByTrxId](capi-relational-store-h.md#oh_rdb_rollbackbytrxid).<br>**RDB_E_NOT_SUPPORTED** indicates that the current operation is not supported.| 1469 1470### OH_Rdb_CommitByTrxId() 1471 1472``` 1473int OH_Rdb_CommitByTrxId(OH_Rdb_Store *store, int64_t trxId) 1474``` 1475 1476**Description** 1477 1478Commits the executed SQL statements based on the specified transaction ID. This API supports only vector stores. 1479 1480**Since**: 14 1481 1482 1483**Parameters** 1484 1485| Parameter| Description| 1486| -- | -- | 1487| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1488| int64_t trxId | Transaction ID.| 1489 1490**Returns** 1491 1492| Type| Description| 1493| -- | -- | 1494| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates invalid parameters. The possible causes are as follows:<br>The input parameter is a null pointer.<br>The current transaction ID is not obtained by calling [OH_Rdb_BeginTransWithTrxId](capi-relational-store-h.md#oh_rdb_begintranswithtrxid).<br>The current transaction ID has been submitted by calling [OH_Rdb_CommitByTrxId](capi-relational-store-h.md#oh_rdb_commitbytrxid).<br>The current transaction ID has been rolled back by calling [OH_Rdb_RollBackByTrxId](capi-relational-store-h.md#oh_rdb_rollbackbytrxid).<br>**RDB_E_NOT_SUPPORTED** indicates that the current operation is not supported.| 1495 1496**See** 1497 1498OH_Rdb_Store 1499 1500### OH_Rdb_Backup() 1501 1502``` 1503int OH_Rdb_Backup(OH_Rdb_Store *store, const char *databasePath) 1504``` 1505 1506**Description** 1507 1508Backs up an RDB store using the backup file of the specified path. This API supports vector stores. 1509 1510**Since**: 10 1511 1512 1513**Parameters** 1514 1515| Parameter| Description| 1516| -- | -- | 1517| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1518| const char *databasePath | Pointer to the destination directory in which the RDB store is backed up.| 1519 1520**Returns** 1521 1522| Type| Description| 1523| -- | -- | 1524| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1525 1526**See** 1527 1528OH_Rdb_Store 1529 1530### OH_Rdb_Restore() 1531 1532``` 1533int OH_Rdb_Restore(OH_Rdb_Store *store, const char *databasePath) 1534``` 1535 1536**Description** 1537 1538Restores a database from a specified database backup file. This API supports vector stores. 1539 1540**Since**: 10 1541 1542 1543**Parameters** 1544 1545| Parameter| Description| 1546| -- | -- | 1547| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1548| const char *databasePath | Pointer to the destination directory in which the RDB store is backed up.| 1549 1550**Returns** 1551 1552| Type| Description| 1553| -- | -- | 1554| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1555 1556### OH_Rdb_GetVersion() 1557 1558``` 1559int OH_Rdb_GetVersion(OH_Rdb_Store *store, int *version) 1560``` 1561 1562**Description** 1563 1564Obtains the RDB store version. 1565 1566**Since**: 10 1567 1568 1569**Parameters** 1570 1571| Parameter| Description| 1572| -- | -- | 1573| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1574| int *version | Pointer to the version number.| 1575 1576**Returns** 1577 1578| Type| Description| 1579| -- | -- | 1580| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1581 1582### OH_Rdb_SetVersion() 1583 1584``` 1585int OH_Rdb_SetVersion(OH_Rdb_Store *store, int version) 1586``` 1587 1588**Description** 1589 1590Sets the RDB store version. 1591 1592**Since**: 10 1593 1594 1595**Parameters** 1596 1597| Parameter| Description| 1598| -- | -- | 1599| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1600| int version | Version to set.| 1601 1602**Returns** 1603 1604| Type| Description| 1605| -- | -- | 1606| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1607 1608**See** 1609 1610OH_Rdb_Store 1611 1612### OH_Rdb_SetDistributedTables() 1613 1614``` 1615int OH_Rdb_SetDistributedTables(OH_Rdb_Store *store, const char *tables[], uint32_t count, Rdb_DistributedType type,const Rdb_DistributedConfig *config) 1616``` 1617 1618**Description** 1619 1620Sets distributed database tables. 1621 1622**Since**: 11 1623 1624 1625**Parameters** 1626 1627| Parameter| Description| 1628| -- | -- | 1629| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1630| onst char *tables[] | Pointer to the names of the distributed tables to set.| 1631| uint32_t count | Number of distributed database tables to be set.| 1632| [Rdb_DistributedType](#rdb_distributedtype) type | [Rdb_DistributedType](capi-relational-store-h.md#rdb_distributedtype) of the table.| 1633| const [Rdb_DistributedConfig](capi-rdb-rdb-distributedconfig.md) *config | Distributed configuration information of a table ([Rdb_DistributedConfig](capi-rdb-rdb-distributedconfig.md)).| 1634 1635**Returns** 1636 1637| Type| Description| 1638| -- | -- | 1639| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1640 1641**See** 1642 1643OH_Rdb_Store 1644 1645### OH_Rdb_FindModifyTime() 1646 1647``` 1648OH_Cursor *OH_Rdb_FindModifyTime(OH_Rdb_Store *store, const char *tableName, const char *columnName,OH_VObject *values) 1649``` 1650 1651**Description** 1652 1653Obtains the last modification time of a table in an RDB store. 1654 1655**Since**: 11 1656 1657 1658**Parameters** 1659 1660| Parameter| Description| 1661| -- | -- | 1662| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1663| const char *tableName | Pointer to the target distributed database table name.| 1664| const char *columnName | Pointer to the column name of the database table to query.| 1665| [OH_VObject](capi-rdb-oh-vobject.md) *values | Pointer to the primary keys of the rows to query. If the database table has no primary key, **rowid** must be passed in through **columnName**. In this case, **values** specifies the row number of the database table to query.| 1666 1667**Returns** 1668 1669| Type| Description| 1670| -- | -- | 1671| [OH_Cursor](capi-rdb-oh-cursor.md) | Returns the pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance created if the operation is successful; returns null otherwise.| 1672 1673### Rdb_BriefObserver() 1674 1675``` 1676typedef void (*Rdb_BriefObserver)(void *context, const char *values[], uint32_t count) 1677``` 1678 1679**Description** 1680 1681Callback used to return the device-cloud data change event. 1682 1683**Since**: 11 1684 1685 1686**Parameters** 1687 1688| Parameter| Description| 1689| -- | -- | 1690| void *context | Pointer to the context of the data observer.| 1691| const char *values[] | Pointer to the accounts whose device-cloud data is changed.| 1692| uint32_t count | Number of accounts whose device-cloud data is changed.| 1693 1694### Rdb_DetailsObserver() 1695 1696``` 1697typedef void (*Rdb_DetailsObserver)(void *context, const Rdb_ChangeInfo **changeInfo, uint32_t count) 1698``` 1699 1700**Description** 1701 1702Callback used to return the details about the device-cloud data change. 1703 1704**Since**: 11 1705 1706 1707**Parameters** 1708 1709| Parameter| Description| 1710| -- | -- | 1711| void *context | Pointer to the context of the data observer.| 1712| const [Rdb_ChangeInfo](capi-rdb-rdb-changeinfo.md) **changeInfo | Information about the changed table ([Rdb_ChangeInfo](capi-rdb-rdb-changeinfo.md)).| 1713| uint32_t count | Number of changed tables.| 1714 1715### OH_Rdb_Subscribe() 1716 1717``` 1718int OH_Rdb_Subscribe(OH_Rdb_Store *store, Rdb_SubscribeType type, const Rdb_DataObserver *observer) 1719``` 1720 1721**Description** 1722 1723Registers an observer for an RDB store. The registered callback will be called when data in a distributed or local RDB store changes. 1724 1725**Since**: 11 1726 1727 1728**Parameters** 1729 1730| Parameter| Description| 1731| -- | -- | 1732| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1733| [Rdb_SubscribeType](#rdb_subscribetype) type | Subscription type ([Rdb_SubscribeType](capi-relational-store-h.md#rdb_subscribetype)). If the value is **RDB_SUBSCRIBE_TYPE_LOCAL_DETAILS**, the callback is called when the data in the local RDB store changes.| 1734| const [Rdb_DataObserver](capi-rdb-rdb-dataobserver.md) *observer | Pointer to the [Rdb_DataObserver](capi-rdb-rdb-dataobserver.md) instance.| 1735 1736**Returns** 1737 1738| Type| Description| 1739| -- | -- | 1740| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1741 1742### OH_Rdb_Unsubscribe() 1743 1744``` 1745int OH_Rdb_Unsubscribe(OH_Rdb_Store *store, Rdb_SubscribeType type, const Rdb_DataObserver *observer) 1746``` 1747 1748**Description** 1749 1750Unregisters the observer of the specified type. 1751 1752**Since**: 11 1753 1754 1755**Parameters** 1756 1757| Parameter| Description| 1758| -- | -- | 1759| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1760| [Rdb_SubscribeType](#rdb_subscribetype) type | Subscription type ([Rdb_SubscribeType](capi-relational-store-h.md#rdb_subscribetype)).| 1761| const [Rdb_DataObserver](capi-rdb-rdb-dataobserver.md) *observer | Pointer to the [Rdb_DataObserver](capi-rdb-rdb-dataobserver.md) instance. If this parameter is **nullptr**, all observers of this type will be unregistered.| 1762 1763**Returns** 1764 1765| Type| Description| 1766| -- | -- | 1767| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1768 1769### OH_Rdb_GetTableDetails() 1770 1771``` 1772Rdb_TableDetails *OH_Rdb_GetTableDetails(Rdb_ProgressDetails *progress, int32_t version) 1773``` 1774 1775**Description** 1776 1777Obtains the device-cloud sync statistics of a table. 1778 1779**Since**: 11 1780 1781 1782**Parameters** 1783 1784| Parameter| Description | 1785| -- |------------------------------------------------------------| 1786| [Rdb_ProgressDetails](capi-rdb-rdb-progressdetails.md) *progress | Pointer to the [OH_ProgressDetails](capi-rdb-rdb-progressdetails.md) instance. | 1787| int32_t version | Version of the current [Rdb_ProgressDetails](capi-rdb-rdb-progressdetails.md).| 1788 1789**Returns** 1790 1791| Type| Description| 1792| -- | -- | 1793| [Rdb_TableDetails](capi-rdb-rdb-tabledetails.md) | Returns a pointer to [Rdb_TableDetails](capi-rdb-rdb-tabledetails.md) if the operation is successful; returns null otherwise.| 1794 1795**See** 1796 1797Rdb_TableDetails 1798 1799### Rdb_ProgressCallback() 1800 1801``` 1802typedef void (*Rdb_ProgressCallback)(void *context, Rdb_ProgressDetails *progressDetails) 1803``` 1804 1805**Description** 1806 1807Defines a callback used to return the device-cloud sync progress. 1808 1809**Since**: 11 1810 1811 1812**Parameters** 1813 1814| Parameter | Description | 1815|-------------------|--------------| 1816| void *context | | 1817| [Rdb_ProgressDetails](capi-rdb-rdb-progressdetails.md) *progressDetails | Details about the device-cloud sync progress.| 1818 1819### Rdb_SyncCallback() 1820 1821``` 1822typedef void (*Rdb_SyncCallback)(Rdb_ProgressDetails *progressDetails) 1823``` 1824 1825**Description** 1826 1827Defines a callback for device-cloud sync. 1828 1829**Since**: 11 1830 1831 1832**Parameters** 1833 1834| Parameter| Description| 1835| -- | -- | 1836| [Rdb_ProgressDetails](capi-rdb-rdb-progressdetails.md) *progressDetails | Statistics of device-cloud sync.| 1837 1838### OH_Rdb_CloudSync() 1839 1840``` 1841int OH_Rdb_CloudSync(OH_Rdb_Store *store, Rdb_SyncMode mode, const char *tables[], uint32_t count,const Rdb_ProgressObserver *observer) 1842``` 1843 1844**Description** 1845 1846Performs device-cloud sync. 1847 1848**Since**: 11 1849 1850 1851**Parameters** 1852 1853| Parameter| Description| 1854| -- | -- | 1855| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1856| [Rdb_SyncMode](#rdb_syncmode) mode | Type of the sync process ([Rdb_SyncMode](capi-relational-store-h.md#rdb_syncmode)).| 1857| const char *tables[] | Pointer to the names of the tables to be synced.| 1858| uint32_t count | Number of tables to sync. If the value is **0**, all tables in the RDB store are synced.| 1859| const [Rdb_ProgressObserver](capi-rdb-rdb-progressobserver.md) *observer | Pointer to the [Rdb_ProgressObserver](capi-rdb-rdb-progressobserver.md) instance.| 1860 1861**Returns** 1862 1863| Type| Description| 1864| -- | -- | 1865| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1866 1867### OH_Rdb_SubscribeAutoSyncProgress() 1868 1869``` 1870int OH_Rdb_SubscribeAutoSyncProgress(OH_Rdb_Store *store, const Rdb_ProgressObserver *observer) 1871``` 1872 1873**Description** 1874 1875Subscribes to the auto sync progress of an RDB store.<br>The registered callback will be invoked to return the auto sync progress. 1876 1877**Since**: 11 1878 1879 1880**Parameters** 1881 1882| Parameter| Description| 1883| -- | -- | 1884| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the target [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1885| const [Rdb_ProgressObserver](capi-rdb-rdb-progressobserver.md) *observer | Pointer to the [Rdb_ProgressObserver](capi-rdb-rdb-progressobserver.md) instance, which invokes the callback to return the automatic sync progress.| 1886 1887**Returns** 1888 1889| Type| Description| 1890| -- | -- | 1891| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1892 1893### OH_Rdb_UnsubscribeAutoSyncProgress() 1894 1895``` 1896int OH_Rdb_UnsubscribeAutoSyncProgress(OH_Rdb_Store *store, const Rdb_ProgressObserver *observer) 1897``` 1898 1899**Description** 1900 1901Unsubscribes from the auto sync process of an RDB store. 1902 1903**Since**: 11 1904 1905 1906**Parameters** 1907 1908| Parameter| Description| 1909| -- | -- | 1910| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the target [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1911| const [Rdb_ProgressObserver](capi-rdb-rdb-progressobserver.md) *observer | Pointer to the [Rdb_ProgressObserver](capi-rdb-rdb-progressobserver.md) instance. If the pointer is null, all callbacks for the auto sync process will be unregistered.| 1912 1913**Returns** 1914 1915| Type| Description| 1916| -- | -- | 1917| int | Returns **RDB_OK** if the operation is successful; returns an error code otherwise.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1918 1919### OH_Rdb_LockRow() 1920 1921``` 1922int OH_Rdb_LockRow(OH_Rdb_Store *store, OH_Predicates *predicates) 1923``` 1924 1925**Description** 1926 1927Locks data in an RDB store based on specified conditions. The locked data will be blocked from the device-cloud sync. 1928 1929**Since**: 12 1930 1931 1932**Parameters** 1933 1934| Parameter| Description| 1935| -- | -- | 1936| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1937| [OH_Predicates](capi-rdb-oh-predicates.md) *predicates | Pointer to the [OH_Predicates](capi-rdb-oh-predicates.md) instance, specifying the lock conditions.| 1938 1939**Returns** 1940 1941| Type| Description| 1942| -- | -- | 1943| int | Returns the operation result.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1944 1945### OH_Rdb_UnlockRow() 1946 1947``` 1948int OH_Rdb_UnlockRow(OH_Rdb_Store *store, OH_Predicates *predicates) 1949``` 1950 1951**Description** 1952 1953Unlocks data in an RDB store based on the specified conditions. 1954 1955**Since**: 12 1956 1957 1958**Parameters** 1959 1960| Parameter| Description| 1961| -- | -- | 1962| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1963| [OH_Predicates](capi-rdb-oh-predicates.md) *predicates | Pointer to the [OH_Predicates](capi-rdb-oh-predicates.md) instance, specifying the unlock conditions.| 1964 1965**Returns** 1966 1967| Type| Description| 1968| -- | -- | 1969| int | Returns the operation result.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.| 1970 1971### OH_Rdb_QueryLockedRow() 1972 1973``` 1974OH_Cursor *OH_Rdb_QueryLockedRow(OH_Rdb_Store *store, OH_Predicates *predicates, const char *const *columnNames, int length) 1975``` 1976 1977**Description** 1978 1979Queries the locked data in an RDB store. 1980 1981**Since**: 12 1982 1983 1984**Parameters** 1985 1986| Parameter| Description| 1987| -- | -- | 1988| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 1989| [OH_Predicates](capi-rdb-oh-predicates.md) *predicates | Pointer to the [OH_Predicates](capi-rdb-oh-predicates.md) instance, specifying the query conditions.| 1990| const char *const *columnNames | Columns to query. If this parameter is not specified, the query applies to all columns.| 1991| int length | Length of **columnNames**. If **length** is greater than the length of **columnNames** array, out-of-bounds access occurs.| 1992 1993**Returns** 1994 1995| Type| Description| 1996| -- | -- | 1997| [OH_Cursor](capi-rdb-oh-cursor.md) | Returns the pointer to the [OH_Cursor](capi-rdb-oh-cursor.md) instance if the operation is successful; returns null otherwise.| 1998 1999### OH_Rdb_CreateTransaction() 2000 2001``` 2002int OH_Rdb_CreateTransaction(OH_Rdb_Store *store, const OH_RDB_TransOptions *options, OH_Rdb_Transaction **trans) 2003``` 2004 2005**Description** 2006 2007Creates a transaction object. 2008 2009**Since**: 18 2010 2011 2012**Parameters** 2013 2014| Parameter| Description| 2015| -- | -- | 2016| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 2017| const [OH_RDB_TransOptions](capi-rdb-oh-rdb-transoptions.md) *options | Pointer to the [OH_RDB_TransOptions](capi-rdb-oh-rdb-transoptions.md) instance.| 2018| [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) **trans | Double pointer to the [OH_Rdb_Transaction](capi-rdb-oh-rdb-transaction.md) instance if the operation is successful; otherwise, **nullptr** is returned.<br>Release the memory using [OH_RdbTrans_Destroy](capi-oh-rdb-transaction-h.md#oh_rdbtrans_destroy) if the created transaction is used.| 2019 2020**Returns** 2021 2022| Type| Description| 2023| -- | -- | 2024| int | Returns the execution result.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_ERROR** indicates a common database error.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_ALREADY_CLOSED** indicates that the database is already closed.<br>**RDB_E_DATABASE_BUSY** indicates that the database does not respond.<br>**RDB_E_SQLITE_FULL** indicates an SQLite error: the database is full.<br>**RDB_E_SQLITE_CORRUPT** indicates that the database is corrupted.<br>**RDB_E_SQLITE_PERM** indicates an SQLite error: access denied.<br>**RDB_E_SQLITE_BUSY** indicates an SQLite error: database file locked.<br>**RDB_E_SQLITE_NOMEM** indicates an SQLite: insufficient database memory.<br>**RDB_E_SQLITE_IOERR** indicates an SQLite: disk I/O error.<br>**RDB_E_SQLITE_CANT_OPEN** indicates an SQLite error: unable to open the database file.| 2025 2026### OH_Rdb_Attach() 2027 2028``` 2029int OH_Rdb_Attach(OH_Rdb_Store *store, const OH_Rdb_ConfigV2 *config, const char *attachName, int64_t waitTime,size_t *attachedNumber) 2030``` 2031 2032**Description** 2033 2034Attaches a database file to the database that is currently connected. 2035 2036**Since**: 20 2037 2038 2039**Parameters** 2040 2041| Parameter| Description| 2042| -- | -- | 2043| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 2044| const [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) *config | Pointer to the [OH_Rdb_ConfigV2](capi-rdb-oh-rdb-configv2.md) instance.| 2045| const char *attachName | Pointer to the alias of the database.| 2046| int64_t waitTime | Maximum duration for attaching a database, in seconds. The value ranges from 1 to 300.| 2047| size_t *attachedNumber | Pointer to the number of attached databases.| 2048 2049**Returns** 2050 2051| Type| Description| 2052| -- | -- | 2053| int | Returns the execution result.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_ERROR** indicates a common database error.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_ALREADY_CLOSED** indicates that the database is already closed.<br>**RDB_E_NOT_SUPPORTED** indicates that the operation is not supported.<br>**RDB_E_DATABASE_BUSY** indicates that the database does not respond.<br>**RDB_E_SQLITE_FULL** indicates an SQLite error: the database is full.<br>**RDB_E_SQLITE_CORRUPT** indicates that the database is corrupted.<br>**RDB_E_SQLITE_PERM** indicates an SQLite error: access denied.<br>**RDB_E_SQLITE_BUSY** indicates an SQLite error: database file locked.<br>**RDB_E_SQLITE_LOCKED** indicates an SQLite error: database table locked.<br>**RDB_E_SQLITE_NOMEM** indicates an SQLite: insufficient database memory.<br>**RDB_E_SQLITE_READONLY** indicates an SQLite error: attempt to write a read-only database.<br>**RDB_E_SQLITE_IOERR** indicates an SQLite: disk I/O error.<br>**RDB_E_SQLITE_TOO_BIG** indicates an SQLite error: TEXT or BLOB exceeds the limit.<br>**RDB_E_SQLITE_MISMATCH** indicates an SQLite error: data types mismatch.<br>**RDB_E_SQLITE_CONSTRAINT** indicates an SQLite error code: SQLite constraint.| 2054 2055### OH_Rdb_Detach() 2056 2057``` 2058int OH_Rdb_Detach(OH_Rdb_Store *store, const char *attachName, int64_t waitTime, size_t *attachedNumber) 2059``` 2060 2061**Description** 2062 2063Detaches a specified store from the current database. 2064 2065**Since**: 20 2066 2067 2068**Parameters** 2069 2070| Parameter| Description| 2071| -- | -- | 2072| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 2073| const char *attachName | Pointer to the alias of the database.| 2074| int64_t waitTime | Maximum duration for detaching a database, in seconds. The value ranges from 1 to 300.| 2075| size_t *attachedNumber | Pointer to the number of attached databases.| 2076 2077**Returns** 2078 2079| Type| Description| 2080| -- | -- | 2081| int | Returns the execution result.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_E_ERROR** indicates a common database error.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_ALREADY_CLOSED** indicates that the database is already closed.<br>**RDB_E_NOT_SUPPORTED** indicates that the operation is not supported.<br>**RDB_E_DATABASE_BUSY** indicates that the database does not respond.<br>**RDB_E_SQLITE_FULL** indicates an SQLite error: the database is full.<br>**RDB_E_SQLITE_CORRUPT** indicates that the database is corrupted.<br>**RDB_E_SQLITE_PERM** indicates an SQLite error: access denied.<br>**RDB_E_SQLITE_BUSY** indicates an SQLite error: database file locked.<br>**RDB_E_SQLITE_LOCKED** indicates an SQLite error: database table locked.<br>**RDB_E_SQLITE_NOMEM** indicates an SQLite: insufficient database memory.<br>**RDB_E_SQLITE_READONLY** indicates an SQLite error: attempt to write a read-only database.<br>**RDB_E_SQLITE_IOERR** indicates an SQLite: disk I/O error.<br>**RDB_E_SQLITE_TOO_BIG** indicates an SQLite error: TEXT or BLOB exceeds the limit.<br>**RDB_E_SQLITE_MISMATCH** indicates an SQLite error: data types mismatch.<br>**RDB_E_SQLITE_CONSTRAINT** indicates an SQLite error code: SQLite constraint.| 2082 2083### OH_Rdb_SetLocale() 2084 2085``` 2086int OH_Rdb_SetLocale(OH_Rdb_Store *store, const char *locale) 2087``` 2088 2089**Description** 2090 2091Sets locale. 2092 2093**Since**: 20 2094 2095 2096**Parameters** 2097 2098| Parameter| Description| 2099| -- | -- | 2100| [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) *store | Pointer to the [OH_Rdb_Store](capi-rdb-oh-rdb-store.md) instance.| 2101| const char *locale | Pointer to the locale to set, for example, zh. The value must comply with the ISO 639 standard.| 2102 2103**Returns** 2104 2105| Type| Description| 2106| -- | -- | 2107| int | Returns the execution result.<br>**RDB_OK** indicates that the operation is successful.<br>**RDB_ERR** indicates that the execute function is abnormal.<br>**RDB_E_INVALID_ARGS** indicates that invalid parameters are specified.<br>**RDB_E_ALREADY_CLOSED** indicates that the database is already closed.<br>**RDB_E_SQLITE_BUSY** indicates an SQLite error: database file locked.<br>**RDB_E_SQLITE_NOMEM** indicates an SQLite: insufficient database memory.| 2108