| От | Michael Fuhr |
|---|---|
| Тема | Re: How to temporarily disable referntial integrity? |
| Дата | |
| Msg-id | 20041211182146.GA39964@winnie.fuhr.org обсуждение исходный текст |
| Ответ на | How to temporarily disable referntial integrity? ("Ari Johannesson" <arividar@simnet.is>) |
| Список | pgsql-admin |
On Tue, Dec 07, 2004 at 06:17:48PM -0000, Ari Johannesson wrote: > I have data to import into a postgres database. The data is referentially > sound but during the insert it breaks som foreign-key constraints. Is there > a way to turn off the referential integrity during the insert? You could make the foreign key constraints deferrable and use SET CONSTRAINTS to defer all or some of them. CREATE TABLE foo (id INTEGER PRIMARY KEY); CREATE TABLE bar (id INTEGER REFERENCES foo DEFERRABLE); BEGIN; SET CONSTRAINTS bar_id_fkey DEFERRED; INSERT INTO bar VALUES (1); INSERT INTO foo VALUES (1); COMMIT; -- Michael Fuhr http://www.fuhr.org/~mfuhr/
В списке pgsql-admin по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера