Re: How to create a virtual column

From: Andreas Kretschmer <akretschmer(at)spamfence(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to create a virtual column
Date: 2005-11-06 12:53:04
Message-ID: 20051106125304.GA2881@kaufbach.delug.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Chris <chris(dot)velevitch(at)gmail(dot)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°

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tony Caduto 2005-11-06 18:05:38 Question about 8.1 release news
Previous Message Martijn van Oosterhout 2005-11-06 12:22:36 Re: sequence aliases?