CREATE POSTGRES INSTANCE

statementpartialContainer services & dev tooling

docs.snowflake.com ↗

Object: POSTGRES INSTANCE

Creates a new Snowflake Postgres instance or creates a fork of an existing instance. Forking creates a full, independent copy of an instance at a specific point in time using point-in-time recovery (PITR). This is useful for recovery, testing, or creating development environments from production data.

Syntax

supportedpartialnot supportednot scored

CREATE POSTGRES INSTANCE [ IF NOT EXISTS ] <name>
  COMPUTE_FAMILY = '<compute_family>'
  STORAGE_SIZE_GB = <storage_gb>
  AUTHENTICATION_AUTHORITY = { POSTGRES | POSTGRES_OR_SNOWFLAKE | EXTERNAL_OAUTH }
  [ AUTHENTICATION_PROPERTIES = ( <authentication_properties> ) ]
  [ POSTGRES_VERSION = { 16 | 17 | 18 } ]
  [ NETWORK_POLICY = '<network_policy>' ]
  [ HIGH_AVAILABILITY = { TRUE | FALSE } ]
  [ STORAGE_INTEGRATION = '<storage_integration_name>' ]
  [ POSTGRES_SETTINGS = '<json_string>' ]
  [ COMMENT = '<string_literal>' ]
  [ [ WITH ] TAG ( <tag_name> = '<tag_value>' [ , ... ] ) ]

The following syntax creates a fork of an existing instance at a point in time. The FORK clause uses point-in-time recovery with the same AT | BEFORE syntax as Time Travel, but creates a full physical copy of the Postgres instance

CREATE POSTGRES INSTANCE [ IF NOT EXISTS ] <name>
  FORK <source_instance>
  [ { AT | BEFORE } ( { TIMESTAMP => <timestamp> | OFFSET => <time_difference> } ) ]
  [ COMPUTE_FAMILY = '<compute_family>' ]
  [ STORAGE_SIZE_GB = <storage_gb> ]
  [ HIGH_AVAILABILITY = { TRUE | FALSE } ]
  [ POSTGRES_SETTINGS = '<json_string>' ]
  [ COMMENT = '<string_literal>' ]
  [ [ WITH ] TAG ( <tag_name> = '<tag_value>' [ , ... ] ) ]

Parameters

