|
>Esta consulta listou tabelas sem chaves primárias e esta mostra quantas delas existem e qual é a porcentagem do total de tabelas.
This query listed tables without primary keys and this one shows how many of them there are and what is the percentage of total tables.
Consulta - Query
SELECT ALL_TABS.TABLES AS ALL_TABLES
, NO_PK.TABLES AS NO_PK_TABLES
, CAST(100.0 * NO_PK.TABLES / ALL_TABS.TABLES AS DECIMAL (14,2)) CONCAT '%'
AS NO_PK_PERCENT
FROM
(SELECT COUNT(*) AS TABLES
FROM SYSCAT.TABLES TAB
LEFT OUTER JOIN SYSCAT.TABCONST CONST
ON CONST.TABSCHEMA = TAB.TABSCHEMA
AND CONST.TABNAME = TAB.TABNAME AND CONST.TYPE ='P'
WHERE TAB.TYPE ='T'
AND TAB.TABSCHEMA NOT LIKE 'SYS%'
AND CONST.CONSTNAME IS NULL
) AS NO_PK
INNER JOIN
(SELECT COUNT(*) AS TABLES
FROM SYSCAT.TABLES
WHERE TYPE = 'T') AS ALL_TABS
ON 1 = 1
|
Colunas
- all_tables - número de todas as tabelas em um banco de dados
- no_pk_tables - número de tabelas sem uma chave primária
- no_pk_percent - porcentagem de tabelas sem chave primária em todas as tabelas
Linhas
- A consulta retorna apenas uma linha.
|
Columns
- all_tables - number of all tables in a database
- no_pk_tables - number of tables without a primary key
- no_pk_percent - percentage of tables without primary key in all tables
Rows
- Query returns just one row.
|
Resultado - Sample results
Eu verifiquei quantas tabelas no banco de dados GSDB não têm chaves primárias.
Acontece que é apenas 4,62%, o que para mim é um bom resultado.
I checked how many tables in GSDB database do not have primary keys.
It turns out it is only 4.62% which for me is a good result.

Copyright © Dataedo.
|