Database

Lists databases¶

GET/api/v2/databases
Lists the accessible databases.

Query Parameters¶

ParameterDescription
like string
Query parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters.
startsWith string
Query parameter to filter the command output based on the string of characters that appear at the beginning of the object name. Uses case-sensitive pattern matching.
showLimit integer
Query parameter to limit the maximum number of rows returned by a command.
fromName string
Query parameter to enable fetching rows only following the first row whose object name matches the specified string. Case-sensitive and does not have to be the full name.
history boolean
Optionally includes dropped databases that have not yet been purged.

Response¶

CodeDescription
200
Successful request.
202
Successfully accepted the request, but it is not completed yet.

Creates a database¶

POST/api/v2/databases
Creates a database, with modifiers as query parameters. You must provide the full database definition when creating a database.

Query Parameters¶

ParameterDescription
createMode string
Query parameter allowing support for different modes of resource creation. Possible values include:
  • errorIfExists: Throws an error if you try to create a resource that already exists.
  • orReplace: Automatically replaces the existing resource with the current one.
  • ifNotExists: Creates a new resource when an alter is requested for a non-existent resource.
kind string
Type of database to create. Currently, Snowflake supports only `transient` and `permanent` (also represented by the empty string).

Response¶

CodeDescription
200
Successful request.
202

Creates a database from a share¶

POST/api/v2/databases:from-share
Creates a database from a given share.

Query Parameters¶

ParameterDescription
share string
ID of the share from which to create the database, in the form "<provider_account>.<share_name>".

Response¶

CodeDescription
200
202

Creates a database from a share (Deprecated)¶

POST/api/v2/databases/{name}:from_share
Creates a database from a given share.

Query Parameters¶

ParameterDescription
share string
ID of the share from which to create the database, in the form "<provider_account>.<share_name>".

Response¶

CodeDescription
200
202

Clones a database¶

POST/api/v2/databases/{name}:clone
Clones an existing database, with modifiers as query parameters. You must provide the full database definition when cloning an existing database.

Query Parameters¶

ParameterDescription
kind string
Type of database to create. Currently, Snowflake supports only `transient` and `permanent` (also represented by the empty string).

Response¶

CodeDescription
200
202

Fetches a database¶

GET/api/v2/databases/{name}
Fetches a database.

Path Parameters¶

ParameterDescription
name 
Identifier (i.e. name) for the resource.

Response¶

CodeDescription
200
successful
202

Creates a new, or alters an existing, database¶

PUT/api/v2/databases/{name}
Creates a new, or alters an existing, database. You must provide the full database definition even when altering an existing database.

Response¶

CodeDescription
200
202

Deletes a database¶

DELETE/api/v2/databases/{name}
Deletes the specified database. If you enable the `ifExists` parameter, the operation succeeds even if the database does not exist. Otherwise, a 404 failure is returned if the database does not exist. if the drop is unsuccessful.

Query Parameters¶

ParameterDescription
ifExists boolean
Query parameter that specifies how to handle the request for a resource that does not exist:
  • true: The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource.
  • false: The endpoint throws an error if the resource doesn't exist.
restrict boolean
Whether to drop the database if foreign keys exist that reference any tables in the database.
  • true: Return a warning about existing foreign key references and don't drop the database.
  • false: Drop the database and all objects in the database, including tables with primary or unique keys that are referenced by foreign keys in other tables.

Response¶

CodeDescription
200
202

Undrop a database¶

POST/api/v2/databases/{name}:undrop
Undrops database.

Response¶

CodeDescription
200
202

Enables database replication¶

POST/api/v2/databases/{name}/replication:enable
Promotes a local database to serve as a primary database for replication. A primary database can be replicated in one or more accounts, allowing users in those accounts to query objects in each secondary (i.e. replica) database.

Query Parameters¶

ParameterDescription
ignore_edition_check boolean
Whether to allow replicating data to accounts on lower editions. Default: `true`. For more information, see the <a href=https://docs.snowflake.com/en/sql-reference/sql/alter-database> ALTER DATABASE</a> reference.

Response¶

CodeDescription
200
202

Disables database replication¶

POST/api/v2/databases/{name}/replication:disable
Disables replication for this primary database, meaning no replica of this database (i.e. secondary database) in another account can be refreshed. Any secondary databases remain linked to the primary database, but requests to refresh a secondary database are denied.

Response¶

CodeDescription
200
202

Refreshes database replications¶

POST/api/v2/databases/{name}/replication:refresh
Refreshes a secondary database from a snapshot of its primary database. A snapshot includes changes to the objects and data. If you call this endpoint while another refresh for the same replica database is running, it fails and returns an error. Snowflake ensures only one refresh is executed at any given time.

Response¶

CodeDescription
200
202

Enables database failover¶

POST/api/v2/databases/{name}/failover:enable
Specifies a comma-separated list of accounts in your organization where a replica of this primary database can be promoted to serve as the primary database.

Response¶

CodeDescription
200
202

Disables database failover¶

POST/api/v2/databases/{name}/failover:disable
Disables failover for this primary database, meaning no replica of this database (i.e. secondary database) can be promoted to serve as the primary database.

Response¶

CodeDescription
200
202

Sets a primary database¶

POST/api/v2/databases/{name}/failover:primary
Promotes the specified secondary (replica) database to serve as the primary database. When promoted, the database becomes writeable. At the same time, the previous primary database becomes a read-only secondary database.

Response¶

CodeDescription
200
202