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@pervasive.com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461