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
| Property | Description |
|---|---|
| Owner | Database owner |
| Encoding | Character encoding |
| LC_COLLATE | Sort order |
| LC_CTYPE | Character classification |
Mini Practice
- Create a database
- List all databases
- Connect to a database
- 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.