{"id":14063380,"url":"https://github.com/PacktPublishing/Learn-PostgreSQL","last_synced_at":"2025-07-29T15:33:01.921Z","repository":{"id":43638338,"uuid":"283710595","full_name":"PacktPublishing/Learn-PostgreSQL","owner":"PacktPublishing","description":"Learn PostgreSQL, published by Packt","archived":false,"fork":false,"pushed_at":"2023-06-23T16:15:12.000Z","size":1797,"stargazers_count":130,"open_issues_count":5,"forks_count":82,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-02-15T10:26:45.910Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PLpgSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PacktPublishing.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-07-30T08:13:26.000Z","updated_at":"2025-01-30T21:57:40.000Z","dependencies_parsed_at":"2024-02-04T20:37:48.250Z","dependency_job_id":null,"html_url":"https://github.com/PacktPublishing/Learn-PostgreSQL","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PacktPublishing/Learn-PostgreSQL","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PacktPublishing%2FLearn-PostgreSQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PacktPublishing%2FLearn-PostgreSQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PacktPublishing%2FLearn-PostgreSQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PacktPublishing%2FLearn-PostgreSQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PacktPublishing","download_url":"https://codeload.github.com/PacktPublishing/Learn-PostgreSQL/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PacktPublishing%2FLearn-PostgreSQL/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267709609,"owners_count":24131922,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-13T07:03:18.675Z","updated_at":"2025-07-29T15:33:01.144Z","avatar_url":"https://github.com/PacktPublishing.png","language":"PLpgSQL","readme":"\n\n\n# Learn PostgreSQL\n\n\u003ca href=\"https://www.packtpub.com/product/learn-postgresql/9781838985288\"\u003e\u003cimg src=\"https://static.packt-cdn.com/products/9781838985288/cover/smaller\" alt=\"Learn PostgreSQL\" height=\"256px\" align=\"right\"\u003e\u003c/a\u003e\n\n\n\n**Build and manage high-performance database solutions using PostgreSQL 12 and 13**\n\n## What is this book about?\nPostgreSQL is one of the fastest-growing open source object-relational database management systems (DBMS) in the world. As well as being easy to use, it’s scalable and highly efficient. In this book, you’ll explore PostgreSQL 12 and 13 and learn how to build database solutions using it. Complete with hands-on tutorials, this guide will teach you how to achieve the right database design required for a reliable environment.\n\nThis book covers the following exciting features:\n* Understand how users and connections are managed by running a PostgreSQL instance\n* Interact with transaction boundaries using server-side programming\n* Identify bottlenecks to maintain your database efficiently\n* Create and manage extensions to add new functionalities to your cluster\n* Choose the best index type for each situation\n\nIf you feel this book is for you, get your [copy](https://www.amazon.com/dp/183898528X) today!\n\n\u003ca href=\"https://www.packtpub.com/?utm_source=github\u0026utm_medium=banner\u0026utm_campaign=GitHubBanner\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/PacktPublishing/GitHub/master/GitHub.png\"\nalt=\"https://www.packtpub.com/\" border=\"5\" /\u003e\u003c/a\u003e\n\n\n## Book Outline\n\nThis Postgres book is for anyone interested in learning about the PostgreSQL database from scratch. Anyone looking to build robust data warehousing applications and scale the database for high-availability and performance using the latest features of PostgreSQL will also find this book useful. Although prior knowledge of PostgreSQL is not required, familiarity with databases is expected.\n\n\nThe book is divided into five main parts. The following is a list of the book chapters.\n\n### Part 1\n\n1) Introduction to PostgreSQL\n2) Getting to know your cluster\n3) Managing Users and Connections\n\n### Part 2\n\n4) Basic Statements\n5) Advanced Statements\n6) Window Functions\n7) Server Side Programming\n8) Triggers and Rules\n9) Partitioning\n\n### Part 3\n\n10)\tUsers, Roles and Database Security\n11)\tTransactions, MVCC, WALs and Checkpoints\n12)\tExtending the database: the Extension ecosystem\n13)\tIndexes and Performance Optimization\n14)\tLogging and Auditing\n15)\tBackup and Restore\n16)\tConfiguration and Monitoring\n\n### Part 4\n\n17) Physical Replication\n18) Logical Replication\n\n### Part 5\n\n19) Usefult tools and useful extensions\n20) Towards PostgreSQL 13\n\n\n\n## Chapters Content\n\nEvery chapter will have the following main structure:\n- a *What you will learn* bullet list that summarize what the reader will learn thru the chapter;\n- a *What you need to know* bullet list that reminds the user basic knowledge **required** to fully understand the contents of the chapter;\n- an *Abstract* that introduces the chapter content at glance;\n- a *Conclusions* section that provides a summary of the chapter and focus on the main concepts;\n- a *References* section with links to documentation, articles and external resources.\n\n\n## Content of this repository\n\nThis repository contains ongoing stuff related to the book, including code examples.\n\n### Naming conventions used in this repository\n\nEvery chapter has its own folder named after the chapter number, for instance `Chapter01` for the very first chapter.\n\nIn order to ease the execution of the code examples by readers, every chapter will have a set of source scripts that the reader can immediatly load into her database.\n\nEvery file is named after the its type, for example `.sql` for an SQL script or a collection of SQL statements.\n\n\n### Pictures\n\nAny picture will be named with the pattern `Chapter\u003cCC\u003e_picture\u003cPP\u003e.\u003ctype\u003e` where:\n- `CC` is the chapter number;\n- `PP` is the picture number as listed within the chapter;\n- `type` is a suffix related to the picture file type (e.g., `png` for a Portable Network Graphic image).\n\n*Images could appear differently from the printed book due to graphical needs*.\n\n[We also provide a PDF file](https://static.packt-cdn.com/downloads/9781838985288_ColorImages.pdf)\nthat has color images of the screenshots/diagrams used in this book.\n\n\n### Command prompts\n\nIn the book code listings and examples, the command prompts are one of the two that follows:\n- a `$` stands for an Unix shell prompt (like Bourne, Bash, Zsh);\n- a `forumdb=\u003e` stands for the `psql(1)` command prompt when an active connection to the database is opened.\n\nAs an example, the following is a command issued on the operating system:\n\n```shell\n$ sudo service postgresql restart\n```\n\nwhile the following is a query issued within an active database connection:\n\n```sql\nforumdb=\u003e SELECT CURRENT_TIMESTAMP;\n```\n\n### Administrative/Superusers command prompts\n\nWhenere there is the need to execute a command or a statement with administrative privileges, the command prompt will reflect it using a `#` sign as the end part of the command prompt. For example, the following is an SQL statement issued as PostgreSQL administrator:\n\n```sql\nforumdb=# SELECT pg_terminate_backend( 987 );\n```\n\nùPlease note the presence of the `#` in the `forumdb=#` prompt, as opposed to the `\u003e` sign in the normal user `forumdb=\u003e` prompt.\n\nIn the case a command on the operating system must be run with superuser (`root`) privileges, the command will be run via `sudo(1)`, as in:\n\n```sql\n$ sudo initdb -D /postgres/12\n```\n\nand therefore in this case the command prompt will not change, rather the presence of the `sudo(1)` command indicates `root` privileges are required.\n\n## Creating the example database\n\nThe book is built over an example database that implements an *online forum* storage. In order to be able to execute any example of any chapter, the reader has to initialize the forum database.\n\nThe scripts in the folder `setup`, executed in lexicographically order, implement the example database and setup the environment so that other examples can be run against the database.\n\nIn particular, in order to get the database structure as shown in Chapter 4 and the followings, you have to executed something has follows:\n\n```shell\npsql -U \u003cyour-username\u003e -h \u003cdatabase-host\u003e \u003c setup/00-forum-database.sql\n```\n\nwhere\n- `your-username` is a PostgreSQL username of choice;\n- `database-host` is the host the database is running on, if different from `localhost`.\n\nThe end result will be to have the `forumdb` created and populated with tables.\nYou can also invoke the script interactively from within a `psql` connection, such as:\n\n```shell\npsql -U \u003cyour-username\u003e -h \u003cdatabase-host\u003e template1\n\ntemplate1=\u003e \\i setup/-00-forum-database.sql\n```\n\nThe simplest form to get the example database up and running is the following one (assuming you are running PostgreSQL locally):\n\n```shell\n$ psql -U postgres   template1 -c 'CREATE ROLE forumdb_user WITH LOGIN CREATEDB;'\n$ psql -U forum_user template1 \u003c setup/00-forum-database.sql\n```\n\n\n### Software and Hardware List\n\n| Chapter  | Software required                   | OS required                        |\n| -------- | ------------------------------------| -----------------------------------|\n| 1        | PostgreSQL 12 - 13                  | Linux OS / FreeBSD |\n\n\n\n\n### Related products\n- Mastering PostgreSQL 12 [[Packt]](https://www.packtpub.com/product/mastering-postgresql-12-third-edition/9781838988821) [[Amazon]](https://www.amazon.com/dp/1838988823)\n- PostgreSQL 12 High Availability Cookbook - Third Edition [[Packt]](https://www.packtpub.com/product/postgresql-12-high-availability-cookbook-third-edition/9781838984854) [[Amazon]](https://www.amazon.com/dp/1838984852)\n- PostgreSQL 11 Server Side Programming - Quick Start Guide [[Packt]](https://www.packtpub.com/product/postgresql-11-server-side-programming-quick-start-guide/9781789342222) [[Amazon]](https://www.amazon.com/PostgreSQL-Server-Programming-Quick-Start-ebook/dp/B07L1MP1F8/ref=sr_1_1?crid=2I7PGMZDCI9O0\u0026dchild=1\u0026keywords=postgresql+11+server+side+programming+quick+start+guide\u0026qid=1605375687\u0026sprefix=postgresql+11+server+%2Caps%2C278\u0026sr=8-1)\n\n\n## Get to Know the Authors\n**Luca Ferrari**\nhas been passionate about computer science since the Commodore 64 era, and today holds a master's degree (with honors) and a Ph.D. from the University of Modena and Reggio Emilia. He has written several research papers, technical articles, and book chapters. In 2011, he was named an Adjunct Professor by Nipissing University. An avid Unix user, he is a strong advocate of open source, and in his free time, he collaborates with a few projects. He met PostgreSQL back in release 7.3; he was a founder and former president of the Italian PostgreSQL Community (ITPUG). He also talks regularly at technical conferences and events and delivers professional training.\n\n**Enrico Pirozzi**\nhas been passionate about computer science since he was a 13-year-old, his first computer was a Commodore 64, and today he holds a master's degree from the University of Bologna. He has participated as a speaker at national and international conferences on PostgreSQL. He met PostgreSQL back in release 7.2, he was a co-founder of the first PostgreSQL Italian mailing list and the first Italian PostgreSQL website, and he talks regularly at technical conferences and events and delivers professional training. Right now, he is employed as a PostgreSQL database administrator at Nexteam (Zucchetti Group S.p.a.).\n\n\n### Suggestions and Feedback\n[Click here](https://docs.google.com/forms/d/e/1FAIpQLSdy7dATC6QmEL81FIUuymZ0Wy9vH1jHkvpY57OiMeKGqib_Ow/viewform) if you have any feedback or suggestions.\n\n\n#### Errata\n* Page 5: the sentence \"All the SQL examples can be run using the psql program or using the GUI tool pdAdmin.\" should be \"All the SQL examples can be run using the psql program or using the GUI tool pgAdmin.\"\n* Page 42 (The template databases): in the code section the command shown is `psql -l`. Unluckily, the first line of command output, that reports `List of databases`, has been placed on the right side of the very same line of the command. In order to reproduce the command, you need to copy and execute only the **`psql -l`** command (reported errata *CA162683* on 2021-09-30);\n* Page 61: the sentence **When you grant a role to another, the former becomes a member of the latter.** should be **When you grant a role to another, the latter becomes a member of the former.**\n* Page 82 (Dropping databases, first paragraph): **to drop a table** _should be_ **to drop a database**\n* Page 122 (Using FULL OUTER JOIN, point 2): **`j_tags_posts`** _should be_ **`j_posts_tags`**\n* Page 143 (first bullet point): **let's create a table named `inserted_post`** should be **let's create a table named `inserted_posts`**;\n* Page 147, in the section entitled *The ROW NUMBER function*, the query placed in the book does not has the column `row_number` shown in the query output. The correct query to use is `select category,count(*) over w , row_number() over w from posts WINDOW w as (partition by category) order by category;`. that reports the output as shown in the section output.\n* Page 152 (`LAST_VALUE` Window Function): the query `select category, row_number() over w, title, last_value(title) over w\nfrom posts WINDOW w as (partition by category order by category) order by category;` should be *`select category, row_number () over w, title, last_value (title) over w from posts WINDOW w as (partition by category order by title) order by category;`*. For more information about this error, see the [issue #6](https://github.com/PacktPublishing/Learn-PostgreSQL/issues/6)\n* Page 174 (section **Chars with fixed-length data types**): the query reported in the example `3` is missing the `FROM` clause, and should be `select pk,tag,length(tag),octet_length(tag),char_length(tag) FROM new_tags;`\n* Page 271 (heading): **Partition Maintenance** should be a second level heading within the section *g declarative partitioning*;\n* Page 581 (Section 5, heading): **The PostegreSQL System** _should be_ **The PostgreSQL System**\n\n\n##### About GNU Debian and Ubuntu Repositories\n\nThe installation example in the *Chapter 1*, with particular regard to the section *Installing PostgreSQL 12 on GNU/Linux Debian, Ubuntu and derivatives* refers to the adoption of the PostgreSQL Global Development Groupd (*PGDG*) repositories, as specified at the first step in the example.\n\nSince PostgreSQL 10, both the GNU Debian and Ubuntu operating system families have renamed the *PostgreSQL Contrib* module removing the version number suffix, therefore the right package to install is `postgresql-contrib` instead of the one presented in the installation instruction in the first chapter, wrongly named `postgresql-contrib-12`.\n\nThe package `postgresql-contrib-12` is a virtual package that refers to `postgresql-12`, threfore to the whole server and not to the contrib module.\n\n### Download a free PDF\n\n \u003ci\u003eIf you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.\u003cbr\u003eSimply click on the link to claim your free PDF.\u003c/i\u003e\n\u003cp align=\"center\"\u003e \u003ca href=\"https://packt.link/free-ebook/9781838985288\"\u003ehttps://packt.link/free-ebook/9781838985288 \u003c/a\u003e \u003c/p\u003e\n","funding_links":[],"categories":["PLpgSQL"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPacktPublishing%2FLearn-PostgreSQL","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPacktPublishing%2FLearn-PostgreSQL","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPacktPublishing%2FLearn-PostgreSQL/lists"}