pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
FOREIGN KEY ...
22+ messages / 17 participants
[nested] [flat]

* FOREIGN KEY ...
@ 1998-06-18 16:57  Pich LY <ly@esigetel.fr>
  0 siblings, 1 reply; 22+ messages in thread

From: Pich LY @ 1998-06-18 16:57 UTC (permalink / raw)
  To: pgsql-sql

Hi there,

I'm a french student at ESIGETEL, a school engineer specialized in
Networks and Telecommunications.

Now, I've some trouble with my end year project. We are 4 students
working on an local Intranet using PostgreSQL as the database manager
(and Apache as the HTTP server).

The problem is insignifiant : how can you declare an attribute as a
foreign key ?
The tables we are focus on are :
        CLIENT          FACTURATION
        ------          -----------
(pkey)  no_cli  <--\    no_factu        (pkey)
        client      \-- no_cli          (foreign key)
        adr_cli         adr_livr
        ...             ...

The query (in SQL language) used to declare the "FACTURATION" table is :
        CREATE TABLE Facturation
        (
                no_factu        INTEGER PRIMARY KEY,
                no_cli          INTEGER REFERENCES Client,
                adr_livr        VARCHAR(50),
                ...
        );

We can also use :
        CREATE TABLE Facturation
        (
                no_factu        INTEGER PRIMARY KEY,
                no_cli          INTEGER,
                adr_livr        VARCHAR(50),
                ...
                CONSTRAINT ct_factu REFERENCES (no_cli) FOREIGN KEY
Client (no_cli)
        );

But it doesn't seems to work ! "psql" gives us the following message :
        "NOTICE:  CREATE TABLE/FOREIGN KEY clause ignored: not yet
implemented"
!!!

What's the right syntaxe ???

Thanks for the help...

;-)



^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* Re: [SQL] FOREIGN KEY ...
@ 1998-06-19 07:56  Marin D <marin@cybernet.bg>
  parent: Pich LY <ly@esigetel.fr>
  0 siblings, 0 replies; 22+ messages in thread

From: Marin D @ 1998-06-19 07:56 UTC (permalink / raw)
  To: Pich LY <ly@esigetel.fr>; +Cc: pgsql-sql


The message says it all...

The syntax is recognized ( u've used the right one ) but foreign keys are
not implemented in this version.

U may wish to take a look at contrib/spi/refint* 
under the Postgres source tree for implementation of referential integrity

	Marin

          -= Why do we need gates in a world without fences? =-


On Thu, 18 Jun 1998, Pich LY wrote:

> Hi there,
> 
> I'm a french student at ESIGETEL, a school engineer specialized in
> Networks and Telecommunications.
> 
> Now, I've some trouble with my end year project. We are 4 students
> working on an local Intranet using PostgreSQL as the database manager
> (and Apache as the HTTP server).
> 
> The problem is insignifiant : how can you declare an attribute as a
> foreign key ?
> The tables we are focus on are :
>         CLIENT          FACTURATION
>         ------          -----------
> (pkey)  no_cli  <--\    no_factu        (pkey)
>         client      \-- no_cli          (foreign key)
>         adr_cli         adr_livr
>         ...             ...
> 
> The query (in SQL language) used to declare the "FACTURATION" table is :
>         CREATE TABLE Facturation
>         (
>                 no_factu        INTEGER PRIMARY KEY,
>                 no_cli          INTEGER REFERENCES Client,
>                 adr_livr        VARCHAR(50),
>                 ...
>         );
> 
> We can also use :
>         CREATE TABLE Facturation
>         (
>                 no_factu        INTEGER PRIMARY KEY,
>                 no_cli          INTEGER,
>                 adr_livr        VARCHAR(50),
>                 ...
>                 CONSTRAINT ct_factu REFERENCES (no_cli) FOREIGN KEY
> Client (no_cli)
>         );
> 
> But it doesn't seems to work ! "psql" gives us the following message :
>         "NOTICE:  CREATE TABLE/FOREIGN KEY clause ignored: not yet
> implemented"
> !!!
> 
> What's the right syntaxe ???
> 
> Thanks for the help...
> 
> ;-)
> 




^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* FOREIGN KEY
@ 1998-07-31 20:07  Alexey Pushkin <Alexey.Pushkin@fi.uib.no>
  0 siblings, 0 replies; 22+ messages in thread

