Automatic PK values not added to new rows

From: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Automatic PK values not added to new rows
Date: 2022-05-25 17:43:14
Message-ID: e4a17cde-9941-5eb5-e88d-246577e4488c@appl-ecosys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

The People table has 965 rows; the table structure is:
Table "public.people"
Column | Type | Collation | Nullable | Default

---------------+-----------------------+-----------+----------+-------------------------------------
person_nbr | integer | | not null | nextval('people_person_nbr_seq'::reg
class)
lname | character varying(32) | | not null | '??'::character varying
fname | character varying(15) | | not null | '??'::character varying
job_title | character varying(48) | | |
company_nbr | integer | | |
loc_nbr | integer | | not null | 1
loc_phone_ext | character varying(32) | | |
direct_phone | character varying(15) | | |
direct_fax | character varying(15) | | |
cell_phone | character varying(15) | | |
email | character varying(64) | | |
active | boolean | | not null | true
comment | text | | |
Indexes:
"people_pkey" PRIMARY KEY, btree (person_nbr)
Foreign-key constraints:
"people_org_nbr_fkey" FOREIGN KEY (company_nbr) REFERENCES companies(company_nbr) ON UPDATE CASC
ADE ON DELETE RESTRICT

I'm trying to insert 15 new rows to that table by inserting all columns
except the first one.. Psql tells me:
psql:insert_into_people.sql:16: ERROR: duplicate key value violates unique constraint "people_pkey"
DETAIL: Key (person_nbr)=(683) already exists.

person_nbr 683 is not in any row to be inserted.

I was under the impression that the person_nbr for the new rows would start
with 966 but that's apparently not happening.

What have I missed?

Rich

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2022-05-25 17:45:53 Re: Automatic PK values not added to new rows
Previous Message David G. Johnston 2022-05-25 17:33:08 Re: "Join Postgres on Slack" ?