Postgresql operation is quite different from mysql
Can be usedpsql
Command line tools or other PostgreSQL client tools to view tables. The following is usedpsql
How to view tables with command line tools:
Connect to a PostgreSQL database
If a PostgreSQL connection is
postgresql://username:[email protected]:5432/Library name?sslmode=disable
Then can be passedpsql -h 127.0.0.1 -p 5432 -U Username -d Library name
, and enter your password Log in
List all tables in the database
existpsql
Enter the following command in the command line:
\dt
This lists all the tables in the database to which you connect.
View information for a specific table
existpsql
Enter the following command in the command line:
\d table_name
in,table_name
It is the table name to view. This will display the column information, constraints, indexes and other detailed information of the table.
Query the data in the table
existpsql
Enter the following command in the command line:
SELECT * FROM table_name;
in,table_name
It is the table name to be queried. This will display all data in the table.
Exit psql command line tool
existpsql
Enter the following command in the command line:
\q
This will exitpsql
Command line tools.
The above is the detailed explanation of the command to operate PostgreSQL database using psql. For more information about operating PostgreSQL databases, please pay attention to my other related articles!