first commit

This commit is contained in:
Regina Obe
2026-01-02 11:42:04 -05:00
commit 1bc9a9b4be
4 changed files with 510954 additions and 0 deletions

19
README.md Normal file
View File

@@ -0,0 +1,19 @@
The .sql is a plain text SQL backup
that should be restored with psql.
It consists of the census and staging schemas. As well as some other minor tables
Some of these are built as part of exercises in the book.
To restore:
```sql
CREATE DATABASE postgresql_book;
\connect postgresql_book
\i postgresql_book.sql
```
IMDB movies list comes from ftp://ftp.fu-berlin.de/pub/misc/movies/database/movies.list.gz
refer to copyright details in http://www.imdb.com/interfaces
Information courtesy of
IMDb
(http://www.imdb.com).
Used with permission.

8
ch04/psqlrc.conf Normal file
View File

@@ -0,0 +1,8 @@
\pset pager always
\pset null 'NULL'
\encoding latin1
\set PROMPT1 '%n@%M:%>%x %/# '
\set PROMPT2 ''
\timing on
\set qstats 'SELECT usename, datname, left(query,100) || ''...'' As query FROM pg_stat_activity WHERE state != ''idle'' ;'
\pset pager always

24
ch04/settings_report.psql Normal file
View File

@@ -0,0 +1,24 @@
\o settings_report.html
\T 'cellspacing=0 cellpadding=0'
\qecho '<html><head><style>H2{color:maroon}</style>'
\qecho '<title>PostgreSQL Settings</title></head><body>'
\qecho '<table><tr valign=''top''><td><h2>Planner Settings</h2>'
\x on
\t on
\pset format html
SELECT category, string_agg(name || '=' || setting, E'\n' ORDER BY name) As settings
FROM pg_settings
WHERE category LIKE '%Planner%' GROUP BY category ORDER BY category;
\H
\qecho '</td><td><h2>File Locations</h2>'
\x off
\t on
\pset format html
SELECT name, setting
FROM pg_settings
WHERE category = 'File Locations' ORDER BY name;
\qecho '<h2>Memory Settings</h2>'
SELECT name, setting, unit
FROM pg_settings WHERE category ILIKE '%memory%' ORDER BY name;
\qecho '</td></tr></table>'
\qecho '</body></html>'

510903
postgresql_book.sql Normal file

File diff suppressed because one or more lines are too long