creating table

Поиск
Список
Период
Сортировка
От Mark Cubitt
Тема creating table
Дата
Msg-id DBEMKPHNFHCHBCDFFDFJEEALCAAA.mark.cubitt@applegate.co.uk
обсуждение исходный текст
Ответ на Re: Transaction Logs Recycling Problem  (Dennis Gearon <gearond@cvc.net>)
Ответы Re: creating table  (Richard Huxton <dev@archonet.com>)
Список pgsql-general
Hi,

I am trying to create a table where one of the fields gets the results from another table,

the table I need to get the field from was created like this:

CREATE TABLE "companies" (
    "compid" serial,
    "compname" character varying(100) NOT NULL,
    "compadd1" character varying(100),
    "compadd2" character varying(100),
    "compcity" character varying(150),
    "comppcode" character varying(10),
    "compcounty" character varying(20),
    "compphone" character varying(15),
    "compfax" character varying(15),
    "compwebsite" character varying(50),
    "compemail" character varying(50),
    "compcontact" character varying(50),
    "compdescription" character varying(250),
    "comptype" integer NOT NULL,
    "complevel" integer NOT NULL
);

and the new table needs to be like this

CREATE TABLE "location" (
    "compcity" character varying(150),
    "loc_description" character varying(250)
);

where the "compcity" field is the result of "SELECT DISTINCT(compcity) FROM companies;" and update automatically,

I think this may be possible with references but I'm not sure if it is or how to do it.

any help would be much appreciated

regards

Mark Cubitt


В списке pgsql-general по дате отправления:

Предыдущее
От: Jonathan Bartlett
Дата:
Сообщение: Re: Table Partitioning in Postgres:
Следующее
От: Guy Fraser
Дата:
Сообщение: Has the attribute name for oid changed in pgsql 7.3 ?