Recall & Review
beginner
What is a GENERATED column in PostgreSQL?
A GENERATED column is a special column in a table whose value is automatically computed from other columns using an expression. PostgreSQL only supports stored generated columns.
Click to reveal answer
intermediate
What is a stored GENERATED column in PostgreSQL?
A stored GENERATED column saves the computed value physically in the table. Virtual GENERATED columns are not supported.
Click to reveal answer
beginner
How do you define a stored GENERATED column in PostgreSQL?
Use the syntax: <column_name> data_type GENERATED ALWAYS AS (expression) STORED. The expression calculates the value stored in the column.
Click to reveal answer
beginner
Can you insert or update values directly into a GENERATED column?
No, you cannot insert or update values directly into a GENERATED column because its value is always computed automatically from the expression.
Click to reveal answer
intermediate
Why might you choose a stored GENERATED column?
Stored GENERATED columns improve query performance because values are precomputed and saved, but they use more storage. Virtual columns are not supported in PostgreSQL.
Click to reveal answer
Which keyword is required to define a stored GENERATED column in PostgreSQL?
✗ Incorrect
In PostgreSQL, the keyword STORED is used to define a stored GENERATED column.
Can you manually insert a value into a GENERATED column?
✗ Incorrect
GENERATED columns compute their values automatically; manual inserts or updates are not allowed.
What happens when you query a GENERATED column in PostgreSQL?
✗ Incorrect
PostgreSQL only supports stored GENERATED columns; values are retrieved from storage.
Which of these is a benefit of stored GENERATED columns?
✗ Incorrect
Stored GENERATED columns improve query speed because values are precomputed and saved.
Which PostgreSQL version introduced support for stored GENERATED columns?
✗ Incorrect
PostgreSQL 12 introduced support for stored GENERATED columns.
Explain what a GENERATED column is and how it works (stored vs virtual concept, noting PostgreSQL support).
Think about when the value is calculated and where it is saved.
You got /4 concepts.
Describe how to create a stored GENERATED column in PostgreSQL with an example.
Focus on the exact keywords and structure.
You got /3 concepts.