Skip to content

Managing RAI Database Links

Learn how to manage and configure RAI database links. A RAI database link is a core component that provides Snowflake users access to the RAI Integration Services.

Introduction

What is a RAI Database Link?

A RAI database link is the main component of the RAI Integration Services.

A RAI database link comes with the SQL Library for Snowflake, consisting of user-defined functions and procedures. The SQL Library for Snowflake provides functionality for core tasks like creating and managing RAI data streams, as well as for application-focused workloads around graph analytics and schema mapping.

The management of the various RAI resources that are enabled by the SQL Library for Snowflake also happens inside a RAI database link.

The RAI database link is located in a Snowflake database and schema that you must specify during creation.

🔎

A RAI database link is the collection of objects within a Snowflake schema that enables and manages RAI resources and functionalities.

RAI Database Link Versus RAI Integration

A RAI database link uses a RAI integration to communicate with the RAI resources. The RAI integration needs to be specified during the creation of the RAI database link and cannot be changed.

🔎

A RAI database link belongs to a RAI integration.

However, multiple RAI database links can use the same RAI integration.

Managing a RAI Database Link

This section discusses how to create, update, and delete RAI database links within a specific RAI integration. It also provides details on how to retrieve information for certain RAI database links.

To manage a RAI database, you generally need to know the RAI integration that the RAI database link is using.

Even though the owner of the RAI database link is the Snowflake role <integration_user_role>, specified during creation, its creation and deletion requires ACCOUNTADMIN privileges.

Creating a RAI Database Link

To create a RAI database link and install the SQL Library for Snowflake in the schema <sf_database_name>.<sf_schema_name> using the RAI integration <rai_integration_name>, execute the following command:

rai create-snowflake-database-link <rai_integration_name>  \
    --database=<sf_database_name>                          \
    --schema=<sf_schema_name>                              \
    --role=<integration_user_role>                         \
    --profile=<rai_admin_profile>                          \
    --username=<sf_username>                               \
    --password=<sf_password>

The table below explains each option for the rai create-snowflake-database-link command:

OptionValueDescription
RAI integration name<rai_integration_name>RAI integration name.
Database name<sf_database_name>Snowflake database.
Role name<integration_user_role>The Snowflake user role that will own the RAI database link.
Schema name<sf_schema_name>Snowflake schema. By default, the schema is rai.
RAI profile<rai_admin_profile>RAI profile name.
Admin username<sf_username>Your Snowflake admin username.
Admin password<sf_password>Your Snowflake admin password.
🔎

By default, a RAI database link installs the SQL Library for Snowflake in the schema rai.

The Snowflake role <integration_user_role>, specified during creation, is the owner of the RAI database link.

🔎

All the objects associated with this RAI database link — including the SQL Library for Snowflake — are owned by <integration_user_role>.

However, you need ACCOUNTADMIN privileges in Snowflake to create a RAI database link.

Getting Information for a RAI Database Link

Retrieve information about a RAI database link with the following command:

rai get-snowflake-database-link <rai_integration_name> --database <sf_database_name> --schema rai

This gives the following JSON output:

{
    "id": "08******",
    "name": "<sf_database_name>.rai",
    "account": "<rai_account_name>",
    "createdBy": "******n@clients",
    "createdOn": "2023-06-13T23:13:11.492Z",
    "state": "CREATED",
    "integration": "<rai_integration_name>",
    "snowflake": {
        "database": "<sf_database_name>",
        "schema": "rai"
    }
}

You can also check the RAI database link status by listing all available RAI database links within your RAI integration:

rai list-snowflake-database-links <rai_integration_name>

Updating a RAI Database Link

To ensure that you have the latest version of the SQL Library for Snowflake, you need to update your RAI database link. To update a RAI database link, execute the following command:

rai update-snowflake-database-link <rai_integration_name>  \
    --database=<sf_database_name>                          \
    --schema=<sf_schema_name>                              \
    --role=<integration_user_role>                         \
    --profile=<rai_admin_profile>                          \
    --username=<sf_username>                               \
    --password=<sf_password>

The table below explains each option for the rai update-snowflake-database-link command:

OptionValueDescription
RAI integration name<rai_integration_name>RAI integration name.
Database name<sf_database_name>Snowflake database.
Role name<integration_user_role>The Snowflake user role that will own the RAI database link.
Schema name<sf_schema_name>Snowflake schema. By default, the --schema flag is rai.
RAI profile<rai_admin_profile>RAI profile name (located in <HOME_DIR>/.rai/config).
Admin username<sf_username>Your Snowflake admin username.
Admin password<sf_password>Your Snowflake admin password.

By updating the RAI database link, you only update existing and add new functions and procedures. Deprecated functions and procedures are not removed.

âš 

To remove deprecated versions of the SQL Library for Snowflake, you have to delete and recreate the RAI database link.

Deleting a RAI Database Link

To delete a RAI database link, execute the following command:

rai delete-snowflake-database-link <rai_integration_name>  \
    --database=<sf_database_name>                          \
    --schema=<sf_schema_name>                              \
    --role=<integration_user_role>                         \
    --profile=<rai_admin_profile>                          \
    --username=<sf_username>                               \
    --password=<sf_password>

The table below explains each option for the rai update-snowflake-database-link command:

OptionValueDescription
RAI integration name<rai_integration_name>RAI integration name.
Database name<sf_database_name>Snowflake database.
Role name<integration_user_role>The Snowflake user role that will own the RAI database link.
Schema name<sf_schema_name>Snowflake schema. By default, the --schema flag is rai.
RAI profile<rai_admin_profile>RAI profile name.
Admin username<sf_username>Your Snowflake admin username.
Admin password<sf_password>Your Snowflake admin password.

By deleting a RAI database link, you also delete all SQL objects associated with it. All RAI data streams, graphs, and schema mappings will be deleted.

See Also

For more information on configuring and managing RAI resources from Snowflake, check out the RAI Resources guide.

Was this doc helpful?