Skip to Content
Tables & SQLSchemas & Session Settings

Schemas and Session Settings

KalamDB schemas group tables, types, and routines. Use PostgreSQL CREATE SCHEMA and qualify application objects so queries behave consistently across connections.

Create a KalamDB schema

SQL
CREATE SCHEMA IF NOT EXISTS app;CREATE TABLE app.notes (  id BIGSERIAL PRIMARY KEY,  body TEXT NOT NULL) WITH (TYPE = 'USER');SELECT * FROM app.notes;

CREATE NAMESPACE remains a compatibility alias. New schemas should use CREATE SCHEMA.

Resolve names with search_path

SQL
SET search_path TO app, public;SHOW search_path;SELECT * FROM notes;RESET search_path;

The default resolves "$user", public. A stored schema named default is distinct from public; changing the search path does not rename or merge schemas. Quoted names preserve case; unquoted names fold to lowercase.

Session settings

SQL
SET app.request_id = 'request-123';SELECT current_setting('app.request_id');SELECT set_config('app.request_id', 'request-456', false);RESET app.request_id;

A PGWire connection retains settings until changed or disconnected. HTTP SQL settings last for the request, so send SET and the statements that depend on it in the same SQL request. Do not expect a later HTTP call to inherit the previous request’s settings. For application queries, schema-qualified names avoid this dependency.

Rename and remove schemas

SQL
ALTER SCHEMA app RENAME TO workspace;-- Only after moving or removing its objects:DROP SCHEMA workspace;

DROP SCHEMA ... CASCADE also removes dependent objects. Use it only when you intend to remove them.

Inspect schemas

SQL
SELECT schema_name FROM information_schema.schemata;SELECT nspname FROM pg_catalog.pg_namespace;

Next: Tables and constraints. Reference: PostgreSQL connections.