請務必使用與你的伺服器版本相符的 PostgreSQL 文件。不確定版本時,直接查詢:

show server_version;
 server_version
════════════════
 9.6.5
(1 row)

理想上你會有一台資料庫伺服器可以邊讀邊玩:

本書會大量使用 psql,之後會介紹如何把它設定得順手。你也可以偏好 pgAdmin 或 OmniDB 這類視覺化工具——重點是要能輕鬆地編輯 SQL、執行、修正重跑,以及查看查詢的 explain 計畫。

書附程式碼與資料集#

若你購買的是 Full Edition 或 Enterprise Edition,皆隨附 SQL 檔案。檔案樹頂層的 toc.txt 含詳細目錄與各節對應的檔案清單,例如:

2 Introduction
  2 Structured Query Language
    2.1 Some of the Code is Written in SQL
    2.2 A First Use Case
    2.3 Loading the Data Set
        02-intro/02-usecase/03_01_factbook.sql
    2.4 Application Code and SQL
        02-intro/02-usecase/04_01.sql
        02-intro/02-usecase/04_02_factbook-month.py
    ...
  3 Software Architecture
    3.1 Why PostgreSQL?
        02-intro/03-postgresql/01_01.sql
    3.2 The PostgreSQL Documentation
  4 Getting Ready to read this Book
      02-intro/04-postgresql/01.sql
  • 執行查詢還需要資料集:Full Edition 附抓取資料並載入本機 PostgreSQL 的說明;Enterprise Edition 則直接附上已載好所有資料的 PostgreSQL 實例,並預先設定好視覺化工具,點一下就能執行查詢。