Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: the1donI have an anonymous block I run in Oracle to get the number of records in every table in a schema to get output like this. I have tried a DB Query node, DB Execute node. I have run the top query and passed that into a filter node and created 3 commands (ex Select COUNT(*) from DON>TABLE1 , etc). That works if I only have one row. Fails on 2 or more rows.
Any ideas would be appreciated.
Output
DON.TABLE1 977
DON.TABLE2 3
DON.TABLE3 256658
DECLARE
match_count integer;
BEGIN
FOR t IN (SELECT owner, table_name
FROM all_tab_columns
WHERE owner = 'DON'
GROUP BY owner, table_name
)
LOOP
BEGIN
EXECUTE IMMEDIATE
'SELECT COUNT(*) FROM '||t.owner || '.' || t.table_name
INTO match_count;
dbms_output.put_line( t.owner || '.' || t.table_name ||' '||match_count );
END;
END LOOP;
END;