在视图或者子查询中查询rowid出错提示cannot select ROWID from a join view without a key-preserved table
比如
select * from ( select row_.*, rownum rownum_,rowid rowid_ from ( select t.*,u.user_companyname uname,u.user_mobile umobile,ceil((sysdate - fzrq)*24) as OVERTIME from vc_apply t,vc_user u,vc_cl v where 1=1 and (t.apply_newwzhgzbh=v.zchgzbh and APPLY_RESULT = 1) and t.apply_userid = u.userid order by APPLY_DATE ) row_ where rownum <= 70) where rownum_ > 0
原因,是因为子查询中查询出的记录不能保证唯一性,所以无法确认ROWID
解决方法:检查条件,看是否查询条件查询出的记录唯一,如果不是唯一的,试试在使用到的列上建立唯一索引或主键。
本文介绍了一种在复杂SQL查询中遇到的ROWID查询错误,该错误提示为“cannot select ROWID from a join view without a key-preserved table”。文章详细解释了错误的原因,并提供了解决方案:通过检查查询条件来确保查询结果的唯一性,必要时可以在相关列上创建唯一索引或设置为主键。
1163

被折叠的 条评论
为什么被折叠?



