select namea as name,agea as age from tablea
union all
select nameb as name,ageb as age from tableb
union all
select namec as name,agec as age from tablec
union all
select named as name,aged as age from tabled这条sql语句查询时非常的慢  如果在存储过程里面改写 怎么弄呢 
各位高手帮忙看看吧 谢谢!

解决方案 »

  1.   

    ? 你想做什么如果只是想把数据合并,那就 INSERT /*+APPEND*/ INTO ...
    如果想对合并后的结果查询,那就在几个表上需要查询的字段建好索引,然后上层建视图CREATE OR REPLACE VIEW V AS
    SELECT ... FROM A1
    UNION ALL
    SELECT ... FROM A2
    ...
    /
      

  2.   

    查询慢可能是你的索引问题吧,查询的字段建上索引
    sql没法子优化,都得这么写
      

  3.   

    光光sql本身已经不存在优化的问题.做四个全表扫描是必须的。