Skip to main content

databases

Creates, updates, deletes, gets or lists a databases resource.

Overview​

Namedatabases
TypeResource
Idovh.hosting_private_database.databases

Fields​

The following fields are returned by SELECT queries:

successful operation

NameDatatypeDescription
database_namestringDatabase name (wire: databaseName)
backup_timestring (time)Time of the next backup (every day) (example: 15:04:05) (wire: backupTime)
creation_datestring (date-time)Creation date of the database (wire: creationDate)
quota_usedobjectSpace used by the database (wire: quotaUsed)
usersarrayUsers granted to this database

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectdatabase_name, service_nameReturns the size and creation date of the database, its daily backup time and the users granted on it.
listselectservice_namex_pagination_modeReturns the names of the databases of the service.
createinsertservice_name, database_nameCreates an empty database on the service and returns a task to follow the creation. To also create a user with access to it, use the database wizard.
deletedeletedatabase_name, service_nameDeletes the database and returns a task to follow the deletion. Its dumps are kept as orphan dumps.
copy_restoreexecdatabaseName, serviceName, copyIdRestores a copy into the database. The database is not flushed before the restore unless requested.
importexecdatabaseName, serviceName, documentIdImports a dump file stored in /me/document into the database. The database is not flushed before the import unless requested.

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
api_hoststringThe OVHcloud API host. Selected by OVH_ENDPOINT (ovh-eu, ovh-ca or ovh-us; default ovh-eu). (default: api.eu.ovhcloud.com, x-stackQL-envVarSelector: {"envVar":"OVH_ENDPOINT","default":"ovh-eu","values":{"ovh-eu":"api.eu.ovhcloud.com","ovh-ca":"api.ca.ovhcloud.com","ovh-us":"api.us.ovhcloud.com"}})
databaseNamestringDatabase name
database_namestringDatabase name (wire: databaseName)
serviceNamestringService name
service_namestringService name (wire: serviceName)
x_pagination_modestringSent as CachedObjectList-Pages by default so the list returns the full objects rather than their identifiers. (wire: X-Pagination-Mode)

SELECT examples​

Returns the size and creation date of the database, its daily backup time and the users granted on it.

SELECT
database_name,
backup_time,
creation_date,
quota_used,
users
FROM ovh.hosting_private_database.databases
WHERE database_name = '{{ database_name }}' -- required
AND service_name = '{{ service_name }}' -- required
;

INSERT examples​

Creates an empty database on the service and returns a task to follow the creation. To also create a user with access to it, use the database wizard.

INSERT INTO ovh.hosting_private_database.databases (
database_name,
service_name
)
SELECT
'{{ database_name }}' /* required */,
'{{ service_name }}'
RETURNING
id,
dump_id,
database_name,
user_name,
done_date,
function,
last_update,
start_date,
status
;

DELETE examples​

Deletes the database and returns a task to follow the deletion. Its dumps are kept as orphan dumps.

DELETE FROM ovh.hosting_private_database.databases
WHERE database_name = '{{ database_name }}' --required
AND service_name = '{{ service_name }}' --required
;

Lifecycle Methods​

EXEC variables use wire (API) names.

Restores a copy into the database. The database is not flushed before the restore unless requested.

EXEC ovh.hosting_private_database.databases.copy_restore
@databaseName='{{ databaseName }}' --required,
@serviceName='{{ serviceName }}' --required
@@json=
'{
"copyId": "{{ copyId }}",
"flushDatabase": {{ flushDatabase }}
}'
;