> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omni.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Connecting Amazon Redshift to Omni

> Learn how to create a database user, grant permissions, and connect your Amazon Redshift data warehouse to Omni.

export const BaseAccess = () => {
  return <span>
      <ParamField path="Base Access" required>
        Select the <a href="/administration/users/permissions">minimum level of access</a> users should have to models in the connection.
      </ParamField>
    </span>;
};

export const AlwaysScopeViewNames = () => {
  return <span>
      <ParamField path="Always Scope View Names" default="enabled">
        When enabled, Omni will prefix generated view names with schema and catalog, e.g. <code>my_catalog_public__orders</code> instead of <code>orders</code>. Defaults to enabled. See <a href="/connect-data/view-name-generation">View name generation</a> for more information.
      </ParamField>
    </span>;
};

export const QueryTimeout = ({defaultValue}) => {
  return <span>
      <ParamField path="Query Timeout" default={defaultValue}>
        Maximum time in seconds before a query times out.
      </ParamField>
    </span>;
};

export const AutoGenerateRelationships = () => {
  return <span>
      <ParamField path="Auto-generate relationships" default="enabled">
        When enabled, Omni will automatically infer relationships between tables based on column name matching during schema refreshes. Defaults to enabled.
      </ParamField>
    </span>;
};

export const AllowUserSpecificTimezones = () => {
  return <span>
      <ParamField path="Allow User-Specific Timezones">
        When enabled, users can override the connection timezone with their own when querying.
      </ParamField>
    </span>;
};

export const QueryTimezone = () => {
  return <span>
      <ParamField path="Query Timezone" required>
        The timezone to use for Omni queries. If a timezone is specified, data will be converted from the <strong>Database Timezone</strong> to the selected timezone.
      </ParamField>
    </span>;
};

export const DatabaseTimezone = () => {
  return <span>
      <ParamField path="Database Timezone" required>
        The timezone used by the database.
      </ParamField>
    </span>;
};

export const Password = () => {
  return <span>
      <ParamField path="Password" required>
        The password for database authentication.
      </ParamField>
    </span>;
};

export const Username = () => {
  return <span>
      <ParamField path="Username" required>
        The username for database authentication.
      </ParamField>
    </span>;
};

export const Default = ({term = "Schema", required = true, defaultValue}) => {
  const lower = term.toLowerCase();
  return <span>
      <ParamField path={`Default ${term}`} required={required} default={defaultValue}>
        The default {lower} for the connection.
      </ParamField>
    </span>;
};

export const TableUploads = ({label = "Schema for Table Uploads", term = "schema"}) => {
  return <span>
      <ParamField path={label}>
        The name of the {term} to use for table (CSV) uploads. If left blank, you can upload tables but they won't be pushed to the database or be available for use in joins.
      </ParamField>
    </span>;
};

export const Offloaded = ({term = "Schemas"}) => {
  const lower = term.toLowerCase();
  return <span>
      <ParamField path={`Offloaded ${term}`}>
        A comma-separated list of {lower} to include in the connection, which will only load on demand. This setting is good for large {lower} or dbt dev {lower}.
      </ParamField>
    </span>;
};

export const Include = ({term = "Schemas"}) => {
  const lower = term.toLowerCase();
  return <span>
      <ParamField path={`Include ${term}`}>
        A comma-separated list of {lower} to include in the connection.
      </ParamField>
    </span>;
};

export const IncludeOther = ({term = "Schemas"}) => {
  const lower = term.toLowerCase();
  return <span>
      <ParamField path={`Include Other ${term}`}>
        A comma-separated list of other {lower} to include in the connection.
      </ParamField>
    </span>;
};

export const Database = () => {
  return <span>
      <ParamField path="Database" required>
        The database to connect to.
      </ParamField>
    </span>;
};

export const Port = ({defaultValue}) => {
  return <span>
      <ParamField path="Port" required default={defaultValue}>
        The port number for the database connection.
      </ParamField>
    </span>;
};

export const Host = ({additionalCopy}) => {
  return <span>
      <ParamField path="Host" required>
        The address of the database server. {additionalCopy}
      </ParamField>
    </span>;
};

export const DisplayName = () => {
  return <span>
      <ParamField path="Display Name" required>
        A user-friendly name for the connection, which will be used throughout Omni.
      </ParamField>
    </span>;
};

## Requirements

To follow the steps in this guide, you'll need:

* **Organization Admin permissions in Omni**
* **Permissions in Redshift** that allow you to create database users and grant permissions

## Setup

