Conceptual information on relational databases and tables is of course entirely moot if you don't have any concept of how to directly interact with your data. From a general perspective, SQL consists entirely of structured statements , 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 will dissect the anatomy of a SQL statement into its structural pieces, explaining the significance of each, and their relation to one another. When example PostgreSQL statement results are displayed, the literal output is taken from the standard PostgreSQL command-line client, psql .
Our SQL examples will commonly take place almost within an example database called booktown , the database for our imaginary book store, Book Town. The output from psql will consistently be prefixed with a default prompt style, which looks like this for our booktown examples:
Some simpler examples may take place in our generic test database, called testdb , if not specific to the Book Town examples. By default, the psql 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 psql 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 psql output.
Chapter 4 documents psql in more detail, and it is only mentioned here to explain the source and style of this book's SQL examples using PostgreSQL.