PostgreSQL Cheat Sheet/Create database

Create a new database in the cluster.

Section: Database and Role Lifecycle

Create database

sql
sql
CREATE DATABASE appdb;
Explanation

Databases are cluster-level objects and must be created from another existing database such as `postgres`.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Database and Role Lifecycle
Create database with owner
Create a database with explicit owner and template.
OpenIn sheetsqlsame section
Rename database
Rename an existing database.
OpenIn sheetsqlsame section
Drop database
Delete a database permanently.
OpenIn sheetsqlsame section
Create login role
Create a role that can log in.
OpenIn sheetsqlsame section
Create role with privileges
Create a role with explicit capability flags.
OpenIn sheetsqlsame section
Change role password
Update a role password.
OpenIn sheetsqlsame section