How to query the names of all user-defined data tables in a database in PostgreSQL

Source: Internet
Author: User
How to query the names of all user-defined data tables in a database in PostgreSQL

@ Forandever 2011-11-13

1. query through command line
\ D database-- Obtain the names of all tables.
\ D table name-- Get the table structure
 
2. query through SQL statements
"Select * From pg_tables"-- Obtain information about all tables in the current database (pg_tables is the system view here)

"Select tablename from pg_tables where schemaname = 'public '"-- Obtain the names of all user-defined tables (here, the "tablename" field is the table name, and "schemaname" is the schema name. If the user-defined table is not specially processed, it is put under the schema named public by default)

@ For & ever 2011-11-13

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.