# Snowflake

Add your Snowflake warehouse as an external catalog in Altertable to query and analyze it alongside your other data sources.

## Prerequisites

### Setup Snowflake Network Policy

Before connecting Snowflake to Altertable, you'll need to configure your Snowflake network policy to allow connections from Altertable.

Update your Snowflake network policy to include [Altertable's egress IP addresses](/docs/lakehouse/network.md#egress-ip-addresses) in the allowed list.

#### Example: Creating a Network Policy

You can create a network rule in and network policy to allow Altertable's IP address:

```sql
-- Create a network rule for Altertable's IP
CREATE NETWORK RULE altertable_network_rule
  MODE = INGRESS
  TYPE = IPV4
  VALUE_LIST = ('46.224.237.164', '46.4.253.101', '94.130.221.56', '188.40.149.154', '138.199.242.155', '138.199.241.17');

-- Create a network policy that uses the network rule
CREATE NETWORK POLICY altertable_network_policy
  ALLOWED_NETWORK_RULE_LIST = ('altertable_network_rule');

-- Apply the policy to your user
-- WARNING: This action may revoke the user's access to the Snowflake dashboard.
-- Using a dedicated user is recommended.
ALTER USER "<username>" SET NETWORK_POLICY = altertable_network_policy;

-- Or add the rule to an existing policy
ALTER NETWORK POLICY your_existing_policy
  ADD ALLOWED_NETWORK_RULE_LIST = ('altertable_network_rule');
```

This ensures that Altertable can establish connections to your Snowflake account. Refer to Snowflake's [network policy documentation](https://docs.snowflake.com/en/user-guide/network-policies) for more details on managing network policies.

### Create an Access Token

> **Recommendation: use an access token:**
>
> A programmatic access token isn't required—Altertable can authenticate with your password—but using one is recommended because it lets you:
>
> - Avoid sharing your Snowflake account password
> - Bypass multi-factor authentication (TOTP)
> - Revoke Altertable's access at any time without changing your password

Generate one for the user and role you want Altertable to connect with:

```sql
ALTER USER "<username>" ADD  PROGRAMMATIC ACCESS TOKEN altertable_token
  ROLE_RESTRICTION = '<role>'
  DAYS_TO_EXPIRY = 365;
```

## Connecting to Altertable

To add a new Snowflake external catalog:

1. Navigate to the **Catalogs** section in the dashboard

2. Click **New catalog**

3. Select **Snowflake** as the engine

4. Fill in the connection details:

   - **Snowflake Account URL**: Your Snowflake account URL ([learn how to find your account URL](https://docs.snowflake.com/en/user-guide/admin-account-identifier))
   - **Snowflake Warehouse**: The warehouse to use for queries ([learn more about warehouses](https://docs.snowflake.com/en/user-guide/warehouses-overview))
   - **Username**: Your Snowflake username
   - **Access Token**: Your Snowflake access token
   - **Database**: The name of the database to connect to
   - **Schema** (optional): The name of the schema to connect to

5. Click **Save**

![New Snowflake connection form](/screenshots/components-connectionform--snowflake-empty.png)

*New Snowflake connection form*

Once added, you can start querying your Snowflake data through Altertable's SQL engine.