gpt4 book ai didi

sql - ORA-01446 - 无法从带有 DISTINCT、GROUP BY 等的 View 中选择 ROWID

转载 作者:行者123 更新时间:2023-12-04 13:55:00 27 4
gpt4 key购买 nike

我创建了一个在 select 子句中有一个不同的 View 。

当我尝试使用“select * from view”选择所有记录时,出现以下错误:

ORA-01446: cannot select ROWID from view with DISTINCT, GROUP BY, etc.

我正在寻找为什么会发生这种情况并得出以下结论:

You tried to create a view that included a ROWID in the SELECT statement as well as a clause such as DISTINCT or GROUP BY. This is not allowed. Reference



这很尴尬,因为 View 中的 select 语句没有选择 rowid 并且它没有用于任何其他子句(where、order 等)。

对此有什么想法吗?

更新

我无法发布查询本身,但我发布了一个类似的内容。这里是:
SELECT DISTINCT t1.c1 TABLE1_C1,
t1.c2 TABLE1_C2,
t1.c3 TABLE1_C3,
t1.c4 TABLE1_C4,
t1.c4 TABLE1_C4,
t1.c5 TABLE1_C5,
t1.c6 TABLE1_C6,
t1.c7 TABLE1_C7,
t1.c8 TABLE1_C8,
t2.c1 TABLE2_C1,
t2.c2 TABLE2_C2,
t2.c3 TABLE2_C3,
t2.c4 TABLE2_C4,
t2.c5 TABLE2_C5,
t3.c1 TABLE3_C1,
t2.c6 TABLE2_C6,
t4.c1 TABLE4_C1,
t4.c2 TABLE4_C2,
t4.c3 TABLE4_C3
FROM table1 t1
LEFT JOIN table2 t2
ON t1.c1 = t2.c7
left JOIN table4 t4
ON t4.c4 = t2.c1
LEFT JOIN table3 t3
ON (t2.c1 = t3.c2
AND t2.c8 = t3.c3
AND t2.c9 = t3.c4)
WHERE (t2.cp5 = 0 or t2.cp5 is null)
AND (t2.c3 =
(SELECT MAX(c3)
FROM table2 s_t2
WHERE s_t2.c3 LIKE t2.c3
AND s_t2.c7 = t1.c1
) or t2.c3 is null)

最佳答案

如果您使用 distinct 或 group by 几行可以限定条件。因此,不同的执行会返回不同的行 ID,另一个问题是,如果多行符合条件,您会返回哪一个?

这根本没有意义

关于sql - ORA-01446 - 无法从带有 DISTINCT、GROUP BY 等的 View 中选择 ROWID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9806657/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com