How To Install pgformatter on Ubuntu 22.04

In this tutorial we learn how to install pgformatter on Ubuntu 22.04. pgformatter is PostgreSQL SQL syntax beautifier

Introduction

In this tutorial we learn how to install pgformatter on Ubuntu 22.04.

What is pgformatter

pgformatter is:

This SQL formatter/beautifier supports keywords from SQL-92, SQL-99, SQL-2003, SQL-2008, SQL-2011 and PostgreSQL specifics keywords. May works with any other databases too.

pgFormatter can work as a console program or as a CGI. pg_format will automatically detect its environment and output as text or as HTML following the context.

There are three methods to install pgformatter on Ubuntu 22.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install pgformatter Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install pgformatter using apt-get by running the following command:

sudo apt-get -y install pgformatter

Install pgformatter Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install pgformatter using apt by running the following command:

sudo apt -y install pgformatter

Install pgformatter Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install pgformatter using aptitude by running the following command:

sudo aptitude -y install pgformatter

How To Uninstall pgformatter on Ubuntu 22.04

To uninstall only the pgformatter package we can use the following command:

sudo apt-get remove pgformatter

Uninstall pgformatter And Its Dependencies

To uninstall pgformatter and its dependencies that are no longer needed by Ubuntu 22.04, we can use the command below:

sudo apt-get -y autoremove pgformatter

Remove pgformatter Configurations and Data

To remove pgformatter configuration and data from Ubuntu 22.04 we can use the following command:

sudo apt-get -y purge pgformatter

Remove pgformatter configuration, data, and all of its dependencies

We can use the following command to remove pgformatter configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge pgformatter

References

Summary

In this tutorial we learn how to install pgformatter package on Ubuntu 22.04 using different package management tools: apt, apt-get and aptitude.