pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jonathan Gardner <jgardner@jonathangardner.net>
To: eVl One <evl@my-mail.com.ua>
To: Bruno Wolff III <bruno@wolff.to>
Cc: pgsql-sql@postgresql.org
Subject: Re: How to check: is some key referenced from sometable
Date: Tue, 12 Aug 2003 09:46:54 -0700
Message-ID: <200308120946.56006.jgardner@jonathangardner.net> (raw)
In-Reply-To: <18618711976.20030810004432@my-mail.com.ua>
References: <3159.195.5.48.107.1059985076.squirrel@my-mail.com.ua>
	<20030809150809.GA22927@wolff.to>
	<18618711976.20030810004432@my-mail.com.ua>

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

On Saturday 09 August 2003 14:44, eVl One wrote:
> So I need:
>    "silent delete" - i.e. when trying to DELETE row from A I'll not
> fall out with "$1 referential integrity violation - key in A still
> referenced from Bxx", but silently doesn't delete row ('cause run it
> from function and need function to executes farther after delete);
> "something to check reference" - system (potgresql) is very quickly
> realizes that key is referenced from another table, maybe this
> information may be accessed through some system relations, or so?
> Thanx for attention.

You may want to check out the "ON DELETE" and "ON UPDATE" clauses of the 
FOREIGN KEY syntax. This will help you keep you data consistent.

Otherwise, if you want to know what is referencing something, you'll 
have to query all of those tables. Your database structure should be 
well-defined and thought out, so you should be able to figure out what 
all is referencing it. If you need it for day-to-day queries, you may 
want to rethink your design.

If you like, take a look at the pg_trigger table. The way PostgreSQL 
manages the foreign key references is through triggers. You may be able 
to identify which triggers are which, and from there, determine which 
tables are referencing which tables.

- -- 
Jonathan Gardner <jgardner@jonathangardner.net>
Live Free, Use Linux!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE/ORn/WgwF3QvpWNwRAsJ5AJ9iGmopncQsyizb6yIh2CvCQsSmwQCg0UZ/
xImGLW35bdAJSuzCWc7yxBU=
=eQGH
-----END PGP SIGNATURE-----



view thread (5+ messages)

Message-ID: <200308120946.56006.jgardner@jonathangardner.net>
Permalink:  ../200308120946.56006.jgardner@jonathangardner.net/
Also on:    postgresql.org/message-id/200308120946.56006.jgardner@jonathangardner.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jgardner@jonathangardner.net, evl@my-mail.com.ua, bruno@wolff.to
  Subject: Re: How to check: is some key referenced from sometable
  In-Reply-To: <200308120946.56006.jgardner@jonathangardner.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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