内联视图查询

发布于 2024-12-29 13:23:22 字数 202 浏览 2 评论 0原文

我想从这个表 mytemp 中删除我最近添加的一些记录,请告诉我这个查询有什么问题, 已使用游标填充所选列中的数据,

DELETE FROM (SELECT ROWNUM RM, S from mytemp) where rm > 20;

错误为:

ORA-01732:数据操作操作在此视图上不合法

I wanted to delete some records which i added recently, from this table mytemp, please tell me what is wrong with this query,
data in selected column had been populated using cursor

DELETE FROM (SELECT ROWNUM RM, S from mytemp) where rm > 20;

error is:

ORA-01732: data manipulation operation not legal on this view

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

扭转时空 2025-01-05 13:23:22

为了准确性进行了编辑...

以下是您收到的错误的描述:

http://ora-01732。 ora-code.com/

尝试对某个对象使用 UPDATE、INSERT 或 DELETE 语句
包含表达式或函数或派生自更多内容的视图
比一张桌子。如果使用连接操作来创建视图或
视图包含从函数或表达式派生的虚拟列,
那么视图只能被查询。

因此,看起来可更新视图可以代替表,只要它不连接多个表或使用虚拟列。就您而言,问题在于虚拟 ROWNUM 列。

Edited for accuracy...

Here's the description of the error you are getting:

http://ora-01732.ora-code.com/

An attempt was made to use an UPDATE, INSERT, or DELETE statement on a
view that contains expressions or functions or was derived from more
than one table. If a join operation was used to create the view or the
view contains virtual columns derived from functions or expressions,
then the view may only be queried.

So it looks like an updateable view can be substituted for a table, as long as it doesn't join more than one table or use virtual columns. In your case, the problem is the virtual ROWNUM column.

我ぃ本無心為│何有愛 2025-01-05 13:23:22

这是 rownum>20 语句。

ROWNUM>x,其中大于正整数的 x 值始终为 false。

select * from ANYTABLE where rownum>(ANY POSITIVE INTEGER) 

不返回任何记录。

提取的第一行被分配 ROWNUM 1 并使条件为假。要提取的第二行现在是第一行,并且还分配了 ROWNUM 1 并使条件为 false。随后所有行都无法满足条件,因此不会返回任何行。

检查 了解更多信息。

您可以执行以下操作:

delete from (select amount from TABLE t where t.amount=1000)

但它与

delete from TABLE where amount=1000

It's the rownum>20 statement.

ROWNUM>x, where x values greater than a positive integer are always false.

select * from ANYTABLE where rownum>(ANY POSITIVE INTEGER) 

doesn't return any record.

The first row fetched is assigned a ROWNUM of 1 and makes the condition false. The second row to be fetched is now the first row and is also assigned a ROWNUM of 1 and makes the condition false. All rows subsequently fail to satisfy the condition, so no rows are returned.

Check THIS for further info.

You can do the following:

delete from (select amount from TABLE t where t.amount=1000)

but it's the same as

delete from TABLE where amount=1000
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文