PostgreSQL – How to Determine the Row Count of a Table
You can count the number of rows in a table in PostgreSQL using the SELECT COUNT(*)
query. Here’s how you can do it:
SELECT COUNT(*) FROM table_name;
Replace table_name
with the name of the table for which you want to count the rows. When you run this query, PostgreSQL will return a single value, which is the total number of rows in the specified table.
For example, if you have a table named “employees,” you can count the rows in that table like this:
SELECT COUNT(*) FROM employees;
PostgreSQL will return a result like:
count
-------
1000
(1 row)
In this example, the table “employees” contains 1000 rows.
Below is a screenshot of row count from a table named ‘sales’. Output of the query shown the table has 2 rows.
![](https://postgresql-tutorial.com/wp-content/uploads/2023/10/image-7-1024x259.png)