PostgreSQL13.2に指定したデータベースへ接続する

環境
windows10 64bit
postgresql 13.2

1.データベースを指定する
>psql -U postgres
ユーザ postgres のパスワード:
psql (13.2)
“help"でヘルプを表示します。

2.¥cコマンドを使ってデータベース「testdb」に接続する
postgres=# \c testdb
データベース"testdb"にユーザ"postgres"として接続しました。

3.現在接続しているデーベース名を取得する

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
testdb=# select current_database();
current_database
------------------
testdb
(1)
testdb=# select current_database(); current_database ------------------ testdb (1 行)
testdb=# select current_database();
 current_database
------------------
 testdb
(1 行)

 

PostgreSQL

Posted by arkgame