我有一個PostgeresDB具有以下約束:的Postgres忽略插入錯誤並進行ONY
CONSTRAINT "Car_Data_3PM_pkey" PRIMARY KEY ("F_ID", "Date"),
CONSTRAINT "Car_Data_3PM_F_ID_fkey" FOREIGN KEY ("F_ID")
REFERENCES "Bike_Data" ("F_ID") MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
當我嘗試使用插入多個值:
INSERT INTO "Car_Data_3PM" ("F_ID","Date","Price_Type","O","H","L","LT","EQ","V","NAD") VALUES (38,'2016-10-02 08:19:40.056679','x',0,0,0,112.145,0,0,112.145),(14,'2016-10-02 08:19:40.056679','x',0,0,0,5476,0,0,5476),(13,'2016-10-02
我得到這個錯誤:
ERROR: insert or update on table "Car_Data_3PM" violates foreign key constraint "Car_Data_3PM_F_ID_fkey" SQL state: 23503 Detail: Key (F_ID)=(38) is not present in table "Bike_Data".
未插入行。
如何讓Postgres只丟失約束條件成問題的行?即插入大部分?
無關,但:您應該***避免引用標識符。他們是更加麻煩,然後他們是值得的。 –