relational_store.h

Overview

Provides APIs to manage a relational database (RDB) store.

File to include: <database/rdb/relational_store.h>

Library: libnative_rdb_ndk.z.so

Since: 10

Related module: RDB

Summary

Structs

Name Description
OH_Rdb_Config Defines the RDB store configuration.
OH_Rdb_Store Defines the RDB store type.
Rdb_DistributedConfig Defines the distributed configuration of a table.
Rdb_KeyInfo Defines the primary key or row number of the row that changes.
Rdb_KeyInfo::Rdb_KeyData Defines the changed data.
Rdb_ChangeInfo Defines the details about the device-cloud sync process.
Rdb_SubscribeCallback Defines the callback used to return the result.
Rdb_DataObserver Defines the data observer.
Rdb_Statistic Defines the device-cloud sync statistics of a database table.
Rdb_TableDetails Defines the statistics of device-cloud upload and download tasks of a database table.
Rdb_ProgressDetails Defines the statistics of the overall device-cloud upload and download tasks of an RDB store.
Rdb_ProgressObserver Defines the observer of the device-cloud sync progress.

Macros

Name Description
DISTRIBUTED_CONFIG_VERSION   1 Version of Rdb_DistributedConfig.
DISTRIBUTED_CHANGE_INFO_VERSION   1 Version of Rdb_ChangeInfo.
DISTRIBUTED_PROGRESS_DETAIL_VERSION   1 Version of Rdb_ProgressDetails.

Types

Name Description
OH_Rdb_SecurityLevel Defines an enum for RDB store security levels.
Rdb_SecurityArea Defines an enum for security area levels of an RDB store.
Rdb_DistributedType Defines an enum for distributed types.
Rdb_DistributedConfig Defines a struct for the distributed configuration of a table.
Rdb_ChangeType Defines an enum for data change types.
Rdb_KeyInfo Defines a struct for the primary key or row number of the row that changes.
Rdb_ChangeInfo Defines a struct for details about the device-cloud sync process.
Rdb_SubscribeType Defines an enum for subscription types.
Rdb_BriefObserver Defines a callback used to return the device-cloud data change event.
Rdb_DetailsObserver Defines a callback used to return the details about the device-cloud data change.
Rdb_SubscribeCallback Defines a callback used to return the subscribed event.
Rdb_DataObserver Defines a struct for the data observer.
Rdb_SyncMode Defines an enum for RDB sync modes.
Rdb_Statistic Defines a struct for device-cloud sync statistics of a database table.
Rdb_TableDetails Defines a struct for statistics of device-cloud upload and download tasks of a database table.
Rdb_Progress Defines an enum for device-cloud sync progresses.
Rdb_ProgressCode Defines an enum for states in the device-cloud sync process.
Rdb_ProgressDetails Defines a struct for statistics of the overall device-cloud upload and download tasks of an RDB store.
Rdb_ProgressCallback Defines a callback used to return the device-cloud sync progress.
Rdb_SyncCallback Defines a callback to be invoked in device-cloud sync.
Rdb_ProgressObserver Defines a struct for the observer of the device-cloud sync progress.

Enums

Name Description
OH_Rdb_SecurityLevel { S1 = 1, S2, S3, S4} Enumerates the RDB store security levels.
Rdb_SecurityArea { RDB_SECURITY_AREA_EL1 = 1, RDB_SECURITY_AREA_EL2, RDB_SECURITY_AREA_EL3, RDB_SECURITY_AREA_EL4 } Enumerates the security area levels of an RDB store.
Rdb_DistributedType { RDB_DISTRIBUTED_CLOUD } Enumerates the distributed types.
Rdb_ChangeType { RDB_DATA_CHANGE, RDB_ASSET_CHANGE } Enumerates the data change types.
Rdb_SubscribeType { RDB_SUBSCRIBE_TYPE_CLOUD, RDB_SUBSCRIBE_TYPE_CLOUD_DETAILS } Enumerates the subscription types.
Rdb_SyncMode { RDB_SYNC_MODE_TIME_FIRST, RDB_SYNC_MODE_NATIVE_FIRST, RDB_SYNC_MODE_CLOUD_FIRST } Enumerates the RDB sync modes.
Rdb_Progress { RDB_SYNC_BEGIN, RDB_SYNC_IN_PROGRESS, RDB_SYNC_FINISH } Enumerates the device-cloud sync progresses.
Rdb_ProgressCode {
RDB_SUCCESS, RDB_UNKNOWN_ERROR, RDB_NETWORK_ERROR, RDB_CLOUD_DISABLED,
RDB_LOCKED_BY_OTHERS, RDB_RECORD_LIMIT_EXCEEDED, RDB_NO_SPACE_FOR_ASSET
}
Enumerates the states in the device-cloud sync process.

