Experts in Postgres and Open Source Infrastructure

24x7, 365 Enterprise services since 1997

Education

Professional Postgres and Open Source support

Command Prompt, Inc., is the oldest Postgres Company in North America and one of the oldest Open Source firms still operating today. We serve our clients with best in class expertise and professionalism. You can read more about support and services here:


You have landed at the largest single source of Postgres education blogs in the world. At Command Prompt, we believe deeply that the education of the community is critical to the continued success of Postgres and related technologies. We hope you find content you are looking for and don't hesitate to Contact us today for all your Postgres and Open Source consulting and support needs.

How to Use Generated Columns in PostgreSQL

The generated columns do not have a fixed value; rather this value is automatically computed by the expression that is determined at the time of column definition.

How to Transpose Columns to Rows in PostgreSQL?

In PostgreSQL, the crosstab() function and the unnest() function are used to transpose columns into rows. These functions help us transform the table by returning the transposed table.

How to Select Random Rows in PostgreSQL

To get random rows from a database table, use the RANDOM() function with the ORDER BY clause. We can also specify the limit of the number of rows we want to fetch/retrieve.

Understanding Postgres LCM() and GCD() Functions Using Examples

The lcm() and gcd() functions take two numeric type parameters and return their lowest common factor and the greatest common divisor respectively.

How to Query Data Between Specific Date Ranges in PostgreSQL

To get the data between two specified date ranges, use the “WHERE” and “AND” clauses, the BETWEEN operator, the SYMMETRIC keyword, and the Range data types.

How to Find the Size of a Postgres Tablespace

To find the size of the Postgres Tablespace, use the “pg_tablespace_size” function that takes the tablespace name as an argument and returns its size.

How to Round an Average to 2 Decimal Places in PostgreSQL

To find the average of a column we use the AVG() function taking the name of the column as a parameter. The ROUND() function rounds off a specified number up to particular decimal places.

How to Custom Sort in PostgreSQL ORDER BY Clause?

In PostgreSQL, the ordering is done by using the ASC and DESC keywords but we can also customize the sorting order using several ways, such as the CASE keyword, array_position() function, etc.

How to Change Primary Key in Postgres

To change a Primary key in Postgres, remove the existing primary key from the table, and add a new primary key using the “ALTER TABLE ADD PRIMARY KEY” statement.

A Comprehensive Guide on psql Meta-Commands

The meta-commands are the commands offered by psql to perform certain operations. These commands start with the backslash and do not end with the semicolon.