@mose
To delete a PostgreSQL database on Linux, you can follow these steps:
1
|
sudo -i -u postgres |
1
|
psql |
1
|
l |
1
|
c database_name |
Make sure to replace database_name
with the name of the database you want to delete.
1
|
SELECT pg_stat_get_backend_pid(pg_backend_pid()) AS pg_backend_pid; |
If you see a non-null result, it indicates that you are still connected to the database. In that case, you can disconnect from the database by running:
1
|
SELECT pg_terminate_backend(pg_stat_get_backend_pid(pg_backend_pid())); |
1
|
DROP DATABASE database_name; |
Replace database_name
with the name of the database you want to delete.
After following these steps, the specified PostgreSQL database should be successfully deleted from your Linux system.
@mose
Remember to exercise caution when deleting databases as this action is irreversible and can result in data loss. Before deleting a database, ensure that you have backed up any important data.