SQL 如何解决 ORA-00911:无效字符错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27987882/
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
How can I solve ORA-00911: invalid character error?
提问by CHHIBI AMOR
I tried to execute an SQL
INSERT
with Toad for oracle
:
我试图执行一个SQL
INSERT
with Toad for oracle
:
INSERT INTO GRAT_ACTIVITY
(UUID, IP_ADRESS, SEND_MAIL, DATE_CREA, DATE_UPD, CREATOR, CENTER, ETAT, REQUEST)
VALUES('555-vgd9-pllkd-5513', '172.12.23.130', 'N', SYSDATE, SYSDATE, '1554', 'M18', 'I', 8842);
--COMMIT;
the GRAT_ACTIVITY
table structure is as below:
该GRAT_ACTIVITY
表结构如下:
CREATE TABLE CASH.GRAT_ACTIVITY
(
UUID VARCHAR2(64 BYTE) NOT NULL,
IP_ADRESS VARCHAR2(15 BYTE),
SEND_MAIL VARCHAR2(1 BYTE),
DATE_CREA DATE,
DATE_UPD DATE,
CREATOR VARCHAR2(4 BYTE),
CENTER VARCHAR2(4 BYTE),
ETAT VARCHAR2(1 BYTE),
REQUEST NUMBER
)
the error message:
错误信息:
ORA-00911: invalid character
Cause: identifiers may not start with any ASCII character other than letters and numbers. $#_ are also allowed after the first character. Identifiers enclosed by doublequotes may contain any character other than a doublequote. Alternative quotes (q'#...#') cannot use spaces, tabs, or carriage returns as delimiters. For all other contexts, consult the SQL Language Reference Manual.
Action: None
ORA-00911: 无效字符
原因:标识符不能以字母和数字以外的任何 ASCII 字符开头。$#_ 也允许在第一个字符之后。双引号括起来的标识符可以包含双引号以外的任何字符。替代引号 (q'#...#') 不能使用空格、制表符或回车作为分隔符。对于所有其他上下文,请参阅 SQL 语言参考手册。
行动:无
How can I solve it?
我该如何解决?
回答by Alex Poole
The statement you're executing is valid. The error seems to mean that Toad is including the trailing semicolon as part of the command, which does cause an ORA-00911
when it's included as part of a statement - since it is a statement separator in the client, not part of the statement itself.
您正在执行的语句是有效的。该错误似乎意味着 Toad 将尾随分号作为命令的一部分包含在内,这会导致ORA-00911
何时将其作为语句的一部分包含在内 - 因为它是客户端中的语句分隔符,而不是语句本身的一部分。
It may be the following commented-out line that is confusing Toad (as described here); or it might be because you're trying to run everything as a single statement, in which case you can try to use the run script command (F9) instead of run statement (F5).
可能是以下注释掉的行让 Toad 感到困惑(如此处所述);或者可能是因为您试图将所有内容作为单个语句运行,在这种情况下,您可以尝试使用运行脚本命令 ( F9) 而不是运行语句 ( F5)。
Just removing the commented-out line makes the problem go away, but if you also saw this with an actual commit then it's likely to be that you're using the wrong method to run the statements.
只需删除注释掉的行就可以解决问题,但是如果您在实际提交中也看到了这一点,那么很可能是您使用了错误的方法来运行语句。
There is a bit more information about how Toad parses the semicolons in a comment on this related question, but I'm not familiar enough with Toad to go into more detail.
回答by Bablu Ahmed
Remove the semicolon (;), backtick (``) etc. from inside a query
从查询中删除分号 (;)、反引号 (``) 等
回答by root
I'm using a 3rd party program that executes Oracle SQL and I encountered this error. Prior to a SELECT
statement, I had some commented notes that included special characters. Removing the comments resolved the issue.
我正在使用执行 Oracle SQL 的第 3 方程序,但遇到此错误。在SELECT
发表声明之前,我有一些注释注释,其中包含特殊字符。删除评论解决了问题。
回答by Norbert Wupona
I encountered the same thing lately. it was just due to spaces when copying a script from a document to sql developer. I had to remove the spaces and the script ran.
我最近遇到了同样的事情。这只是由于将脚本从文档复制到 sql 开发人员时的空格。我不得不删除空格并运行脚本。
回答by azzurroverde
I had the same problem and it was due to the end of line. I had copied from another document. I put everythng on the same line, then split them again and it worked.
我遇到了同样的问题,这是由于行尾。我是从另一个文件复制过来的。我把所有的东西都放在同一条线上,然后再次拆分它们并且它起作用了。
回答by erakm
回答by Ashutosh dwivedi
The option(s) to resolve this Oracle error are:
解决此 Oracle 错误的选项是:
Option #1 This error occurs when you try to use a special character in a SQL statement. If a special character other than $, _, and # is used in the name of a column or table, the name must be enclosed in double quotations.
选项 #1 当您尝试在 SQL 语句中使用特殊字符时会发生此错误。如果列或表的名称中使用了 $、_ 和 # 以外的特殊字符,则名称必须用双引号括起来。
Option #2 This error may occur if you've pasted your SQL into your editor from another program. Sometimes there are non-printable characters that may be present. In this case, you should try retyping your SQL statement and then re-execute it.
选项#2 如果您已将 SQL 从另一个程序粘贴到编辑器中,则可能会发生此错误。有时可能会出现不可打印的字符。在这种情况下,您应该尝试重新键入 SQL 语句,然后重新执行它。
Option #3 This error occurs when a special character is used in a SQL WHERE clause and the value is not enclosed in single quotations.
选项 #3 当在 SQL WHERE 子句中使用特殊字符并且该值没有用单引号括起来时,会发生此错误。
For example, if you had the following SQL statement:
例如,如果您有以下 SQL 语句:
SELECT * FROM suppliers WHERE supplier_name = ?;
选择 * 从供应商 WHERE 供应商名称 = ?;