如何避免在 Oracle 中具有 numberAlphabet 模式的列的列名中的 select 语句中出现“”?
How to avoid " " in select statement in column name for column that has numberAlphabet pattern in Oracle?
我对 Oracle 中的双引号列名有疑问。我尝试以 number_alphabets 模式创建列名,但这行不通。然后我使用双引号,我能够用这个列名创建 table 。当我执行 select 时,列名包含在双引号内。
我在这里附上了脚本。
CREATE TABLE test
(
"100_title" VARCHAR2(200) NULL
)
SELECT * FROM test
当我执行 select 时,在结果集中,列名将是“100_title”,但我不希望其中包含“”。有办法解决这个问题吗?
来自 Database Object Names and Qualifiers 文档:
- Nonquoted identifiers cannot be Oracle Database reserved words. Quoted identifiers can be reserved words, although this is not recommended.
和
Nonquoted identifiers must begin with an alphabetic character from your database character set. Quoted identifiers can begin with any character.
Nonquoted identifiers can only contain alphanumeric characters from your
database character set and the underscore (_). Database links can contain
periods (.) and "at" signs (@).
Quoted identifiers can contain any characters and punctuations marks as well
as spaces. However, neither quoted nor nonquoted identifiers can contain
double quotation marks or the null character ([=14=]).
所以你的问题:
When I do select, in result set, column name will be "100_title" but I do not want "" in it. Is there a way to fix this?
列标识符 100_title
以 non-alphabetic 字符开头,因此在该文档的第 6 点,您必须对标识符使用双引号。
列名称的显示方式取决于您使用的用户界面。在 db<>fiddle 上,列名称显示时不带引号,这与许多其他界面相同。
如果您使用的用户界面仅输出带有引号的标识符,那么您可以将标识符从 "100_title"
更改为 title_100
,因为它以字母字符开头并且仅包含 alpha-numeric 和下划线字符,因此不需要引用。
简短版本是“否;选择一个以字母开头的名称”
如果您使用以数字开头的名称,则每次提及列名称时都必须使用 "
, 和 您必须把案子弄对。您的专栏名为 "100_title"
,而不是 "100_Title"
或 "100_TITLE"
叫它title_100
,然后你可以随便引用它,如果你喜欢甚至TiTLe_100
,一般你的生活会更轻松
我对 Oracle 中的双引号列名有疑问。我尝试以 number_alphabets 模式创建列名,但这行不通。然后我使用双引号,我能够用这个列名创建 table 。当我执行 select 时,列名包含在双引号内。 我在这里附上了脚本。
CREATE TABLE test
(
"100_title" VARCHAR2(200) NULL
)
SELECT * FROM test
当我执行 select 时,在结果集中,列名将是“100_title”,但我不希望其中包含“”。有办法解决这个问题吗?
来自 Database Object Names and Qualifiers 文档:
- Nonquoted identifiers cannot be Oracle Database reserved words. Quoted identifiers can be reserved words, although this is not recommended.
和
Nonquoted identifiers must begin with an alphabetic character from your database character set. Quoted identifiers can begin with any character.
Nonquoted identifiers can only contain alphanumeric characters from your database character set and the underscore (_). Database links can contain periods (.) and "at" signs (@).
Quoted identifiers can contain any characters and punctuations marks as well as spaces. However, neither quoted nor nonquoted identifiers can contain double quotation marks or the null character ([=14=]).
所以你的问题:
When I do select, in result set, column name will be "100_title" but I do not want "" in it. Is there a way to fix this?
列标识符 100_title
以 non-alphabetic 字符开头,因此在该文档的第 6 点,您必须对标识符使用双引号。
列名称的显示方式取决于您使用的用户界面。在 db<>fiddle 上,列名称显示时不带引号,这与许多其他界面相同。
如果您使用的用户界面仅输出带有引号的标识符,那么您可以将标识符从 "100_title"
更改为 title_100
,因为它以字母字符开头并且仅包含 alpha-numeric 和下划线字符,因此不需要引用。
简短版本是“否;选择一个以字母开头的名称”
如果您使用以数字开头的名称,则每次提及列名称时都必须使用 "
, 和 您必须把案子弄对。您的专栏名为 "100_title"
,而不是 "100_Title"
或 "100_TITLE"
叫它title_100
,然后你可以随便引用它,如果你喜欢甚至TiTLe_100
,一般你的生活会更轻松