Use psql tool introduced

See what database

psql -l
or
\ l

See what tables

\d

Connect to a database

\ C [dbname database name]

View a table structure definition

\ d [tabname Table Name]
or
\ d + [tabname table]

View index information

\ d [idxname Index Name]
or
\ d + [idxname index name]

View table to begin with certain letters of the structure definition

\ d [table name beginning with the letter]?
or
\ d [table name beginning with the letter]
or
\ d + [table name beginning with the letter]?
or
\ d + [table name begins with the letters]

Show only matching table

\dt

Show only matching index

\of

Matching sequences show only

\ds

Display only matching view

\dv

Show only matching function

\df

Time display Executed SQL

\timing

List all of the schema

\dn

Show all table spaces

\db

Lists all database users or roles

\ dg
some
\ du

Permission to display the distribution of a table

\ Dp [tabname Table name]

Specify the client character encoding

\ Encoding [character code] such as: \ encoding gbk, \ encoding utf8

Set the output format

Output content without borders

\pset border 0

Only within the borders

\pset border 1

There are internal and external borders (recommended)

\pset border 2

Each row of data are split into single-line display

\ x
or
psql -x

Execute SQL statements stored in an external file or command

\ i [filename filename]
or
psql -s [filename filename]

Line will

\ Echo [content]

For more command

?

Disable automatic commit

Transaction execution

the begin;
[the SQL statements]
the commit; or ROLLBACK;

Disable automatic commit

\set autocommit off

SQL statements in order to obtain the actual implementation of psql

psql -E

\set echo_hidden on|off

Guess you like

Origin www.cnblogs.com/nolanchan/p/12275311.html