0

CREATE TABLE & the DDL you write

Schemaused in ~100% of apps

Every table you have queried since concept 7 — profiles, posts — did not appear by magic. Someone typed a CREATE TABLE statement, ran it, and every choice in it became a permanent fact about the app: what shape a row can have, what a column is allowed to contain, and — the one that catches almost everyone — whether a stranger on the internet can read every row the moment the table exists. That someone is about to be you.

Core idea. CREATE TABLE name (column type constraint, column type constraint, …, table-level constraint) declares a table's shape once, and Postgres enforces it on every future write, forever, regardless of which client sent it. This exact text — not a friendlier version of it — is what lives inside a migration file. And the fact that trips up almost every junior: a table created this way is not row-level-secured. It is wide open until you say otherwise, on purpose, in a second statement.
Playground, this isn't a screenshot
Live demointeractive
Real Postgres · in your browseridle
This posts table was created by the exact CREATE TABLE above — no RLS, no policy, nothing else. Run it as anon (already selected). You are a total stranger to this app, and you can see both posts — including the private draft. Nothing has stopped you. Keep this tab open; the next code block flips the switch, and you will come back here to rerun this exact query.
Querying as
Cmd/Ctrl + Enter
↑ play a little first, then dig in