IBM DB2 Query Toolbox - Number of tables by the number of rows



Desenvolvido por DORNELLES Carlos Alberto - Analista de Sistemas - Brasília DF. - cad_cobol@hotmail.com

IBM Db2 Query Toolbox - Number of tables by the number of rows in Db2 database

Se você deseja obter uma visão geral do número de linhas que as tabelas contêm em seu banco de dados, uma maneira de contá-los é por intervalos de linhas.
Esta consulta retorna o número de tabelas agrupadas pelo número de linhas em intervalos predefinidos.

If you want to get an overview of the number of rows the tables contain in your database, one way to count them is by intervals of rows.
This query returns the number of tables grouped by the number of rows at predefined intervals.

Consulta - Query

SELECT ROW_COUNT
,      COUNT(TABLE_NAME) AS TABLES
  FROM (
      SELECT TABSCHEMA || '.'|| TABNAME AS TABLE_NAME, 
             CASE WHEN CARD > 1000000000 THEN '1B ROWS AND MORE'
                  WHEN CARD > 1000000 THEN '1M - 1B ROWS'
                  WHEN CARD > 1000 THEN '1K - 1M ROWS'
                  WHEN CARD > 100 THEN '100 - 1K ROWS'
                  WHEN CARD > 10 THEN '10 - 100 ROWS'
                  ELSE  '0 - 10 ROWS' END AS ROW_COUNT
        FROM SYSCAT.TABLES
       WHERE TABSCHEMA NOT LIKE 'SYS%'
       ) AS TABLES_ROWS_INTERVAL
 GROUP BY ROW_COUNT
 ORDER BY ROW_COUNT

Colunas

  • row_count - intervalos de contagem de linha predefinidos:
    • 0 - 10 linhas
    • 10 - 100 linhas
    • 100 - 1k linhas
    • 1k - 1m linhas
    • 1m - 1b linhas
    • 1b linhas e mais
  • tabelas - número de tabelas cuja contagem de linhas cai nesse intervalo

Linhas

  • Uma linha: representa um intervalo
  • Escopo das linhas: todos os intervalos de contagem de linhas que aparecem no banco de dados (esquema)
  • Ordenado por: do menor número de linhas da tabela para o maior

Columns

  • row_count - predefined row count intervals:
    • 0 - 10 rows
    • 10 - 100 rows
    • 100 - 1k rows
    • 1k - 1m rows
    • 1m - 1b rows
    • 1b rows and more
  • tables - number of tables whose row count falls in that interval

Rows

  • One row: represents one interval
  • Scope of rows: all row count intervals that appear in the database (schema)
  • Ordered by: from the smallest table row count to the largest

Resultado - Sample results


Copyright © Dataedo.