Skip to main content

databases

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

Overview

Namedatabases
TypeResource
Iddatabricks_workspace.postgres.databases

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringThe resource name of the database. Format: projects/{project_id}/branches/{branch_id}/databases/{database_id}
create_timestring (date-time)A timestamp indicating when the database was created.
parentstringThe branch containing this database. Format: projects/{project_id}/branches/{branch_id}
specobjectThe desired state of the Database.
statusobjectThe observed state of the Database.
update_timestring (date-time)A timestamp indicating when the database was last updated.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_databasesselectproject_id, branch_id, deployment_namepage_size, page_tokenList Databases.
create_databaseinsertproject_id, branch_id, deployment_name, databasedatabase_idCreate a Database.

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
branch_idstringThe unique identifier of the branch where this Database will be created. Format: projects/{project_id}/branches/{branch_id}
deployment_namestringThe Databricks Workspace Deployment Name (default: dbc-abcd0123-a1bc)
project_idstringThe unique identifier of the Postgres project. Format: projects/{project_id}
database_idstringThe ID to use for the Database, which will become the final component of the database's resource name. This ID becomes the database name in postgres. This value should be 4-63 characters, and only use characters available in DNS names, as defined by RFC-1123 If database_id is not specified in the request, it is generated automatically.
page_sizeintegerUpper bound for items returned.
page_tokenstringPagination token to go to the next page of Databases. Requests first page if absent.

SELECT examples

List Databases.

SELECT
name,
create_time,
parent,
spec,
status,
update_time
FROM databricks_workspace.postgres.databases
WHERE project_id = '{{ project_id }}' -- required
AND branch_id = '{{ branch_id }}' -- required
AND deployment_name = '{{ deployment_name }}' -- required
AND page_size = '{{ page_size }}'
AND page_token = '{{ page_token }}'
;

INSERT examples

Create a Database.

INSERT INTO databricks_workspace.postgres.databases (
database,
project_id,
branch_id,
deployment_name,
database_id
)
SELECT
'{{ database }}' /* required */,
'{{ project_id }}',
'{{ branch_id }}',
'{{ deployment_name }}',
'{{ database_id }}'
;