</>
Skip to content
PostgreSQL lessons (6/38)

PostgreSQL — Databases

Create Database

CREATE DATABASE mydb;

Create with Options

CREATE DATABASE mydb
    WITH OWNER = postgres
    ENCODING = 'UTF8'
    CONNECTION LIMIT = -1;

List Databases

SELECT datname FROM pg_database;

Or psql command: \l

Connect to Database

\c mydb

Or:

SELECT pg_database.datname FROM pg_database;

Drop Database

DROP DATABASE mydb;

Database Properties

PropertyDescription
OwnerDatabase owner
EncodingCharacter encoding
LC_COLLATESort order
LC_CTYPECharacter classification

Mini Practice

  1. Create a database
  2. List all databases
  3. Connect to a database
  4. Drop a database

Up Next

Continue with Create Database — creating databases.

Related Topics

Frequently Asked Questions about Databases

What is Databases in PostgreSQL?

Databases is a fundamental concept in PostgreSQL. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn Databases?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Databases.

Why is Databases important in PostgreSQL?

Databases is essential for PostgreSQL development. Understanding this concept will help you write better code and solve real-world problems more effectively.