Conceptual information on relational databases and tables is of course entirely moot if you don't have any idea of
how to directly interact with your data. From a general perspective, SQL consists entirely of structured
, with which all data in the database is added, modified, and removed. These statements form
the basis for your communication with the PostgreSQL server.
The following sections dissect the anatomy of a SQL statement into its structural pieces, explaining the significance of each, and their relation to one another. The standard PostgreSQL command-line client,
, provides output to display example PostgreSQL statements.
Our SQL examples commonly take place within an example database called
booktown, the database for our imaginary bookstore, Book Town. The output from
is consistently prefixed with a default prompt style, which looks like this:
Some simpler examples may use our generic test database, testdb, if
not specific to the Book Town examples. By default, the
prompt displays only the name
of the connected database and the =# characters indicating that the system is ready for a
new command (though you will see that the = symbol will change dynamically as
tracks the status of SQL input). We display this prompt along with the SQL input and
output in order to help familiarize you with the
Chapter 4 documents
in more detail, and it is only mentioned
here to explain the source and style of this book's SQL examples using PostgreSQL.
Note: The schema (with sample data) for the booktown database can be found in the
file, on the CD-ROM. To install this database, type
psql -U postgres template1 -f /mnt/cdrom/booktown.sql
from the command line (where
is the path to your mounted CD, and