0

What is the formal definition of a SQL identifier in the ISO/IEC 9075:2016 standard?

Most specifically, in the case of both regular and delimited identifiers, what limitations exist on:

  • Character set (UTF8?)
  • First character set
  • Subsequent character set
  • Length limits

1 Answers1

4

You can look up the rules e.g. here

So a "regular" (i.e. "non-delimited") identifier must start with a <simple Latin letter> which is essentially only the characters a-z (either upper or lower case).

Then it maybe followed by an <SQL language identifier part> which is either a <simple Latin letter> or a <digit> or the <underscore>

To sum it up: a regular identifier must start with a letter from a-z, and can only contain letters, digits (0-9) and the underscore.

A regular expression to validate a simple identifier would be: [a-zA-Z][a-zA-Z0-9_]*

Mandating "simple latin letters" makes any multi-byte character set (e.g. UTF-8) invalid for use with a simple identifier.

Other character (e.g. a space) can only be used when using a "delimited" (aka "quoted") identifier which is enclosed in double quotes, e.g. "%foo bar$". As far as I know this is also true for multi-byte characters.

The allowed length of an identifier is discussed in this question: Does the SQL-1992 standard restrict naming identifiers to 18 characters?

Hannah Vernon
  • 70,928
  • 22
  • 177
  • 323