Book Image

Learn PostgreSQL - Second Edition

By : Luca Ferrari, Enrico Pirozzi
1 (2)
Book Image

Learn PostgreSQL - Second Edition

1 (2)
By: Luca Ferrari, Enrico Pirozzi

Overview of this book

The latest edition of this PostgreSQL book will help you to start using PostgreSQL from absolute scratch, helping you to quickly understand the internal workings of the database. With a structured approach and practical examples, go on a journey that covers the basics, from SQL statements and how to run server-side programs, to configuring, managing, securing, and optimizing database performance. This new edition will not only help you get to grips with all the recent changes within the PostgreSQL ecosystem but will also dig deeper into concepts like partitioning and replication with a fresh set of examples. The book is also equipped with Docker images for each chapter which makes the learning experience faster and easier. Starting with the absolute basics of databases, the book sails through to advanced concepts like window functions, logging, auditing, extending the database, configuration, partitioning, and replication. It will also help you seamlessly migrate your existing database system to PostgreSQL and contains a dedicated chapter on disaster recovery. Each chapter ends with practice questions to test your learning at regular intervals. By the end of this book, you will be able to install, configure, manage, and develop applications against a PostgreSQL database.
Table of Contents (22 chapters)
20
Other Books You May Enjoy
21
Index

To get the most out of this book

For this book to be useful, basic knowledge of the Linux (or another Unix-like) operating system is required. All the SQL examples can be run using the psql command-line program or any available GUI tool (not presented in the book), like the PostgreSQL-specific pgAdmin4. Shell scripts will be executed using the GNU Bash scripting language.

Software/hardware covered in the book

OS requirements

PostgreSQL 16

Linux OS/Unix-like OS (e.g., FreeBSD, OpenBSD)

The book provides a set of Docker images, so that the reader can follow and test all the code examples. Running the Docker images is not mandatory, but it does not require you to have your own customized PostgreSQL installation. In order to run the Docker images, you need to install the Docker application on your operating system.

If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

Download the example code files

The code bundle for the book is hosted on GitHub at https://github.com/PacktPublishing/Learn-PostgreSQL-Second-Edition. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://packt.link/gbp/9781837635641.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. For example: “Mount the downloaded WebStorm-10*.dmg disk image file as another disk in your system.”

A block of code is set as follows:

SELECT rolname, rolcanlogin,
            rolconnlimit, rolpassword
            FROM pg_roles
            WHERE rolname = 'luca';

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

SELECT line_number, type,
                  database, user_name,
                  address, auth_method
                  FROM pg_hba_file_rules;

Any command-line input or output is written as follows:

$ sudo cat $PGDATA/rejected_users.txt

Bold: Indicates a new term, an important word, or words that you see on the screen. For instance, words in menus or dialog boxes appear in the text like this. For example: “Select System info from the Administration panel.”

Warnings or important notes appear like this.

Tips and tricks appear like this.