Snowflake

Database & Schema

Basic Object model

Organization-->Account-->Database-->Schema-->Tables, views etc.

Database

A Database is a logical container that holds a set of schemas, tables, views and other database objects.

A Database name should be unique in the account.

Database names should start with the alphabet and should not contain any special characters.
Creating a Database in Snowflake

New database creation.

CREATE DATABASE snowflake_demo_DB

It can be cloned from another database.

CREATE DATABASE snowflake_demo_clone_DB CLONE snowflake_demo_DB

It can replicate from another account till the retention period.

If the organization and account are different the database can be cloned.

CREATE DATABASE snowflake_demo_DB as REPLICA OF ORG.ACC.snowflake_demo_DB DATA_RETENCTION_TIME_IN_DAYS=<no_of_days>

Schema

A schema in Snowflake is a logical container within a database that helps organize and group related database objects such as tables, views and functions.

A schema name should be unique in the Database.

The schema name should start with the alphabet and should not contain any special characters.

Creating a Schema in Snowflake

New schema creation.

CREATE SCHEMA snowflake_demo_sch

It can be cloned from another schema.

CREATE DATABASE snowflake_demo_clone_sch CLONE snowflake_demo_sch