查询驱动视图和实际视图不返回相同的结果
我有一个视图返回四列数据以推送到外部程序。当我简单地查询视图(“Select * from schema.view_name”)时,我得到 10353 行。当我运行创建视图的实际 SQL 时(我实际上复制并粘贴了 Oracle 存储的内容,减去“创建或替换”语句),我得到 238745 行。
任何想法为什么会发生这种情况?
I have a view that is returning four columns of data to be pushed to an external program. When I simply query the view ("Select * from schema.view_name") I get 10353 rows. When I run the actual SQL that created the view (I literally copied and pasted what Oracle had stored, minus the "Create or Replace" statement), I get 238745 rows.
Any ideas why this might occur?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最佳猜测:当您独立运行查询时,您没有在创建视图的同一架构中运行它(我是从您在示例
SELECT
中包含架构名称这一事实推断出这一点的) 。运行查询的架构要么有自己的表,其名称与视图中的基表之一相同,要么其中一个名称是指向另一个视图的同义词,该视图仅包含视图中行的子集。基础表。Best guess: when you run the query standalone you're not running it in the same schema the view was created in (I am inferring this from the fact that you included the schema name in your example
SELECT
). The schema where you're running the query either has its own table with the same name as one of the base tables in the view, or one of the names is a synonym pointing to yet another view that contains only a subset of the rows in the underlying table.