From: Alexey Pushkin @ 1998-07-31 20:07 UTC (permalink / raw)
  To: pgsql-sql

Hi all.

As far as I understand PostgreSQL does not support
FOREIGN KEY syntax. (Do I gather right ?).

What is the recommended work around ?

---
Alexey Pushkin
Well Service Technology AS



^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* RE: [SQL] FOREIGN KEY
@ 1998-07-31 22:58  Jackson, DeJuan <djackson@cpsgroup.com>
  0 siblings, 0 replies; 22+ messages in thread

From: Jackson, DeJuan @ 1998-07-31 22:58 UTC (permalink / raw)
  To: Alexey Pushkin <Alexey.Pushkin@fi.uib.no>; pgsql-sql

> Hi all.
> 
> As far as I understand PostgreSQL does not support
> FOREIGN KEY syntax. (Do I gather right ?).
Postgres supports the 'syntax' just fine, it simply ignores it.

> What is the recommended work around ?
There is a work-around (triggers) in the contrib directory of the
distribution (refint).  It comes with examples of usage.

> ---
> Alexey Pushkin
> Well Service Technology AS



^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* Foreign Key ??
@ 1998-11-08 16:59  David Jackson <cjamblue@smokies.amnix.com>
  0 siblings, 1 reply; 22+ messages in thread

From: David Jackson @ 1998-11-08 16:59 UTC (permalink / raw)
  To: pgsql-novice@hub.org; +Cc: pgsql-sql@hub.org

Good-day,
How are foreign keys implemented in PostgresSQL ?
I tried using the following statment:
CREATE TABLE orders(
	order_no	int 	primary key,
	client_name	char(30),
	CONSTRAINT  NAME_FK FOREIGN KEY (client_name)
		REFERENCES client(client_name)
);
This results in FUNCTION NOT IMPLETEMENTED error.

Thanks for you time
David Jackson




^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* Re: [SQL] Foreign Key ??
@ 1998-11-09 09:49  Fabio Mancinelli <mancinel@univaq.it>
  parent: David Jackson <cjamblue@smokies.amnix.com>
  0 siblings, 0 replies; 22+ messages in thread

From: Fabio Mancinelli @ 1998-11-09 09:49 UTC (permalink / raw)
  To: David Jackson <cjamblue@smokies.amnix.com>; +Cc: pgsql-novice@hub.org; pgsql-sql@hub.org

On Sun, 8 Nov 1998, David Jackson wrote:

> 	CONSTRAINT  NAME_FK FOREIGN KEY (client_name)
> 		REFERENCES client(client_name)
> );
> This results in FUNCTION NOT IMPLETEMENTED error.
>
Yes, that's true. There is no built-in referential integrity in
PostgresSQL. Anyway there are two "external" functions in the contrib/spi
directory which implement the referential integrity.
You can use these functions via triggers.

All the docs and the sources are in the contrib/spi dir in the source code
distribution (v6.4), I don't remember if they are also available in the
v6.3 source code distibution.

Bye.
 
------------------------------------------------------------------------------
 Greetings from Fabio Mancinelli   E-Mail : mancinel@univaq.it
 Computer Science Student                   xenon@olografix.org
 University of L'Aquila               WWW : http://univaq.it/~mancinel
 (PGP Public Key available)                 http://www.olografix.org/xenon




^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* foreign key
@ 2000-04-12 19:03  Arindam Guha <arindam_guha@hotmail.com>
  0 siblings, 1 reply; 22+ messages in thread

From: Arindam Guha @ 2000-04-12 19:03 UTC (permalink / raw)
  To: pgsql-sql

How to avoid  updation anomaly like this :

While trying to update in the parent table it says child record exists
and
while trying to update in the child table it says parent record exists

I am trying to update the foreign key column in both the tables ?

Also how to delete a foreign key constraint ?

Thanks
Arindam
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com




^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* Re: foreign key
@ 2000-04-13 11:18  Stephan Szabo <sszabo@bigpanda.com>
  parent: Arindam Guha <arindam_guha@hotmail.com>
  0 siblings, 0 replies; 22+ messages in thread

From: Stephan Szabo @ 2000-04-13 11:18 UTC (permalink / raw)
  To: Arindam Guha <arindam_guha@hotmail.com>; +Cc: pgsql-sql

How did you define the foreign key constraint on the tables?
Also, are you sure that on update of child table it is saying
that the parent record exists instead of doesn't (see below)?

