🗄️CREATE DATABASE
Provision a new catalog boundary
CREATE DATABASE allocates a namespace: system catalogs, default roles, encoding and collation, tablespaces or filegroups, and sometimes replication hooks. It is infrastructure work, usually owned by IaC and DBAs, not sprinkled through application migrations the way CREATE TABLE is.
Prefer schemas inside one database for modular teams; spin a separate database when you need hard isolation (compliance, noisy neighbor blast radius, independent backup/restore cycles).
PostgreSQL-style (explicit encoding + template)
CREATE DATABASE biotech_app
WITH OWNER = app_owner
ENCODING = 'UTF8'
LC_COLLATE = 'en_US.UTF-8'
LC_CTYPE = 'en_US.UTF-8'
TEMPLATE = template0;| result |
|---|
| CREATE DATABASE |
⚡ Advanced / dialect note
CREATE DATABASE as a synonym for CREATE SCHEMA. SQL Server uses CREATE DATABASE … COLLATE … plus file growth and filegroup options. Cloud managed instances may wrap this in an API that provisions storage and HA, read the vendor defaults before relying on implicit charset.🔤Collation and charset
Wrong once, expensive forever, sorting, unique indexes, and string comparisons all inherit.
Pick UTF8 (or engine equivalent) and a collation that matches your application’s sort/compare expectations for MRNs, gene symbols, and locale-specific patient names. Changing later may require index rebuilds and application retesting.
One micro-database per microservice by default
Dozens of tiny databases multiply connection pools, backup windows, migration runners, and cross-join analytics, without delivering real tenant isolation.
Default to schema-per-service; split databases for isolation requirements
Model security with roles, schemas, and row-level security first; split catalogs when compliance or blast radius truly demands it.
Post-create checklist
Revoke public connect where inappropriate, apply ALTER DEFAULT PRIVILEGES on Postgres, create app roles, wire monitoring, and register the DSN in your secret store, not only in a wiki.
Templates
PostgreSQL’s template0 avoids copying stray objects from a dirty template database, use it for reproducible automation.
IaC
Codify CREATE DATABASE in Terraform, CloudFormation, or vendor CLI scripts with peer review, never rely on hand-clicked prod catalogs that drift from staging.
TL;DR
CREATE DATABASE provisions a new catalog (namespace) on the server: encoding/collation, file layout, and default limits live here. Managed clouds often wrap this in control-plane APIs, your app rarely runs raw DDL in production. Treat database creation as infrastructure: version it, set owners and extensions explicitly, and align naming with backup/restore and connection string conventions.