Learn Snowflake

Snowflake Create and Clone and Drop Database

Snowflake Create, Clone, Drop Database

a) Create a Snowflake Database

è Using CREATE DABATAE you can create a Snowflake database.

E.g:-

CREATE DATABASE EMPLOYEE;

CREATE DATABASE EMPLOYEE DATA_RETENTION_TIME_IN_DAYS 5;

 

b) Create or Replace Database

è Use OR REPLACE in order to drop the existing Snowflake database and create a new database. You can also do this first by running DROP DATABASE and running CREATE DATABASE.

E.g:-

CREATE OR REPLACE DATABASE EMPLOYEE;

 

c) Create a Transient database

è Use TRASIENT option to create a transient database. transient databases are not fail-safe and take less storage hence, there is no recovery when data loss.

E.g:-

CREATE TRANSIENT DATABASE EMPLOYEE;

 

d) Clone Database

è use optional CLONE optional parameter in order to clone the existing database, Cloning database copies all schema, tables and everything from the database.

E.g:-

CREATE DATABASE EMPLOYEE_CLONE CLONE EMPLOYEE ;

 

f) Drop Database

è DROP DATABSE is used to drop the existing snowflake database

E.g:-

DROP DATABASE EMPLOYEE;

 

g) Show Database

è Using SHOW DATABSE, you can see all the tables in the Snowflake account.

E.g:-

SHOW DATABASES;

It also shows all default databases that come with account creation.

 

h) Set default Database

è If you wanted to set the default database.

E.g:-

USE employee_clone