Trying to drop the primary database "foo", I get the error
ERROR: cannot drop the currently open database
Whats the right way to drop the primary psql database?
For finding the duplicates, we can utilize the Postgres COUNT() function. While to remove duplicate rows, we can use the “DELETE USING” Statement, subquery, or Postgres immediate Table.
Once a database is no longer needed, you can drop it by using the DROP DATABASE statement. To delete a database: Specify the name of the database that you want to delete after the DROP DATABASE clause. Use IF EXISTS to prevent an error from removing a non-existent database.
The first method to remove a PostgreSQL database is to use the following SQL statement: DROP DATABASE <database name>; The command removes the directory containing the database information and the catalog entries. Only the database owner can execute the DROP DATABASE command.
The command \d in psql lists all tables, views, and sequences.
Create a new database to log into while you drop the original one - I guess?
create database _;
(relog with -d _ )
drop database dbname;
create database dbname;
(relog)
drop database _;
That's what the database postgres
is there for.
Connect to it to drop your database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With