postgresqlHow do I list tables in PostgreSQL?
To list tables in PostgreSQL, you can use the \dt
command. This command will list all the tables in the current database.
For example:
\dt
This will output a list of the tables in the current database, along with their schemas and sizes in kilobytes.
List of relations
Schema | Name | Type | Owner
--------+----------------+-------+---------
public | mytable | table | username
public | myothertable | table | username
(2 rows)
In addition to \dt
, you can also use \d
to list all the objects in the current database, including tables, views, functions, and other objects.
For example:
\d
This will output a list of all the objects in the current database, along with their types, schemas, sizes, and other information.
List of relations
Schema | Name | Type | Owner
--------+----------------+-------+---------
public | mytable | table | username
public | myothertable | table | username
public | myview | view | username
public | myfunction | func | username
(4 rows)
For more information, see the PostgreSQL Documentation and the PostgreSQL Command Line Cheat Sheet.
More of Postgresql
- How do I use PostgreSQL ZonedDateTime to store date and time information?
- How can Zalando use PostgreSQL to improve its software development?
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How can I use PostgreSQL and ZFS snapshots together?
- How can I integrate PostgreSQL with Yii2?
- How can I retrieve data from PostgreSQL for yesterday's date?
- How can I use PostgreSQL XML functions to manipulate XML data?
- How do I use PostgreSQL's XMLTABLE to parse XML data?
- How can I set a PostgreSQL interval to zero?
- How can I use PostgreSQL's "zero if null" feature?
See more codes...