Here are two options for listing out the triggers in a PostgreSQL database.
Continue readingCategory: PostgreSQL
Return Just the Numeric Values from a PostgreSQL Database Column
The following PostgreSQL examples return only those rows that have numeric values in a given column.
Continue reading2 Ways to Return Rows that Contain Only Alphanumeric Characters in PostgreSQL
Below are two methods for returning rows that only contain alphanumeric characters in PostgreSQL.
Alphanumeric characters are alphabetic characters and numeric characters.
Continue readingHow to Show the Current Setting for Null Output in PostgreSQL (psql)
When using psql, null values are returned as an empty string by default.
This can easily be changed with the \pset
command, so it could be a value other than the default empty string.
If you’re not sure what your current value is, you can use the show \pset null
command to show the current value.
DROP TABLE IF EXISTS Example in PostgreSQL
In PostgreSQL, we can use the IF EXISTS
clause of the DROP TABLE
statement to check whether the table exists or not before dropping it.
How to Check a Column’s Data Type in SQL
In SQL, the columns
information schema view, which returns information about columns, is an ISO standard view that is supported by most of the major RDBMSs. You can use this view to get information about a column’s data type.
Most of the major RDBMs also provide other methods for getting column information.
Here are examples of getting the data type of a column in various SQL databases.
Continue readingSUM() Function in PostgreSQL
In PostgreSQL, the SUM()
function computes the sum of the non-null input values and returns the result.
In other words, it adds numbers and returns the result.
Continue readingAVG() Function in PostgreSQL
In PostgreSQL, the AVG()
function computes the average (arithmetic mean) of all the non-null input values, and returns the result.
PostgreSQL DESCRIBE TABLE Equivalent
Some DBMSs such as Oracle, MySQL, and MariaDB have a DESCRIBE
command that returns information about tables and views. It goes DESCRIBE table
where table is the name of the table or view, and it can also be followed by a column name if you only want information about a specific column.
PostgreSQL doesn’t have a DESCRIBE TABLE
command as such, but there are alternatives.
3 Ways to List All Functions in PostgreSQL
Here are three options for listing out all functions in a PostgreSQL database.
Continue reading