Re: Duplicate Key Values

From: mark bradley <markbradyju(at)outlook(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, Ron Johnson <ronljohnsonjr(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Duplicate Key Values
Date: 2025-03-13 16:25:32
Message-ID: SJ2PR22MB4328FA1F103D7BC658A6987CBAD32@SJ2PR22MB4328.namprd22.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> I'm assuming that by 'simple version' you mean no inheritance.

Inheritance was not specified by me in either case. By simple, I mean that I used fewer columns in the test version, like so:

[cid:c8b9cd7d-1fe4-496a-be63-cbb8f658a785]

[cid:b4c79bd5-7eac-4dbf-bf79-750adc941b74]

Where node_id is a foreign key in dataset, and node_type is not.

Best regards,
Mark Brady
amazon.com/author/markjbrady<https://amazon.com/author/markjbrady>
________________________________
From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Sent: Thursday, March 13, 2025 12:05 PM
To: mark bradley <markbradyju(at)outlook(dot)com>; Ron Johnson <ronljohnsonjr(at)gmail(dot)com>; pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Duplicate Key Values

On 3/13/25 08:56, mark bradley wrote:
> >Postgresql does not assume / default to inheritance. In text-mode
> clients where you type >in "raw" SQL, you have to explicitly add an
> explicit "INHERITS <parent_table>" clause to the >"CREATE TABLE foo"
> statement.
>
> >Are you creating the tables via PgAdmin point-and-click?
>
> I am using PgAdmin 4 v9.1.
>
> I think the problem may also be related to the fact that I had
> *node_id* and *node_type *were in both tables from an earlier design and
> Postgres would not let me delete* node_type* from the* dataset* table.

Because it was inherited:

create table node (node_id integer primary key, fld1 varchar);

create table node_1 (node_id integer primary key, node_1_fld boolean)
inherits ( node);

alter table node_1 drop column fld1;
ERROR: cannot drop inherited column "fld1"

>
> As an experiment, I created a simple version of the same tables from
> scratch without *node_type* in the *dataset* table. So far, no dups are
> appearing.

I'm assuming that by 'simple version' you mean no inheritance.

>
> Best regards,
> Mark Brady
> _amazon.com/author/markjbrady <https://amazon.com/author/markjbrady>_
> ------------------------------------------------------------------------

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message mark bradley 2025-03-13 16:35:03 Re: Duplicate Key Values
Previous Message Adrian Klaver 2025-03-13 16:05:37 Re: Duplicate Key Values