agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
How to use postgresql generated generated always COLUMN ?
3+ messages / 2 participants
[nested] [flat]

* How to use postgresql generated generated always COLUMN ?
@ 2016-12-31 04:29  tank.zhang <6220104@qq.com>
  0 siblings, 1 reply; 3+ messages in thread

From: tank.zhang @ 2016-12-31 04:29 UTC (permalink / raw)
  To: pgsql-sql

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?*


Thank you!



--
View this message in context: http://postgresql.nabble.com/How-to-use-postgresql-generated-generated-always-COLUMN-tp5936872.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How to use postgresql generated generated always COLUMN ?
@ 2016-12-31 04:52  David G. Johnston <david.g.johnston@gmail.com>
  parent: tank.zhang <6220104@qq.com>
  0 siblings, 1 reply; 3+ messages in thread

From: David G. Johnston @ 2016-12-31 04:52 UTC (permalink / raw)
  To: tank.zhang <6220104@qq.com>; +Cc: pgsql-sql

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.

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How to use postgresql generated generated always COLUMN ?
@ 2016-12-31 05:03  tank.zhang <6220104@qq.com>
  parent: David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: tank.zhang @ 2016-12-31 05:03 UTC (permalink / raw)
  To: pgsql-sql

Thank you for your help, I under test



--
View this message in context: http://postgresql.nabble.com/How-to-use-postgresql-generated-generated-always-COLUMN-tp5936872p59368...
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2016-12-31 05:03 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-12-31 04:29 How to use postgresql generated generated always COLUMN ? tank.zhang <6220104@qq.com>
2016-12-31 04:52 ` David G. Johnston <david.g.johnston@gmail.com>
2016-12-31 05:03   ` tank.zhang <6220104@qq.com>

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