In PostgreSQL, the EXCEPT
operator returns rows that are returned by the left input query that aren’t returned by the right input query. This can also be referred to as the difference between two queries.
Category: PostgreSQL
3 Ways to List All Stored Procedures that Reference a Table in PostgreSQL
Here are three examples of returning a list of stored procedures that reference a specific table in PostgreSQL.
Continue reading3 Ways to List all Triggers for a Given Table in PostgreSQL
Here are three options for listing out the triggers for a given table in PostgreSQL.
Continue reading5 Ways to Select Rows with the Maximum Value for their Group in SQL
Here are five options for using SQL to return only those rows that have the maximum value within their group.
These examples work in most major RDBMSs, including MySQL, MariaDB, Oracle, PostgreSQL, SQLite, and SQL Server.
Continue reading3 Ways to Select the Row with the Maximum Value in SQL
Here are three examples that use SQL to find and select the row with the maximum value in a given column.
The examples work in most major RDBMSs, including MySQL, MariaDB, PostgreSQL, SQLite, Oracle, and SQL Server.
Continue reading4 Ways to Select Duplicate Rows in PostgreSQL
If you have a table with duplicate rows in PostgreSQL, you can use any of the following queries to return the duplicate rows.
Continue readingFind Values That Don’t Contain Numbers in PostgreSQL
The following example returns all rows that don’t contain any numbers in PostgreSQL.
Numbers can be represented by words and other symbols, but for this article “number” simply means “numerical digit”. So we’re finding values that don’t contain any numerical digits.
Continue reading4 Ways to Find Rows that Contain Uppercase Characters in PostgreSQL
Here are four options for returning rows that contain uppercase letters in PostgreSQL.
Continue readingHow to List All Views in a PostgreSQL Database
In PostgreSQL, we can use the information_schema.views
view to return all views in a database.
We can also use the \dv
psql command to do the same thing.
How to Get Multiple Rows into a Comma Separated List in SQL
Most of the major RDBMSs have a function that enables us to return our query results as a comma separated list.
That is, we can use such a function to convert each row into a separate list item, within a comma separated list.
Below are examples of how to achieve this in some of the more popular RDBMSs.
Continue reading