PostgreSQL bills itself as the worlds most advanced open source database. We couldnt agree more.
What we hope to accomplish in this book is to give you a firm grounding in the concepts and features that make PostgreSQL so impressive. Along the way, we should convince you that PostgreSQL does indeed stand up to its claim to fame. Because the database is advanced, no book short of the 3500 pages of documentation can bring out all its glory. But then again, most users dont need to delve into the most abstruse features that PostgreSQL has to offer. So in our shorter 300-pager, we hope to get you, as the subtitle proclaims, Up and Running.
Each topic is presented with some context so you understand when to use it and what it offers. We assume you have prior experience with some other database so that we can jump right to the key points of PostgreSQL. We generously litter the pages of this book with links to references so you can dig deeper into topics of interest. These links lead to sections in the manual, to helpful articles, to blog posts of PostgreSQL vanguards. We also link to our own site at Postgres OnLine Journal, where we have collected many pieces that we have written on PostgreSQL and its interoperability with other applications.
This book focuses on PostgreSQL versions 9.5, 9.6, and 10, but we will cover some unique and advanced features that are also present in prior versions.
Audience
For migrants from other database engines, well point out parallels that PostgreSQL shares with other leading products. Perhaps more importantly, we highlight feats you can achieve with PostgreSQL that are difficult or impossible to do in other databases.
We stop short of teaching you SQL, as youll find many excellent sources for that. SQL is much like chessa few hours to learn, a lifetime to master. You have wisely chosen PostgreSQL. Youll be greatly rewarded.
If youre currently a savvy PostgreSQL user or a weather-beaten DBA, much of the material in this book should be familiar terrain, but youll be sure to pick up some pointers and shortcuts introduced in newer versions of PostgreSQL. Perhaps youll even find the hidden gem that eluded you. If nothing else, this book is at least ten times lighter than the PostgreSQL manual.
Not using PostgreSQL yet? This book is propagandathe good kind. Each day you continue to use a database with limited SQL capabilities, you handicap yourself. Each day that youre wedded to a proprietary system, youre bleeding dollars.
Finally, if your work has nothing to do with databases or IT, or if youve just graduated from kindergarten, the cute picture of the elephant shrew on the cover should be worthy of the price alone.
For More Information on PostgreSQL
PostgreSQL has a well-maintained set of online documentation: PostgreSQL manuals. We encourage you to bookmark it. The manual is available both as HTML and as a PDF. Hardcopy collector editions are available for purchase.
Other PostgreSQL resources include:
Planet PostgreSQL is an aggregator of PostgreSQL blogs. Youll find PostgreSQL core developers and general users showcasing new features, novel ways to use existing ones, and reporting of bugs that have yet to be patched.
PostgreSQL Wiki provides tips and tricks for managing various facets of the database and migrating from other databases.
PostgreSQL Books is a list of books about PostgreSQL.
PostGIS in Action Books is the website for the books weve written on PostGIS, the spatial extender for PostgreSQL, and more recently pgRouting, another PostgreSQL extension that provides network routing capabilities useful for building driving apps.
Code and Output Formatting
For elements in parentheses, we gravitate toward placing the open parenthesis on the same line as the preceding element and the closing parenthesis on a line by itself. This is a classic C formatting style that we like because it cuts down on the number of blank lines:
function(Welcome to PostgreSQL);
We also remove gratuitous spaces in screen output, so if the formatting of your results doesnt match ours exactly, dont fret.
We omit the space after a serial comma for short elements. For example, ('a','b','c').
The SQL interpreter treats tabs, newlines, and carriage returns as whitespace. In our code, we generally use whitespaces for indentation, not tabs. Make sure that your editor doesnt automatically remove tabs, newlines, and carriage returns or convert them to something other than spaces.
After copying and pasting, if you find your code not working, check the copied code to make sure it looks like what we have in the listing.
We use examples based on both Linux and Windows. Path notations differ between the two, namely the use of solidus (/
) versus reverse solidus (\
). While on Windows, use the Linux solidus, always! /
, not \
. You may see a path such as /postgresql_book/somefile.csv. These are always relative to the root of your server. If you are on Windows, you must include the drive letter: C:/postgresql_book/somefile.csv.
Conventions Used in This Book
The following typographical conventions are used in this book:
ItalicIndicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings. Used within paragraphs, where needed for clarity, to refer to programming elements such as variables, functions, databases, data types, environment variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.