TASIOMIND.DEV — OPERATIONAL▸▸▸FULL STACK DEVELOPER @ GWQ SERVICEPLUS AG▸▸▸FOUNDER — K8SGPT.AI▸▸▸OPEN SOURCE: ACTIVE▸▸▸DISTRIBUTED SYSTEMS / KUBERNETES / AI▸▸▸RUST + GO + PYTHON▸▸▸FIELD TESTED / STATUS — NOMINAL▸▸▸LOCATION: EUROPE/BERLIN▸▸▸TASIOMIND.DEV — OPERATIONAL▸▸▸FULL STACK DEVELOPER @ GWQ SERVICEPLUS AG▸▸▸FOUNDER — K8SGPT.AI▸▸▸OPEN SOURCE: ACTIVE▸▸▸DISTRIBUTED SYSTEMS / KUBERNETES / AI▸▸▸RUST + GO + PYTHON▸▸▸FIELD TESTED / STATUS — NOMINAL▸▸▸LOCATION: EUROPE/BERLIN▸▸▸

Getting started with PostgreSQL on Ubuntu

February 18, 2023

Install

code
sudo apt update
sudo apt install -y postgresql postgresql-contrib
sudo systemctl enable --now postgresql

Rollen und DBs

code
sudo -u postgres createuser --interactive
sudo -u postgres createdb mydb

psql Basics

code
sudo -u postgres psql

Meta-Commands:

code
\l  -- Datenbanken
\du -- Roles
\c db -- connect
\q  -- quit

Beispiele

code
CREATE TABLE celebs (
  id SERIAL PRIMARY KEY,
  name TEXT,
  age INT
);

INSERT INTO celebs (name, age) VALUES ('Justin Bieber', 22);
SELECT * FROM celebs;

Hinweise

  • Roles sind User
  • Strings mit ' (single quotes)
  • Escapes mit E'...' wenn noetig