2.3. Identifiers
All database objects have names, often called identifiers. The maximum identifier length is 63 characters character set UTF8 (252 bytes).
Two types of names are valid as identifiers: regular identifiers, similar to variable names in regular programming languages, and delimited identifiers that are specific to SQL.
Identifier syntax
<identifier> ::=
<regular identifier>
| <delimited identifier>
To be valid, each type of identifier must conform to a set of rules, as follows:
2.3.1. Rules for Regular Identifiers
Length cannot exceed 63 characters
The identifier must start with an unaccented, 7-bit ASCII alphabetic character. It may be followed by other 7-bit ASCII letters, digits, underscores or dollar signs. No other characters, including spaces, are valid. The identifier is case-insensitive, meaning it can be declared and used in either upper or lower case. Thus, from the system’s point of view, the following identifiers are the same:
fullnameFULLNAMEFuLlNaMeFullNameRegular identifiers are stored in uppercase
Regular identifier syntax
<regular identifier> ::=
<letter> [ { <letter> | <digit> | <special> }... ]
<letter> ::= <upper letter> | <lower letter>
<upper letter> ::=
A | B | C | D | E | F | G | H | I | J | K | L | M
| N | O | P | Q | R | S | T | U | V | W | X | Y | Z
<lower letter> ::=
a | b | c | d | e | f | g | h | i | j | k | l | m
| n | o | p | q | r | s | t | u | v | w | x | y | z
<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<special> ::= _ | $
2.3.2. Rules for Delimited Identifiers
Length cannot exceed 63 characters in character set UTF8 (252 bytes). Identifiers are stored in character set
UTF8, which means characters outside the ASCII range are stored using 2 to 4 bytes.The entire identifier must be enclosed in double-quotes, e.g.
"anIdentifier"A double-quote in an identifier can be escaped by doubling it, e.g.
"with""doublequote"; we recommend avoiding double-quotes in delimited identifiers.It may contain any character from the
UTF8character set, including accented characters, spaces and special charactersAn identifier can be a reserved word
Delimited identifiers are stored as-is and are case-sensitive in all contexts
Trailing spaces in delimited identifiers are removed, as with any string constant
Delimited identifiers are available in Dialect 3 only. For more details on dialects, see Section 2.1.2, “SQL Dialects”
Delimited identifier syntax
<delimited identifier> ::= "<permitted character>[<permitted character> ...]"
A delimited identifier such as "FULLNAME" is the same as the regular identifiers FULLNAME, fullname, FullName, and so on.
The reason is that Firebird stores regular identifiers in upper case, regardless of how they were defined or declared.
Delimited identifiers are always stored according to the exact case of their definition or declaration.
Thus, "FullName" (quoted, or delimited) is different from FullName (unquoted, or regular) which is stored as FULLNAME in the metadata.
2.3.3. Identifier Chains
Identifier chains are a sequence of identifiers separated by a period. These are used for schema-qualified object names, packaged objects, referencing columns in a specific table using the table name or alias, and so on.
Identifier chain syntax
<identifier chain> ::=
<identifier> [<scope-specifier>] [ { <period> <identifier> }... ]
<scope-specifier> ::= '%' { SCHEMA | PACKAGE }
The maximum length of the chain depends on the context and the type of referenced object.
The scope-specifier can be used for disambiguation between package and schema references. By default, an ambiguous reference will first be tried as a schema, and then as a package in the schemas on the search path. When the scope-specifier is used, it will only be tried as a schema or as a package in the schemas on the search path.
Use of a scope-specifier might not be valid in all syntax contexts where an identifier chain is accepted.