<Steps>
  <Step title="Create a database user for Omni" titleSize="h3">
    In your Redshift database, run the following command to create a database user for Omni:

    ```sql title="Create an Omni database user" theme={null}
    CREATE USER omni WITH PASSWORD '<password>';
    GRANT USAGE ON SCHEMA '<schema_name>' TO omni;
    GRANT SELECT ON TABLE information_schema.tables TO omni;
    GRANT SELECT ON TABLE information_schema.columns TO omni;
    ```

    Next, run the following command for each schema you want to use in Omni:

    ```sql title="Grant Omni access to schemas" theme={null}
    GRANT SELECT ON ALL TABLES IN SCHEMA '<schema_name>' TO omni;
    ```

    <Tip>
      If you're using Redshift views via dbt, Omni may not be granted permissions if there are dependencies with other schemas. To grant access to those views, you'll also need to grant `SELECT` access to the views. If objects are declared as tables, they will be available in Omni.
    </Tip>
  </Step>

  <Step title="Set up a table upload schema" titleSize="h3">
    <Callout icon="hand-point-up" color="#FF5FA2">
      **This step is optional.** However, we recommend completing it as part of the initial set up or you won't be able to use uploaded files like CSVs in joins.
    </Callout>

    In this step, you'll create a dedicated schema to use for [table uploads](/analyze-explore/data-input-csvs). This schema can't be used for other modeled tables.

    1. Create the schema in Redshift.
    2. Run the following to grant the Omni user the required privileges:

       ```sql title="Grant Omni access to table upload schema" theme={null}
       GRANT USAGE, CREATE ON SCHEMA 'upload_schema_name' TO omni;
       ```
  </Step>

  <Step title="Allowlist Omni's IP addresses" titleSize="h3">
    If access to the Redshift database is limited by IP address, you'll need to add Omni's IPs to the allowlist before you create the database connection. For Redshift, this typically means creating a security group and adding an inbound traffic rule for each IP address.

    Omni's IP addresses can be found on an individual connection's page, accessed by navigating to **Settings > Connections** and clicking a connection.
  </Step>

  <Step title="Create the connection in Omni" titleSize="h3">
    1. In Omni, click **Settings > Connections**.

    2. Click the **Redshift** option.

    3. On the connection setup page, fill in the connection details:

           <DisplayName />

           <Host />

           <Port defaultValue="5439" />

           <Database />

           <IncludeOther term="Databases" />

           <Include />

           <Offloaded />

           <TableUploads />

           <Default required={false} defaultValue="public" />

           <Username />

           <Password />

           <DatabaseTimezone />

           <QueryTimezone />

           <AllowUserSpecificTimezones />

           <AutoGenerateRelationships />

           <QueryTimeout defaultValue="900" />

           <AlwaysScopeViewNames />

           <BaseAccess />

    4. When finished, click **Create connection**.
  </Step>
</Steps>

## Connecting to Redshift datashares

[Redshift data sharing](https://docs.aws.amazon.com/redshift/latest/dg/datashare-overview.html) lets you share data across Redshift databases and clusters. To make datashare tables available in Omni, you need to create an external schema in the database Omni connects to and grant the Omni user access to it.

### Create an external schema

In the consumer database (the one Omni connects to), run:

```sql title="Create an external schema for the datashare" theme={null}
CREATE EXTERNAL SCHEMA <external_schema_name>
FROM REDSHIFT DATABASE '<datashare_database_name>'
SCHEMA '<source_schema_name>';
```

Replace the following placeholders:

* `<external_schema_name>` — the name the schema will have in your local database
* `<datashare_database_name>` — the name of the shared database
* `<source_schema_name>` — the schema within the shared database to expose

### Grant the Omni user access

Grant the Omni user usage on the external schema:

```sql title="Grant schema access to the Omni user" theme={null}
GRANT USAGE ON SCHEMA <external_schema_name> TO omni;
```

If the datashare was created with the `WITH_PERMISSIONS` flag, you also need to grant usage on the shared database:

```sql title="Grant database access (WITH_PERMISSIONS datashares only)" theme={null}
GRANT USAGE ON DATABASE '<datashare_database_name>' TO omni;
```

### Verify Omni can see the tables

To confirm the external schema and its tables are visible to the Omni user, run the following queries as the Omni user:

```sql title="Verify table visibility" theme={null}
SELECT * FROM SVV_TABLES WHERE table_schema = '<external_schema_name>';
```

```sql title="Verify column visibility" theme={null}
SELECT column_name FROM SVV_COLUMNS WHERE table_schema = '<external_schema_name>';
```

If both queries return rows, Omni will be able to discover and model the datashare tables.

## What's next?

Now that your database is set up, you can:

* Use the Omni Agent's [quickstart skill](/modeling/topics/quickstart) to create your first topic from business questions
* Configure user permissions, [schema refreshes](/modeling/develop/schema-refreshes), [environments](/connect-data/dynamic-environments) and [timezone settings](/connect-data/timezones)
* Learn how Omni [generates the model](/modeling/develop/model-generation) associated with the connection
