DECLARE
v_tot NUMBER;
v_size NUMBER;
vsele VARCHAR2 (200);
BEGIN
FOR i IN (SELECT table_name tname, column_name cname, data_type ctype
FROM user_tab_cols
where table_name in (select table_name from user_tables))
LOOP
IF i.ctype IN ('BLOB', 'CLOB')
THEN
vsele :=
'select avg(dbms_lob.getlength( '
|| i.cname
|| ' )) csize from '
|| i.tname;
ELSE
vsele :=
'select avg(vsize( ' || i.cname || ' )) csize from ' || i.tname;
END IF;
EXECUTE IMMEDIATE vsele
INTO v_size;
v_tot := nvl(v_tot,0) + nvl(v_size,0);
END LOOP;
DBMS_OUTPUT.put_line ('total '|| (trunc(v_tot,4) / 1024) );
END;
|