PostgreSQL database user requirements
The PostgreSQL connector for Lakeflow Connect is in Public Preview. Reach out to your Databricks account team to enroll in the Public Preview.
This page describes the privileges required for the PostgreSQL replication user that you create for Databricks ingestion.
Standard PostgreSQL
Required privileges | Where to run the commands | Commands to grant |
|---|---|---|
| Database cluster (superuser required) | Run the following SQL commands: SQL |
| Target database | Run the following SQL command: SQL |
| Target database | Run the following SQL command for each schema: SQL |
| Target database | Run the following SQL command for each table or schema: SQL |
AWS RDS and Aurora PostgreSQL
Required privileges | Where to run the commands | Commands to grant |
|---|---|---|
| Any database | Run the following SQL commands: SQL |
| Target database | Run the following SQL command: SQL |
| Target database | Run the following SQL command for each schema: SQL |
| Target database | Run the following SQL command for each table or schema: SQL |
For AWS RDS and Aurora, you don't need superuser privileges. The rds_replication role provides the necessary replication privileges.
Azure Database for PostgreSQL
Required privileges | Where to run the commands | Commands to grant |
|---|---|---|
| Target database | Run the following SQL commands: SQL |
| Target database | Run the following SQL command: SQL |
| Target database | Run the following SQL command for each schema: SQL |
| Target database | Run the following SQL command for each table or schema: SQL |
For Azure Database for PostgreSQL Flexible Server, ensure logical replication is enabled in the server parameters. For Single Server, the azure_replication_support server parameter must be set to REPLICA.
GCP Cloud SQL for PostgreSQL
Required privileges | Where to run the commands | Commands to grant |
|---|---|---|
| Target database | Run the following SQL commands: SQL |
| Target database | Run the following SQL command: SQL |
| Target database | Run the following SQL command for each schema: SQL |
| Target database | Run the following SQL command for each table or schema: SQL |
System catalog privileges
The replication user requires SELECT privileges on system catalog tables for all PostgreSQL platforms.
Run the following SQL commands on the target database:
GRANT SELECT ON pg_catalog.pg_publication TO databricks_replication;
GRANT SELECT ON pg_catalog.pg_replication_slots TO databricks_replication;
GRANT SELECT ON pg_catalog.pg_namespace TO databricks_replication;
GRANT SELECT ON pg_catalog.pg_class TO databricks_replication;
GRANT SELECT ON pg_catalog.pg_attribute TO databricks_replication;
GRANT SELECT ON pg_catalog.pg_type TO databricks_replication;
GRANT SELECT ON pg_catalog.pg_index TO databricks_replication;
Verify replication user privileges
After granting the necessary privileges, verify that the replication user has the correct permissions:
-- Check replication privilege
SELECT rolname, rolreplication FROM pg_roles WHERE rolname = 'databricks_replication';
-- Check table privileges
SELECT grantee, privilege_type
FROM information_schema.table_privileges
WHERE grantee = 'databricks_replication' AND table_schema = 'your_schema';
-- Check schema privileges
SELECT nspname, has_schema_privilege('databricks_replication', nspname, 'USAGE') AS has_usage
FROM pg_namespace
WHERE nspname = 'your_schema';