SQL Generated And Identity Columns

Guides the two standard SQL ways to let the database derive a column value for you — `GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY` for surrogate keys instead of vendor `SERIAL`/`AUTO_INCREMENT`/`IDENTITY(1,1)`, and `GENERATED ALWAYS AS (expr) STORED|VIRTUAL` computed columns instead of recomputing a derived value in every query or maintaining it by hand in application code. Auto-invokes when writing or editing auto-increment / surrogate-key columns, `SERIAL`/`AUTO_INCREMENT`/`IDENTITY(1,1)`, computed/derived columns, `GENERATED` clauses in `CREATE TABLE`, or on "auto-incrementing id" / "computed column" / "store a total/full-name/age" requests. Builds on the foundation `sql-relational-and-null-discipline`.

ctoth d3eeadd 3 files · 28.8 KB Updated

File contents

ctoth/sql-skills-plugin/tree/main/plugins/sql/skills/sql-generated-and-identity-columns commit d3eeadd25d

Frequently asked questions

npx skillmds@latest add ctoth/sql-generated-and-identity-columns