Search Postgresql Archives

Question Regarding DELETE FROM ONLY

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello List:

Please observe the following example that reproduces my problem:

CREATE TABLE ptable (code VARCHAR) WITHOUT OIDS;
CREATE TABLE

CREATE TABLE ctable (code VARCHAR, name VARCHAR)
	INHERITS (ptable) WITHOUT OIDS;
NOTICE:  merging column "code" with inherited definition
CREATE TABLE

INSERT INTO ctable (code, name) VALUES ('code_one', 'Code One');
rnd=# SELECT * FROM ptable;
   code
----------
 code_one
(1 row)

rnd=# SELECT * FROM ctable;
        code   |   name
---------------+----------
 code_one | Code One
(1 row)

DELETE FROM ONLY ctable WHERE code ~* 'code_one';

rnd=# SELECT * FROM ptable;
 code
------
(0 rows)

The record in ctable AND the record in ptable are both deleted even though I 
specified "ONLY ctable" in the delete phrase. Why is this happening? The two 
tables in this example represent a greatly simplified version of what I'm 
doing in developing an application and if "ONLY" doesn't work then I've got a 
big problem. Have I misunderstood inheritance altogether?

TIA...

rnd=# select version();
                                                   version
--------------------------------------------------------------------------------------------------------------
 PostgreSQL 7.4.6 on i686-redhat-linux-gnu, compiled by GCC gcc (GCC) 3.2.3 
20030502 (Red Hat Linux 3.2.3-49)
(1 row)
 


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux