This page contains answers to Frequently Asked Questions, additional information, and errata related to material in Practical SQL.
Figure 1 on page xxxiii of the Introduction shows the pgAdmin app's opening screen. Beginning with version 3.0 of pgAdmin, released in April 2018, the application loads as a tab within your default web browser. Previous versions of pgAdmin run as a standalone desktop application. All other functionality for pgAdmin described in the book remains the same.
Errata:
Page 195: The results shown for Listing 12-3 are correct. However, the first sentence after the results has an incorrect number. It should read, "The difference between the median and average, 72,376, is nearly three times the size of the median."
Errata:
Page 230: The final line in Listing 13-13 should have a space instead of a comma between the quote marks in the second argument. It should read:
SELECT regexp_split_to_array('Phil Mike Tony Steve', ' ');
It's correct in the code listing on GitHub here.
Page 238: The final line of Listing 13-25 is missing a semi-colon. It should read:
LIMIT 5;
It's correct in the code listing on GitHub here.
As noted on page 257 of the book, the shapefile GUI tool that's available for Windows and Linux is unfortunately no longer maintained for macOS. If that changes, I'll note here. In the meantime, use the shp2pgsql
utility covered in Chapter 16 to load shapefiles into your database. The commands for both the Census county data and the New Mexico roads and waterways are here.
When attempting to run the command CREATE EXTENSION plpythonu;
from Listing 15-14 on page 281, Windows users may receive the error could not access file "$libdir/plpython2": No such file or directory
. This means PostgreSQL was unable to find the necessary Python language files on your system.
Upon investigation, I discovered that the file plpython3.dll
included with PostgreSQL during the EnterpriseDB Windows installation is looking for the file python34.dll
to be present in the C:\Windows\System32
directory. This file is included with the EDB Language Pack but not placed in that directory.
Here's how to remedy the situation. Note that you must have installed the EDB Language Pack as described on page xxx of the introduction to "Practical SQL":
- Using your File Explorer, navigate to
C:\edb\languagepack-10\x64\Python-3.4
- Copy the file
python34.dll
(right-click and select Copy). - Using File Explorer, navigate to
C:\Windows\System32
and paste the file. - You then should be able to execute the command
CREATE EXTENSION plpython3u;
within your database. Note that this command is slightly different than in the book. You're namingplpython3u
instead ofplpythonu
.