Snowflake - Double Quotes

Sometimes when I select a column from a table in snowflake, I am required to use double quotes or it's case sensitive, but in other cases, it is not.

I am new to Snowflake.

  1. Why would some columns be case sensitive?
  2. What characters in a column name would require me to list the whole column name in double quotes when I use it in a select statement?

Upvotes: 2

Views: 1710

Answers (2)

Simon Kah Fye Chung
Simon Kah Fye Chung

Reputation: 41

Why would some columns be case-sensitive?

  • Some of the column names are stored as-is when ingested from the data source systems, and using double quotes allows us to ingest them without altering the original name mapping.

What characters in a column name would require me to list the whole column name in double quotes when I use it in a select statement?

  • When you have proper nouns or special characters the column name or whitespace in the column names, you will need the escape them with double quotes

We don't need to use double quotes when referencing them in the select statement when we use only uppercase with no special characters or whitespace, but that may differ from the original column name from the source systems.

Upvotes: 0

Lukasz Szozda
Lukasz Szozda

Reputation: 175566

Why would some columns be case sensitive?

Identifiers

When an identifier is double-quoted, it is stored and resolved exactly as entered, including case.


What characters in a column name would require me to list the whole column name in double quotes when I use it in a select statement?

Everything that is outside the [A-Za-z_0-9$] or that needs to be case-sensitive requires quoting with "

Unquoted object identifiers:

  • Start with a letter (A-Z, a-z) or an underscore (“_”).

  • Contain only letters, underscores, decimal digits (0-9), and dollar signs (“$”).

  • Are case-insensitive.

Upvotes: 1

Related Questions