Skip site navigation (1) Skip section navigation (2)

Re: how to know this row has been referenced or not????

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Akbar <tuxer(at)myrealbox(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: how to know this row has been referenced or not????
Date: 2005-02-10 05:22:37
Message-ID: 20050210052237.GA59173@winnie.fuhr.org (view raw or flat)
Thread:
Lists: pgsql-novice
On Thu, Feb 10, 2005 at 07:00:14PM +0700, Akbar wrote:

> How do I know for sure that "this row" or "that row" has or has not
> been referenced by other table????

Why do you need to know?  What are you trying to do?

> Of cource I can test it by trying to delete it.... if it has
> been referenced, the delete command will fail, and if it has not been
> referenced the delete command will success.....

If the referencing table uses ON DELETE CASCADE then the delete
will succeed and it'll also delete the rows in the other table.

Even if you do find out that nobody's referencing the row, the
situation could change immediately after the check unless you take
steps to prevent that from happening (e.g., through locking).

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

In response to

Responses

pgsql-novice by date

Next:From: AkbarDate: 2005-02-10 12:00:14
Subject: how to know this row has been referenced or not????
Previous:From: Oisin GlynnDate: 2005-02-09 18:48:19
Subject: Re: Returning a long string (varchar from a function)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group