Snowflake Foreign Key Constraint and Syntax

Similar to the primary key constraint, the Snowflake foreign key constraint is also information only. It is not enforced when you insert the data into a table. Constraints other than NOT NULL are created as disabled. Snowflake Foreign Key Constraint You can create the foreign key while creating tables on the Snowflake cloud data warehouse. But, foreign key will not be enforced when you load the tables. However, constraints provide valuable metadata. The optimizer uses the foreign keys to create an optimal execution plan. A table can have multiple unique…

Continue ReadingSnowflake Foreign Key Constraint and Syntax
Comments Off on Snowflake Foreign Key Constraint and Syntax

Snowflake Primary Key Constraint and Syntax

For the compatibility with other databases, Snowflake provides the primary key constraint. The primary key constraint is informational only; It is not enforced when you insert the data into a table. Snowflake supports referential integrity constraints such as primary key, foreign key, unique key, and NOT NULL. Snowflake Primary Key Constraint You can create the primary key while creating tables on the Snowflake cloud data warehouse. But, primary key will not be enforced when you load the tables. However, constraints provide valuable metadata. The optimizer uses the primary key to…

Continue ReadingSnowflake Primary Key Constraint and Syntax
Comments Off on Snowflake Primary Key Constraint and Syntax

Snowflake Set Operators: UNION, EXCEPT/MINUS and INTERSECT

Snowflake set operators are used to combine similar resultset from two or more SELECT statements. The data type of the two or more result sets should also match, otherwise explicit type cast has to be used to convert the result set to required data types. Types of Snowflake Set Operators Cloud data warehouse supports the three types of set operators: UNION and UNION ALLINTERSECT EXCEPT or MINUS Snowflake Set Operators Syntax Below is the syntax of Set operators in Snowflake: query { UNION [ ALL ] | INTERSECT | EXCEPT…

Continue ReadingSnowflake Set Operators: UNION, EXCEPT/MINUS and INTERSECT
Comments Off on Snowflake Set Operators: UNION, EXCEPT/MINUS and INTERSECT

Identify and Remove Duplicate Records from Snowflake Table

Snowflake supports primary, foreign key(s) and unique key(s), but, does not enforce them. Snowflake table allows you to insert duplicate rows. There are chances that some application may insert the records multiple times. There are several methods you can use to de-duplicate the snowflake tables. In this article, we will check how to identify and remove duplicate records from Snowflake table. Remove Duplicate Records from Snowflake Table There are many methods that you can use to remove the duplicate records from the Snowflake table. For example, use the DISTINCT keyword…

Continue ReadingIdentify and Remove Duplicate Records from Snowflake Table
Comments Off on Identify and Remove Duplicate Records from Snowflake Table

Snowflake WITH Clause Syntax, Usage and Examples

Snowflake WITH Clause is an optional clause that always precedes SELECT clause in the query statements or construct. The WITH clause usually contains a sub query that is defined as a temporary table similar to View definition. Each sub query in the WITH clause is associated with the name, an optional list of a column names, and a query that evaluates to a table. The query expression is usually a select statement. In this article, we will check Snowflake WITH clause syntax, usage, types of WITH clause with some examples.…

Continue ReadingSnowflake WITH Clause Syntax, Usage and Examples
Comments Off on Snowflake WITH Clause Syntax, Usage and Examples

Snowflake Regular Expression Functions and Examples

The regular expressions are commonly used functions in programming languages such as Python, Java, R, etc. The Snowflake regular expression functions identify the precise pattern of the characters in given string. Regular expressions are commonly used in validating strings, for example, extracting numbers from the string values, etc. In this article, we will check the supported Regular expression functions in Snowflake. Snowflake Regular Expression Functions The regular expression functions are string functions that match a given regular expression. These functions are commonly called as a 'regex' functions. Below are some…

Continue ReadingSnowflake Regular Expression Functions and Examples
Comments Off on Snowflake Regular Expression Functions and Examples

How to use Snowflake Python Connector and Example

Snowflake is a cloud data warehouse environment and provides support for many major programming languages that uses JDBC or ODBC drivers. You can use Snowflake provided connector to connect your application. In this article, we will check one of the such connectors. i.e Python connector for Snowflake. Snowflake Python Connector The Snowflake Connector for Python provides an interface for developing Python applications that can connect to cloud data warehouse and perform all standard operations.  The connector is a pure python package that can be used to connect your application to…

Continue ReadingHow to use Snowflake Python Connector and Example
Comments Off on How to use Snowflake Python Connector and Example

Execute SQL Script File using Snowflake Snowsql Variable Substitution

Snowflake allows variable substitution using -D or --variable options. The variable substitution is one of the nice feature that allows you to pass values to the script dynamically. For example, pass month value to the SQL script. Many modern day databases support the variable substitution. In this article, we will check how to a execute SQL script file using Snowflake Snowsql variable substitution with an example. Snowflake Snowsql Variable Substitution Snowsql supports the variable substitution with the help of -D or --variable option. You can use that defined variable inside…

Continue ReadingExecute SQL Script File using Snowflake Snowsql Variable Substitution
Comments Off on Execute SQL Script File using Snowflake Snowsql Variable Substitution

Access Snowflake using Snowsql without Password Prompt – Snowsql Environment Variables

There are many ways you can connect to Snowflake cloud data warehouse server. The options include Snowsql, JDBC and ODBC drivers, python connector, Spark connectors, etc. In this article, we will discuss how to access Snowflake using Snowsql without password prompt. We will also check Snowsql environment variables. Access Snowflake using Snowsql without Password Prompt Password less access is useful when your application requires to connect to Snowflake frequently. There are multiple options that you can use to achieve password less communication to Snowflake server. Export Snowflake Database Server Environmental…

Continue ReadingAccess Snowflake using Snowsql without Password Prompt – Snowsql Environment Variables
Comments Off on Access Snowflake using Snowsql without Password Prompt – Snowsql Environment Variables

Snowsql Command Line Options and Examples

SnowSQL is a Python based command line interface to connect Snowflake from Windows, Linux, and Mac OS. The SnowSQL is an interactive terminal for Snowflake. You can use it to execute queries, create database objects and perform some of the admin tasks. In this article, we will check how to use Snowsql, what are the SnowSQL command line options. Snowsql Command Usage You can use following command to connect to Snowflake using Snowsql. snowsql -a accountName -u userName -d databaseName -s schemaName For example, consider following command to connect Snowflake…

Continue ReadingSnowsql Command Line Options and Examples
Comments Off on Snowsql Command Line Options and Examples