On this page
CNT
Core command
Counts the rows of a table, as SELECT COUNT(*) FROM the table would.
Syntax
CNT [<schema>.]<table>
Arguments
| Argument | Required | Values | Default |
|---|---|---|---|
<table> | Yes | A table name, in double quotes when it contains spaces or special characters | None |
<schema>. | No | The schema of the table, followed by a dot | The current schema |
Examples
CNT CUSTOMER;
CNT PUBLIC.CUSTOMER;
CNT "Sales Data";
Details
A name containing spaces or other special characters is written in double quotes (CNT "Sales Data"). The table is found exactly as ALL finds it: the name as typed, then in upper case, then in lower case. The count runs on that table, its name quoted for the connected database. A plain name that no lookup finds is sent to the database as typed; otherwise the command reports that the table does not exist.
Related
- ALL, how the table is found
- SHOW TABLES
Used in these how-tos
- How do I explore an unfamiliar database in fifteen minutes?
- How do I find orphan rows, duplicates and missing values?
- Estimated row count of every table (PostgreSQL) Scripts Gallery
Last modified in release 5.5.0.
Found something wrong or unclear on this page? Tell us, with the page address.