RelationalAI Schema Management#

RelationalAI (RAI) schemas are used to organize data and logic within the RAI Native App for Snowflake. Each schema includes procedures, functions, and views for data interaction, along with application roles to grant appropriate user privileges to the schema.

Data are streamed from Snowflake tables and views into a RAI schema for consumption by the relationalai Python package. Schema users can access data in the schema, but not in other schemas, unless explicitly granted permission.

Managing RAI Schemas#

You can manage RAI schemas using SQL procedures provided by the RAI Native App. To manage RAI schemas, you must have schema_admin application role privileges.

Create a Schema#

Use the create_schema() procedure to create a schema:

-- NOTE: RAI schema names are case-sensitive.
CALL relationalai.api.create_schema('<schema_name>');

Replace <schema_name> with the name of the schema you want to create.

The new schema contains functions and stored procedures for data interaction as well as a set of application roles to grant user access to the schema.

Clone a RAI Schema#

You may clone an existing schema using the clone_schema() procedure:

-- NOTE: RAI schema names are case-sensitive.
CALL relationalai.app.clone_schema('<target_schema_name>', '<source_schema_name>');

Snapshots of the source schema’s data are cloned into the target schema. However, CDC streams are not cloned and must be recreated in the new schema.

The target schema receives a new set of schema-specific roles. These roles must be granted to users who need access to the new schema.

Delete a RAI Schema#

To delete a schema, use the delete_schema() procedure:

-- Note: RAI schema names are case sensitive.
CALL relationalai.api.delete_schema('<schema_name>');

Deleting a schema removes all SQL objects and RAI resources, including CDC streams and Python models, within the schema.

List All RAI Schemas#

To view a list of all schemas you have access to, query the schemas view:

SELECT * FROM relationalai.api.schemas;