Tutorialsteacher

Follow Us

Articles
  • C#
  • C# OOP
  • ASP.NET Core
  • ASP.NET MVC
  • LINQ
  • Inversion of Control (IoC)
  • Web API
  • JavaScript
  • TypeScript
  • jQuery
  • Angular 11
  • Node.js
  • D3.js
  • Sass
  • Python
  • Go lang
  • HTTPS (SSL)
  • Regex
  • SQL
  • SQL Server
  • PostgreSQL
  • MongoDB
  • PostgreSQL - Get Started
  • Install PostgreSQL
  • Connect to PostgreSQL DB
  • Create Database
  • Create Table
  • Copy Table
  • Drop Table
  • Drop Database
  • Truncate Table
  • ALTER Table
  • Rename Table
  • Rename Columns
  • Add Columns
  • Modify Column Type
  • Set Default Value of Column
  • Remove Columns
  • Add Constraints to Table
  • Insert Data
  • Upsert Data
  • Update Data
  • Delete Data
  • SELECT Statement
  • WHERE Clause
  • GROUP BY Clause
  • HAVING Clause
  • ORDER BY Clause
  • DISTINCT Clause
  • Inner Join
  • Left Outer Join
  • Right Outer Join
  • Full Outer Join
  • Self Join
  • Natural Join
  • Cross Join
  • LIMIT OFFSET Clause
  • GROUPING SETS
  • GROUPING() Function
  • GROUP BY CUBE
  • GROUP BY ROLLUP
  • Sub Query
  • ALL Operator
  • ANY Operator
  • UNION Operator
  • INTERSECT Operator
  • EXCEPT Operator
  • IS NULL Operator
  • BETWEEN Operator
  • LIKE Operator
  • CAST Operator
  • CASE Expressions
  • NULLIF()
  • COALESCE()
  • GREATEST(), LEAST()
  • WITH Queries (CTE)
  • Constraints
  • NOT NULL Constraint
  • Unique Constraint
  • Check Constraint
  • Primary Key
  • Foreign Key
  • Sequence
  • Serial Type
  • Identity Columns
  • Generated Columns
  • Data Types
  • Boolean Type
  • Character Type
  • Integer Type
  • Numeric Type
  • Date Type
  • Time Type
  • TimeStamp Type
  • Interval Type
  • Array Type
  • Json Type
Entity Framework Extensions - Boost EF Core 9
  Bulk Insert
  Bulk Delete
  Bulk Update
  Bulk Merge

Create Database in PostgreSQL using psql and pgAdmin

PostgreSQL database can be created using psql (SQL Shell) and pgAdmin.

Create Database using psql

Use the CREATE DATABASE command in psql to create a new database in PostgreSQL.

CREATE DATABASE <databse_name>

Let's create the 'HR' database in psql.

Create Database in psql

Now, we can check whether the database is created or not by using \l command which will display the list of databases on the server.

List All Databases in psql

The postgres=# in psql indicates the current database name. At this point it is pointing to the default postgres database. All the tables and other database objects you will be created in the postgres database.

We can switch the current database using the \connect database-name or \c database-name command. Let's switch to our new 'HR' database.

Switch Databases in psql

Create Database using pgAdmin

We can also create a new database in PostgreSQL using GUI based tool pgAdmin.

Open pgAdmin and right-click on the server name (here it is default server name PostgreSQL 14) -> Create -> Database..., as shown below.

Create Database in pgAdmin

This will open Create – Database dialog, as shown below. Here you can provide a Database name, select owner (postgres will be the owner by default). You can also provide other settings in Defination, Security, Parameters, Advanced, and SQL tabs. Click on Save to create this new database.

Create Database

pgAdmin will list a newly created database under the Databases node in the left pane, as shown below.

Create Database

Click on the database name to expand it, as shown below.

Create Database

Thus, you can create and configure a new database in a nice UI-based pgAdmin tool.

TUTORIALSTEACHER.COM

TutorialsTeacher.com is your authoritative source for comprehensive technologies tutorials, tailored to guide you through mastering various web and other technologies through a step-by-step approach.

Our content helps you to learn technologies easily and quickly for learners of all levels. By accessing this platform, you acknowledge that you have reviewed and consented to abide by our Terms of Use and Privacy Policy, designed to safeguard your experience and privacy rights.

[email protected]

ABOUT USTERMS OF USEPRIVACY POLICY
copywrite-symbol

2024 TutorialsTeacher.com. (v 1.2) All Rights Reserved.