# How to switch database using PostgreSQL

> Learn how to switch the active database inside the psql tool in PostgreSQL using the connect command (or its c shortcut) to reconnect to another database.

Author: Flavio Copes | Published: 2020-01-02 | Canonical: https://flaviocopes.com/postgres-how-to-switch-database/

Inside `psql`, you always have one active database, where you are "into". By default it's the one you connect to in the first place. When you run:

```bash
psql postgres
```

you'll connect to the `postgres` database.

To switch database, use the `\connect` command, or `\c`:

![Switch database in PostgreSQL](https://flaviocopes.com/images/postgres-how-to-switch-database/Screen_Shot_2019-12-19_at_10.07.35.png)

PostgreSQL will close the connection to the previous database you were connected to, and will connect to the new one you specified.
