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

Re: TRUNCATE question

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Mike Mascari <mascarm(at)mascari(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TRUNCATE question
Date: 2001-09-06 20:11:40
Message-ID: 200109062011.f86KBeG19396@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Added to TODO.  Thanks.


> Bruce Momjian wrote:
> > 
> > Is there a TODO item here?
> 
> Yes. It should read:
> 
> "Disallow TRUNCATE TABLE on tables that are parents of a referential
> integrity constraint"
> 
> In PostgreSQL current sources I can do:
> 
> CREATE TABLE employees (
>  employeeid INTEGER PRIMARY KEY NOT NULL
> );
> 
> CREATE TABLE salaries ( 
>  employeeid INTEGER NOT NULL REFERENCES employees(employeeid),
>  salary FLOAT NOT NULL
> );
> 
> INSERT INTO employees VALUES (1);
> 
> INSERT INTO salaries VALUES (1, 45000);
> 
> TRUNCATE TABLE employees;
> 
> SELECT * FROM salaries;
> 
>  employeeid | salary 
> ------------+--------
>           1 |  45000
> (1 row)
> 
> In Oracle, the following occurs:
> 
> CREATE TABLE employees (
>  employeeid INTEGER NOT NULL PRIMARY KEY
> );
> 
> CREATE TABLE salaries (
>  employeeid INTEGER NOT NULL REFERENCES employees(employeeid),
>  salary FLOAT NOT NULL
> );
> 
> INSERT INTO employees VALUES (1);
> 
> INSERT INTO salaries VALUES (1, 40000);
> 
> TRUNCATE TABLE employees;
> 
> TRUNCATE TABLE employees;
>                *
> ERROR at line 1:
> ORA-02266: unique/primary keys in table referenced by enabled
> foreign keys
> 
> Mike Mascari
> mascarm(at)mascari(dot)com
> 

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

In response to

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2001-09-06 20:36:52
Subject: Re: Question about todo item
Previous:From: Mike MascariDate: 2001-09-06 20:01:16
Subject: Re: TRUNCATE question

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