は、私はテーブルには、次のように説明している:私はあなたがすべてのこれらの3つのフィールドを見ることができるように を(COUNTRY_ID、from_country_id、to_country_id)の外部キーを作成しようとしていますPostgresのDatebaseマルチ外部キー
Table "public.lead"
Column | Type | Modifiers
-----------------------------+--------------------------------+-----------------------------------------
id | character varying(36) | not null
reference_code | character varying(20) | not null
country_id | character varying(36) | not null
language_id | character varying(36) | not null
locale_id | character varying(36) | not null
from_country_id | character varying(36) | not null
to_country_id | character varying(36) | not null
customer_id | character varying(36) | not null
user_id | character varying(36) |
from_date | date | not null
from_date_type | smallint | not null default (0)::smallint
from_street | character varying(200) |
from_postalcode | character varying(25) |
from_city | character varying(100) |
from_country | character varying(50) |
from_apartment_type | character varying(255) | not null default '0'::character varying
from_floor | smallint |
from_rooms | numeric(3,1) |
from_people | integer |
from_squaremeter | integer |
from_elevator | smallint | not null
を関係を持っていますテーブル付き。 しかし、これらの外部キーを作成しようとすると、次のエラーが発生します。
ERROR: insert or update on table "lead" violates foreign key constraint "lead_to_country_id" Detail: Key (to_country_id)=(United Kingdom) is not present in table "country". Details
エラーは、 'insert'または' update'ステートメントによって発生します。あなたの質問とそのすべてのステートメントを[編集]してください。 –