Identifiers

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

An identifier is a string used to identify an object such as a table, view, schema, or column. Azure Databricks supports non-delimited (regular) identifiers and delimited identifiers, which are enclosed within backticks.

Identifiers are case-insensitive when referenced.

For identifiers persisted with a metastore and data source the permitted characters permitted can be restricted.

See Names for details on the specific usage of identifiers.

Non delimited identifiers

Syntax

{ letter | '_' } [ letter | digit | '_' ] [ ... ]

Parameters

  • letter: Any ASCII letter from A-Z or a-z.
  • digit: Any ASCII numeral from 0 to 9.

Note

In Databricks Runtime, if spark.sql.ansi.enabled and spark.sql.ansi.enforceReservedKeywords are set to true, you cannot use an ANSI SQL reserved keyword as a non-delimited identifier. For details, see ANSI Compliance.

Delimited identifiers

Syntax

`c [ ... ]`

Parameters

  • c: Any character from the Unicode character set. Use ` to escape ` itself.

Examples

-- This statement fails because the undelimited identifier uses a non-ASCII letter.
> DESCRIBE SELECT 5 AS Ä;
 INVALID_IDENTIFIER

-- You can delimit the identifier to use a non-ASCII letter
> DESCRIBE SELECT 5 AS `Ä`;
 Ä

-- An identifier with dash needs to be delimited
> DESCRIBE SELECT 5 AS `a-b`;
 a-b

-- An identifier with a space needs to be delimited
> DESCRIBE SELECT 5 AS `a b`;
 a b

-- An identifier with a special character needs to be delimited
> DESCRIBE SELECT 5 AS `a@b`;
 a@b

-- An identifier with a Chinese character needs to be delimited
> DESCRIBE SELECT 5 AS `a中b`;
 a中b

-- An identifier with a backtick needs to be delimited and escaped.
> DESCRIBE SELECT 5 AS `a``b`;
 a`b