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 Drop Database Through PSQL in PostgreSQLThis article describes how to drop a database through Psql in PostgreSQL. How to Terminate a PostgreSQL ConnectionThis article describes how to terminate an opened connection in PostgreSQL. How to PostgreSQL - Check Date and Time Relative to TodayThis article demonstrates how to check the current date and time relative to today. Postgres Connection StringThis article shows the correct format of connection string in Postgres. Learn how to construct secure and efficient Postgres connection strings using environment variables and SSL encryption. Explore practical examples to enhance your database interaction and streamline your development process. How to Upsert (Merge, Insert on Duplicate Update) in PostgreSQLThis article describes how to perform an upsert operation in PostgreSQL. Auto Increment Values in PostgreSQLLearn how PostgreSQL identity columns, SERIAL, and sequences generate identifier values. How to Change User Password in PostgresThis tutorial shows how to change the user password in Postgres. Learn different methods, including SQL commands, psql command line, and pgAdmin, to securely manage user passwords in PostgreSQL. Keep your database secure with our easy-to-follow guide. How to Transpose Columns to Rows in PostgreSQLLearn how to turn column-oriented values into rows in PostgreSQL with unnest(), and when crosstab() is the reverse operation. PostgreSQL Default PortPostgreSQL uses port 5432 by default. Learn how to identify the instance listening, connect on a chosen port, change its configuration, and diagnose connection mismatches. How to Connect to PostgreSQL With PasswordThis article shows various methods for connecting PostgreSQL with password. It can be via command-line, pgpass file, PGPASSWORD environment variable or the connection string. How to Login and Authenticate to PostgreSQLLearn how to connect to a PostgreSQL database with psql, create a login role and database, and troubleshoot authentication failures. How to Query Between Date Ranges in PostgreSQLLearn how to filter PostgreSQL DATE values with rolling intervals, inclusive bounds, and daterange containment. How to List All Tables in PostgreSQLList every table in a PostgreSQL database by querying the INFORMATION_SCHEMA views or by using psql table-listing meta-commands, and filter the results by schema. How to Start PostgreSQL Server on WindowsThis article teaches how to start a PostgreSQL server on Windows. 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 Check if PostgreSQL Server Is Running on macOSThis article mentions several BASH commands to check for the status of PostgreSQL. How to Use UTC Current Time as Default in PostgreSQLLearn how to get the current time in UTC and use it as a PostgreSQL column default. PostgreSQL Naming ConventionsLearn a consistent way to name PostgreSQL databases, tables, sequences, keys, constraints, and indexes, and how quoted identifiers behave. How to Insert or Update if Exists in PostgreSQLIn PostgreSQL, use INSERT ... ON CONFLICT to insert a row or update it when its key already exists. How to Select Random Rows in PostgreSQLThis article teaches about the different ways we can select random rows in PostgreSQL. How to Write Case-Insensitive Queries in PostgreSQLLearn how to write case-insensitive text queries in PostgreSQL with ILIKE, normalized comparisons, indexes, and CITEXT. How to Subtract a Day From a Timestamp in PostgreSQLSubtract one day from a PostgreSQL timestamp with INTERVAL, or cast it to DATE when you want a date-only result. How to Run PostgreSQL Queries in PSQLLearn how to run SQL interactively, select a PostgreSQL database, use psql single-line mode, and execute a SQL file. How to Cast an Integer to String in PostgreSQLLearn to cast an integer to PostgreSQL text with CAST or the :: operator, and use CONCAT separately to combine text with values of other types.