In this draft of SQL:1992, I found…
Section 5.2
Leveling Rules
….
The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions:
a) No
<regular identifier>
or<delimited identifier body>
shall contain more than 18<character representation>
s.
…and…
Annex A.1
Subclause 5.2, "
<token>
and<separator>
":a) In conforming Intermediate SQL language, a
<regular identifier>
or a<delimited identifier body>
shall not comprise more than 18<character representation>
s.b) A
<delimiter token>
shall not be a<bit string literal>
or a<hex string literal>
.c) Conforming Intermediate SQL language shall contain no
<identifier body>
that ends in an<underscore>
.
For implementors of SQL, or for users of SQL?
I searched the document multiple times, but could never get a sense of the meaning of identifier
.
-
Is the spec referring to labeling within an implementation of SQL (such as PostreSQL or Oracle)? So labels used within the SQL product cannot contain identifiers that are over 18 characters or end in an underscore.
-
Or is the spec referring to users of a SQL implementation? So we who are naming our schemas, tables, columns, and other such database objects cannot use names over 18 characters or end in an underscore?
Best Answer
Unless you're implementing SQL-1992's "Full SQL" (which is the 1992 spec), you should not have identifiers with more than 18 characters.
SQL 1992 defines three levels of compatibility,
At the top you're quoting "Entry SQL" which though stricter is a "low" level of SQL conformance with the 1992 spec. This mode was for backwards compatibility with SQL:89 and the spec is pretty explicit
While I couldn't personally dig up the SQL-89 standard, I assume it does have an 18 character limit on identifiers.
The other part is alarming to me, because I believe this shouldn't apply to Intermediate SQL from the spirit of the spec which is defined as,
But none the less, the spec is the letter of the law. Clearly even in Intermediate SQL the
<regular identifier>
and<delimited identifier body>
should not be more than 18 characters.