agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Tank.zhang <6220104@qq.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: 回复: [SQL] How to use postgresql generated generated always COLUMN ?
Date: Sat, 31 Dec 2016 13:01:28 +0800
Message-ID: <tencent_361943BF2ACDFC4F78D72742@qq.com> (raw)
In-Reply-To: <CAKFQuwZ03vgSE55YYtp1wZ4QRypmAODDzEeD4KT5Fp24JX1qGQ@mail.gmail.com>
References: <1483158588371-5936872.post@n3.nabble.com>
	<CAKFQuwZ03vgSE55YYtp1wZ4QRypmAODDzEeD4KT5Fp24JX1qGQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

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.

Message-ID: <tencent_361943BF2ACDFC4F78D72742@qq.com>
Permalink:  ../tencent_361943BF2ACDFC4F78D72742@qq.com/
Also on:    postgresql.org/message-id/tencent_361943BF2ACDFC4F78D72742@qq.com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: 6220104@qq.com, david.g.johnston@gmail.com
  Subject: Re: =?gb18030?B?u9i4tKO6IFtTUUxdIEhvdyB0byB1c2UgcG9zdGdy?= =?gb18030?B?ZXNxbCBnZW5lcmF0ZWQgZ2VuZXJhdGVkIGFsd2F5?= =?gb18030?B?cyBDT0xVTU4gPw==?=
  In-Reply-To: <tencent_361943BF2ACDFC4F78D72742@qq.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox