More about preparing a PostgreSQL destination¶
Why these privileges¶
| Privilege | Why it's needed |
|---|---|
LOGIN and CONNECT on the database |
To connect. |
Ownership of the schema (AUTHORIZATION sqdruser) |
To create tables in it. The tables the role creates belong to it, so it can alter, index, truncate and drop them, and read and change their rows, without other grants. |
TEMPORARY on the database |
For the temporary merge tables of Merge groups and the temporary work tables of ADD Copy. PostgreSQL grants it to PUBLIC by default; grant it explicitly if it was revoked. |
Tables in a schema the role doesn't own¶
To create the tables in an existing schema another role owns, grant the use of the schema and the right to create in it:
GRANT USAGE, CREATE ON SCHEMA myschema TO sqdruser;
The tables the Replicator Service creates there still belong to sqdruser. Since PostgreSQL 15, the public schema
no longer lets every role create tables: grant CREATE ON SCHEMA public the same way if you use it.
Tables owned by another role. Only the owner (or a member of the owning role) can alter, index or drop a table.
Either make sqdruser a member of that role (GRANT app_owner TO sqdruser;), or use Use existing table for
baseline for their subscriptions, so the Replicator Service never creates, alters, drops or indexes them, and grant
the table privileges:
GRANT USAGE ON SCHEMA myschema TO sqdruser;
GRANT SELECT, INSERT, UPDATE, DELETE, TRUNCATE ON ALL TABLES IN SCHEMA myschema TO sqdruser;
| Privilege | Why it's needed |
|---|---|
SELECT |
UPDATE and DELETE statements whose WHERE clause reads the key columns, and the MERGE. |
INSERT, UPDATE, DELETE |
Loading and applying changes. |
TRUNCATE |
Truncate table before replication. Without it, use Delete existing data before replication. |
Then create the index on the replication key yourself (see The key at the destination).
Names and search_path¶
PostgreSQL folds unquoted names to lower case. With Fold case of identifiers per destination default and Quote SQL
identifiers on (the defaults; see Options that change the mapping), the
Replicator Service creates table and column names in lower case and quotes them, so you can query the tables without
quotes. With folding off, upper-case names from sources such as Db2 or Oracle stay upper case and must be quoted in
every query: SELECT "CUSTNO" FROM myschema."CUSTOMER".
The Replicator Service names the destination tables with their schema, so the role's search_path needn't include
it.