From: | Tank(dot)zhang <6220104(at)qq(dot)com> |
---|---|
To: | David G(dot) Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org <pgsql-sql(at)postgresql(dot)org> |
Subject: | 回复: [SQL] How to use postgresql generated generated always COLUMN ? |
Date: | 2016-12-31 05:01:28 |
Message-ID: | tencent_361943BF2ACDFC4F78D72742@qq.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Thank you for your help, I under test
------------------ 原始邮件 ------------------
发件人: "David G. Johnston"<david(dot)g(dot)johnston(at)gmail(dot)com>;
发送时间: 2016年12月31日(星期六) 中午12:52
收件人: "Tank.zhang"<6220104(at)qq(dot)com>;
抄送: "pgsql-sql(at)postgresql(dot)org"<pgsql-sql(at)postgresql(dot)org>;
主题: Re: [SQL] How to use postgresql generated generated always COLUMN ?
On Friday, December 30, 2016, tank.zhang <6220104(at)qq(dot)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(at)db2 ~]$ db2 "insert into emp(id,name,salary)
values(100,'asdf',51100)"
[db2inst2(at)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.
From | Date | Subject | |
---|---|---|---|
Next Message | tank.zhang | 2016-12-31 05:03:05 | Re: How to use postgresql generated generated always COLUMN ? |
Previous Message | David G. Johnston | 2016-12-31 04:52:12 | Re: How to use postgresql generated generated always COLUMN ? |