【问题标题】:getting the table names and their row counts using a query in oracle db使用 oracle db 中的查询获取表名及其行数
【发布时间】:2015-09-06 21:22:45
【问题描述】:

我有一个数据库,我想获取该数据库中表的名称以及这些表中的数据行数。

select table_name from dba_tables where owner = 'owner'

返回数据库中所有表的名称,但我无法获取每个表中的行数。

查询 num_rows 列不会实时给出行数,因为它需要对所有表运行“分析”命令。

有没有办法使用单个查询获取两个列、表名和每个表的行数?

【问题讨论】:

    标签: sql database oracle oracle-sqldeveloper


    【解决方案1】:

    用途:

    SELECT 
       table_name, 
       num_rows,
       last_analyzed
    FROM dba_tables 
    

    您之前可能需要更新统计信息:

    exec dbms_stats.gather_schema_stats(ownname => 'NAME');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-18
      • 2018-04-18
      • 2017-12-23
      • 1970-01-01
      • 2010-12-16
      • 2021-11-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多