DEFINITIONS

Definitions More Info.
Definition ID2.016
TitlePOSTGRESQL
CategoryNOTES
Definitiontablo kayit count sayilari meta data ile
Definition DescriptionI. Yontem

SELECT schemaname,relname,n_live_tup
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC;

II. Yontem
https://stackoverflow.com/questions/2596670/how-do-you-find-the-row-count-for-all-your-tables-in-postgres

WITH tbl AS
(SELECT table_schema,
TABLE_NAME
FROM information_schema.tables
WHERE TABLE_NAME not like 'pg_%'
AND table_schema in ('public'))
SELECT table_schema,
TABLE_NAME,
(xpath('/row/c/text()', query_to_xml(format('select count(*) as c from %I.%I', table_schema, TABLE_NAME), FALSE, TRUE, '')))[1]::text::int AS rows_n
FROM tbl
ORDER BY rows_n DESC;
RecordBycunay
Record Date10-04-2020 20:26:25
Düzenle
Kopyala
Sil