creating table - Mailing list pgsql-general

From Mark Cubitt
Subject creating table
Date
Msg-id DBEMKPHNFHCHBCDFFDFJEEALCAAA.mark.cubitt@applegate.co.uk
Whole thread Raw
In response to Re: Transaction Logs Recycling Problem  (Dennis Gearon <gearond@cvc.net>)
Responses Re: creating table  (Richard Huxton <dev@archonet.com>)
List 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 by date:

Previous
From: Jonathan Bartlett
Date:
Subject: Re: Table Partitioning in Postgres:
Next
From: Guy Fraser
Date:
Subject: Has the attribute name for oid changed in pgsql 7.3 ?