CREATE SCHEMA
Create a new schema (namespace) in the current database.
Syntax
Parameters
| Parameter | Description |
|---|---|
IF NOT EXISTS | Do not raise an error if a schema with the same name already exists |
| schema_name | Name 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;