データベースの一覧を確認

シェルから

 $ psql -l
 $ psql --list
 
                                    List of databases
    Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
 -----------+----------+----------+-------------+-------------+-----------------------
  kurz_prod | pgadmin  | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
  pgadmin   | pgadmin  | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
  postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
  template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
            |          |          |             |             | postgres=CTc/postgres
  template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
            |          |          |             |             | postgres=CTc/postgres
 (5 rows)

psqlから

 => \l
 =>\list
                                                                     List of databases
 Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   |  Size   | Tablespace |                Description
 ------------+----------+----------+-------------+-------------+-----------------------+---------+------------+--------------------------------------------
 pgbench    | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                       | 29 MB   | pg_default |
 postgres   | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                       | 6073 kB | pg_default | default administrative connection database
 slonmaster | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                       | 1401 MB | movespace  |
 slonslave  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                       | 32 MB   | pg_default |
 template0  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +| 5785 kB | pg_default | unmodifiable empty database
         |          |          |             |             | postgres=CTc/postgres |         |            |
 template1  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +| 5985 kB | pg_default | default template for new databases
         |          |          |             |             | postgres=CTc/postgres |         |            |
 test       | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                       | 13 MB   | pg_default |
 (7 rows)

SQLで

 SELECT datname FROM pg_database WHERE datistemplate = false

参考

https://dba.stackexchange.com/questions/1285/how-do-i-list-all-databases-and-tables-using-psql


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS

Last-modified: 2018-06-04 (月) 11:28:14