PostgreSQL Create Database
Overview
In PostgreSQL, a database is the top-level container for storing data. Creating a database is the first step in using PostgreSQL. This chapter explains how to create databases using SQL commands and command-line tools.
CREATE DATABASE Statement
Basic Syntax
Simple Examples
Complete Syntax
Parameter Description
Using Command Line Tools
createdb Command
Using psql
Practical Examples
Creating Development Environment Databases
List All Databases
Important Notes
- Naming conventions: Database names should use lowercase letters, numbers, and underscores
- Permissions required: Requires CREATEDB privilege or superuser rights
- Encoding choice: UTF8 encoding is recommended for multi-language support
- Template database: Defaults to copying from template1, can specify other templates