Unix Technical Forum

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

This is a discussion on adding a new data to existing psql table from comma del file within the pgsql Novice forums, part of the PostgreSQL category; --> Hi, can somebody help me, I am trying to update a psql table in my data base. I created ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Novice

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 08:18 PM
sloftus
 
Posts: n/a
Default adding a new data to existing psql table from comma del file

Hi,

can somebody help me, I am trying to update a psql table in my data base.
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?

any suggestions appreciated.

sgloftus@lbgeographic




---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 08:18 PM
Michael Fuhr
 
Posts: n/a
Default Re: adding a new data to existing psql table from comma del file

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/

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:31 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com