matillionsnowflake-cloud-data-platform

Snowflake check if Schema exists


Snowflake doesn't accept T-sql but i'm trying to Create schema If it doesn't exists.

    IF NOT EXISTS (SELECT * FROM SYS.SCHEMA WHERE NAME = 'CBS')
    CREATE SCHEMA 'CBS';

How to do this in Snowflake?


Solution

  • Just use the 'if not exists' syntax:

    Create schema if not exists 'cbs';