1. PostgreSQL 修改 pgsql 提示符 PG 数据库安装完后进入pgsql默认是只显示数据库,不显示当前登录用户。 psql psql (12.2) Type "help" for help.

1.1 PostgreSQL 自定义 pgsql 提示符 -- 登录家目录下 $ pwd /home/pg12

--创建 .psqlrc 文件并添加变量 $ more .psqlrc \set PROMPT1 '%n@%/=>'

-- 验证 $ psql psql (12.2) Type "help" for help. postgres@postgres=>\c hwdb You are now connected to database "hwdb" as user "postgres". postgres@hwdb=> 1.2 SQL提示符的参数 %n:当前登录用户名 %/:当前登录的数据库 %M:服务器主机名称 %>:服务器监听端口 %#:超级用户显示符(#超级用户 >普通用户) %p:当前连接的后台进程编号