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

Home -> Community -> Usenet -> c.d.o.server -> Re: How to duplicate many rows from SQL

Re: How to duplicate many rows from SQL

From: Manu <emmanuel.pl.bontemps_at_wanadoo.fr>
Date: Tue, 15 Jun 1999 14:59:46 +0200
Message-ID: <7k5iof$21u$1@oceanite.cybercable.fr>


Try this :

insert into emp (emp_type, col2, col3, col4 etc.) (

    select '321', col2, col3, col4 etc
    from emp
    where salary > 9000);

Stephen Jackson,SL/BI a écrit dans le message <37664956.8BCD0443_at_cern.ch>...
>
> Hi,
>
> Here's my problem. I want to duplicate create a new set of records,
>based
> on an existing set of records, but changing one field so as not to
>violate a
> constraint.
>
> So far, the only solution I have (which works) is the following:
>
>create table temp_table as select * from emp where salary >9000;
>update temp_table set emp_type = 321;
>insert into emp select * from temp_table;
>drop table temp_table;
>
> This copies the data I want to duplicate into a temp table, changes
>it
> appropriately, then copies it back to the original table.
>
> Is there a better way of doing this from SQL?
>
> Cheers,
>
> Stephen Jackson
>
>If you reply via eMail, please send to Stephen.Jackson_at_cern.ch
>
>
>
Received on Tue Jun 15 1999 - 07:59:46 CDT

Original text of this message

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