pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedInherancing
5+ messages / 3 participants
[nested] [flat]
* Inherancing
@ 2003-01-07 11:42 Nasair Junior da Silva <njunior@univates.br>
0 siblings, 2 replies; 5+ messages in thread
From: Nasair Junior da Silva @ 2003-01-07 11:42 UTC (permalink / raw)
To: pgsql-sql
Hi people,
supposing i have the tables :
create table cities (id int, name varchar, primary key(id) );
create table centers (state varchar(2)) inherits (cities);
ant the tuple
insert into cities values (1, 'Lajeado');
How i do if i want to make this city as a center ?
Thanks,
xx===============================xx
|| °v° Nasair Junior da Silva ||
|| /(_)\ Linux User: 246054 ||
|| ^ ^ njunior@univates.br ||
||CPD - Desenvolvimento ||
||Univates - Centro Universitário||
xx===============================xx
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Inherancing
@ 2003-01-07 12:02 Adam Witney <awitney@sghms.ac.uk>
parent: Nasair Junior da Silva <njunior@univates.br>
1 sibling, 1 reply; 5+ messages in thread
From: Adam Witney @ 2003-01-07 12:02 UTC (permalink / raw)
To: pgsql-sql
On 7/1/03 11:42 am, "Nasair Junior da Silva" <njunior@univates.br> wrote:
> Hi people,
> supposing i have the tables :
>
> create table cities (id int, name varchar, primary key(id) );
> create table centers (state varchar(2)) inherits (cities);
>
> ant the tuple
> insert into cities values (1, 'Lajeado');
>
> How i do if i want to make this city as a center ?
If I understand you correctly you probably want to do this instead...
insert into centers values (1, 'Lajeado', 'AZ');
Where AZ is your state
HTH
adam
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Inherancing
@ 2003-01-07 12:09 Nasair Junior da Silva <njunior@univates.br>
parent: Adam Witney <awitney@sghms.ac.uk>
0 siblings, 1 reply; 5+ messages in thread
From: Nasair Junior da Silva @ 2003-01-07 12:09 UTC (permalink / raw)
To: Adam Witney <awitney@sghms.ac.uk>; +Cc: pgsql-sql
In this case, when i do
select * from cities;
i'll have two tuples with the name 'Lajeado'.
Does it the only way i have ?
Thanks again,
Nasair Júnior da Silva
Lajeado - RS - Brasil.
Em Tue, 07 Jan 2003 12:02:13 +0000, Adam Witney <awitney@sghms.ac.uk> escreveu:
>On 7/1/03 11:42 am, "Nasair Junior da Silva" <njunior@univates.br> wrote:
>
>> Hi people,
>> supposing i have the tables :
>>
>> create table cities (id int, name varchar, primary key(id) );
>> create table centers (state varchar(2)) inherits (cities);
>>
>> ant the tuple
>> insert into cities values (1, 'Lajeado');
>>
>> How i do if i want to make this city as a center ?
>
>If I understand you correctly you probably want to do this instead...
>
>insert into centers values (1, 'Lajeado', 'AZ');
>
>Where AZ is your state
>
>HTH
>
>adam
>
>
xx===============================xx
|| °v° Nasair Junior da Silva ||
|| /(_)\ Linux User: 246054 ||
|| ^ ^ njunior@univates.br ||
||CPD - Desenvolvimento ||
||Univates - Centro Universitário||
xx===============================xx
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Inherancing
@ 2003-01-07 12:21 Adam Witney <awitney@sghms.ac.uk>
parent: Nasair Junior da Silva <njunior@univates.br>
0 siblings, 0 replies; 5+ messages in thread
From: Adam Witney @ 2003-01-07 12:21 UTC (permalink / raw)
To: njunior@univates.br; +Cc: pgsql-sql
Yes, if you do
insert into cities values (1, 'Lajeado');
insert into centers values (1, 'Lajeado', 'AZ');
Then select * from cities will give you
1 Lajedo
1 Lajedo
And select * from centers will give
1 Lajedo AZ
However, if rather than duplicating the insert and just doing
insert into centers values (1, 'Lajeado', 'AZ');
Then select * from cities will give you
1 Lajedo
And select * from centers will give
1 Lajedo AZ
Is this what you want?
adam
> In this case, when i do
> select * from cities;
> i'll have two tuples with the name 'Lajeado'.
>
> Does it the only way i have ?
>
> Thanks again,
>
> Nasair Júnior da Silva
> Lajeado - RS - Brasil.
>
> Em Tue, 07 Jan 2003 12:02:13 +0000, Adam Witney <awitney@sghms.ac.uk>
> escreveu:
>> On 7/1/03 11:42 am, "Nasair Junior da Silva" <njunior@univates.br> wrote:
>>
>>> Hi people,
>>> supposing i have the tables :
>>>
>>> create table cities (id int, name varchar, primary key(id) );
>>> create table centers (state varchar(2)) inherits (cities);
>>>
>>> ant the tuple
>>> insert into cities values (1, 'Lajeado');
>>>
>>> How i do if i want to make this city as a center ?
>>
>> If I understand you correctly you probably want to do this instead...
>>
>> insert into centers values (1, 'Lajeado', 'AZ');
>>
>> Where AZ is your state
>>
>> HTH
>>
>> adam
>>
>>
>
>
> xx===============================xx
> || °v° Nasair Junior da Silva ||
> || /(_)\ Linux User: 246054 ||
> || ^ ^ njunior@univates.br ||
> ||CPD - Desenvolvimento ||
> ||Univates - Centro Universitário||
> xx===============================xx
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Inherancing
@ 2003-01-07 17:16 Daniel Schuchardt <daniel_schuchardt@web.de>
parent: Nasair Junior da Silva <njunior@univates.br>
1 sibling, 0 replies; 5+ messages in thread
From: Daniel Schuchardt @ 2003-01-07 17:16 UTC (permalink / raw)
To: pgsql-sql
You have to insert in th centers-table. Because it is inherited from cities,
the record is automatically in cities. Search for SELECT * FROM ONLY in the
docs too.
> create table cities (id int, name varchar, primary key(id) );
> create table centers (state varchar(2)) inherits (cities);
>
> ant the tuple
> insert into cities values (1, 'Lajeado');
Lajeado isn't a center here. You should do :
insert into centers ....
You can do then SELECT * FROM cities -> you will get all cities. Or SELECT *
FROM centers -> you will get all centers. Or SELECT * FROM ONLY cities ->
you will get only cities who aren't centers.
Daniel.
"Nasair Junior da Silva" <njunior@univates.br> schrieb im Newsbeitrag
news:20030107094225.0345a050.njunior@univates.br...
> Hi people,
> supposing i have the tables :
>
> create table cities (id int, name varchar, primary key(id) );
> create table centers (state varchar(2)) inherits (cities);
>
> ant the tuple
> insert into cities values (1, 'Lajeado');
>
> How i do if i want to make this city as a center ?
>
> Thanks,
>
> xx===============================xx
> || °v° Nasair Junior da Silva ||
> || /(_)\ Linux User: 246054 ||
> || ^ ^ njunior@univates.br ||
> ||CPD - Desenvolvimento ||
> ||Univates - Centro Universitário||
> xx===============================xx
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2003-01-07 17:16 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-01-07 11:42 Inherancing Nasair Junior da Silva <njunior@univates.br>
2003-01-07 12:02 ` Adam Witney <awitney@sghms.ac.uk>
2003-01-07 12:09 ` Nasair Junior da Silva <njunior@univates.br>
2003-01-07 12:21 ` Adam Witney <awitney@sghms.ac.uk>
2003-01-07 17:16 ` Daniel Schuchardt <daniel_schuchardt@web.de>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox