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

From Charles Clavadetscher
Subject Re: Request to share information regarding errors
Date
Msg-id 00c601d23fd4$e6340070$b29c0150$@swisspug.org
Whole thread Raw
In response to Re: Request to share information regarding errors  (Yogesh Sharma <Yogesh1.Sharma@nectechnologies.in>)
Responses Re: Request to share information regarding errors  (Yogesh Sharma <Yogesh1.Sharma@nectechnologies.in>)
List pgsql-general
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



pgsql-general by date:

Previous
From: Yogesh Sharma
Date:
Subject: Re: Request to share information regarding errors
Next
From: Yogesh Sharma
Date:
Subject: Re: Request to share information regarding errors