Re: How to create a virtual column - Mailing list pgsql-general

From Andreas Kretschmer
Subject Re: How to create a virtual column
Date
Msg-id 20051106125304.GA2881@kaufbach.delug.de
Whole thread Raw
In response to How to create a virtual column  (Chris <chris.velevitch@gmail.com>)
List pgsql-general
Chris <chris.velevitch@gmail.com> schrieb:

> How do I create a virtaul column?
>
> A virtual column is accessible like any other column except that there is no
> physical column associated with it (unless it's indexed). The data for the
> column is derived from other columns in the table. For example, in a table
> people, a persons name is the concatentation if their first, middle and surnames.

A view. Example:

test=> create table person (first varchar, middle varchar, surname varchar);
CREATE TABLE
test=> insert into person values ('First', 'Middle', 'Surname');
INSERT 934777 1
t=> create view view_person as select first || ' ' || middle || ' ' || surname from person;
CREATE VIEW
test=> select * from view_person ;
       ?column?
----------------------
 First Middle Surname
(1 Zeile)


HTH, Andreas
--
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect. (Linus Torvalds)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: sequence aliases?
Next
From: Tony Caduto
Date:
Subject: Question about 8.1 release news