testdb=# \h
Available help:
ABORT ALTER SEQUENCE CREATE AGGREGATE CREATE SUBSCRIPTION DROP EXTENSION DROP TEXT SEARCH PARSER RESET
ALTER AGGREGATE ALTER SERVER CREATE CAST CREATE TABLE DROP FOREIGN DATA WRAPPER DROP TEXT SEARCH TEMPLATE REVOKE
ALTER COLLATION ALTER STATISTICS CREATE COLLATION CREATE TABLE AS DROP FOREIGN TABLE DROP TRANSFORM ROLLBACK
ALTER CONVERSION ALTER SUBSCRIPTION CREATE CONVERSION CREATE TABLESPACE DROP FUNCTION DROP TRIGGER ROLLBACK PREPARED
ALTER DATABASE ALTER SYSTEM CREATE DATABASE CREATE TEXT SEARCH CONFIGURATION DROP GROUP DROP TYPE ROLLBACK TO SAVEPOINT
ALTER DEFAULT PRIVILEGES ALTER TABLE CREATE DOMAIN CREATE TEXT SEARCH DICTIONARY DROP INDEX DROP USER SAVEPOINT
ALTER DOMAIN ALTER TABLESPACE CREATE EVENT TRIGGER CREATE TEXT SEARCH PARSER DROP LANGUAGE DROP USER MAPPING SECURITY LABEL
ALTER EVENT TRIGGER ALTER TEXT SEARCH CONFIGURATION CREATE EXTENSION CREATE TEXT SEARCH TEMPLATE DROP MATERIALIZED VIEW DROP VIEW SELECT
ALTER EXTENSION ALTER TEXT SEARCH DICTIONARY CREATE FOREIGN DATA WRAPPER CREATE TRANSFORM DROP OPERATOR END SELECT INTO
ALTER FOREIGN DATA WRAPPER ALTER TEXT SEARCH PARSER CREATE FOREIGN TABLE CREATE TRIGGER DROP OPERATOR CLASS EXECUTE SET
ALTER FOREIGN TABLE ALTER TEXT SEARCH TEMPLATE CREATE FUNCTION CREATE TYPE DROP OPERATOR FAMILY EXPLAIN SET CONSTRAINTS
ALTER FUNCTION ALTER TRIGGER CREATE GROUP CREATE USER DROP OWNED FETCH SET ROLE
ALTER GROUP ALTER TYPE CREATE INDEX CREATE USER MAPPING DROP POLICY GRANT SET SESSION AUTHORIZATION
ALTER INDEX ALTER USER CREATE LANGUAGE CREATE VIEW DROP PROCEDURE IMPORT FOREIGN SCHEMA SET TRANSACTION
ALTER LANGUAGE ALTER USER MAPPING CREATE MATERIALIZED VIEW DEALLOCATE DROP PUBLICATION INSERT SHOW
ALTER LARGE OBJECT ALTER VIEW CREATE OPERATOR DECLARE DROP ROLE LISTEN START TRANSACTION
ALTER MATERIALIZED VIEW ANALYZE CREATE OPERATOR CLASS DELETE DROP ROUTINE LOAD TABLE
ALTER OPERATOR BEGIN CREATE OPERATOR FAMILY DISCARD DROP RULE LOCK TRUNCATE
ALTER OPERATOR CLASS CALL CREATE POLICY DO DROP SCHEMA MERGE UNLISTEN
ALTER OPERATOR FAMILY CHECKPOINT CREATE PROCEDURE DROP ACCESS METHOD DROP SEQUENCE MOVE UPDATE
ALTER POLICY CLOSE CREATE PUBLICATION DROP AGGREGATE DROP SERVER NOTIFY VACUUM
ALTER PROCEDURE CLUSTER CREATE ROLE DROP CAST DROP STATISTICS PREPARE VALUES
ALTER PUBLICATION COMMENT CREATE RULE DROP COLLATION DROP SUBSCRIPTION PREPARE TRANSACTION WITH
ALTER ROLE COMMIT CREATE SCHEMA DROP CONVERSION DROP TABLE REASSIGN OWNED
ALTER ROUTINE COMMIT PREPARED CREATE SEQUENCE DROP DATABASE DROP TABLESPACE REFRESH MATERIALIZED VIEW
ALTER RULE COPY CREATE SERVER DROP DOMAIN DROP TEXT SEARCH CONFIGURATION REINDEX
ALTER SCHEMA CREATE ACCESS METHOD CREATE STATISTICS DROP EVENT TRIGGER DROP TEXT SEARCH DICTIONARY RELEASE SAVEPOINT
testdb=#
testdb-# \dt
List of relations
Schema | Name | Type | Owner
--------+------+-------+----------
public | emp | table | postgres
(1 row)
testdb-# \di
Did not find any relations.
testdb-# \ds
Did not find any relations.
testdb-# \dv
Did not find any relations.
testdb-# \df
List of functions
Schema | Name | Result data type | Argument data types | Type
--------+------+------------------+---------------------+------
(0 rows)
3. 显示执行时间
\timing on
testdb=# \timing on
Timing is on.
testdb=# select * from emp;
empid | last_name
-------+-----------
(0 rows)
Time: 0.326 ms
4、列出所有模式
\dn
postgres=# \dn
List of schemas
Name | Owner
--------+-------------------
public | pg_database_owner
(1 row)
postgres=#
5、列出所有表空间
\db
postgres=# \db
List of tablespaces
Name | Owner | Location
------------+----------+----------
pg_default | postgres |
pg_global | postgres |
(2 rows)
6、列出所有用户
\dg \du 都一样
postgres=# \dg
List of roles
Role name | Attributes
-----------+------------------------------------------------------------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS
postgres=# \du
List of roles
Role name | Attributes
-----------+------------------------------------------------------------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS
postgres=#
7.列出某各表的权限
testdb=# \dp emp
Access privileges
Schema | Name | Type | Access privileges | Column privileges | Policies
--------+------+-------+-------------------+-------------------+----------
public | emp | table | | |
(1 row)