X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0CDA9D1B53C for ; Mon, 2 Feb 2004 17:56:16 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 10893-08 for ; Mon, 2 Feb 2004 13:56:13 -0400 (AST) Received: from smtp014.mail.yahoo.com (smtp014.mail.yahoo.com [216.136.173.58]) by svr1.postgresql.org (Postfix) with SMTP id A3BDCD1B4BE for ; Mon, 2 Feb 2004 13:56:04 -0400 (AST) Received: from unknown (HELO europa.janwieck.net) (janwieck@68.80.245.191 with login) by smtp014.mail.yahoo.com with SMTP; 2 Feb 2004 17:56:03 -0000 Received: from Yahoo.com (ismtp.afilias.com [216.217.55.254]) (authenticated) by europa.janwieck.net (8.11.6/8.11.6) with ESMTP id i12Htsr31150; Mon, 2 Feb 2004 12:55:56 -0500 Message-ID: <401E80D2.9080909@Yahoo.com> Date: Mon, 02 Feb 2004 11:54:42 -0500 From: Jan Wieck User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Stephan Szabo Cc: Tom Lane , Enio Schutt Junior , pgsql-sql@postgresql.org Subject: Re: Sometimes referential integrity seems not to work References: <20040126175147.B3BD046E09@mail.passofundo.rs.gov.br> <20040131124500.H98710@megazone.bigpanda.com> <9148.1075592448@sss.pgh.pa.us> <20040131214655.W11452@megazone.bigpanda.com> In-Reply-To: <20040131214655.W11452@megazone.bigpanda.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/20 X-Sequence-Number: 16711 Stephan Szabo wrote: > On Sat, 31 Jan 2004, Tom Lane wrote: > >> Stephan Szabo writes: >> > On Mon, 26 Jan 2004, Enio Schutt Junior wrote: >> >> In a database I am working, I sometimes have to delete all the records in >> >> some tables. According to the referential integrity defined in the creation >> >> of the tables, postmaster should not delete the records, but it does. I have >> >> used the following commands: "delete from table_1" and "truncate table_1". >> >> ... >> >> can the postgres user delete records despite referential integrity? >> >> I think the first PG release or two that had TRUNCATE TABLE would allow >> you to apply it despite the existence of foreign-key constraints on the >> table. Recent releases won't though. > > Yeah, truncate didn't worry me much, but the implication that delete from > table_1; worked did. TRUNCATE cannot be used inside of a transaction, and since 7.3 it checks for foreign keys. So I guess Enio is getting but ignoring the error message when trying the delete, but then the truncate does the job in his pre-7.3 database. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com #