常用 psql 命令记忆技巧

d → Display

n → Namespaces ⇔ schema

b → Block → 联想到表空间

\d + 首字母 = 显示某类对象

\dt --- Tables (表)

\di --- Indexes (索引)

\dv --- Views (视图)

\df --- Functions (函数)

\ds --- Sequences (序列)

\dy --- Event Triggers (事件触发器)

\l --- List databases (数据库列表)

\c --- Connect (连接)

\conninfo --- Connection Information

\du --- Display Users (用户)

\dg --- Display Groups (角色组)

\db --- Display Tablespace (Block 存储) (表空间)

\dp --- Display Privileges (权限)

\dn --- Display Namespaces,在 PostgreSQL 内部,schema 实际上就是 namespace

sql 复制代码
mydb=# select * from pg_namespace;
  oid  |      nspname       | nspowner |                            nspacl                             
-------+--------------------+----------+---------------------------------------------------------------
    99 | pg_toast           |       10 | 
    11 | pg_catalog         |       10 | {postgres=UC/postgres,=U/postgres}
  2200 | public             |     6171 | {pg_database_owner=UC/pg_database_owner,=U/pg_database_owner}
 13255 | information_schema |       10 | {postgres=UC/postgres,=U/postgres}
 16394 | schema_fred        |       10 | 
(5 rows)

mydb=# select * from information_schema.schemata;
 catalog_name |    schema_name     |   schema_owner    | default_character_set_catalog | default_character_set_schema | default_character_set_name | sql_path 
--------------+--------------------+-------------------+-------------------------------+------------------------------+----------------------------+----------
 mydb         | schema_fred        | postgres          |                               |                              |                            | 
 mydb         | information_schema | postgres          |                               |                              |                            | 
 mydb         | pg_catalog         | postgres          |                               |                              |                            | 
 mydb         | pg_toast           | postgres          |                               |                              |                            | 
 mydb         | public             | pg_database_owner |                               |                              |                            | 
(5 rows)

mydb=#
相关推荐
jnrjian9 小时前
\dx Postgres 查看EXTENSION
postgresql
Lihua奏10 小时前
高可用与扩展:一台 PostgreSQL 不够用之后怎么办?
postgresql
鸽芷咕14 小时前
MySQL/PostgreSQL 迁移金仓 KES:LEFT JOIN 丢数据排查与避坑指南
数据库·mysql·postgresql
Java面试题总结1 天前
PostgreSQL 数据库技术详解
数据库·postgresql
Lihua奏2 天前
PostgreSQL:数据还在内存里,为什么断电也不怕?
postgresql
周杰伦的稻香2 天前
PostgreSQL中的METHOD(认证方法)
数据库·postgresql
Zhu7582 天前
对docker环境的postgresql数据库做快速初始化
数据库·docker·postgresql
l1t3 天前
测试用rust重写的postgresql: pgrust
开发语言·postgresql·rust
IvorySQL4 天前
云环境下PostgreSQL的Cgroup内存管理实践
java·数据库·postgresql