Database Viewer

Browse the SQL that builds any database used across the lessons, without running it.

Loaded: Lesson 21 database ยท postgres-locks.database-init

CREATE TABLE accounts (
  id SERIAL PRIMARY KEY,
  owner TEXT NOT NULL,
  balance INTEGER NOT NULL
);

CREATE TABLE transfers (
  id SERIAL PRIMARY KEY,
  account_id INTEGER NOT NULL REFERENCES accounts (id),
  amount INTEGER NOT NULL,
  status TEXT NOT NULL DEFAULT 'pending'
);


INSERT INTO accounts (owner, balance)
VALUES
  ('alice', 1000),
  ('bob', 500);

INSERT INTO transfers (account_id, amount)
VALUES
  (1, 100),
  (1, 250),
  (2, 75);