原 PG如何在psql命令中显示快捷命令真实执行的SQL语句(ECHO_HIDDEN或-E)
Tags: 原创PGPostgreSQL命令介绍ECHO_HIDDEN真实SQL语句
简介
如何查看已有权限,如何查看某个schema下所有对象的权限等。 可以使用psql提供的一些快捷命令。
1 | \dp+ usera.* |
如果想知道这些快捷命令后面用了什么SQL,可以开启-E选项
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | C:\Users\lhrxxt>psql -U postgres -h 192.168.66.35 -d postgres -p15432 -E Password for user postgres: psql (11.6, server 11.11) Type "help" for help. postgres=# \l ********* QUERY ********** SELECT d.datname as "Name", pg_catalog.pg_get_userbyid(d.datdba) as "Owner", pg_catalog.pg_encoding_to_char(d.encoding) as "Encoding", d.datcollate as "Collate", d.datctype as "Ctype", pg_catalog.array_to_string(d.datacl, E'\n') AS "Access privileges" FROM pg_catalog.pg_database d ORDER BY 1; ************************** List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+-------------+-------------+----------------------- lhrpg | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | lhrpgdb | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres (5 rows) |