常用 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=#
相关推荐
七牛云行业应用2 小时前
Moltbook一夜崩盘:150万密钥泄露背后的架构“死穴”与重构实战
网络安全·postgresql·架构·高并发·七牛云
AskHarries3 小时前
Debian 12 环境下 PostgreSQL 15 部署与安全配置
postgresql
资深web全栈开发18 小时前
PostgreSQL枚举还是字符串:ENUM vs VARCHAR + CHECK 的权衡
数据库·postgresql
Aaron_Wjf20 小时前
PG Vector测试
数据库·postgresql
Aaron_Wjf20 小时前
PG逻辑复制槽应用
数据库·postgresql
智商偏低21 小时前
Postgresql导入几何数据(shp,geojson)的几种方式
数据库·postgresql
我是Superman丶1 天前
在 PostgreSQL 中使用 JSONB 类型并结合 MyBatis-Plus 实现自动注入,主要有以下几种方案
数据库·postgresql·mybatis
松涛和鸣1 天前
70、IMX6ULL LED驱动实战
linux·数据库·驱动开发·postgresql·sqlserver
数据知道1 天前
PostgreSQL 核心原理:什么场景下开启 JIT 能提升性能?(JIT 编译)
数据库·postgresql
盒马coding1 天前
postgreSQL中调整Checkpoint的重要性
数据库·mysql·postgresql