need help with import
От | Andreas |
---|---|
Тема | need help with import |
Дата | |
Msg-id | 4F3C55C2.8070005@gmx.net обсуждение исходный текст |
Ответы |
Re: need help with import
Re: need help with import |
Список | pgsql-sql |
Hi I get CSV files to import. Th structure is like this. main part, sub part Could be like this A, a1 A, a2 A, a3 B, b1 B, b2 The database has a table for main_part and one for sub_part. The relation needs to be n:m so there is a relation table that holds ( main_id, sub_id ). The 2 primary keys main_part.id and sub_part.id are both serials. Is there a way to do an import with SQL? I can read the CSV into a temporary table and I can do a INSERT INTO main_part ( ... ) SELECT DISTINCT main columns FROM import; as well as a INSERT INTO sub_part ( ... ) SELECT sub columns FROM import; But how would I know what main_id and sub_id to insert into the n:m relation? At first when I do the import the relation is actually 1:n.
В списке pgsql-sql по дате отправления: