Skip to main content

CREATE SCHEMA

Create a new schema (namespace) in the current database.

Syntax

Parameters

ParameterDescription
IF NOT EXISTSDo not raise an error if a schema with the same name already exists
schema_nameName of the schema to create

Examples

Create a schema

CREATE SCHEMA IF NOT EXISTS analytics;

Create a table in the schema

CREATE TABLE analytics.page_views (
id INTEGER PRIMARY KEY,
url TEXT NOT NULL,
viewed_at TIMESTAMP DEFAULT NOW()
);

SELECT * FROM analytics.page_views;

See also