Friday 4 April 2014

script to get the all the tables and counts for a perticular schema in postgress

SELECT
  nspname AS schemaname,relname,reltuples
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE
  nspname NOT IN ('pg_catalog', 'information_schema') AND
  relkind='r'
ORDER BY reltuples DESC;

Thursday 3 April 2014

script to find the tables and records count in a perticular schema

declare
cnt number;
v_st varchar2(2000);
begin
for rec in (select table_name from all_tables where owner='APPS') loop
cnt :=0;
v_st :='';
v_st :=' Select count(1) from ' || rec.table_name;
 execute_immediate (v_st) into 
cnt ;
dbms_output.put_line(rec.table_name||'|'||cnt);
end loop;
end;
/


* replace the Apps into your schema name.