More about preparing a Db2 for LUW or Db2 for z/OS destination¶
Privileges on Db2 for LUW¶
Why the user in Db2 for LUW needs each privilege:
| Privilege | Why it's needed |
|---|---|
CONNECT on the database |
To connect. |
CREATETAB on the database, USE of the table space |
To create the destination tables (CREATE TABLE needs both). |
Ownership of the schema (AUTHORIZATION SQDRUSER) |
The schema owner can create, alter and drop objects in it. The tables the user creates are its own, with CONTROL on them, so it can index, alter, truncate and drop them, and read and change their rows, without other grants. |
USE of a user temporary table space |
Merge groups and ADD Copy declare temporary tables, which Db2 for LUW creates only in a user temporary table space that the user may use and whose page size fits the row. Without one, the declare fails (SQL0286N) and the group reports a polling error. A 32 KB page size fits the widest rows. |
EXECUTE on SYSPROC.ADMIN_CMD |
ALTER processing reorganizes the table after altering it. The REORG also needs the system temporary table space TEMPSPACE1, which Db2 creates with the database; and authority to reorganize the table, which CONTROL on it gives. |
Privileges on Db2 for z/OS¶
Why the user in Db2 for z/OS needs each privilege or setting:
| Privilege or setting | Why it's needed |
|---|---|
CREATETAB and CREATETS on DSNDB04 |
To create the destination tables in implicitly created databases and table spaces. The user owns the tables it creates, so it can index, alter, truncate and drop them, and read and change their rows. |
| A work file table space with a 32 KB page size | Merge groups and ADD Copy declare temporary tables, which Db2 for z/OS keeps in the work file database; Db2 can't declare one unless that database has a table space with a page size of at least 32 KB. Declaring them needs no privilege. |
Test the privileges¶
The privileges are first used when a subscription runs. When you create subscriptions, you can test them first with a snapshot subscription of a small table. Its replication events show each step and any Db2 error.
Tables you create yourself¶
Tables owned by another user (Db2 for LUW)¶
For existing tables that SQDRUSER doesn't own, use Use existing table for baseline or Use existing table in
their subscriptions and grant the table privileges:
GRANT SELECT, INSERT, UPDATE, DELETE, ALTER ON TABLE MYSCHEMA.MYTABLE TO USER 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. DELETE is also the privilege TRUNCATE needs. |
ALTER |
TRUNCATE ... IMMEDIATE ignores delete triggers, which needs ALTER (or CONTROL). Without it, use Delete existing data before replication. |
Then create the index on the replication key yourself.
Tables in your own databases and table spaces (Db2 for z/OS)¶
If your standards don't allow implicitly created objects, create the tables yourself and use Use existing table for
baseline (incremental) or Use existing table (snapshot) in their subscriptions, so the Replicator Service never
creates, alters, indexes or drops them. Grant SELECT, INSERT, UPDATE, DELETE on them (and ALTER for Truncate
table before replication, which ignores delete triggers), and create the index on the replication key yourself (see
The key at the destination).