私はコマンドラインインターフェイスを使ってLinux上でpostgresqlを学びたいと思っています。Linuxでpostgresqlデータベースを削除するには
いくつかのチュートリアル(これまで私が学んだすべてを忘れてしまった後)に続いて、いくつかのデータベースを戻しながら追加しました。
これらのデータベースを削除します。
私は、postgresqlのコマンドラインインターフェイスであるpsqlを使用してこれを行うべきであると仮定しました。
私は次のコマンドライン出力で試したことが分かり、それがどれも成功していないことがわかります。
psql (9.5.6)
Type "help" for help.
postgres=# \list
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 |
template0 | postgres | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
testdb | postgres | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 |
(4 rows)
postgres=# dropdb template1
postgres-# \list
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 |
template0 | postgres | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
testdb | postgres | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 |
(4 rows)
postgres-# DROP DATABASE template1
postgres-# \list
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 |
template0 | postgres | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
testdb | postgres | UTF8 | en_CA.UTF-8 | en_CA.UTF-8 |
(4 rows)
empty_database psqlを[について読んで、テンプレートのデータベースを削除しないでくださいそれらのファイルを削除します。](https://www.postgresql.org/docs/current/static/manage-ag-templatedbs.html) – klin