I would guess from the behavior you are seeing that you 
did not define any actions for update or delete.  In that case,
updates to the master will fail if any child references that row,
and updates to the child will fail if the master you are updating
to does not exist.  

I'd say that you probably want to define the cascade action
for update, so that changes to the master table will propogate 
into the child table.  To do this, you need to say "on update cascade"
in the definition of the constraint (for example:
 masterid int references master(id) on update cascade
)

And right now, the only way to permanently delete a foreign key 
constraint is to remove the triggers.  You need to find the
rows in pg_trigger that are associated with the constraint and
drop those triggers.  There should be 3 triggers I believe.

----- Original Message ----- 
From: Arindam Guha <arindam_guha@hotmail.com>
To: <pgsql-sql@postgresql.org>
Sent: Wednesday, April 12, 2000 7:03 PM
Subject: [SQL] foreign key


> How to avoid  updation anomaly like this :
> 
> While trying to update in the parent table it says child record exists
> and
> while trying to update in the child table it says parent record exists
> 
> I am trying to update the foreign key column in both the tables ?
> 
> Also how to delete a foreign key constraint ?
> 
> Thanks
> Arindam
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
> 




^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* Foreign key
@ 2001-08-02 16:23  Lorenzo De Vito <lorenzodevito@email.it>
  0 siblings, 3 replies; 22+ messages in thread

From: Lorenzo De Vito @ 2001-08-02 16:23 UTC (permalink / raw)
  To: pgsql-sql

What's the best way to build a relation between two tables ?
I know that Foreign key is no longer supported.

^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* RE: Foreign key
@ 2001-08-02 18:19  Robby Slaughter <webmaster@robbyslaughter.com>
  parent: Lorenzo De Vito <lorenzodevito@email.it>
  2 siblings, 0 replies; 22+ messages in thread

From: Robby Slaughter @ 2001-08-02 18:19 UTC (permalink / raw)
  To: Lorenzo De Vito <lorenzodevito@email.it>; pgsql-sql

Uh...I think foreign keys are supported:

CREATE TABLE main
  ( id INTEGER,
    data TEXT );

CREATE TABLE secondary
  ( mainid INTEGER REFERENCES main(id),
    data TEXT );

That will make your joins:

 SELECT * FROM main,secondary WHERE id = mainid;

much more efficient.

-Robby
  -----Original Message-----
  From: pgsql-sql-owner@postgresql.org
[mailto:pgsql-sql-owner@postgresql.org]On Behalf Of Lorenzo De Vito
  Sent: Thursday, August 02, 2001 11:24 AM
  To: pgsql-sql@postgresql.org
  Subject: [SQL] Foreign key


  What's the best way to build a relation between two tables ?
  I know that Foreign key is no longer supported.

^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* Re: Foreign key
@ 2001-08-02 19:43  Jason Earl <jdearl@yahoo.com>
  parent: Lorenzo De Vito <lorenzodevito@email.it>
  2 siblings, 0 replies; 22+ messages in thread

From: Jason Earl @ 2001-08-02 19:43 UTC (permalink / raw)
  To: Lorenzo De Vito <lorenzodevito@email.it>; pgsql-sql

Where did you get the idea that Foreign Key was no
longer supported?  It works fine on my 7.1.2 box:



processdata=> select version();
                            version                   
        
---------------------------------------------------------------
 PostgreSQL 7.1.2 on i686-pc-linux-gnu, compiled by
GCC 2.95.4
(1 row)

processdata=> CREATE TABLE foo (tes_key varchar(5)
PRIMARY KEY);
NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit
index 'foo_pkey' for table 'foo'
CREATE
processdata=> CREATE TABLE bar (bar_key SERIAL, foo_id
varchar(5) REFERENCES foo);
NOTICE:  CREATE TABLE will create implicit sequence
'bar_bar_key_seq' for SERIAL column 'bar.bar_key'
NOTICE:  CREATE TABLE/UNIQUE will create implicit
index 'bar_bar_key_key' for table 'bar'
NOTICE:  CREATE TABLE will create implicit trigger(s)
for FOREIGN KEY check(s)
CREATE

Good Luck,
Jason

--- Lorenzo De Vito <lorenzodevito@email.it> wrote:
> What's the best way to build a relation between two
> tables ?
> I know that Foreign key is no longer supported.
> 


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/



