On this page
Concepts#
- A database is an isolated namespace with its own tables and write-ahead log. Database
plomidis the default; every other database is isolated from it. - A schema is a namespace inside a database (
publicby default).search_pathcontrols unqualified name resolution. - Database names must match
[_A-Za-z][_A-Za-z0-9]*.
Steps#
CREATE DATABASE shop;
USE shop; -- switch session database
CREATE SCHEMA analytics;
SET search_path TO analytics, public;
SHOW databases; -- also: SHOW database | SHOW schemas | SHOW tablesVia the wire protocol, connect with database=shop in the startup message (psql "postgresql://plomid:secret@localhost:5432/shop").
Behavior#
CREATE DATABASE shopcreates an isolated database; other names are fully separated fromplomid.USE <db>switches the session's database context; unknown names error.SHOW tableslists the current database's tables.
Constraints#
CREATE/DROP DATABASE,USE, andSHOW DATABASESrun outside the normal statement path and cannot execute inside an explicit transaction.- No
RENAME DATABASEin v0.1.0.
Next#
Was this page helpful? Thanks — noted locally, nothing is sent anywhere.