Database.Guide

Skip to content

Beginners

  • What is a Database?
  • Database Tutorial

SQL

  • SQL Tutorial
  • SQL Reference
  • SQL Joins Tutorial
  • SQL Transactions Tutorial
  • Basic SQL Queries

Categories

  • Azure SQL Edge (17)
  • Database Concepts (99)
  • Database Tools (72)
  • DBMS (9)
  • DuckDB (156)
  • MariaDB (424)
  • Microsoft Access (17)
  • MongoDB (265)
  • MySQL (602)
  • NoSQL (8)
  • Oracle (301)
  • PostgreSQL (480)
  • Redis (210)
  • SQL (697)
  • SQL Server (1,170)
  • SQLite (299)

Category: PostgreSQL

2 Ways to Get the Size of a Database in PostgreSQL

Posted on November 12, 2021 by Ian

Below are two ways to return the size of a specific database in PostgreSQL.

Continue reading →
PostgreSQL how to

3 Ways to Format a Number as a Percentage in PostgreSQL

Posted on November 11, 2021 by Ian

We have several options if we want to display numbers with a percentage sign in PostgreSQL.

We can use the TO_CHAR() function to format the number along with the percentage sign. Or we can simply concatenate the number with the percentage sign, either with the CONCAT() function or with the concatenation operator.

Continue reading →
PostgreSQL how to, number format

Add Leading Zeros in SQL

Posted on November 10, 2021March 11, 2022 by Ian

Below are examples of adding a leading zero to a number in SQL, using various DBMSs.

Continue reading →
Azure SQL Edge, MariaDB, MySQL, Oracle, PostgreSQL, SQL, SQL Server how to, number format

STRING_AGG() Function in PostgreSQL

Posted on November 6, 2021November 6, 2021 by Ian

In PostgreSQL, we can use the STRING_AGG() function to return columns from a query as a delimited list.

Continue reading →
PostgreSQL aggregate functions, aggregation, functions, what is

How to Show Null Values When Running Queries in psql (PostgreSQL)

Posted on November 5, 2021November 6, 2021 by Ian

By default, null values are returned as an empty string in psql. But this can easily be changed.

One reason you might want to change this is to avoid null values being confused with actual empty strings.

You can change this with the \pset null 'value' command.

Continue reading →
PostgreSQL how to, psql

How POSITION() Works in PostgreSQL

Posted on November 5, 2021 by Ian

PostgreSQL has a POSITION() function that returns the first starting index of a specified substring within a string.

If the substring doesn’t exist in the string, then zero is returned.

Continue reading →
PostgreSQL functions, string functions, what is

2 Ways to Add Leading Zeros in PostgreSQL

Posted on November 3, 2021 by Ian

In PostgreSQL, we can use the TO_CHAR() function to add leading zeros to a number. The function converts the number to a string, using the (optional) format we specify.

Another option is to use the LPAD() function to pad a number with leading zeros.

Continue reading →
PostgreSQL how to, number format

Padding in SQL

Posted on November 1, 2021 by Ian

Some RDBMSs provide an LPAD() and RPAD() function that enables us to left pad or right pad a string. Some functions also allow us to add leading or trailing zeros numbers.

Below are examples of applying SQL padding in some of the more popular RDBMSs.

Continue reading →
Azure SQL Edge, MariaDB, MySQL, Oracle, PostgreSQL, SQL, SQL Server how to, string characters

Concatenate a String and a Number in PostgreSQL

Posted on October 31, 2021 by Ian

PostgreSQL provides us with the following ways to concatenate strings and numbers:

  • The CONCAT() function, which concatenates its arguments.
  • The pipe concatenation operator (||), which concatenates its operands.

Examples of each below.

Continue reading →
PostgreSQL how to

RPAD() Function in PostgreSQL

Posted on October 30, 2021 by Ian

In PostgreSQL, RPAD() is a function that enables us to add padding to the right part of a string.

Continue reading →
PostgreSQL functions, string functions, what is
  • «
  • 1
  • …
  • 33
  • 34
  • 35
  • 36
  • 37
  • …
  • 48
  • »

About Database.Guide | Privacy Policy