Title: Generated Columns in PostgreSQL: GENERATED ALWAYS AS STORED
Open Graph Title: Generated Columns in PostgreSQL: GENERATED ALWAYS AS STORED
X Title: Generated Columns in PostgreSQL: GENERATED ALWAYS AS STORED
Description: PostgreSQL generated columns: GENERATED ALWAYS AS STORED, indexing, restrictions, and when to pick them over a trigger or view.
Open Graph Description: PostgreSQL generated columns: GENERATED ALWAYS AS STORED, indexing, restrictions, and when to pick them over a trigger or view.
X Description: PostgreSQL generated columns: GENERATED ALWAYS AS STORED, indexing, restrictions, and when to pick them over a trigger or view.
Keywords:
Opengraph URL: https://sql.coderang.dev/en/blog/sql-generated-column
Domain: sql.coderang.dev
IPv4 address: 79.137.205.149
{"@context":"https://schema.org","@type":"Organization","@id":"https://sql.coderang.dev/#organization","name":"SQL Arena","url":"https://sql.coderang.dev","logo":{"@type":"ImageObject","url":"https://sql.coderang.dev/android-chrome-192x192.png","width":192,"height":192},"sameAs":["https://t.me/coderang"],"description":"SQL Arena is an interactive SQL training platform — a practice arena, duels, a reference handbook and tutorials for analysts and backend developers."}
{"@context":"https://schema.org","@type":"WebSite","name":"SQL Arena","url":"https://sql.coderang.dev","inLanguage":"en-US","publisher":{"@id":"https://sql.coderang.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":"https://sql.coderang.dev/trainer/tasks?search={search_term_string}","query-input":"required name=search_term_string"}}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Generated Columns in PostgreSQL: GENERATED ALWAYS AS STORED","description":"PostgreSQL generated columns: GENERATED ALWAYS AS STORED, indexing, restrictions, and when to pick them over a trigger or view.","image":{"@type":"ImageObject","url":"https://sql.coderang.dev/og?lang=en&title=Generated%20Columns%20in%20PostgreSQL%3A%20GENERATED%20ALWAYS%20AS%20STORED","width":1200,"height":630},"datePublished":"2026-06-19T02:55:52.394Z","dateModified":"2026-06-19T02:55:52.394Z","author":{"@type":"Organization","@id":"https://sql.coderang.dev/#organization","name":"SQL Arena"},"publisher":{"@type":"Organization","@id":"https://sql.coderang.dev/#organization","name":"SQL Arena","url":"https://sql.coderang.dev","logo":{"@type":"ImageObject","url":"https://sql.coderang.dev/android-chrome-192x192.png","width":192,"height":192},"sameAs":["https://t.me/coderang"],"description":"SQL Arena is an interactive SQL training platform — a practice arena, duels, a reference handbook and tutorials for analysts and backend developers."},"mainEntityOfPage":{"@type":"WebPage","@id":"https://sql.coderang.dev/en/blog/sql-generated-column"},"inLanguage":"en-US","wordCount":508,"timeRequired":"PT3M","articleSection":"sql"}
{"@context":"https://schema.org","@type":"BreadcrumbList","inLanguage":"en-US","itemListElement":[{"@type":"ListItem","position":1,"name":"SQL Arena","item":"https://sql.coderang.dev/en"},{"@type":"ListItem","position":2,"name":"Blog","item":"https://sql.coderang.dev/en/blog"},{"@type":"ListItem","position":3,"name":"Generated Columns in PostgreSQL: GENERATED ALWAYS AS STORED","item":"https://sql.coderang.dev/en/blog/sql-generated-column"}]}
{"@context":"https://schema.org","@type":"FAQPage","inLanguage":"en-US","mainEntity":[{"@type":"Question","name":"What GENERATED ALWAYS AS does","acceptedAnswer":{"@type":"Answer","text":"A generated column is a column whose value the database computes from other columns of the same row, using a fixed expression. In PostgreSQL it is always STORED: the result is physically written to disk like an ordinary column and recomputed whenever the source fields are inserted or updated. You cannot write to total directly — that is the server's job:"}},{"@type":"Question","name":"When a trigger or a view is better","acceptedAnswer":{"@type":"Answer","text":"A generated column is great for a pure, row-local formula. Outside that: - A BEFORE INSERT/UPDATE trigger — when you need data from other tables, non-deterministic values (now()), or complex logic. You pay by maintaining the invariant yourself. - A VIEW — when the derived value is only needed at read time and should not consume storage or participate in an index. It is computed on the fly and always fresh. Rule of thumb: deterministic, single-row formula — use a generated column; external data or manual writes — a trigger; read-only with no storage — a view."}}]}
| theme-color | #0a0a0a |
| application-name | SQL Arena |
| author | SQL Arena |
| creator | SQL Arena |
| publisher | SQL Arena |
| googlebot | index, follow, max-image-preview:large, max-snippet:-1 |
| google-site-verification | EaorZzgqTO4qTFsEEiRorcvcDZOqzyHpTwUJwsCjq_Q |
| og:site_name | SQL Arena |
| og:locale | en_US |
| og:image | https://sql.coderang.dev/og?lang=en&title=Generated Columns in PostgreSQL: GENERATED ALWAYS AS STORED |
| og:image:width | 1200 |
| og:image:height | 630 |
| og:image:alt | Generated Columns in PostgreSQL: GENERATED ALWAYS AS STORED |
| og:image:type | image/png |
| og:type | article |
| article:published_time | 2026-06-19T02:55:52.394Z |
| article:modified_time | 2026-06-19T02:55:52.394Z |
| article:tag | clickhouse |
| twitter:card | summary_large_image |
| twitter:image | https://sql.coderang.dev/og?lang=en&title=Generated Columns in PostgreSQL: GENERATED ALWAYS AS STORED |
| twitter:image:alt | Generated Columns in PostgreSQL: GENERATED ALWAYS AS STORED |
Links:
| Server | nginx |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | s-maxage=300, stale-while-revalidate |
Viewport: width=device-width, initial-scale=1, maximum-scale=5, viewport-fit=cover
Robots: index, follow