^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* Re: Foreign key
@ 2001-08-02 20:56  Jan Wieck <JanWieck@Yahoo.com>
  parent: Lorenzo De Vito <lorenzodevito@email.it>
  2 siblings, 0 replies; 22+ messages in thread

From: Jan Wieck @ 2001-08-02 20:56 UTC (permalink / raw)
  To: Lorenzo De Vito <lorenzodevito@email.it>; +Cc: pgsql-sql

Lorenzo De Vito wrote:
> What's the best way to build a relation between two tables ?
> I know that Foreign key is no longer supported.

    Who told you so?


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com




^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* [postgres] Foreign Key
@ 2003-10-13 08:55  Stefan Sturm <stefan@urkman.de>
  0 siblings, 0 replies; 22+ messages in thread

From: Stefan Sturm @ 2003-10-13 08:55 UTC (permalink / raw)
  To: postgres@yahoogroups.de

Hallo zusammen,

ich würde gerne folgenden Foreign Key in meine DB einbauen. Leider
bekomme ich immer eine Fehlermeldung.
Hier die Situation:

Ich habe 2 Tabellen:
status:
ID Numeric
Name Text

logins:
ID Numeric
Name Text
Status__id Numeric

In der Tabelle status befinden sich Datensätze. Die Tabelle logins ist
leer. Nun versuche ich folgenden Befehl:

ALTER TABLE "public"."login " ADD CONSTRAINT "test" FOREIGN KEY
("status__id") REFERENCES "public"."status"("id")
  ON DELETE RESTRICT
  ON UPDATE RESTRICT
  NOT DEFERRABLE;

Jetzt bekomme ich immer die Fehlermeldung:
ERROR:  Query was cancelled.

Und das war auch schon alles.

Kann mir da einer Helfen?

Danke und Grüße,
Stefan Sturm

PS: Ich mache das ganze mit dem Programm EMS PostgreSQL Manager Version
1.8.0.1


Wenn Sie Ihr Abonnement fuer diese Gruppe kuendigen moechten, senden 
Sie eine E-Mail an:
postgres-unsubscribe@egroups.de

 

Die Nutzung von Yahoo! Groups ist Bestandteil von http://de.docs.yahoo.com/info/utos.html 





^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* Re: [postgres] Foreign Key
@ 2003-10-13 10:37  Alvar Freude <alvar@a-blast.org>
  0 siblings, 1 reply; 22+ messages in thread

From: Alvar Freude @ 2003-10-13 10:37 UTC (permalink / raw)
  To: postgres@yahoogroups.de

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hallo,

- -- Stefan Sturm <stefan@urkman.de> wrote:

> In der Tabelle status befinden sich Datensätze. Die Tabelle logins ist
> leer. Nun versuche ich folgenden Befehl:
> 
> ALTER TABLE "public"."login " ADD CONSTRAINT "test" FOREIGN KEY
> ("status__id") REFERENCES "public"."status"("id")
>   ON DELETE RESTRICT
>   ON UPDATE RESTRICT
>   NOT DEFERRABLE;
> 
> Jetzt bekomme ich immer die Fehlermeldung:
> ERROR:  Query was cancelled.

hmmm, die Fehlermeldung ist seltsam und tritt normalerweise bei Abbruch zum
Beispiel bei ^C im Frontent auf.

Bei ALTER TABLE kann Postgres noch nicht alle Features; je älter die
Version, desto weniger ;-)

Evtl. sind auch die Anführungszeichen ein Problem.


Einfach mal in der Doku zu alter Table nachschauen, was da geht

Ciao
  Alvar



- -- 
** Alvar C.H. Freude -- http://alvar.a-blast.org/
** 
**   ODEM.org-Tour:  http://tour.odem.org/
**
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQE/ioBaOndlH63J86wRApScAJ49Wci7CmjVu3qkSOKUCNCTOqY1DQCfSzyW
MjDrIJmz+Yy8/gM5gQcVlDs=
=Guu6
-----END PGP SIGNATURE-----


Wenn Sie Ihr Abonnement fuer diese Gruppe kuendigen moechten, senden 
Sie eine E-Mail an:
postgres-unsubscribe@egroups.de

 

Die Nutzung von Yahoo! Groups ist Bestandteil von http://de.docs.yahoo.com/info/utos.html 





^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* Re: [postgres] Foreign Key
@ 2003-10-13 10:47  Stefan Sturm <stefan@urkman.de>
  parent: Alvar Freude <alvar@a-blast.org>
  0 siblings, 0 replies; 22+ messages in thread

