有多个表a、b、c、d,想统计每个表的记录数,一次性返回,如何写呢?

解决方案 »

  1.   

    select decode(tab,1,a),decode(tab,2,a),decode(tab,3,a),decode(tab,4,a) from(
    select count(*) a,1 tab from a
    union all
    select count(*) ,2 from b
    union all
    select count(*) ,3 from c
    union all
    select count(*) ,4 from d)
      

  2.   

    试试
    select num_rows
    from all_tables
    where owner = ... 
    and table_name in(....)
      

  3.   


    select table_name,num_rows from user_tables