Hi coders, Today I’m going to show you how you can create database in PostgreSQL, I’m going to show you two different methods – Using command line, and then Using PgAdmin.
Creating Database in PostgreSQL:
There are two things that you must have installed into your system before moving to given steps:
Once you’ve successfully installed above tools then you’re ready to move further.
Creating a Database using PSQL Command Line:
Basically, when you install PostgreSQL, then you might have noticed that it also asks for PSQL(Command line to work with Postgres). So, If you have successfully installed PostgreSQL then you will also PSQL command line.
Just click on windows and search “PSQL”, and then open PSQL command line and follow given steps.
1. Open PSQL(Shell) and Fill details:
When you will open PSQL, then you need to enter a few details, you can leave most as default. But You need to enter the correct password in order to enter inside PostgreSQL DB.
2. Enter Following command to create DATABASE:
CREATE DATABASE database_name;
3. Enter the command \l to see the list of all database:
You can see now we also have cchit database in out list.
4. To establish connection with database enter \c command:
\c database_name
Creating a Database using PgAdmin:
Open your PgAdmin dashboard via clicking on PgAdmin icon.
Now follow all given steps to create database using PgAdmi.
Open you PgAdmin dashboard, and then expand the tree and then right click on Database > create > database
2. Fill the pop up form:
When you click on create > database, then you will get pop up form to fill details of that database.
Now just click on save.
3. Database created:
You successfully created database in Postgres using PdAdmin,
Read Also: How to connect PostgreSQL database with Django web framework?
I hope you all liked this article, If yes then please don’t forget to share this article with others.
Thank’s to visit.
1 thought on “How to create a Database in PostgreSQL? The Basic Guide”