Re: adding a new data to existing psql table from comma del file

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: adding a new data to existing psql table from comma del file
Дата
Msg-id 20041231053808.GA95884@winnie.fuhr.org
обсуждение исходный текст
Ответ на adding a new data to existing psql table from comma del file  ("sloftus" <sgloftus@lbgeographic.com>)
Список pgsql-novice
On Thu, Dec 30, 2004 at 08:49:29AM -0500, sloftus wrote:

> I created the table from a
> comma deliminated file that has four col.
>
> state, city, school, autoID.
>
> the current table. RESCHOOL, has about 300 rows, and is ordered using a
> autogenerated sequence which links this table to other tables in the DB.
>
> I need to add some additional schools (about 100),from another cvs file into
> the RESCHOOL.
>
> do I use the copy comand that I used to originally used to create this file?
> Wont that overwrite my existing table, and mess up my ID's from the
> autogenerated number?

If you're not sure how something works, study the documentation and
practice on test data before trying it on "real" data.  Also, when
modifying data, you could use a transaction so you can verify changes
before committing them.  That is, issue a BEGIN statement, make the
changes, issue SELECT statements to verify that the changes are
correct, then issue COMMIT if everything looks good or ROLLBACK to
abandon the changes.

COPY inserts new records without deleting existing records.  As for
automatically-generated values (presumably a key field defined as
a SERIAL type), when you're done inserting new records you could
use ALTER SEQUENCE or setval() to adjust the sequence's value if
necessary.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

В списке pgsql-novice по дате отправления:

Предыдущее
От: Michael Fuhr
Дата:
Сообщение: Re: ERROR: relation "managers" does not exist
Следующее
От: Jason Dixon
Дата:
Сообщение: Grant on multiple objects