Thank you for your help, I under test
------------------ 原始邮件 ------------------
发件人: "David G. Johnston"<david.g.johnston@gmail.com>;
发送时间: 2016年12月31日(星期六) 中午12:52
收件人: "Tank.zhang"<6220104@qq.com>;
抄送: "pgsql-sql@postgresql.org"<pgsql-sql@postgresql.org>;
主题: Re: [SQL] How to use postgresql generated generated always COLUMN ?
On Friday, December 30, 2016, tank.zhang <
6220104@qq.com> wrote:
DB2 operation:
db2 "create table emp(id int,name char(10),salary int,rev_salary integer
generated always as (salary*50/100))"
[db2inst2@db2 ~]$ db2 "insert into emp(id,name,salary)
values(100,'asdf',51100)"
[db2inst2@db2 ~]$ db2 "select * from emp"
ID NAME SALARY REV_SALARY
----------- ---------- ----------- -----------
100 asdf 500 250
100 asdf 6600 3300
100 asdf 51100 25550
*How to use postgresql implement?*
You have to use CREATE VIEW. Possibly with insert/update/delete triggers to interact with the backing table.
David J.
.qmbox style, .qmbox script, .qmbox head, .qmbox link, .qmbox meta {display: none !important;}