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 (149)
  • 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

Add Minutes to a Time Value in PostgreSQL

Posted on October 18, 2022 by Ian

In PostgreSQL, we can use the + operator to add one or more minutes to a time value.

By “time” value, this could be an actual time value, a timestamp, or an interval. We can also add minutes to a date value or a date and time combination.

Continue reading →
PostgreSQL dates, how to, psql

Subtract Seconds from a Time Value in PostgreSQL

Posted on September 18, 2022 by Ian

In PostgreSQL, we can use the - operator to subtract one or more seconds from a time value.

By “time” value, this could be an actual time value, a timestamp, or an interval. We can also subtract seconds from a date value or a date and time combination.

Continue reading →
PostgreSQL dates, how to, psql

How to Get the First Day of the Month in SQL

Posted on September 8, 2022 by Ian

Below are examples of using SQL to return the first day of the month across various DBMSs.

This could be the first day of the current month, or the first day of a month based on a given date.

Continue reading →
MariaDB, MySQL, Oracle, PostgreSQL, SQL, SQL Server, SQLite dates, how to

Add Seconds to a Time Value in PostgreSQL

Posted on August 24, 2022 by Ian

In PostgreSQL, we can use the + operator to add one or more seconds to a time value.

By “time” value, this could be an actual time value, a timestamp, or an interval. We can also add seconds to a date value or a date and time combination.

Continue reading →
PostgreSQL dates, how to, psql

How to Delete Duplicate Rows that have a Primary Key in SQL

Posted on August 3, 2022September 20, 2024 by Ian

The following examples use SQL to delete duplicate rows that have a primary key or unique identifier column.

Specifically, the examples delete all duplicates except one. So for example, in the case of three identical rows, it deletes two of them and keeps one.

Continue reading →
MariaDB, MySQL, Oracle, PostgreSQL, SQL, SQL Server, SQLite how to

2 Ways to Check if a Table has a Generated Column in PostgreSQL

Posted on August 1, 2022 by Ian

PostgreSQL has supported generated columns since version 12. Generated columns can be created easily with the CREATE TABLE and ALTER TABLE statements.

We can check whether a table contains a generated column or not with the following methods.

Continue reading →
PostgreSQL computed columns, how to

PostgreSQL CASE Expression

Posted on July 28, 2022 by Ian

In PostgreSQL, the CASE expression compares a list of conditions and returns one of multiple possible result expressions.

The CASE expression is included in the SQL standard (ISO/IEC 9075), and most major RDBMSs support it.

Continue reading →
PostgreSQL operators, psql, what is

Return Rows that Contain Only Non-Alphanumeric Characters in SQL

Posted on July 24, 2022 by Ian

Here are examples of using SQL to return rows that contain non-alphanumeric characters in various DBMSs.

Non-alphanumeric characters include punctuation characters like !@#&()–[{}]:;',?/* and symbols like `~$^+=<>“, as well as whitespace characters like the space or tab characters.

Continue reading →
MariaDB, MySQL, Oracle, PostgreSQL, SQL, SQL Server, SQLite how to

2 Ways to List All Tables in a PostgreSQL Database

Posted on July 19, 2022 by Ian

Here are a couple of options for getting a list of tables in a database in PostgreSQL.

The first option is a psql command, the second involves querying an information schema view.

Continue reading →
PostgreSQL how to, psql

Return Only Numeric Values in SQL

Posted on July 5, 2022 by Ian

If you ever need to use SQL to return just the numeric values in a character column, the method you use will largely depend on your DBMS. Most DBMSs support regular expressions (regex), but some don’t. And some include functions that can detect numeric values.

Here are examples of how to do it in the more popular DBMSs.

Continue reading →
MariaDB, MySQL, Oracle, PostgreSQL, SQL, SQL Server, SQLite how to
  • «
  • 1
  • …
  • 22
  • 23
  • 24
  • 25
  • 26
  • …
  • 48
  • »

About Database.Guide | Privacy Policy