From: Stefan Sturm @ 2003-10-13 10:47 UTC (permalink / raw)
  To: postgres@yahoogroups.de

Hallo,

> > In der Tabelle status befinden sich Datensätze. Die Tabelle logins
> ist
> > leer. Nun versuche ich folgenden Befehl:
> >
> > ALTER TABLE "public"."login " ADD CONSTRAINT "test" FOREIGN KEY
> > ("status__id") REFERENCES "public"."status"("id")
> >   ON DELETE RESTRICT
> >   ON UPDATE RESTRICT
> >   NOT DEFERRABLE;
> >
> > Jetzt bekomme ich immer die Fehlermeldung:
> > ERROR:  Query was cancelled.
> 
> hmmm, die Fehlermeldung ist seltsam und tritt normalerweise bei
> Abbruch zum
> Beispiel bei ^C im Frontent auf.

Ich tippe mal, das der PostgreSQL Manager da selber ein Timeout macht.
Habe es auch mal mit phpPgAdmin versucht. Der läuft sich Tod.

 
> Bei ALTER TABLE kann Postgres noch nicht alle Features; je älter die
> Version, desto weniger ;-)

Ich verwende die Version 7.3.4. Das sollte doch wohl reichen, oder?

> Evtl. sind auch die Anführungszeichen ein Problem.

Habe es auch ohne versucht, das gleiche Problem.

Ich werde es jetzt mal mit psql, direkt auf dem Server testen.
Vielleicht geht es ja dann.

Grüße,
Stefan


Wenn Sie Ihr Abonnement fuer diese Gruppe kuendigen moechten, senden 
Sie eine E-Mail an:
postgres-unsubscribe@egroups.de

 

Die Nutzung von Yahoo! Groups ist Bestandteil von http://de.docs.yahoo.com/info/utos.html 





^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* Re: [postgres] Foreign Key
@ 2003-10-13 10:51  Stefan Sturm <stefan@urkman.de>
  0 siblings, 0 replies; 22+ messages in thread

From: Stefan Sturm @ 2003-10-13 10:51 UTC (permalink / raw)
  To: postgres@yahoogroups.de

Ich melde mich doch. Ich sitze hier halt uns arbeite. Ich arbeite aber
derzeit (außer der Formel1 Auswertung) nur an meinen Sachen. Und ich
mache das schon ganz schön Fortschritte.

Michelle hat gerade hier geklingelt. Sie kommt heute um ca. 19 Uhr zu
uns.

> -----Original Message-----
> From: Stefan Sturm [mailto:stefan@urkman.de]
> Sent: Monday, October 13, 2003 12:48 PM
> To: postgres@yahoogroups.de
> Subject: RE: [SQL] [postgres] Foreign Key
> 
> Hallo,
> 
> > > In der Tabelle status befinden sich Datensätze. Die Tabelle logins
> > ist
> > > leer. Nun versuche ich folgenden Befehl:
> > >
> > > ALTER TABLE "public"."login " ADD CONSTRAINT "test" FOREIGN KEY
> > > ("status__id") REFERENCES "public"."status"("id")
> > >   ON DELETE RESTRICT
> > >   ON UPDATE RESTRICT
> > >   NOT DEFERRABLE;
> > >
> > > Jetzt bekomme ich immer die Fehlermeldung:
> > > ERROR:  Query was cancelled.
> >
> > hmmm, die Fehlermeldung ist seltsam und tritt normalerweise bei
> > Abbruch zum
> > Beispiel bei ^C im Frontent auf.
> 
> Ich tippe mal, das der PostgreSQL Manager da selber ein Timeout macht.
> Habe es auch mal mit phpPgAdmin versucht. Der läuft sich Tod.
> 
> 
> > Bei ALTER TABLE kann Postgres noch nicht alle Features; je älter die
> > Version, desto weniger ;-)
> 
> Ich verwende die Version 7.3.4. Das sollte doch wohl reichen, oder?
> 
> > Evtl. sind auch die Anführungszeichen ein Problem.
> 
> Habe es auch ohne versucht, das gleiche Problem.
> 
> Ich werde es jetzt mal mit psql, direkt auf dem Server testen.
> Vielleicht geht es ja dann.
> 
> Grüße,
> Stefan
> 
> 
> Wenn Sie Ihr Abonnement fuer diese Gruppe kuendigen moechten, senden
> Sie eine E-Mail an:
> postgres-unsubscribe@egroups.de
> 
> 
> 
> Die Nutzung von Yahoo! Groups ist Bestandteil von
> http://de.docs.yahoo.com/info/utos.html
> 



