SQL Snippets

Collection of often used SQL fragments.

Examples and snippets for frequently used database operations.

Setup a simple database and user

-- Run as superuser
CREATE ROLE "demo-user" WITH NOSUPERUSER INHERIT NOCREATEROLE CREATEDB LOGIN NOREPLICATION NOBYPASSRLS PASSWORD 'demo-user';

CREATE DATABASE "demo" WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE_PROVIDER = libc LOCALE = 'en_US.UTF-8';

ALTER DATABASE "demo" OWNER TO "demo-user";
Back

© 2014–2025 Claus Gerull. All rights reserved.