Re: Request to share information regarding errors - Mailing list pgsql-general

From Yogesh Sharma
Subject Re: Request to share information regarding errors
Date
Msg-id 8F86F8F397DDD345B25EA2EF3E2164829ECBA278@EXCH-MB02-U1.nectechnologies.in
Whole thread Raw
In response to Re: Request to share information regarding errors  ("Charles Clavadetscher" <clavadetscher@swisspug.org>)
Responses Re: Request to share information regarding errors  ("Charles Clavadetscher" <clavadetscher@swisspug.org>)
List pgsql-general
Dear Charles,

Thanks for sharing such information.
First thing, I want to confirm.
>You are trying to insert a row in a table that has a not-null constraint on a field.
>Find the record that causes the error and include a valid value for the column that has the not null constraint.
Entry is already deleted from table and value is defined not null in create table query.
But this type of error is not displaying every time.

>A foreign key must match the primary key of the table it refers to. So you should create the primary key contraint on
table2using id and phone_id. 
At this time, DB is shutdown.
This shutdown is related to this error or not?


Regards,
Yogesh

-----Original Message-----
From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Charles Clavadetscher
Sent: Wednesday, November 16, 2016 3:44 PM
To: Yogesh Sharma; pgsql-general@postgresql.org
Subject: Re: [GENERAL] Request to share information regarding errors

Good morning

> -----Original Message-----
> From: pgsql-general-owner@postgresql.org
> [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Yogesh Sharma
> Sent: Mittwoch, 16. November 2016 07:09
> To: pgsql-general@postgresql.org
> Subject: Re: [GENERAL] Request to share information regarding errors
>
> Dear All,
>
> Thanks for your support.
>
> I am using postgresql 9.3.6 rpm in RHEL6 version.
>
> In postgresql logs, I have found below error messages.
> ERROR:  null value in column "column name" violates not-null constraint.

You are trying to insert a row in a table that has a not-null constraint on a field.
Find the record that causes the error and include a valid value for the column that has the not null constraint.

> Second error found:
> ERROR:  there is no unique constraint matching given keys for referenced table "table2"
> alter table1 table_name add constraint fk_key foreign key (id,
> phone_id) references table2 (id, phone_id) on delete restrict on
> update restrict;

A foreign key must match the primary key of the table it refers to. So you should create the primary key contraint on
table2using id and phone_id. 

CREATE UNIQUE INDEX table2_pkey ON table2 (id, phone_id); ALTER TABLE table2 ADD PRIMARY KEY USING INDEX table2_pkey;

After that you should be able to add the foreign key to table1.

Hope this helps.
Charles

> Could you please share the details of these errors and how to resolve these errors from logs.
>
>
> Regards,
> Yogesh
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general



--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


pgsql-general by date:

Previous
From: "Charles Clavadetscher"
Date:
Subject: Re: Request to share information regarding errors
Next
From: Chris Withers
Date:
Subject: Re: dumping table contents in a sensible order