From: | Stan Raby <sraby(at)computerpark(dot)co(dot)uk> |
---|---|
To: | pgsql-admin(at)postgreSQL(dot)org |
Subject: | How do I insert data into a table within a table |
Date: | 2000-11-28 16:19:04 |
Message-ID: | 00112816263400.11277@Cpark34 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
--
As I understand it when you create a table in postgres that it is automatically
a type. Therefore you can then the declare an attribute of this type in another
table e.g
create table person
(
first_name char(20),
second_name char(20)
);
create table couple
(
man person,
woman person
);
The couple table can be queried without any problems e.g.
select * from couple;
returns :
man|woman
---+-----
(0 rows)
select couple.man.first_name, couple.man.second_name from couple;
returns :
first_name|second_name
----------+-----------
(0 rows)
But how do you put data into the couple table ?
I have tried a number of methods but without any success.
e.g.
insert into
couple(couple.man.first_name,couple.man.second_name,couple.woman.first_name,couple.woman.second_name)
values('Fred','Smith','Jane','White');
insert into
couple(man(first_name,second_name),woman(first_name,second_name))
values('Fred','Smith','Jane','White');
insert into
couple.man.first_name,couple.man.second_name,couple.woman.first_name,couple.woman.second_name
values('Fred','Smith','Jane','White');
insert into
couple(man.first_name,man.second_name,woman.first_name,woman.second_name)
values('Fred','Smith','Jane','White');
All of these (plus others) all produce parser errors.
e.g. ERROR : parser: parse error at or near "."
Thankyou in advance for any help.
------------------------------------
Stan Raby
Computer Park Limited
Tel: +44 1536 417155
Fax: +44 1536 417566
email: sraby(at)computerpark(dot)co(dot)uk
From | Date | Subject | |
---|---|---|---|
Next Message | will | 2000-11-29 00:51:33 | developer deleted a database directory, postgres won't start |
Previous Message | Annett Katzschner | 2000-11-28 16:03:38 | Where are the downloads for the the supported Windows NT |