Unix Technical Forum

SQL COPY Command

This is a discussion on SQL COPY Command within the pgsql Novice forums, part of the PostgreSQL category; --> Will this command APPEND TO or REPLACE data in an existing table ? The documentation doesn't seem to indicate. ...


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:45 PM
Van Ingen, Lane
 
Posts: n/a
Default SQL COPY Command

Will this command APPEND TO or REPLACE data in an existing table ?

The documentation doesn't seem to indicate.

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 08:45 PM
Tom Lane
 
Posts: n/a
Default Re: SQL COPY Command

"Van Ingen, Lane" <lvaningen@ESNCC.com> writes:
> Will this command APPEND TO or REPLACE data in an existing table ?
> The documentation doesn't seem to indicate.


The first paragraph on the COPY reference page is

COPY moves data between PostgreSQL tables and standard file-system
files. COPY TO copies the contents of a table to a file, while COPY FROM
copies data from a file to a table (appending the data to whatever is in
the table already).


regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 08:45 PM
Keith Worthington
 
Posts: n/a
Default Re: SQL COPY Command

On Wed, 27 Apr 2005 10:56:09 -0400, Tom Lane wrote
> "Van Ingen, Lane" <lvaningen@ESNCC.com> writes:
> > Will this command APPEND TO or REPLACE data in an existing table ?
> > The documentation doesn't seem to indicate.

>
> The first paragraph on the COPY reference page is
>
> COPY moves data between PostgreSQL tables and standard file-system
> files. COPY TO copies the contents of a table to a file, while COPY FROM
> copies data from a file to a table (appending the data to whatever
> is in the table already).
>
> regards, tom lane


Sheesh, how did I miss that?

Oh well, Documentation talks the talk but testing walks the walk. ;-)

Kind Regards,
Keith

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-17-2008, 08:45 PM
Keith Worthington
 
Posts: n/a
Default Re: SQL COPY Command

On Wed, 27 Apr 2005 10:43:58 -0400, Van Ingen, Lane wrote
> Will this command APPEND TO or REPLACE data in an existing table ?
>
> The documentation doesn't seem to indicate.
>


You appear to be correct. I was not able to find the answer in the
documentation either.

Testing indicates that the data will be appended. If a primary key is defined
on the table and any of the contents of the COPY violate that key then the
entire contents of the COPY are rejected. During large copies this can result
in a lot of wasted space.

Kind Regards,
Keith

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

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 09:10 AM.


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