Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> how to copy row from one table to another...

how to copy row from one table to another...

From: Sharkie <sharkie2_at_my-deja.com>
Date: Sun, 19 Mar 2000 06:04:15 GMT
Message-ID: <8b1qko$vma$1@nnrp1.deja.com>


without explicitly naming each column?

I have a table with many columns (over 100), and supposedly I want to copy a few rows to a different table with the same structure. Due to large amount of columns I'd like to do this without typing each column.

I know I can create a new table with something like:
<sql snippet>

create table2 as select * from table1 where rownum<11
</sql snippet>

But in my case my table2 already exists, I'd like to do something like:
<sql snippet>

declare
cursor table_cur is
  select *
    from table1
   where rownum<11; --10 rows wanted, or other where clause... begin
  for table_rec in table_cur
  loop
    insert into table2 values(table_rec.*); /* the above will not work, and of cource I can use

   table_rec.column1, table_rec.columns2, etc    but is there a way to insert all the columns at once? */
  end loop;
end;
</sql snippet>

Or is there a different way of copying records programatically (I guess there are tools to do that, but I'd like to do that using SQL)?

Thanks for any help.

--
If the human brain were so simple
that we could understand it,
we would be so simple we couldn't.
-Makes Sense... don't it?

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Sun Mar 19 2000 - 00:04:15 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US