-
Notifications
You must be signed in to change notification settings - Fork 437
Identifiers
Rene Saarsoo edited this page Jul 17, 2022
·
16 revisions
Most dialects support [a-zA-Z_] as first character and [a-zA-Z0-9_] as rest of the characters.
The differences from this are listed below:
-
BigQuery: single dashes (
-) can be used, but not at the beginning or end. - DB2: first char can only be a (uppercase) letter (a lowercase letter gets converted to uppercase).
- Hive: (no differences)
-
MariaDB: no first-letter restrictions. The characters
[a-zA-Z0-9_$]and unicode letters are allowed everywhere. Can begin with digit, but can't only contain digits. - MySQL: same as MariaDB.
- N1QL: (no differences)
-
PL/SQL: can't start with
_. Allows$,#in rest of the identifier. -
PostgreSQL: additionally
$after first char. Also unicode letters are allowed. - Redshift: also unicode letters are allowed.
- Spark: Seems like the usual syntax is allowed. But the docs are confusing.
- SQLite: (no differences)
-
Transact-SQL:
@and#are allowed as first chars plus$in the rest. Also unicode letters are allowed. Though the beginning@signifies a local variable or parameter and#a temporary table or procedure. -
Trino:
[a-zA-Z0-9_]+, no first-letter restrictions
SQL standard specifies double-quotes ".." for delimited identifiers.
There is a considerable variation in implementations:
-
`..`BigQuery -
".."DB2 -
`..`Hive -
`..`, (".."1,[..]2) MariaDB -
`..`, (".."1) MySQL -
`..`N1QL -
".."PL/SQL -
"..",U&".."PostgreSQL -
".."Redshift -
`..`Spark -
"..",`..`,[..]SQLite -
".."3,[..]Transact-SQL -
"..",`..`Trino
Notes:
- when ANSI_QUOTES mode enabled
- when MSSQL mode enabled
- unless QUOTED_IDENTIFIER option has been set OFF