Files
postgresql_up_and_running_4…/ch04/build_stats.psql
2026-01-17 18:57:46 -05:00

19 lines
394 B
Plaintext

\a
\t
\cd /tmp
\g create_script.sql
DROP TABLE IF EXISTS table_stats;
SELECT
'CREATE TABLE table_stats (
table_name varchar(255), count bigint);';
SELECT format(''INSERT INTO TABLE staging.table_stats(
table_name, count
)
VALUES (%1$I.%2$I,
(SELECT COUNT(1)
FROM %1$I.%2$I
) )', table_schema, table_name)
FROM information_schema.tables
WHERE table_schema = 'pg_catalog';
\o
\i create_script.sql