By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table test (a int, b int)
alter table test add c int generated always as (a-b) stored
insert into test (a, b) values (1, 5), (5, 2), (4, 4), (6, 4)
select * from test
a | b | c |
---|---|---|
1 | 5 | -4 |
5 | 2 | 3 |
4 | 4 | 0 |
6 | 4 | 2 |