建立一个新连接

最近更新时间: 2024-06-12 15:06:00

  • 连接到另外一个库(也可以是当前库)。

      postgres=# select pg_backend_pid();
      pg_backend_pid 
     ----------------
               2408
     (1 row)
      postgres=# \c
     You are now connected to database"postgres" as user "tbase".
      postgres=# select pg_backend_pid();
      pg_backend_pid 
     ----------------
               2426
     (1 row)
      postgres=# \c template1
     You are now connected to database"template1" as user "tbase".
     template1=#
  • 连接到外一台服务。

     postgres=# \c postgres tbase 172.16.0.4715432
     You are now connected to database"postgres" as user "tbase" on host "172.16.0.47"at port "15432".