Identify a table with maximum rows in Oracle

后端 未结 7 1411
猫巷女王i
猫巷女王i 2021-01-13 08:15

I have a set of tables in Oracle and I would like to identify the table that contains the maximum number of rows.

So if, A has 200 rows, B has 345 rows and C has 120

7条回答
  •  攒了一身酷
    2021-01-13 08:42

    Given that you said you were using Oracle I would just query the meta-data.

    select table_name, max(num_rows) from all_tables where table_name in ('A', 'B', 'C');
    

    Just saw your edit. Just run the above without the where clause and it will return the largest table in the database. Only problem may be that you might get a SYS$ table or something. Alternately if you are just doing this for your own knowledge just do

    select table_name, num_rows from all_tables order by num_rows; 
    

    and you'll see what the biggest are.

提交回复
热议问题