PostgreSQL: PostgreSQL SERIAL and REFERENCES #30
Ready — edit the code above and click Run.
CREATE TABLE orders (
id SERIAL PRIMARY KEY,
customer_id INT NOT NULL REFERENCES customers(id),
amount NUMERIC(12,2) NOT NULL CHECK (amount >= 0),
created_at TIMESTAMPTZ DEFAULT NOW()
);
Try solving on your own first, then reveal the official answer.
PostgreSQL: CTEs, window functions, ILIKE, JSONB @>, EXPLAIN ANALYZE.