In this query, we used a condition in the WHERE clause to filter system tables. Schemaname != 'information_schema' Code language: SQL (Structured Query Language) ( sql ) It will add the size and description columns: postgres= # \dt+ Code language: PHP ( php ) Showing tables using pg_catalog schemaĪnother way to show tables in PostgreSQL is to use the SELECT statement to query data from the PostgreSQL catalog as follows: SELECT * To get more information on tables, you can use the \dt+ command. Third, use the \dt command from the PostgreSQL command prompt to show tables in the dvdrental database: postgres= # \dt Code language: PHP ( php ) In this command, you connect to the dvdrental database using the postgres user. In this command, the -d flag means database. Note that you can connect to a specific database when you log in to the PostgreSQL database server: $ psql -U postgres -d dvdrental You are now connected to database "dvdrental" as user "postgres". Third, switch to a database e.g., dvdrental: postgres= # \c dvdrental ![]() Second, enter the password for the user postgres and press the Enter keyboard: Password for user postgres: In this command, you use the postgres user to log in to the PostgreSQL database server. The -U flag stands for the user and -W option requires you to provide the password. ![]() Showing tables from PostgreSQL using psqlįirst, connect to PostgreSQL using the psql tool. PostgreSQL does not support the SHOW TABLES statement directly but provides you with an alternative. If you are coming from MySQL, you may want to use the popular SHOW TABLES statement that displays all tables in a specific database. Summary: in this tutorial, you will learn how to show tables in PostgreSQL using psql tool and pg_catalog schema.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |