CARVIEW |
Select Language
HTTP/2 301
date: Sat, 11 Oct 2025 09:47:47 GMT
server: Fly/6f91d33b9d (2025-10-08)
location: /postgresql/show-schema
content-type: text/plain
content-encoding: gzip
via: 2 fly.io, 2 fly.io
fly-request-id: 01K79APNEHR304S2RT6S5QP740-bom
HTTP/2 200
date: Sat, 11 Oct 2025 09:47:47 GMT
server: Fly/6f91d33b9d (2025-10-08)
content-type: text/html; charset=utf-8
content-encoding: gzip
via: 2 fly.io, 2 fly.io
fly-request-id: 01K79APNPNDREEJQVNP65EYP60-bom
Show the SQL schema for a PostgreSQL database | Simon Willison’s TILs
Show the SQL schema for a PostgreSQL database
This took me longer to figure out than I care to admit.
pg_dump -s name-of-database
Surprisingly there doesn't seem to be an easy way to do this using a SELECT
statement within PostgreSQL itself.
StackOverflow offers up a terrifying 72 line SQL monstrosity that attempts to recreate the CREATE TABLE
for a given table.
Related
- sqlite List all columns in a SQLite database - 2020-05-06
- fly Configuring Django SQL Dashboard for Fly PostgreSQL - 2023-08-21
- postgresql Upgrade Postgres.app on macOS - 2024-06-15
- gis Using SQL with GDAL - 2023-03-09
- datasette Searching all columns of a table in Datasette - 2021-08-23
- postgresql Granting a PostgreSQL user read-only access to some tables - 2021-02-26
- heroku Using heroku pg:pull to restore a backup to a macOS laptop - 2020-07-10
- github-actions Installing different PostgreSQL server versions in GitHub Actions - 2021-07-05
- bash Escaping a SQL query to use with curl and Datasette - 2020-12-08
- sqlite SQLite timestamps with floating point seconds - 2024-03-13
Created 2021-02-23T19:03:04-08:00 · Edit