【发布时间】:2014-08-09 00:23:33
【问题描述】:
我有一个庞大的数据库,其中包含数百万行,我的查询中包含多个表。我想测试我的查询,以便知道我的查询是否正常工作。
如果我运行我的查询,它需要几个小时才能给出查询的输出,并且在阅读了 oracle 中的 Rownum 之后我尝试了,但 rownum 仅在查询执行后执行。
有什么快速的方法来测试我的查询,以便我可以显示前 100 行。
select
p.attr_value product,
m.attr_value model,
u.attr_value usage,
l.attr_value location
from table1 t1 join table2 t2 on t1.e_subid = t2.e_subid
join table4 t4 on t4.loc_id = t1.loc_id
join table3 p on t2.e_cid = p.e_cid
join table3 m on t2.e_cid = m.e_cid
join table3 u on t2.e_cid = u.e_cid
Where
t4.attr_name = 'SiteName'
and p.attr_name = 'Product'
and m.attr_name = 'Model'
and u.attr_name = 'Usage'
order by product,location;
attempt1:获取前100名的查询结果
select
p.attr_value product,
m.attr_value model,
u.attr_value usage,
l.attr_value location
from table1 t1 join table2 t2 on t1.e_subid = t2.e_subid
join table4 t4 on t4.loc_id = t1.loc_id
join table3 p on t2.e_cid = p.e_cid
join table3 m on t2.e_cid = m.e_cid
join table3 u on t2.e_cid = u.e_cid
Where
ROWNUM <= 100
and t4.attr_name = 'SiteName'
and p.attr_name = 'Product'
and m.attr_name = 'Model'
and u.attr_name = 'Usage'
order by product,location;
我确实尝试了上述方法,并在几分钟内得到了一些结果,但不确定这是否是正确的方法......你觉得呢?
【问题讨论】:
-
+1 感谢您的尝试。
-
@WillMarcouiller 谢谢