How to create and delete a PostgreSQL database on the command line

H

How Can We Help?

This can be accomplished by using the dropdb and createdb command line wrappers

The syntax to create a new database on the command line is createdb [ options ] dbname

 

Example:

createdb -O user  new_database - E UTF8

This will create a new database called new_database and assign the user user to it and use the encoding UTF8

 

To drop a database on the command line the syntax dropdb [ options ] dbname is used.

 

Example:

dropdb new_database

About the author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

About Author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

Follow Me