SELECT Sys_context(‘userenv’, ‘db_name’) AS DATABASE_NAME,
DBA_TAB.table_name AS Table_Name,
Sum(us.bytes)AS TABLE_SIZE_BYTES,
Nvl(ut.num_rows, 0) AS NUM_ROWS,
DBA_TAB.column_name AS Column_Name,
Nvl(DBA_TAB.num_distinct, 0) AS num_unique_val
FROM dba_tab_columns DBA_TAB
JOIN user_segments US
ON ( DBA_TAB.table_name = us.segment_name )
JOIN user_tables ut
ON( DBA_TAB.table_name = ut.table_name )
WHERE owner NOT IN ( ‘ANONYMOUS’, ‘APEX_040200’, ‘APEX_PUBLIC_USER’,
‘APPQOSSYS’,
‘AUDSYS’, ‘BI’, ‘CTXSYS’, ‘DBSNMP’,
‘DIP’, ‘DVF’, ‘DVSYS’, ‘EXFSYS’,
‘FLOWS_FILES’, ‘GSMADMIN_INTERNAL’, ‘GSMCATUSER’,
‘GSMUSER’,
‘HR’, ‘IX’, ‘LBACSYS’, ‘MDDATA’,
‘MDSYS’, ‘OE’, ‘ORACLE_OCM’, ‘ORDDATA’,
‘ORDPLUGINS’, ‘ORDSYS’, ‘OUTLN’, ‘PM’,
‘SCOTT’, ‘SH’, ‘SI_INFORMTN_SCHEMA’,
‘SPATIAL_CSW_ADMIN_USR’,
‘SPATIAL_WFS_ADMIN_USR’, ‘SYS’, ‘SYSBACKUP’, ‘SYSDG’,
‘SYSKM’, ‘SYSTEM’, ‘WMSYS’, ‘XDB’,
‘SYSMAN’, ‘RMAN’, ‘RMAN_BACKUP’, ‘OLAPSYS’,
‘APEX_030200’, ‘OWBSYS’ )
GROUP BY Sys_context(‘userenv’, ‘db_name’),
DBA_TAB.table_name,
Nvl(DBA_TAB.num_distinct, 0),
Nvl(ut.num_rows, 0), DBA_TAB.column_name;