Hey all, is there such a thing as "Virtual columns...
# help
p
Hey all, is there such a thing as "Virtual columns" or "Generated Columns" in Supabase?
s
Can you describe what these are or where could I get a reference to what they are supposed to be?
how can i make a code block?
`` A generated column is a special column that is always computed from other columns. Thus, it is for columns what a view is for tables. There are two kinds of generated columns: stored and virtual. A stored generated column is computed when it is written (inserted or updated) and occupies storage as if it were a normal column. A virtual generated column occupies no storage and is computed when it is read. Thus, a virtual generated column is similar to a view and a stored generated column is similar to a materialized view (except that it is always updated automatically). PostgreSQL currently implements only stored generated columns. ``
s
If its available in postgres then yes you can use it
p
bet, then i'll take a look on how to achieve what i wanna do
another question, since i don't remember seeing anything related to it in the UI, i guess i'll have to do it through the SQL editor, right?
s
Yes you will have to use the SQL editor#
p
Yeah, just tested it, it does work with SQL editor. but to insert any values to that table i also have to do it through the SQL editor, it won't me insert through the UI, it gave me an error:
Error: Error: cannot insert into column "height_in"
thats the table i created:
Copy code
CREATE TABLE people (
  height_cm numeric,
  height_in numeric GENERATED ALWAYS AS (height_cm / 2.54) STORED
);