Wenn Sie Ihr Abonnement fuer diese Gruppe kuendigen moechten, senden 
Sie eine E-Mail an:
postgres-unsubscribe@egroups.de

 

Die Nutzung von Yahoo! Groups ist Bestandteil von http://de.docs.yahoo.com/info/utos.html 





^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* Re: [postgres] Foreign Key
@ 2003-10-13 10:54  Stefan Sturm <stefan@urkman.de>
  0 siblings, 0 replies; 22+ messages in thread

From: Stefan Sturm @ 2003-10-13 10:54 UTC (permalink / raw)
  To: postgres@yahoogroups.de

Sorry für die letzte Mail. Habe bei der falschen Mail auf Antwort
geklickt.

Nochmals Sorry,
Stefan

> -----Original Message-----
> From: Stefan Sturm [mailto:stefan@urkman.de]
> Sent: Monday, October 13, 2003 12:48 PM
> To: postgres@yahoogroups.de
> Subject: RE: [SQL] [postgres] Foreign Key
> 
> Hallo,
> 
> > > In der Tabelle status befinden sich Datensätze. Die Tabelle logins
> > ist
> > > leer. Nun versuche ich folgenden Befehl:
> > >
> > > ALTER TABLE "public"."login " ADD CONSTRAINT "test" FOREIGN KEY
> > > ("status__id") REFERENCES "public"."status"("id")
> > >   ON DELETE RESTRICT
> > >   ON UPDATE RESTRICT
> > >   NOT DEFERRABLE;
> > >
> > > Jetzt bekomme ich immer die Fehlermeldung:
> > > ERROR:  Query was cancelled.
> >
> > hmmm, die Fehlermeldung ist seltsam und tritt normalerweise bei
> > Abbruch zum
> > Beispiel bei ^C im Frontent auf.
> 
> Ich tippe mal, das der PostgreSQL Manager da selber ein Timeout macht.
> Habe es auch mal mit phpPgAdmin versucht. Der läuft sich Tod.
> 
> 
> > Bei ALTER TABLE kann Postgres noch nicht alle Features; je älter die
> > Version, desto weniger ;-)
> 
> Ich verwende die Version 7.3.4. Das sollte doch wohl reichen, oder?
> 
> > Evtl. sind auch die Anführungszeichen ein Problem.
> 
> Habe es auch ohne versucht, das gleiche Problem.
> 
> Ich werde es jetzt mal mit psql, direkt auf dem Server testen.
> Vielleicht geht es ja dann.
> 
> Grüße,
> Stefan
> 
> 
> Wenn Sie Ihr Abonnement fuer diese Gruppe kuendigen moechten, senden
> Sie eine E-Mail an:
> postgres-unsubscribe@egroups.de
> 
> 
> 
> Die Nutzung von Yahoo! Groups ist Bestandteil von
> http://de.docs.yahoo.com/info/utos.html
> 



Wenn Sie Ihr Abonnement fuer diese Gruppe kuendigen moechten, senden 
Sie eine E-Mail an:
postgres-unsubscribe@egroups.de

 

Die Nutzung von Yahoo! Groups ist Bestandteil von http://de.docs.yahoo.com/info/utos.html 





^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* Re: [postgres] Foreign Key
@ 2003-10-13 10:56  Alvar Freude <alvar@a-blast.org>
  0 siblings, 1 reply; 22+ messages in thread

From: Alvar Freude @ 2003-10-13 10:56 UTC (permalink / raw)
  To: postgres@yahoogroups.de

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hallo,

- -- Stefan Sturm <stefan@urkman.de> wrote:

> Ich tippe mal, das der PostgreSQL Manager da selber ein Timeout macht.
> Habe es auch mal mit phpPgAdmin versucht. Der läuft sich Tod.

Ist die Tabelle groß? Da kann es natürlich sein, dass da ein ganzer Haufen
an Updates gemacht werden muss, und dass gerade dies in diesem Falle
überhaupt nicht optimiert ist.

Zumindest muss ja ein Test auf die References-Tabelle gemacht werden. Sind
da entsprechende Indexe drauf? Evtl. hilft da auch das Clustern.


