|
| 1 | +--- |
| 2 | +title: DB2 Reverse ETL Setup |
| 3 | +--- |
| 4 | + |
| 5 | +Set up DB2 as your Reverse ETL source. |
| 6 | + |
| 7 | +At a high level, when you set up DB2 for Reverse ETL, the configured database user must have read permissions on any tables involved in the query, and write permissions on a managed schema (`SEGMENT_REVERSE_ETL`) that Segment uses to track sync progress. Authentication is handled through username and password credentials configured in the Segment app. |
| 8 | + |
| 9 | +> info "DB2 Reverse ETL sources support Segment's dbt extension" |
| 10 | +> If you have an existing dbt account with a Git repository, you can use [Segment's dbt extension](/docs/segment-app/extensions/dbt/) to centralize model management and versioning, reduce redundancies, and run CI checks to prevent breaking changes. |
| 11 | +
|
| 12 | +## Required permissions |
| 13 | + |
| 14 | +In order to run a Reverse-ETL sync in a DB2 warehouse, Segment needs the following permissions: |
| 15 | + |
| 16 | +1. **Permission to read from all tables used in the model** (i.e., the tables included in your SELECT query). |
| 17 | +2. **Permission to create and manage a schema** for tracking sync metadata. |
| 18 | + |
| 19 | +In your DB2 instance, the commands to grant these permissions would look like: |
| 20 | + |
| 21 | +```sql |
| 22 | +-- Grant permissions to create schemas and manage objects within them |
| 23 | +GRANT CREATEIN ON DATABASE TO USER <username>; |
| 24 | +GRANT IMPLICIT_SCHEMA ON DATABASE TO USER <username>; |
| 25 | +GRANT DBADM ON DATABASE TO USER <username>; -- Optional but ensures full access |
| 26 | + |
| 27 | +-- Grant read access on each table used in the model |
| 28 | +GRANT SELECT ON TABLE <schema_name>.<table_name> TO USER <username>; |
| 29 | +``` |
| 30 | + |
| 31 | +> info "" |
| 32 | +> The `SEGMENT_REVERSE_ETL` schema will be created and managed by Segment to track the status of each sync. You can also choose to create this schema yourself and explicitly grant Segment privileges on it. |
| 33 | +
|
| 34 | +If you'd rather create the tracking schema yourself and limit the granted privileges: |
| 35 | + |
| 36 | +```sql |
| 37 | +CREATE SCHEMA SEGMENT_REVERSE_ETL; |
| 38 | + |
| 39 | +-- Grant full access on the schema to the Segment user |
| 40 | +GRANT USAGE ON SCHEMA SEGMENT_REVERSE_ETL TO USER <username>; |
| 41 | +GRANT CREATETAB ON SCHEMA SEGMENT_REVERSE_ETL TO USER <username>; |
| 42 | +GRANT DROPIN, ALTERIN ON SCHEMA SEGMENT_REVERSE_ETL TO USER <username>; |
| 43 | +``` |
| 44 | + |
| 45 | +> info "Use a dedicated user for Segment" |
| 46 | +> It's recommended to create a dedicated DB2 user for Segment with access limited to only the relevant schemas and tables. |
| 47 | +
|
| 48 | +## Set up guide |
| 49 | + |
| 50 | +To set up DB2 as your Reverse ETL source: |
| 51 | + |
| 52 | +1. Make sure your DB2 database is network-accessible from Segment's IPs. |
| 53 | +2. Create a dedicated user (or choose an existing one) with appropriate privileges. |
| 54 | +3. Open [your Segment workspace](https://app.segment.com/workspaces){:target="_blank"}. |
| 55 | +4. Navigate to **Connections > Sources** and select the **Reverse ETL** tab. |
| 56 | +5. Click **+ Add Reverse ETL source**. |
| 57 | +6. Select **DB2** and click **Add Source**. |
| 58 | +7. Enter the configuration settings for your DB2 source: |
| 59 | + * Hostname: `<hostname>` |
| 60 | + * Port: `<port>` (default) |
| 61 | + * Database: `<db_name>` |
| 62 | + * Username: `<segment_db2_user>` |
| 63 | + * Password: `<password>` |
| 64 | + * Schema [optional]: If not specified, Segment will use the user’s default schema |
| 65 | +8. Click **Test Connection** to validate the setup. |
| 66 | +9. If the connection is successful, click **Add source**. |
| 67 | + |
| 68 | +> warning "" |
| 69 | +> Segment only supports user/password authentication for DB2. |
| 70 | +> Ensure that your DB2 instance is configured to allow remote connections and the user has the necessary permissions. |
| 71 | +
|
| 72 | +After you've successfully added your DB2 source, [add a model](/docs/connections/reverse-etl/setup/#step-2-add-a-model) and follow the rest of the steps in the Reverse ETL setup guide. |
0 commit comments