Configure a Postgres internal storage integration for Snowflake Postgres¶
A Snowflake Postgres internal storage integration allows you to read from and write to the managed storage associated with a Snowflake Postgres instance. This feature enables seamless data movement between Snowflake and your Postgres instances using an external stage. For the full SQL syntax, see CREATE STORAGE INTEGRATION (Postgres Internal Storage).
Postgres instances in Snowflake come with managed storage allocated by the Postgres instance. While users can already access this storage to read files through Iceberg tables using a Snowflake Postgres catalog integration, a storage integration provides a path to write data from Snowflake to the Postgres managed bucket.
Note
Postgres internal storage integrations are currently supported on AWS and Azure only.
Prerequisites¶
A Snowflake account with the Snowflake Postgres feature enabled.
A Postgres instance in READY state. To create a Postgres instance, see CREATE POSTGRES INSTANCE.
The role that creates the storage integration must have the following privileges:
OWNERSHIPon the Postgres instance.CREATE INTEGRATIONon the account.
Considerations¶
Consider the following when you use a Postgres internal storage integration:
Cloud provider support: This feature currently supports AWS and Azure only.
Stage restrictions: When creating a stage (see CREATE STAGE) that uses a Postgres internal storage integration, the
URL,ENCRYPTION, andDIRECTORYstage properties are disallowed.Path configuration: The integration automatically appends a
/filessubpath to the base storage location retrieved from the Postgres instance.
Create a storage integration for Postgres internal storage¶
To create a storage integration for Postgres internal storage, use the
CREATE STORAGE INTEGRATION (Postgres Internal Storage)
command with TYPE = POSTGRES_INTERNAL_STORAGE.
For example:
Where:
TYPE = POSTGRES_INTERNAL_STORAGE: Specifies the integration type for Postgres managed storage. Required.POSTGRES_INSTANCE = '<instance_name>': Specifies the name of the Snowflake Postgres instance. Required.
For the full syntax and parameter reference, see CREATE STORAGE INTEGRATION (Postgres Internal Storage).
Create a stage for Postgres storage¶
After creating the integration, you can create an external stage to interact with the storage. Use
the RELATIVE_URL property to specify a user-chosen path prefix under the Postgres managed
storage that this stage should reference. This value is an arbitrary path that you define to
organize files within the managed storage location.
For example:
Move data between Snowflake and Postgres¶
You can use the COPY FILES command to move data between Snowflake stages and your Postgres
managed storage. These examples assume you have already created a separate Snowflake stage
in addition to the Postgres stage created above.
Snowflake to Postgres (write)¶
To move data from an existing Snowflake stage into the Postgres managed storage:
Where <source_stage> refers to a pre-existing Snowflake stage that contains the files you want
to move, and <postgres_stage> is the Postgres stage created in the previous step.
On the Postgres side, you can then load the data:
Where @STAGE is a preconfigured placeholder for the stage location on the Postgres side.
Postgres to Snowflake (read)¶
To move data written by Postgres back into an existing Snowflake stage:
Where <destination_stage> refers to a pre-existing Snowflake stage where you want to copy
the files, and <postgres_stage> is the Postgres stage created earlier.
Access control¶
The standard Snowflake storage integration privilege model applies:
Ownership: The role that creates the integration must own the associated Postgres instance.
Usage: To use the integration to create a stage, a role must have the
USAGEprivilege on the integration object.Stage privileges: Users need standard privileges (for example,
READ,WRITE) on the stage itself to perform data movement operations.
For example, to grant another role the ability to create stages using the storage integration: