SQL 更新记录时出现“ORA-00903:无效表名”错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15767034/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 14:36:38  来源:igfitidea点击:

"ORA-00903: invalid table name" error while updating a record

sqloracle

提问by Anonymous Person

I have this table called iowe. It hasbeen created and exists in my database. This is how it looks like:

我有一张名为iowe. 它被创建并存在在我的数据库。这是它的样子:

NAME           AMOUNT Serial Number
---------- ---------- -------------
Praveen         20500
Roshan           5000             2
Rohit            5000             3
Shashi           7500             4

When I try to update the Serial Number corresponding to the name Praveen, by inputting the command

当我尝试通过输入命令更新与名称 Praveen 对应的序列号时

update table iowe
set "Serial Number" = 1 where amount = 20500

or

或者

update table iowe
set "Serial Number" = 1 where name = 'Praveen'

I get the following error: ORA-00903: invalid table name

我收到以下错误: ORA-00903: invalid table name

Other commands execute fine on this table.

其他命令在这个表上执行得很好。

回答by Alex Poole

You don't need the keyword tablein an update statement:

你不需要的关键字table更新语句

update iowe
set "Serial Number" = 1
where amount = 20500

As you have it, it's looking for a table called'table', while giving it the alias'iowe'.

正如你所拥有的,它正在寻找一个名为'table'的表,同时给它一个别名' iowe'。

Not relevant to the question, but I would also really advise not giving objects mixed-case or non-standard names, since you have to quote them - as you are with "Serial Number". I have yet to see a case where the added complication and opportunities for confusion can be justified.

与问题无关,但我也真的建议不要给对象混合大小写或非标准名称,因为您必须引用它们 - 就像使用"Serial Number". 我还没有看到可以证明增加的复杂性和混淆机会的情况。

回答by sgeddes

Remove the word "table" from your update statement:

从更新语句中删除“table”一词:

update iowe
set "Serial Number" = 1 
where name = 'Praveen'