Re: How to create a virtual column

Поиск
Список
Период
Сортировка
От Andreas Kretschmer
Тема Re: How to create a virtual column
Дата
Msg-id 20051106125304.GA2881@kaufbach.delug.de
обсуждение исходный текст
Ответ на How to create a virtual column  (Chris <chris.velevitch@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: sequence aliases?
Следующее
От: Tony Caduto
Дата:
Сообщение: Question about 8.1 release news