Oracle
 sql >> Database >  >> RDS >> Oracle

Come contare (*) di più tabelle, dimensioni e tablespace in una query

Poiché il segmento viene solitamente chiamato come la tabella:

SELECT ut.table_name,
       to_number(extractvalue(xmltype (dbms_xmlgen.getxml ('select count(*) c from ' ||ut.table_name)),'/ROWSET/ROW/C')) row_count,
       db.blocks*8192/1024/1024 as MB,
       db.tablespace_name 
FROM user_tables ut
  join dba_segments db on db.segment_name = ut.table_name
WHERE ut.table_name LIKE 'AUD_2012080%'
ORDER BY ut.table_name DESC