5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PostgreSQL: データベースを切り替えるコマンドは `\c`

Last updated at Posted at 2019-06-14

PostgreSQLでデータベースを切り替える(接続する)コマンドを紹介する。MySQLのUSE database相当。

psqlコマンドで対話ターミナルを開く:

psql

対話ターミナル上で下記メタコマンドを実行すると、データベースが切り替わる:

\c データベース名

\cの代わりに\connectでも良い:

\connect データベース名

実行例

root=# \c movies
You are now connected to database "movies" as user "root".

root=# \connect music
You are now connected to database "music" as user "root".

覚え方

connect (接続する)

関連

5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?