Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 175dbf7

Browse files
committed
Make discussion of names clearer and more accurate.
1 parent 996bc53 commit 175dbf7

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

doc/src/sgml/syntax.sgml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,17 +340,23 @@ A comment beginning with "/*" extends to the first occurrence of "*/".
340340
<title>Names</title>
341341

342342
<para>
343-
Names in SQL are sequences of less than NAMEDATALEN alphanumeric characters,
344-
starting with an alphabetic character. By default, NAMEDATALEN is set
345-
to 32 (but at the time the system is built, NAMEDATALEN can be changed
346-
by changing the <literal>#define</literal> in
347-
src/backend/include/postgres.h).
348-
Underscore ("_") is considered an alphabetic character.
343+
Names in SQL must begin with a letter
344+
(<literal>a</literal>-<literal>z</literal>) or underscore
345+
(<literal>_</literal>).
346+
Subsequent characters in a name can be letters, digits
347+
(<literal>0</literal>-<literal>9</literal>),
348+
or underscores. The system uses no more than NAMEDATALEN-1 characters
349+
of a name; longer names can be written in queries, but they will be
350+
truncated.
351+
By default, NAMEDATALEN is 32 so the maximum name length is 31 (but
352+
at the time the system is built, NAMEDATALEN can be changed in
353+
src/include/postgres_ext.h).
349354
</para>
350355

351356
<para>
352357
Names containing other characters may be formed by surrounding them
353-
with double quotes. For example, table or column names may contain
358+
with double quotes (<literal>"</literal>). For example, table or column
359+
names may contain
354360
otherwise disallowed characters such as spaces, ampersands, etc. if
355361
quoted. Quoting a name also makes it case-sensitive,
356362
whereas unquoted names are always folded to lower case. For example,
@@ -359,6 +365,12 @@ A comment beginning with "/*" extends to the first occurrence of "*/".
359365
considered the same by <productname>Postgres</productname>, but
360366
<literal>"Foo"</literal> is a different name.
361367
</para>
368+
369+
<para>
370+
Double quotes can also be used to protect a name that would otherwise
371+
be taken to be an SQL keyword. For example, <literal>IN</literal>
372+
is a keyword but <literal>"IN"</literal> is a name.
373+
</para>
362374
</sect1>
363375

364376
<sect1>

0 commit comments

Comments
 (0)