<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/generated-columns-in-postgresql-y1uesxmvg" -->

---
title: Generated Columns in PostgreSQL | daily.dev
description: Generated columns in PostgreSQL, introduced in version 12, allow data to be computed dynamically at the database level. There are two types: virtual and...
canonical: https://daily.dev/posts/generated-columns-in-postgresql-y1uesxmvg
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Generated Columns in PostgreSQL | daily.dev
og:description: Generated columns in PostgreSQL, introduced in version 12, allow data to be computed dynamically at the database level. There are two types: virtual and...
og:url: https://daily.dev/posts/generated-columns-in-postgresql-y1uesxmvg
og:image: https://api.daily.dev/og/posts/Y1UESxMVg.png
og:image:alt: Generated Columns in PostgreSQL
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Generated Columns in PostgreSQL

**[Hashrocket](https://daily.dev/sources/hashrocket)** · 4 min read · 14 upvotes · 1 comments

## Summary

Generated columns in PostgreSQL, introduced in version 12, allow data to be computed dynamically at the database level. There are two types: virtual and stored, though PostgreSQL only supports stored columns. This post provides an example of creating and using a generated column, explores when they are computed, and highlights some limitations, such as the inability to reference a generated column from another generated column and the use of constraints on generated columns.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://hashrocket.com/blog/posts/generated-columns-in-postgresql>

## Community discussion

Top comments from developers on daily.dev.

**@tekn0wledg** · 0 upvotes

> Love it. Can't wait to use this.

---

Tags: [#database](https://daily.dev/tags/database), [#backend](https://daily.dev/tags/backend), [#sql](https://daily.dev/tags/sql), [#postgresql](https://daily.dev/tags/postgresql)

[View this post on daily.dev](https://daily.dev/posts/generated-columns-in-postgresql-y1uesxmvg)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Generated Columns in PostgreSQL","url":"https://daily.dev/posts/generated-columns-in-postgresql-y1uesxmvg","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/generated-columns-in-postgresql-y1uesxmvg"},"datePublished":"2024-06-20T13:03:15.476Z","dateModified":"2024-10-05T16:42:33.030Z","description":"Generated columns in PostgreSQL, introduced in version 12, allow data to be computed dynamically at the database level. There are two types: virtual and...","image":"https://media.daily.dev/image/upload/s--foaA6JGU--/f_auto/v1722860399/public/Placeholder%2004","thumbnailUrl":"https://media.daily.dev/image/upload/s--foaA6JGU--/f_auto/v1722860399/public/Placeholder%2004","isAccessibleForFree":true,"articleSection":"Hashrocket","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Hashrocket","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/0c306503678e48a3bd225aaf7765f0c8","url":"https://daily.dev/sources/hashrocket"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/generated-columns-in-postgresql-y1uesxmvg","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":14},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"database,backend,sql,postgresql","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Hashrocket","item":"https://daily.dev/sources/hashrocket"},{"@type":"ListItem","position":3,"name":"Generated Columns in PostgreSQL"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/generated-columns-in-postgresql-y1uesxmvg","comment":[{"@type":"Comment","text":"Love it. Can’t wait to use this.","datePublished":"2024-06-20T14:40:56.479Z","url":"https://daily.dev/posts/Y1UESxMVg#c-m0Rf2hfxV","author":{"@type":"Person","name":"Scott Davis","url":"https://daily.dev/tekn0wledg","image":"https://avatars.githubusercontent.com/u/355212?v=4"}}]}
```

