postgresql Postgres 列别名是否有任何限制?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5277230/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Are there any restrictions on Postgres column alias names?
提问by DNS
Are there any restrictions, in terms of length, ability to include non-ASCII characters, etc. on the name of a Postgres column alias? And have there been any changes to such restrictions from version 8.1 to the present?
Postgres 列别名的名称在长度、包含非 ASCII 字符的能力等方面是否有任何限制?从 8.1 版到现在,这些限制是否有任何变化?
采纳答案by a_horse_with_no_name
The rules for a column alias are no different to than those for regular column names.
列别名的规则与常规列名的规则没有什么不同。
http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
SQL identifiers and key words must begin with a letter (a-z, but also letters with diacritical marks and non-Latin letters) or an underscore (_). Subsequent characters in an identifier or key word can be letters, underscores, digits (0-9), or dollar signs ($). Key words and unquoted identifiers are case insensitive.
There is a second kind of identifier: the delimited identifier or quoted identifier. It is formed by enclosing an arbitrary sequence of characters in double-quotes ("). Quoted identifiers can contain any character, except the character with code zero.
SQL 标识符和关键字必须以字母(az,但也可以是带有变音符和非拉丁字母的字母)或下划线 (_) 开头。标识符或关键字中的后续字符可以是字母、下划线、数字 (0-9) 或美元符号 ($)。关键字和不带引号的标识符不区分大小写。
还有第二种标识符:分隔标识符或带引号的标识符。它是通过用双引号 (") 将任意字符序列括起来而形成的。带引号的标识符可以包含任何字符,代码为零的字符除外。
回答by Mike Sherrill 'Cat Recall'
What a_horse_with_no_name said. In general, you can see some earlier versions of the documentation by replacing "current" in the URL with the version number. But the documentation for 8.1 is in the manual archive.
a_horse_with_no_name 说了什么。通常,您可以通过将 URL 中的“current”替换为版本号来查看文档的一些早期版本。但是 8.1 的文档在手册存档中。
SQL identifiers and key words must begin with a letter (a-z, but also letters with diacritical marks and non-Latin letters) or an underscore (_). Subsequent characters in an identifier or key word can be letters, underscores, digits (0-9), or dollar signs ($). Note that dollar signs are not allowed in identifiers according to the letter of the SQL standard, so their use may render applications less portable. The SQL standard will not define a key word that contains digits or starts or ends with an underscore, so identifiers of this form are safe against possible conflict with future extensions of the standard.
SQL 标识符和关键字必须以字母(az,但也可以是带有变音符和非拉丁字母的字母)或下划线 (_) 开头。标识符或关键字中的后续字符可以是字母、下划线、数字 (0-9) 或美元符号 ($)。请注意,根据 SQL 标准的字母,标识符中不允许使用美元符号,因此它们的使用可能会使应用程序的可移植性降低。SQL 标准不会定义包含数字或以下划线开头或结尾的关键字,因此这种形式的标识符是安全的,不会与标准的未来扩展发生冲突。
SQL identifiers and key words must begin with a letter (a-z, but also letters with diacritical marks and non-Latin letters) or an underscore (_). Subsequent characters in an identifier or key word can be letters, underscores, digits (0-9), or dollar signs ($). Note that dollar signs are not allowed in identifiers according to the letter of the SQL standard, so their use might render applications less portable. The SQL standard will not define a key word that contains digits or starts or ends with an underscore, so identifiers of this form are safe against possible conflict with future extensions of the standard.
SQL 标识符和关键字必须以字母(az,但也可以是带有变音符和非拉丁字母的字母)或下划线 (_) 开头。标识符或关键字中的后续字符可以是字母、下划线、数字 (0-9) 或美元符号 ($)。请注意,根据 SQL 标准的字母,标识符中不允许使用美元符号,因此它们的使用可能会使应用程序的可移植性降低。SQL 标准不会定义包含数字或以下划线开头或结尾的关键字,因此这种形式的标识符是安全的,不会与标准的未来扩展发生冲突。
No change.
没变化。
Here is the current version of this documentation. It mighthave changed after I wrote this answer.
这是本文档的当前版本。在我写下这个答案后,它可能已经改变了。