NameRequiredDescription
namerequiredSpecifies the identifier (name) for the Postgres instance; must be unique for the account. In addition, the identifier must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes (for example, "My object"). Identifiers enclosed in double quotes are also case-sensitive. For more information, see Identifier requirements.
COMPUTE_FAMILY = 'compute_family'requiredSpecifies the instance size for the Postgres instance. Snowflake Postgres offers three tiers: Burstable (BURST_S, BURST_M): Cost-effective for development and intermittent workloads. Limited to 100GB storage and does not support high availability. Standard (STANDARD_M through STANDARD_24XL): Balanced CPU and memory for general-purpose workloads. Supports all features including high availability. Memory-optimized (HIGHMEM_L through HIGHMEM_48XL): Higher memory-to-CPU ratio for memory-intensive queries and large indexes. Supports all features including high availability. Note Some features require specific compute families. For example, high availability (HIGH_AVAILABILITY = TRUE) is only available on STANDARD and HIGHMEM instances, not on BURST instances.
STORAGE_SIZE_GB = storage_gbrequiredSpecifies the storage size in GB. Must be between 10 and 65,535. Storage is billed separately from compute based on the allocated amount. You can increase or decrease storage size later using ALTER POSTGRES INSTANCE. For more information about costs, see Snowflake Postgres Cost Evaluation. Note When you decrease the storage size, you can’t set it too close to current disk usage. The new size must be at least 1.4x the disk space currently in use. That way, there’s still room to add more data without triggering an automatic storage increase.
AUTHENTICATION_AUTHORITY = { POSTGRES | POSTGRES_OR_SNOWFLAKE | EXTERNAL_OAUTH }requiredSpecifies the authentication authority for the instance: POSTGRES: Postgres authentication. Only Postgres login roles and passwords. This is the default. POSTGRES_OR_SNOWFLAKE: Snowflake token authentication. The instance accepts Postgres passwords and short-lived Snowflake token passwords. EXTERNAL_OAUTH: External OAuth. Access tokens from an external identity provider. Requires AUTHENTICATION_PROPERTIES. For the dialog, the stored audience, the limit of 10 accepted tokens, and when two accepted tokens are rejected, see Configure authentication for Snowflake Postgres.
IF NOT EXISTSoptionalCreates the Postgres instance only if an instance with the same name does not already exist. If an instance with the same name already exists, the command does nothing and completes successfully without creating a new instance. Use this clause to run the command idempotently, for example when re-running a provisioning script or a Terraform plan.
AUTHENTICATION_PROPERTIES = ( <authentication_properties> )optionalSpecifies the External OAuth configuration. Required when AUTHENTICATION_AUTHORITY = EXTERNAL_OAUTH. Specifying these properties with POSTGRES or POSTGRES_OR_SNOWFLAKE returns an error. The properties are ISSUER, AUDIENCE, and ACCEPTED_TOKENS. Each accepted token has MAPPING_CLAIM, SCOPES_CLAIM, and SCOPES. For the dialog, the stored audience, the limit of 10 accepted tokens, and when two accepted tokens are rejected, see Configure authentication for Snowflake Postgres.
POSTGRES_VERSION = { 16 | 17 | 18 }optionalSpecifies the major version of Postgres to use. While the latest version includes new features and improvements, you might choose an earlier version for application compatibility or to match existing instances. You can upgrade to a newer version later using ALTER POSTGRES INSTANCE. Default: The latest Postgres version.
NETWORK_POLICY = 'network_policy'optionalSpecifies the network policy to use for the instance. To specify this parameter, you must have been granted the USAGE privilege on the network policy object. Default: No network policy is applied. Important Without a network policy, the instance can’t accept incoming connections. You can still view the instance using SHOW and DESCRIBE commands, but can’t connect to the Postgres database until you attach a network policy using ALTER POSTGRES INSTANCE.
STORAGE_INTEGRATION = 'storage_integration_name'optionalAttaches a storage integration of type POSTGRES_EXTERNAL_STORAGE to the Postgres instance, enabling the pg_lake extension to access data in external object storage. For the complete setup procedure, see pg_lake. You can also attach or remove a storage integration later using ALTER POSTGRES INSTANCE. Preview Feature — Open Available to all accounts. Default: No storage integration is attached.
HIGH_AVAILABILITY = { TRUE | FALSE }optionalSpecifies whether to enable high availability for the instance. High availability provisions a standby instance in a separate availability zone for automatic failover. This minimizes downtime if the primary becomes unavailable. Without HA, recovery requires restoring from backup, which can take hours for large or active instances. Note that enabling or disabling HA later using ALTER POSTGRES INSTANCE requires a maintenance operation. Important Burstable instance sizes (BURST_S, BURST_M) do not support high availability. Default: FALSE
POSTGRES_SETTINGS = 'json_string'optionalSpecifies custom Postgres server settings for the instance in JSON format:Copy code '{"component:name": "value", ...}' The format uses component:name where component is either postgres (for PostgreSQL server settings) or pgbouncer (for connection pooler settings). For example:Copy code '{"postgres:work_mem": "128MB", "pgbouncer:default_pool_size": "200"}' See Snowflake Postgres Server Settings for available settings. Default: No custom Postgres configuration parameters are set.
COMMENT = 'string_literal'optionalSpecifies a comment for the Postgres instance. Comments are useful for documenting the purpose or ownership of an instance, such as “Production instance for billing service” or “QA environment for team X”. Unlike tags, comments are free-form text and not used for organization or cost tracking. Default: No value.
TAG ( tag_name = 'tag_value' [ , tag_name = 'tag_value' , ... ] )optionalSpecifies the tag name and the tag string value. The tag value is always a string, and the maximum number of characters for the tag value is 256. For information about specifying tags in a statement, see Tag quotas.
FORK source_instanceCreates a new instance as a fork (copy) of the specified source instance. To create a fork of a given source instance, you mush be granted the OWNERSHIP privilege on it.
{ AT | BEFORE } ( { TIMESTAMP => timestamp | OFFSET => time_difference } )Specifies the point in time to fork from. You can’t fork from a point in time more than 10 days in the past. The timestamp or offset must fall within the 10-day Postgres data retention period. The AT | BEFORE clause accepts one of the following parameters: Default: Uses the current time.
TIMESTAMP => timestampSpecifies an exact date and time to use for Time Travel. The value must be explicitly cast to a TIMESTAMP, TIMESTAMP_LTZ, TIMESTAMP_NTZ, or TIMESTAMP_TZ data type.
OFFSET => time_differenceSpecifies the difference in seconds from the current time, in the form -N where N can be an integer or arithmetic expression (for example, -120 is 120 seconds, -30*60 is 30 minutes).

Usage notes

Output

When you create a new instance, the command returns one row with the following columns: Column | Description status | Status of the create operation. host | Hostname for connecting to the instance. access_roles | User names and passwords for the snowflake_admin and application roles. For an External OAuth instance, only snowflake_admin is returned. default_database | Default database for the instance. Important The access_roles column contains credentials that you can’t retrieve later. Save these details in a secure location. When you create a fork, the command returns one row with only status and host columns. The fork uses the same credentials that the source instance had, at the point in time that the fork corresponds to.

Access control requirements

A role used to execute this operation must have the following privileges at a minimum: Privilege | Object | Notes CREATE POSTGRES INSTANCE | Account | By default, only the ACCOUNTADMIN role has this privilege. OWNERSHIP | Postgres instances | Required on existing instance to create a fork of it. USAGE | Network policy | Required only if specifying a NETWORK_POLICY. USAGE | Storage integration | Required only if specifying a STORAGE_INTEGRATION. For instructions on creating a custom role with a specified set of privileges, see Creating custom roles. For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

Known gaps

Parts not fully supported, and recorded divergences from Snowflake.

See also

Referenced by