7

I am a complete beginner with postgresql. I created a test database called iswdp and now I want to delete it. When I do:

dropdb iswdp

the command returns no output and when I \list the table iswdp is still there.

dropdb iswdp;

returns:

ERROR: syntax error at or near "dropdb" LINE 1: dropdb iswdp

I used:

SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE datname = current_database()
AND pid <> pg_backend_pid();

which I found from another stackoverflow post to disconnect from all databases then attempted dropdb iswdp again with the same result.

I'm stuck, can someone help me? I'm doing this on linux mint from the bash terminal.

2 Answers 2

9

The command dropdb is a command issued from a shell prompt. From a sql prompt (like psql), you would want to issue a DROP DATABASE command.

I recommend opening psql and issuing DROP DATABASE iswdp;. That should work.

You may get an error that looks like ERROR: cannot drop the currently open database, which will happen if you connect to iswdp and try to drop it. If that happens, try instead to connect to the postgres database, and issue the same DROP DATABASE command. It should work.

Sign up to request clarification or add additional context in comments.

Comments

3

dropdb is a commando from shell not from psql program, from psql the commnado is drop database iswp;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.