How to Disconnect from a database and go back to the default database in PostgreSQL? -
i'm using postgresql version :
postgres=# select version(); version ------------------------------------------------------------- postgresql 9.2.4, compiled visual c++ build 1600, 64-bit (1 row)
i had connected database postgres=#
newdb=#
.... i'm in newdb=#
database want disconnect , go postgres=#
database ....
how ?
i have tried disconnect newdb;
but giving erroe as::
postgres=# create database newdb; create database postgres=# \c newdb; warning: console code page (437) differs windows code page (1252) 8-bit characters might not work correctly. see psql reference page "notes windows users" details. connected database "newdb" user "postgres". newdb=# disconnect newdb; error: syntax error @ or near "disconnect" line 1: disconnect newdb; ^ newdb=#
it isnt working there other way or wrong in anything!!
it's easy, example.
--my databases
postgres=# \l list of databases name | owner | encoding | collate | ctype | access privileges -----------+----------+----------+---------+-------+--------------------------- francs | postgres | utf8 | c | c | =tc/postgres + | | | | | postgres=ctc/postgres + | | | | | francs=c*t*c*/postgres + | | | | | select_only=c/francs postgres | postgres | utf8 | c | c | source_db | postgres | utf8 | c | c | =tc/postgres + | | | | | postgres=ctc/postgres + | | | | | source_db=c*t*c*/postgres template0 | postgres | utf8 | c | c | =c/postgres + | | | | | postgres=ctc/postgres template1 | postgres | utf8 | c | c | =c/postgres + | | | | | postgres=ctc/postgres (5 rows)
--switch db francs role francs
postgres=# \c francs francs connected database "francs" user "francs".
--swith db postgres role postgres
francs=> \c postgres postgres connected database "postgres" user "postgres". postgres=#
--disconnect db
postgres=# \q
Comments
Post a Comment