PostgreSQL – CREATE Database
PostgreSQL CREATE DATABASE – using SQL Shell
Start the SQL Shell (psql) and run the following SQL Query.
CREATE DATABASE mydb;
where mydb is the database name that we are creating now.
![PostgreSQL CREATE DATABASE](https://www.tutorialkart.com/wp-content/uploads/2019/07/postgresql-create-database-1.png)
A new database with the name mydb
is created successfully.
Create Database using pgAdmin
When you install PostgreSQL, pgAdmin is installed. Start pgAdmin from your start menu.
![PostgreSQL pgAdmin](https://www.tutorialkart.com/wp-content/uploads/2019/07/postgresql-pgadmin.png)
Right click on the Databases, then Create, Database.
![PostgreSQL Create Database](https://www.tutorialkart.com/wp-content/uploads/2019/07/postgresql-create-database-2.png)
A new window ‘Create – Database‘ appears as shown below.
![PostgreSQL Create Database](https://www.tutorialkart.com/wp-content/uploads/2019/07/postgresql-create-database-3.png)
Provide the database name against Database
field. You can select the owner for this database. Also provide a comment.
This window has other tabs, where you can customize your Database while its creation.
Or you can click on Save
button to create the database.
Create – Database: Definition
You can provide the details like Encoding, Template, Tablespace, Collation, Character type, and Connection limit to the database.
![](https://www.tutorialkart.com/wp-content/uploads/2019/07/postgresql-create-database-4.png)
Create – Database: Security
You can provide privileges to users and also add Security labels. Using Security labels, you can manage the security of all the databases.
![](https://www.tutorialkart.com/wp-content/uploads/2019/07/postgresql-create-database-5.png)
Create – Database: Parameters
![](https://www.tutorialkart.com/wp-content/uploads/2019/07/postgresql-create-database-6.png)
Create – Database: SQL
You can also provide your custom SQL code to create Database, using SQL Tab.
![](https://www.tutorialkart.com/wp-content/uploads/2019/07/postgresql-create-database-7.png)
Save Database
Once you click on the Save
button, a new PostgreSQL database is created as shown below.
![PostgreSQL New Database Created](https://www.tutorialkart.com/wp-content/uploads/2019/07/postgresql-create-database-8.png)
Conclusion
In this PostgreSQL Tutorial, we learned to create a PostgreSQL Database using psql and pgAdmin.