From jtr@uni-bonn.de Wed Sep 27 19:34:23 2000 Received: from f1node03.rhrz.uni-bonn.de (node03.rhrz.uni-bonn.de [131.220.18.133]) by hub.org (8.10.1/8.10.1) with ESMTP id e8RJYNr65207 for ; Wed, 27 Sep 2000 15:34:23 -0400 (EDT) Received: from localhost (ascend-tk-p228.dialin.uni-bonn.de [131.220.244.228]) by f1node03.rhrz.uni-bonn.de (8.9.3/8.9.3) with ESMTP id VAA278936 for ; Wed, 27 Sep 2000 21:31:35 +0200 Received: from joachim by localhost with local (Exim 3.16 #1 (Debian)) id 13eLss-0000TL-00 for ; Wed, 27 Sep 2000 20:24:46 +0200 To: pgsql-sql@postgresql.org Subject: copying/moving from one table to another From: Joachim Trinkwitz Date: 27 Sep 2000 20:24:46 +0200 Message-ID: <87og191ymp.fsf@mailout.uni-bonn.de> Lines: 16 User-Agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200009/223 Hi all, is there a handy way to copy or (preferrably) move a whole record from one table to another, equally structured table in the same DB? Background: I have some tables which hold information concerning our staff, where people quite so often come and go, because their employment contract is limited to a year or two. When deleting a person in the DB, I don't want to lose this information completely, but I want to save it in a backup table. I suppose this is a newbie question, maybe I am stirring me blind somewhere ... Greetings and thanks, jaochim From jliang@ipinc.com Wed Sep 27 19:59:40 2000 Received: from tidal.ipinc.com (tidal.ipinc.com [199.245.188.85]) by hub.org (8.10.1/8.10.1) with ESMTP id e8RJxer72278 for ; Wed, 27 Sep 2000 15:59:40 -0400 (EDT) Received: from ipinc.com (jliang.ipinc.com [199.245.188.130]) by tidal.ipinc.com (8.9.3/8.9.3) with ESMTP id MAA77575; Wed, 27 Sep 2000 12:59:31 -0700 (PDT) (envelope-from jliang@ipinc.com) Message-ID: <39D250BC.ECAC0A10@ipinc.com> Date: Wed, 27 Sep 2000 12:55:40 -0700 From: Jie Liang Organization: ipinc.com X-Mailer: Mozilla 4.7 [en] (X11; U; FreeBSD 3.4-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: Joachim Trinkwitz CC: pgsql-sql@postgresql.org Subject: Re: copying/moving from one table to another References: <87og191ymp.fsf@mailout.uni-bonn.de> Content-Type: multipart/alternative; boundary="------------556AD6F8A5142B1AA2F778B0" X-Archive-Number: 200009/224 --------------556AD6F8A5142B1AA2F778B0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, there, I do not quite sure is this what you want? 1. if newtable(one you want save) does not exist: select * into newtable from oldtable; or create table newtable as select * from oldtable; 2. if newtable existed, you append some record into it: insert into newtable select * from oldtable where clause; Joachim Trinkwitz wrote: > Hi all, > > is there a handy way to copy or (preferrably) move a whole record > from one table to another, equally structured table in the same DB? > > Background: I have some tables which hold information concerning our > staff, where people quite so often come and go, because their > employment contract is limited to a year or two. When deleting a > person in the DB, I don't want to lose this information completely, > but I want to save it in a backup table. > > I suppose this is a newbie question, maybe I am stirring me blind > somewhere ... > > Greetings and thanks, > jaochim -- Jie LIANG Internet Products Inc. 10350 Science Center Drive Suite 100, San Diego, CA 92121 Office:(858)320-4873 jliang@ipinc.com www.ipinc.com --------------556AD6F8A5142B1AA2F778B0 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, there,

I do not quite sure is this what you want?

1. if newtable(one you want save) does not exist:
select * into newtable from oldtable;
or
create table newtable as select * from oldtable;

2. if newtable existed, you append some record into it:
insert into newtable select * from oldtable where clause;
 

Joachim Trinkwitz wrote:

Hi all,

is there a handy way to copy or (preferrably) move a whole record
from one table to another, equally structured table in the same DB?

Background: I have some tables which hold information concerning our
staff, where people quite so often come and go, because their
employment contract is limited to a year or two. When deleting a
person in the DB, I don't want to lose this information completely,
but I want to save it in a backup table.

I suppose this is a newbie question, maybe I am stirring me blind
somewhere ...

Greetings and thanks,
jaochim

-- 
Jie LIANG

Internet Products Inc.

10350 Science Center Drive
Suite 100, San Diego, CA 92121
Office:(858)320-4873

jliang@ipinc.com
www.ipinc.com
  --------------556AD6F8A5142B1AA2F778B0--