[SQL] primary keys

2002-11-07 Thread Huub
Hi,

I want to create a table which has 2 columns, and both columns have to 
be primary key (or: together they are the primary key). How can I do 
this using SQL? Using pgAdminII for Postgres7.2.2 on RH8.

Thanks

Huub


---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [SQL] primary keys

2002-11-07 Thread Huub
[EMAIL PROTECTED] wrote:


A table can only have ONE primary key.  It can have additional indexes 
with
a UNIQUE restriction, thereby forcing the second field to be as good as a
primary key.

That is probably what you are looking for, however, you can also in PG 
Admin
II select multiple fields as being the member of the primary key.


Terry Fielder
Network Engineer
Great Gulf Homes / Ashton Woods Homes
[EMAIL PROTECTED]




>-Original Message-
>From: [EMAIL PROTECTED]
>[mailto:pgsql-sql-owner@;postgresql.org]On Behalf Of Huub
>Sent: Wednesday, November 06, 2002 9:19 AM
>To: [EMAIL PROTECTED]
>Subject: [SQL] primary keys
>
>
>Hi,
>
>I want to create a table which has 2 columns, and both
>columns have to
>be primary key (or: together they are the primary key). How can I do
>this using SQL? Using pgAdminII for Postgres7.2.2 on RH8.
>
>Thanks
>
>Huub
>
>
>---(end of
>broadcast)---
>TIP 4: Don't 'kill -9' the postmaster
>



---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly

Thanks..problem solved..

Huub


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



[SQL] changing numeric into int

2002-11-07 Thread Huub
Hi,

I want to change 2 columns in the same table from numeric into int. Can 
I do this without deleting the old table and creating a new one? Data 
stays the same..

Thanks

Huub


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html


[SQL] Error message: standard SQL or PostgreQSL?

2002-11-14 Thread Huub
Hi,

When I copied a function call into an SQL-statement and executed it, I 
got the message 'Aggregate function calls may not be nested'. Does that 
mean this is the case in standard SQL or is this specifically PostgreSQL?

Thanks

Huub


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html


[SQL] primary + foreign key

2002-12-12 Thread Huub
Hi,

I want to create a table where the 2 columns are both primary as well as 
foreign key. What is the correct syntax for that?

Thanks

Huub


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly


Re: [SQL] primary + foreign key

2002-12-12 Thread Huub
Hi,

I suppose 'detail' is the table name? And what is master?

Thanks

Huub

create table detail
(
   id1 integer,
   id2 integer,
   CONSTRAINT c1 PRIMARY KEY(id1,id2),
   CONSTRAINT c2 FOREIGN KEY(id1,id2) REFERENCES master
);

Do you really need such detail table? You can just add columns to master 
table.

Tomasz Myrta


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly



Re: [SQL] primary + foreign key

2002-12-12 Thread Huub
Thanks for pointing out. I'm not that experienced in SQL yet; so detail 
could as well be some extra instruction and I've never seen 'references 
master' before. But I think I'll manage now. Thanks

Tomasz Myrta wrote:
Huub wrote:



Hi,

I suppose 'detail' is the table name? And what is master?

Thanks

Huub



You should know that.
Detail is a table you want to create and master is a table where foreign 
key points to.

Tomasz Myrta


---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
   (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])