0

I try to switch with powershell from databases with postgres (14.1)

So I do this:

postgres-# \l

And then I see all the databases. But for example how can I now switch to the test database?

  Name    |  Owner   | Encoding |         Collate          |          Ctype           |   Access privileges
-----------+----------+----------+--------------------------+--------------------------+-----------------------
 postgres  | postgres | UTF8     | English_Netherlands.1252 | English_Netherlands.1252 |
 template0 | postgres | UTF8     | English_Netherlands.1252 | English_Netherlands.1252 | =c/postgres          +
           |          |          |                          |                          | postgres=CTc/postgres
 template1 | postgres | UTF8     | English_Netherlands.1252 | English_Netherlands.1252 | =c/postgres          +
           |          |          |                          |                          | postgres=CTc/postgres
 test      | postgres | UTF8     | English_Netherlands.1252 | English_Netherlands.1252 |
(4 rows)

I try it like this:

postgres-# -d --test

But that doesn't work.

1 Answer 1

2

Use \connect (or just \c)

Quote from the manual

\c or \connect
Establishes a new connection to a PostgreSQL server. The connection parameters to use can be specified either using a positional syntax (one or more of database name, user, host, and port), or using a conninfo connection string as detailed in Section 34.1.1. If no arguments are given, a new connection is made using the same parameters as before.

The -d parameter can only be used when starting psql:

PS c:\> psql -d test
Sign up to request clarification or add additional context in comments.

1 Comment

ahhh, oke. Thank you!! oke

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.