常用 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=#
相关推荐
tongxh42310 小时前
5、使用 pgAdmin4 图形化创建和管理 PostgreSQL 数据库
数据库·postgresql
F1FJJ1 天前
Shield CLI 的 PostgreSQL 插件 v0.5.0 发布:数据库导出 + 协作增强,ER 图全新体验
网络·数据库·docker·postgresql·go
数据库小组1 天前
Oracle 上云 / 替代场景下,NineData 完成到 PostgreSQL 的低风险迁移
大数据·数据库·mysql·postgresql·oracle·数据一致性·数据库迁移
念念不忘 必有回响1 天前
Drizzle ORM上手指南:在Next.js中优雅地操作PostgreSQL
开发语言·postgresql·nodejs·nextjs·drizzle
GISBox1 天前
PostGIS数据通过GISBox发布WFS/WMS全攻略
数据库·postgresql·wms·gis·postgis·矢量·gisbox
王仲肖1 天前
PostgreSQL 预写日志(WAL)深度解析
数据库·postgresql
王仲肖2 天前
PostgreSQL VACUUM 与 AUTOVACUUM 深度解析
数据库·postgresql
F1FJJ2 天前
Shield CLI 的 PostgreSQL 插件 v0.4.0 已发布:支持 ER 图设计表关系,还能多人协作
网络·网络协议·postgresql·数据分析·开源软件
zbdx不知名菜鸡2 天前
postgre sql 数据库查询优化
数据库·postgresql
Mr.45672 天前
JDK17+Druid+SpringBoot3+ShardingSphere5 多表分库分表完整实践(MySQL+PostgreSQL)
java·数据库·spring boot·mysql·postgresql