creating table

From: "Mark Cubitt" <mark(dot)cubitt(at)applegate(dot)co(dot)uk>
To: <pgsql-general(at)postgresql(dot)org>
Subject: creating table
Date: 2003-02-19 16:26:01
Message-ID: DBEMKPHNFHCHBCDFFDFJEEALCAAA.mark.cubitt@applegate.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-02-19 16:28:13 Re: 7.3.1 takes long time to vacuum table?
Previous Message Dennis Gearon 2003-02-19 16:13:48 Re: Transaction Logs Recycling Problem