Update code and data
This commit is contained in:
19
ch04/build_stats.psql
Normal file
19
ch04/build_stats.psql
Normal file
@@ -0,0 +1,19 @@
|
||||
\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
|
||||
Reference in New Issue
Block a user