> Ich verwende die Version 7.3.4. Das sollte doch wohl reichen, oder?

das weiss ich ehrlich gesagt gerade nicht ;-)
 
Aber die Fehlermeldung sollte durchaus anders aussehen und sofort kommen.


Ciao
  Alvar



- -- 
** Alvar C.H. Freude -- http://alvar.a-blast.org/
** 
**   ODEM.org-Tour:  http://tour.odem.org/
**
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQE/ioTdOndlH63J86wRAsluAJoD9MrrVc65JbsH3cJbN660mQnI9wCePRs5
XMVcvgLIRANIvLUoI7PGLS4=
=bTIL
-----END PGP SIGNATURE-----


Wenn Sie Ihr Abonnement fuer diese Gruppe kuendigen moechten, senden 
Sie eine E-Mail an:
postgres-unsubscribe@egroups.de

 

Die Nutzung von Yahoo! Groups ist Bestandteil von http://de.docs.yahoo.com/info/utos.html 





^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* Re: [postgres] Foreign Key
@ 2003-10-13 11:01  Stefan Sturm <stefan@urkman.de>
  parent: Alvar Freude <alvar@a-blast.org>
  0 siblings, 0 replies; 22+ messages in thread

From: Stefan Sturm @ 2003-10-13 11:01 UTC (permalink / raw)
  To: postgres@yahoogroups.de

Hallo,

> Hallo,
> 
> > Ich tippe mal, das der PostgreSQL Manager da selber ein Timeout
> macht.
> > Habe es auch mal mit phpPgAdmin versucht. Der läuft sich Tod.
> 
> Ist die Tabelle groß? Da kann es natürlich sein, dass da ein ganzer
> Haufen
> an Updates gemacht werden muss, und dass gerade dies in diesem Falle
> überhaupt nicht optimiert ist.
>
> Zumindest muss ja ein Test auf die References-Tabelle gemacht werden.
> Sind
> da entsprechende Indexe drauf? Evtl. hilft da auch das Clustern.

Die Tabelle ist sehr klein. Max. 20 Datensätze. Ist halt noch in der
Entwicklung.
Direkt auf der Datenbank mit psql hat es auf Anhieb geklappt. Hat keine
Sekunde gedauert.
Jetzt frage ich mich, warum? 

Grüße,
Stefan


Wenn Sie Ihr Abonnement fuer diese Gruppe kuendigen moechten, senden 
Sie eine E-Mail an:
postgres-unsubscribe@egroups.de

 

Die Nutzung von Yahoo! Groups ist Bestandteil von http://de.docs.yahoo.com/info/utos.html 





^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* Foreign key
@ 2005-03-25 15:31  ASAKALAL@bouyguestelecom.fr
  0 siblings, 2 replies; 22+ messages in thread

From: ASAKALAL@bouyguestelecom.fr @ 2005-03-25 15:31 UTC (permalink / raw)
  To: pgsql-sql

Hello,

 

When i add table with foreign key in my database, this error return : <
number of referencing and referenced colums for foreign key disagree>.

How resolve this problem ?

 

Thanks

 

alain SAKALALA

Mailto:asakalal@bouyguestelecom.fr

 

^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* Re: Foreign key
@ 2005-03-27 07:47  Michael Fuhr <mike@fuhr.org>
  parent: ASAKALAL@bouyguestelecom.fr
  1 sibling, 0 replies; 22+ messages in thread

From: Michael Fuhr @ 2005-03-27 07:47 UTC (permalink / raw)
  To: ASAKALAL@bouyguestelecom.fr; +Cc: pgsql-sql

On Fri, Mar 25, 2005 at 04:31:16PM +0100, ASAKALAL@bouyguestelecom.fr wrote:
>
> When i add table with foreign key in my database, this error return : <
> number of referencing and referenced colums for foreign key disagree>.

Apparently the referencing key (the foreign key specification) has
a different number of columns than the referenced key (the primary
key or other unique key in the referenced table).  Here's an example
that illustrates the problem:

  CREATE TABLE foo (
      pk1  integer NOT NULL,
      pk2  integer NOT NULL,
      PRIMARY KEY (pk1, pk2)  -- 2-column primary key
  );
  
  CREATE TABLE bar (
      fk  integer NOT NULL REFERENCES foo  -- 1-column foreign key
  );
  
  ERROR:  number of referencing and referenced columns for foreign key disagree

