Practical solutions

PostgreSQL Howtos How-To Guides

Solve the problem. Keep building. Collection of PostgreSQL how-to articles

Find the answer you need

Browse practical solutions, grouped by the task you're working on.

__COUNT__ entries on this page

How to Use UTC Current Time as Default in PostgreSQLThis article teaches how to use UTC current time as default in PostgreSQL. How to Update Data in the JSON Field in PostgreSQLThis article discusses how to update a JSON field in Postgres. Using JSONB_SET(), you can modify the existing JSON key-value. How to Login and Authenticate to PostgreSQLThis article will teach the reader how to login and be authenticated to access a particular PostgreSQL database. How to Install the Client Tools for PostgreSQL on WindowsThis article will teach the reader how to install the client tools for PostgreSQL database to access any remote database. How to Find the Disk Size of a PostgreSQL Table and Its IndexesThis article discusses how we can find the disk size of a PostgreSQL table and its indexes. Using the \l+ command, we can show the database sizes, and using \d+, we can view the table sizes. How to Escape a Single Quote in PostgreSQLThis tutorial discusses how to escape a single quote in PostgreSQL. How to Connect to PostgreSQL in SSL ModeTo encrypt the connection between client and the postgres server, we need to use the SSL mode in postgres. As, it's a secure database, to keep it that way we need to use the SSL mode, whenever we're trying to connect via HTTPS. How to Replace Strings in PostgreSQLThis tutorial discusses how to replace string using PostgreSQL replace() function. How to Select Top N Rows in PostgreSQLThis tutorial walks you through different ways to get the top n rows in a PostgreSQL table. How to Generate a UUID for the Insert Statement in PostgreSQLUUID is a unique identifier id created by the RFC 4122. There are several versions of it. The latest one is the v4. It's a 32-digit hexadecimal code. We can use it as the primary key. How to Check if a User-Defined Type Already Exists in PostgreSQLWe can use a script to check whether or not the type already exists. Query over the pg_type can inform us whether the user-defined type exists or not. How to Add Primary Key to a PostgreSQL Table Only if It Does Not ExistSometimes, we may forget to assign a primary key while executing the CREATE TABLE query. We can use the alter table query to assign the primary key in an existing table. How to Get Array Length in PostgreSQLThis article discusses calculating the length of an array in PostgreSQL. How to Find and Delete Duplicate Records in a Database in PostgreSQLThis article shows how to find duplicate records in a database and then delete them in PostgreSQL. How to Delete All Table Rows in PostgreSQLThis article shows the method to delete all rows in a table in PostgreSQL. How to Check if PostgreSQL Is Installed on LinuxThis tutorial explains how to check whether we have installed PostgreSQL on Linux or not. How to Use Where Clause in the Date Field Using PostgreSQLThis article demonstrates the use of where clause in the date type field using PostgreSQL. How to Upgrade the PostgreSQL Server Version Without Losing Any DataThis tutorial describes the procedure to update the PostgreSQL server version without losing any data. How to Install PSQL Without Installing Full PostgreSQLThe article demonstrates a procedure to install psql without installing the full PostgreSQL server using Homebrew services. How to Insert or Update if Exists in PostgreSQLIn Postgres, there's a method called UPSERT which inserts a row if it's not present in the table. Else, it just updates the field of the row. How to Grant Privileges to the User in PostgreSQLThis article explains how to grant privileges to the user in PostgreSQL. How to Add Days to Date in PostgreSQLThis article illustrates how we can add several days to date while using PostgreSQL. How to Transpose Columns to Rows in PostgreSQLThis article describes the method to transpose columns to rows in PostgreSQL. How to Select From Dual in PostgreSQLThis article discusses the dual table and the alternatives of selecting from dual in PostgreSQL.