Tips Cara Menghapus Database Di Postgresql
Pada tutorial PostgreSQL kali ini, kita akan berguru perihal Cara Menghapus Database. Untuk menghapus Database Di PostgreSQL. Perhatia...

https://tutorialcarapintar.blogspot.com/2019/02/tips-cara-menghapus-database-di.html
postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+---------------------------+---------------------------+----------------------- dbtest | postgres | UTF8 | Indonesian_Indonesia.1252 | Indonesian_Indonesia.1252 | hris | postgres | UTF8 | Indonesian_Indonesia.1252 | Indonesian_Indonesia.1252 | postgres | postgres | UTF8 | Indonesian_Indonesia.1252 | Indonesian_Indonesia.1252 | template0 | postgres | UTF8 | Indonesian_Indonesia.1252 | Indonesian_Indonesia.1252 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | Indonesian_Indonesia.1252 | Indonesian_Indonesia.1252 | =c/postgres + | | | | | postgres=CTc/postgres (5 rows)
Dari daftar database diatas, coba Anda hapus database "dbtest" dan tampilkan kembali daftar database.
postgres=# DROP DATABASE dbtest; DROP DATABASE postgres=#
postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+---------------------------+---------------------------+----------------------- hris | postgres | UTF8 | Indonesian_Indonesia.1252 | Indonesian_Indonesia.1252 | postgres | postgres | UTF8 | Indonesian_Indonesia.1252 | Indonesian_Indonesia.1252 | template0 | postgres | UTF8 | Indonesian_Indonesia.1252 | Indonesian_Indonesia.1252 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | Indonesian_Indonesia.1252 | Indonesian_Indonesia.1252 | =c/postgres + | | | | | postgres=CTc/postgres (4 rows) postgres=#
Menggunakan Perintah dropdb
Cara kedua untuk menghapus sebuah database di PostgreSQL yaitu dengan cara memakai executable command line "dropdb".
Contoh:
dropdb -h localhost -p 5432 -U postgress dbtest Password for user postgress: ****