Re: referential integrity violation
От | missive@frontiernet.net (Lee Harr) |
---|---|
Тема | Re: referential integrity violation |
Дата | |
Msg-id | 9k4ms7$3r3u$1@node21.cwnet.roc.gblx.net обсуждение исходный текст |
Ответ на | referential integrity violation (tony <tony@animaproductions.com>) |
Список | pgsql-general |
On Mon, 30 Jul 2001 15:19:27 +0000 (UTC), tony <tony@animaproductions.com>: > Hello, > > While copying from a text file of tab delimited data I am getting > " ERROR: <unnamed> referential integrity violation - key referenced > from films not found in sales" > > The salesid field > salesid INTEGER PRIMARY KEY DEFAULT NEXTVAL('sales_serial') > > exists It sounds like the table is using a foreign key. This is a way of linking two tables so that data that one table needs will always be available in another table. For instance, you might have a table library with columns library_id and library_name Then in another table book, you could tell which library owns the book by having a column library_id which references table library. By making the reference a foreign key constraint, you would never end up with a library_id in the book table which did not have an entry in the library table. This would look like: CREATE TABLE library (library_id integer PRIMARY KEY, library_name text); CREATE TABLE book (book_name text, library_id integer REFERENCES library); The answer to your question is one of two things: 1) make sure you are copying the data in the right order. ie, copy in the table that holds the primary key that the other tables are referencing first. OR 2) drop the foreign key constraint until all of your data is loaded.
В списке pgsql-general по дате отправления: