Re: [GENERAL] Deleting conflicting rows when creating a foreign key

2009-02-11 Thread Igor Katson
Craig Ringer wrote: Richard Huxton wrote: DELETE FROM table1 WHERE col1 NOT IN (SELECT id from table2); Just as a side note: If you have a large number of missing IDs and don't want to wait a long time, you may be better off with something like (untested, but I think it's right - TEST

Re: [GENERAL] Deleting conflicting rows when creating a foreign key

2009-02-10 Thread Craig Ringer
Richard Huxton wrote: > DELETE FROM table1 WHERE col1 NOT IN (SELECT id from table2); Just as a side note: If you have a large number of missing IDs and don't want to wait a long time, you may be better off with something like (untested, but I think it's right - TEST FIRST): SELECT * FROM table1

Re: [GENERAL] Deleting conflicting rows when creating a foreign key

2009-02-10 Thread Richard Huxton
Igor Katson wrote: > I am doing an ALTER TABLE to create a foreign key, however with some > rows i get: > > insert or update on table "name" violates foreign key constraint > "name_fkey" > > How can I just drop the conflicting rows while doing that? You can't automatically. You can do something

[GENERAL] Deleting conflicting rows when creating a foreign key

2009-02-10 Thread Igor Katson
I am doing an ALTER TABLE to create a foreign key, however with some rows i get: insert or update on table "name" violates foreign key constraint "name_fkey" How can I just drop the conflicting rows while doing that? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make