How duplicate values inserted into the primary key column of table and how to fix it
Hi All,
We are using Postgresql 9.2 database.
In one of the transactional table, I have observed duplicate values for the
primary key columns.
Please guide me how is it possible and how to fix this kind of issue.
--
Regards,
Raghavendra Rao J S V
Hi
you could provide the definition of the table that includes the definition
of the primary key?
El jue., 24 de ene. de 2019 a la(s) 09:18, Raghavendra Rao J S V (
raghavendrajsv@gmail.com) escribió:
Hi All,
We are using Postgresql 9.2 database.
In one of the transactional table, I have observed duplicate values for
the primary key columns.Please guide me how is it possible and how to fix this kind of issue.
--
Regards,
Raghavendra Rao J S V
--
Cordialmente,
Ing. Hellmuth I. Vargas S.
On 1/24/19 4:46 AM, Raghavendra Rao J S V wrote:
Hi All,
We are using Postgresql 9.2 database.
In one of the transactional table, I have observed duplicate values for
the primary key columns.
Best guess a corrupted index. As Hellmuth said more information would be
helpful.
Please guide me how is it possible and how to fix this kind of issue.
--
Regards,
Raghavendra Rao J S V
--
Adrian Klaver
adrian.klaver@aklaver.com
Sounds like you need a unique constraint on the PK field. The duplicate
values may be inserted if the sequence on the PK is out of sync (if
there is a sequence providing values for the PK).
*/Patrick Headley/*
Linx Consulting, Inc.
(303) 916-5522
pheadley@linxco-inc.com
www.linxco-inc.com
Show quoted text
On 1/24/19 8:30 AM, Adrian Klaver wrote:
On 1/24/19 4:46 AM, Raghavendra Rao J S V wrote:
Hi All,
We are using Postgresql 9.2 database.
In one of the transactional table, I have observed duplicate values
for the primary key columns.Best guess a corrupted index. As Hellmuth said more information would
be helpful.Please guide me how is it possible and how to fix this kind of issue.
--
Regards,
Raghavendra Rao J S V
On 25/01/2019 09:28, Patrick Headley wrote:
Sounds like you need a unique constraint on the PK field. The
duplicate values may be inserted if the sequence on the PK is out of
sync (if there is a sequence providing values for the PK).*/Patrick Headley/*
Linx Consulting, Inc.
(303) 916-5522
pheadley@linxco-inc.com
www.linxco-inc.com
On 1/24/19 8:30 AM, Adrian Klaver wrote:On 1/24/19 4:46 AM, Raghavendra Rao J S V wrote:
Hi All,
We are using Postgresql 9.2 database.
In one of the transactional table, I have observed duplicate values
for the primary key columns.Best guess a corrupted index. As Hellmuth said more information would
be helpful.Please guide me how is it possible and how to fix this kind of issue.
--
Regards,
Raghavendra Rao J S V
A PRIMARY KEY, is by definition, UNIQUE! Has been this way, as far back
as I can remember!
From https://www.postgresql.org/docs/11/sql-createtable.html
[...]
The PRIMARY KEY constraint specifies that a column or columns of a table
can contain only unique (non-duplicate), nonnull values
[...]
http://www.postgresqltutorial.com/postgresql-primary-key/
[...]
Technically, a primary key constraint is the combination of a not-null
constraint
<http://www.postgresqltutorial.com/postgresql-not-null-constraint/> and
a UNIQUE constraint
<http://www.postgresqltutorial.com/postgresql-unique-constraint/>.
[...]
Cheers,
Gavin