# DB2 (beta)

1. [Create a Service Account](#id-1.-create-a-service-account)
2. [Create a new datasource in Select Star](#id-2.-create-a-new-data-source-in-select-star)
3. [Choose databases and schemas](#id-3.-choose-databases-and-schemas)

For instances operating within a non-publicly accessible environment, such as a private network, please refer to our guide on [Integrating Private Network Data Sources](https://docs.selectstar.com/integrations/private-network) for detailed instructions and best practices.

## 1. Create a Service Account

We recommend creating a dedicated service account for Select Star with metadata-only roles and permissions. To create a new DB2 user please follow the guidelines mentioned [here](https://www.ibm.com/docs/en/samfess/8.2.0?topic=schema-creating-users-manually).

DB2 user must have SELECT privilege on:

* `SYSCAT.SCHEMATA`
* `SYSCAT.TABLES`
* `SYSCAT.INDEXES`
* `SYSCAT.TABCONST`
* `SYSCAT.KEYCOLUSE`
* `SYSCAT.SQLFOREIGNKEYS`
* `SYSCAT.COLUMNS`
* `SYSCAT.VIEWS`
* `SYSCAT.SEQUENCES`

Sample SQL query to grant `SELECT` privilege on the required tables:

```sql
GRANT SELECT ON SYSCAT.SCHEMATA TO <username>;
GRANT SELECT ON SYSCAT.TABLES TO <username>;
GRANT SELECT ON SYSCAT.INDEXES TO <username>;
GRANT SELECT ON SYSCAT.TABCONST TO <username>;
GRANT SELECT ON SYSCAT.KEYCOLUSE TO <username>;
GRANT SELECT ON SYSCAT.SQLFOREIGNKEYS TO <username>;
GRANT SELECT ON SYSCAT.COLUMNS TO <username>;
GRANT SELECT ON SYSCAT.VIEWS TO <username>;
GRANT SELECT ON SYSCAT.SEQUENCES TO <username>;
```

## 2. Create a new data source in Select Star

* **Display Name** - The Name you want to give to your new datasource.
* **Hostname** - Your hostname defines the location where your database is hosted.
* **Port** - The communication endpoint used to connect clients to the DB2 instance.
* **Username** - Specify the User to connect to the DB2 instance. It should have enough privileges to read all the metadata.
* **Password** - Password.
* **Database** - The database name.

![Create Data Source](https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-794be77d7f75087f28879fa24a5d8c59d0a216a7%2Fdb2-form.png?alt=media)

{% hint style="info" %}
Select Star currently does not support Popularity and Lineage is only supported for views in this integration. If needed, please feel free to contact us so we can explore alternative solutions.
{% endhint %}

## 3. Choose databases and schemas

After you fill in the information, you'll be asked to select the databases you'd like to load into Select Star.

{% hint style="info" %}
Select Star will not read metadata for databases, schemas, or tables that are not loaded. Please load all data for which you expect to see metadata.

You can [change the databases and schemas](https://docs.selectstar.com/data-source-management/manage-data-sources#configure-a-data-source) you have loaded if needed.
{% endhint %}

Your metadata should start loading automatically, once the sync is complete, you'll be able to see it in Select Star.

See the link below for more information on how to navigate through data warehouses.

{% content-ref url="../learning-data/getting-started-data-warehouse" %}
[getting-started-data-warehouse](https://docs.selectstar.com/learning-data/getting-started-data-warehouse)
{% endcontent-ref %}
