0
0

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.

psql で新しいデータベースを作る時にとりあえず接続するDB

0
Posted at

何でそんな仕様になってるかはよくわかりませんが、psql コマンドでPostgreSQLを使う時は必ず何かデータベースに接続しないといけません。 新しいデータベースを作りたいだけなのに何故か別のデータベースにログインしないとダメなんです。 頭の良い人の考えることはよくわからん。

postgres ってデータベースが始めっからあるのでそれに繋ぐ

なので新しいデータベースを作りたいだけの時はデフォルトで作成される postgres データベースに繋ぐそうです。 (バッドノウハウじゃないですかこれ?)

CREATE DATABASEコマンドを実行するためには、データベースサーバに接続している必要があります。 そうすると、あるサイトの最初のデータベースはどのようにして作成するのかという疑問が出てきます。 最初のデータベースはinitdbコマンドでデータ格納領域が初期化される(項17.2を参照してください。)時、必ず作成されます。 このデータベースはpostgresと呼ばれます。 したがって、最初の"通常の"データベースを作成するにはpostgresに接続してください。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?