Functions

Name Description
OH_Rdb_CreateValueObject (void) Creates an OH_VObject instance.
OH_Rdb_CreateValuesBucket (void) Creates an OH_VBucket instance.
OH_Rdb_CreatePredicates (const char *table) Creates an OH_Predicates instance.
OH_Rdb_GetOrOpen (const OH_Rdb_Config *config, int *errCode) Obtains an OH_Rdb_Store instance for RDB store operations.
OH_Rdb_CloseStore (OH_Rdb_Store *store) Destroys an OH_Rdb_Store object and reclaims the memory occupied by the object.
OH_Rdb_DeleteStore (const OH_Rdb_Config *config) Deletes an RDB store with the specified database file configuration.
OH_Rdb_Insert (OH_Rdb_Store *store, const char *table, OH_VBucket *valuesBucket) Inserts a row of data into a table.
OH_Rdb_Update (OH_Rdb_Store *store, OH_VBucket *valuesBucket, OH_Predicates *predicates) Updates data in an RDB store based on specified conditions.
OH_Rdb_Delete (OH_Rdb_Store *store, OH_Predicates *predicates) Deletes data from an RDB store based on specified conditions.
OH_Rdb_Query (OH_Rdb_Store *store, OH_Predicates *predicates, const char *const *columnNames, int length) Queries data in an RDB store based on specified conditions.
OH_Rdb_Execute (OH_Rdb_Store *store, const char *sql) Executes the SQL statement that returns no value.
OH_Rdb_ExecuteQuery (OH_Rdb_Store *store, const char *sql) Queries data in an RDB store based on the SQL statements executed.
OH_Rdb_BeginTransaction (OH_Rdb_Store *store) Starts the transaction before executing the SQL statements.
OH_Rdb_RollBack (OH_Rdb_Store *store) Rolls back the SQL statements that have been executed.
OH_Rdb_Commit (OH_Rdb_Store *store) Commits the executed SQL statements.
OH_Rdb_Backup (OH_Rdb_Store *store, const char *databasePath) Backs up the RDB store in the specified path.
OH_Rdb_Restore (OH_Rdb_Store *store, const char *databasePath) Restores an RDB store from the specified database backup file.
OH_Rdb_GetVersion (OH_Rdb_Store *store, int *version) Obtains the RDB store version.
OH_Rdb_SetVersion (OH_Rdb_Store *store, int version) Sets the RDB store version.
OH_Rdb_SetDistributedTables (OH_Rdb_Store *store, const char *tables[], uint32_t count, Rdb_DistributedType type, const Rdb_DistributedConfig *config) Sets distributed database tables.
OH_Rdb_FindModifyTime (OH_Rdb_Store *store, const char *tableName, const char *columnName, OH_VObject *values) Obtains the last modification time of a table in an RDB store.
OH_Rdb_Subscribe (OH_Rdb_Store *store, Rdb_SubscribeType type, const Rdb_DataObserver *observer) Register an observer for an RDB store. When data in the RDB store changes, a callback will be invoked to return the data changes.
OH_Rdb_Unsubscribe (OH_Rdb_Store *store, Rdb_SubscribeType type, const Rdb_DataObserver *observer) Unregisters the observer of the specified type.
OH_Rdb_GetTableDetails (Rdb_ProgressDetails *progress, int32_t version) Obtains the device-cloud sync statistics of a table.
OH_Rdb_CloudSync (OH_Rdb_Store *store, Rdb_SyncMode mode, const char *tables, int count, const Rdb_ProgressObserver *observer) Performs device-cloud sync.
OH_Rdb_SubscribeAutoSyncProgress (OH_Rdb_Store *store, const Rdb_ProgressObserver *observer) Subscribes to the automatic sync progress of an RDB store. The registered callback will be invoked to return the automatic sync progress.
OH_Rdb_UnsubscribeAutoSyncProgress (OH_Rdb_Store *store, const Rdb_ProgressObserver *observer) Unsubscribes from the automatic sync process of an RDB store.