In the above example we need a 2-column foreign key:

  CREATE TABLE bar (
      fk1  integer NOT NULL,
      fk2  integer NOT NULL,
      FOREIGN KEY (fk1, fk2) REFERENCES foo
  );

Here's another example that references a 1-column unique key that
isn't a primary key:

  CREATE TABLE foo (
      pk1  integer NOT NULL,
      pk2  integer NOT NULL,
      x    integer NOT NULL,
      PRIMARY KEY (pk1, pk2),
      UNIQUE (x)
  );
  
  CREATE TABLE bar (
      fk  integer NOT NULL REFERENCES foo (x)
  );

If these examples don't help, then please post the table definitions
you're working with and explain what you'd like to do.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



^ permalink  raw  reply  [nested|flat] 22+ messages in thread

* Re: Foreign key
@ 2005-03-27 16:33  Bruno Wolff III <bruno@wolff.to>
  parent: ASAKALAL@bouyguestelecom.fr
  1 sibling, 0 replies; 22+ messages in thread

From: Bruno Wolff III @ 2005-03-27 16:33 UTC (permalink / raw)
  To: ASAKALAL@bouyguestelecom.fr; +Cc: pgsql-sql

On Fri, Mar 25, 2005 at 16:31:16 +0100,
  ASAKALAL@bouyguestelecom.fr wrote:
> 
> When i add table with foreign key in my database, this error return : <
> number of referencing and referenced colums for foreign key disagree>.
> 
> How resolve this problem ?

Besides what Mike said, one other thing to remember is that if you don't
specify columns in the referenced table, the primary key of that table
is used, NOT columns with names matching those of the referencing table.

In cases like this it have helped if you had copied and pasted an example
displaying the problem in addition to the error message.



^ permalink  raw  reply  [nested|flat] 22+ messages in thread


end of thread, other threads:[~2005-03-27 16:33 UTC | newest]

Thread overview: 22+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-06-18 16:57 FOREIGN KEY ... Pich LY <ly@esigetel.fr>
1998-06-19 07:56 ` Marin D <marin@cybernet.bg>
1998-07-31 20:07 FOREIGN KEY Alexey Pushkin <Alexey.Pushkin@fi.uib.no>
1998-07-31 22:58 RE: [SQL] FOREIGN KEY Jackson, DeJuan <djackson@cpsgroup.com>
1998-11-08 16:59 Foreign Key ?? David Jackson <cjamblue@smokies.amnix.com>
1998-11-09 09:49 ` Re: [SQL] Foreign Key ?? Fabio Mancinelli <mancinel@univaq.it>
2000-04-12 19:03 foreign key Arindam Guha <arindam_guha@hotmail.com>
2000-04-13 11:18 ` Re: foreign key Stephan Szabo <sszabo@bigpanda.com>
2001-08-02 16:23 Foreign key Lorenzo De Vito <lorenzodevito@email.it>
2001-08-02 18:19 ` RE: Foreign key Robby Slaughter <webmaster@robbyslaughter.com>
2001-08-02 19:43 ` Re: Foreign key Jason Earl <jdearl@yahoo.com>
2001-08-02 20:56 ` Re: Foreign key Jan Wieck <JanWieck@Yahoo.com>
2003-10-13 08:55 [postgres] Foreign Key Stefan Sturm <stefan@urkman.de>
2003-10-13 10:37 Re: [postgres] Foreign Key Alvar Freude <alvar@a-blast.org>
2003-10-13 10:47 ` Re: [postgres] Foreign Key Stefan Sturm <stefan@urkman.de>
2003-10-13 10:51 Re: [postgres] Foreign Key Stefan Sturm <stefan@urkman.de>
2003-10-13 10:54 Re: [postgres] Foreign Key Stefan Sturm <stefan@urkman.de>
2003-10-13 10:56 Re: [postgres] Foreign Key Alvar Freude <alvar@a-blast.org>
2003-10-13 11:01 ` Re: [postgres] Foreign Key Stefan Sturm <stefan@urkman.de>
2005-03-25 15:31 Foreign key ASAKALAL@bouyguestelecom.fr
2005-03-27 07:47 ` Re: Foreign key Michael Fuhr <mike@fuhr.org>
2005-03-27 16:33 ` Re: Foreign key Bruno Wolff III <bruno@wolff.to>

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