Re: How to create a virtual column

From: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>
To: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to create a virtual column
Date: 2005-11-07 19:41:38
Message-ID: 20051107194138.GC19551@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Nov 07, 2005 at 07:05:14AM +0100, A. Kretschmer wrote:
> am 06.11.2005, um 22:54:15 +0000 mailte Chris folgendes:
> > Andreas Kretschmer <akretschmer <at> spamfence.net> writes:
> > > Chris <chris.velevitch <at> gmail.com> schrieb:
> > >
> > > > How do I create a virtaul column?
> > >
> > > A view. Example:
> >
> > Is a view completely compatible with tables? I mean, can I do everything with a
> > view like I can do to a table, like insert, delete or update?
>
> No, only insert. But you can also define RULEs for update and delete.
> http://www.postgresql.org/docs/8.0/interactive/rules-update.html#RULES-UPDATE-VIEWS

Actually, you can't do any data modification without defining rules,
inserts included, at least not it 8.0. There's been talk about
automatically creating these rules for simpler views, but AFAIK
nothing's been done along those lines yet.

decibel=# create table t(t text);
CREATE TABLE
decibel=# create view v_t as select * from t;
CREATE VIEW
decibel=# insert into v_t values('test');
ERROR: cannot insert into a view
HINT: You need an unconditional ON INSERT DO INSTEAD rule.
decibel=# select version();
version
-------------------------------------------------------------------------------------------------------------------------
PostgreSQL 8.0.3 on powerpc-apple-darwin7.9.0, compiled by GCC gcc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1495)
(1 row)

decibel=#
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Carlos Oliva 2005-11-07 19:55:41 Re: Setting max_fsm_pages
Previous Message Will Wright 2005-11-07 19:39:44 Programmatic method to determine currently installed Windows PostrgreSQL version