Paolo Paolo - 1 month ago 15
SQL Question

Tracking row numbers in Oracle

Is there a way I could keep track of modified tables in Oracle?

Is there a master table that keeps track of all other table's row? For example if I add a row to table1 it would update the row count stating that table1 now has 5 rows.

I was thinking of tracking either

dba_tables
or
all_tables
or
user_tables
but I'm not sure which one actually counts the number of rows each table has.

Answer
SELECT TABLE_NAME, NUM_ROWS
FROM USER_TABLES

I highly doubt you're actually using Oracle 3.1. This query works at least in 11g (I don't have other instances to test at the moment).

Keep in mind that this is a data dictionary table and it won't update automatically after you insert a row in any schema table. The Gather Statistics procedure must be run to update these records.

Comments