Re: Proposal: TRUNCATE TABLE table RESTRICT

From: Mike Mascari <mascarm(at)mascari(dot)com>
To: Don Baccus <dhogaza(at)pacifier(dot)com>
Cc: Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Proposal: TRUNCATE TABLE table RESTRICT
Date: 2000-06-08 14:43:00
Message-ID: 393FB0F4.40B976D5@mascari.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Don Baccus wrote:
>
> At 09:24 PM 6/8/00 +0900, Tatsuo Ishii wrote:
> >It seems the truncate command deletes all rows from a table even it is
> >referenced by another tables. TRUNCATE is not in the standard any way,
> >so I would not claim this is a bug. However, sometimes it would be
> >helpful for a user to let him notice that the table about to be
> >truncated is referenced by some tables. So I would propose to add
> >"RESTRICT" option to the command. I mean if RESTRICT is specified,
> >TRUNCATE will fail if the table is referenced.
>
> Shouldn't it always fail if an explicit foreign key reference
> exists to the table, in much the way that delete of a referenced
> row does? If it doesn't now, I think it's a bug.
>
> If the references are implicit (no REFERENCE or FOREIGN KEY given
> to inform the db of the relationship) then a RESTRICT option to
> truncate does seem useful.
>

Just curious, Don. But could you check to see what Oracle's
behavior is on this? That's the feature I was trying to mirror.
At the time, RI wasn't integrated so I wasn't thinking about this
issue. And the Oracle docs state that DML triggers aren't fired
when a TRUNCATE is issued, so I didn't think there would be
issues there. Could you check?

Thanks,

Mike Mascari

> - Don Baccus, Portland OR <dhogaza(at)pacifier(dot)com>
> Nature photos, on-line guides, Pacific Northwest
> Rare Bird Alert Service and other goodies at
> http://donb.photo.net.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Travis Bauer 2000-06-08 14:47:05 RE: java settings in emacs for postgres
Previous Message Tom Lane 2000-06-08 14:41:00 Re: Proposal: TRUNCATE TABLE table RESTRICT