use the following query to selct number of rows in multiple tables
select table_name, num_rows from user_tables where lower(table_name) in ('Table1',
'Table2',
'Table3')
Showing posts with label Oracle. Show all posts
Showing posts with label Oracle. Show all posts
Monday, December 21, 2009
Oracle: Stored procedure for Analyzing Tables
1. Create the following procedure by changing the 'User Name'
CREATE OR REPLACE PROCEDURE analyze_tables IS
BEGIN
FOR syn_cur IN (SELECT table_name
FROM user_tables)
LOOP
DBMS_STATS.GATHER_TABLE_STATS(ownname => 'User Name',
tabname => syn_cur.TABLE_NAME,
estimate_percent => NULL,
cascade => TRUE);
END LOOP;
EXCEPTION
WHEN OTHERS THEN
null;
END analyze_tables;
2. Run the procedure as below
begin
-- Call the procedure
analyze_tables;
end;
That is it.
CREATE OR REPLACE PROCEDURE analyze_tables IS
BEGIN
FOR syn_cur IN (SELECT table_name
FROM user_tables)
LOOP
DBMS_STATS.GATHER_TABLE_STATS(ownname => 'User Name',
tabname => syn_cur.TABLE_NAME,
estimate_percent => NULL,
cascade => TRUE);
END LOOP;
EXCEPTION
WHEN OTHERS THEN
null;
END analyze_tables;
2. Run the procedure as below
begin
-- Call the procedure
analyze_tables;
end;
That is it.
Labels:
Oracle
Subscribe to:
Posts (Atom)