Last active
July 21, 2017 13:43
-
-
Save mujahidk/4a01ee892ff377ac81ee to your computer and use it in GitHub Desktop.
Oracle: Row count of all tables which has ID column
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET SERVEROUTPUT ON | |
DECLARE ROW_COUNT NUMBER(10); | |
BEGIN | |
-- All user tables with column ID. | |
FOR TAB IN (SELECT TABLE_NAME FROM USER_TAB_COLUMNS WHERE COLUMN_NAME = 'ID' ORDER BY TABLE_NAME) | |
LOOP | |
EXECUTE IMMEDIATE 'SELECT COUNT(1) FROM ' || TAB.TABLE_NAME INTO ROW_COUNT; | |
DBMS_OUTPUT.PUT_LINE( TAB.TABLE_NAME || ',' || ROW_COUNT ); | |
END LOOP; | |
END; | |
/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET SERVEROUTPUT ON | |
DECLARE ROW_COUNT NUMBER(10); | |
BEGIN | |
-- All user tables. | |
FOR TAB IN (SELECT TABLE_NAME FROM USER_TABLES ORDER BY TABLE_NAME) | |
LOOP | |
EXECUTE IMMEDIATE 'SELECT COUNT(1) FROM ' || TAB.TABLE_NAME INTO ROW_COUNT; | |
DBMS_OUTPUT.PUT_LINE( TAB.TABLE_NAME || ',' || ROW_COUNT ); | |
END LOOP; | |
END; | |
/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment