如何解决ORA-00911:无效字符错误?

如何解决ORA-00911:无效字符错误?

问题描述:

我试图用Toad for oracle执行SQL INSERT:

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;

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
)

错误消息:

ORA-00911:无效字符

ORA-00911: invalid character

原因:标识符不能以字母和数字以外的任何ASCII字符开头. $#_也可以在第一个之后 特点.用双引号引起来的标识符可以包含任何 除双引号外的字符.替代引号(q'#...#') 不能使用空格,制表符或回车符作为分隔符.对所有人 其他上下文,请查阅《 SQL语言参考手册》.

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.

操作:无

我该如何解决?

您正在执行的语句有效.该错误似乎意味着Toad将尾随分号作为命令的一部分包括在内,当它作为语句的一部分包含在内时,的确会引起ORA-00911-因为它是客户端中的语句分隔符,而不是语句本身的一部分

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感到困惑(如此处所述);或可能是因为您试图将所有内容作为一条语句运行,在这种情况下,您可以尝试使用运行脚本命令( F9 )而不是运行语句( F5 ).

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).

仅删除注释掉的行就可以解决问题,但是如果您还看到了实际的提交,那么很可能是您使用了错误的方法来运行语句.

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.

在有关此相关问题的评论中,关于Toad如何解析分号的更多信息,但是我我对Toad不够熟悉,无法详细介绍.

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.