Identificatori

Si applica a:segno di spunta sì Databricks SQL segno di spunta sì Databricks Runtime

Un identificatore è una stringa usata per identificare un oggetto, ad esempio una tabella, una vista, uno schema o una colonna. Azure Databricks supporta identificatori non delimitati (regolari) e identificatori delimitati, racchiusi all'interno di backtick.

Gli identificatori non fanno distinzione tra maiuscole e minuscole quando viene fatto riferimento.

Per gli identificatori salvati in modo permanente con un metastore e un'origine dati, è possibile limitare i caratteri consentiti.

Per informazioni dettagliate sull'utilizzo specifico degli identificatori, vedere Nomi .

Identificatori non delimitati

Sintassi

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

Parametri

  • lettera: qualsiasi lettera ASCII daZ-A o .a-z
  • digit: qualsiasi numero ASCII da 0 a 9.

Nota

In Databricks Runtime, se spark.sql.ansi.enabled e spark.sql.ansi.enforceReservedKeywords sono impostati su true, non è possibile usare una parola chiave riservata ANSI SQL come identificatore non delimitato. Per informazioni dettagliate, vedere Conformità ANSI.

Identificatori delimitati

Sintassi

`c [ ... ]`

Parametri

  • c: qualsiasi carattere del set di caratteri Unicode. Usare per eseguire ` l'escape ` .

Esempi

-- 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