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: match columns on insert sub select

Re: match columns on insert sub select

From: Dan. <dan_at_nospam.edu>
Date: Tue, 5 Aug 2003 09:35:36 -0700
Message-ID: <bgomcu$5b3$1@news.Stanford.EDU>


Looks like the only way is to write a script reading all_tab_columns for both tables and execute dynamic sql with the matching results from that. Not sure if it's worth it. Thanks for the responses. -Dan

"Umberto Quaia" <umberto..quaia_at_tin.it> wrote in message news:bgirvd$p2gdv$1_at_ID-163428.news.uni-berlin.de... Unfortunately, there is not yet such an instruction.

I agree with you that it would be very useful.

I don't understand Erik's objection about adding a column in source table.
If that column is not in dest table, it's simply not copied.

The objection should be instead on dropping a column in source table. But in this case simply NULL may be inserted.

So, for me it would be just very useful. I don't see any counter-indication in such an instruction.

Umberto

"Dan." <dan_at_nospam.edu> wrote in message news:bgbj69$eok$1_at_news.Stanford.EDU...
> Anyone know of an easy way to copy data from table to table that
will match
> up exact same named columns from the source to the target?
>
>
> TABLE1 (source)
>
> FIELDA
> FIELDB
> FIELDC
> FIELDD
>
>
>
> TABLE2 (target)
>
> FIELDB
> FIELDA
> FIELDD
> FIELDC
> FIELDE
> FIELDF
> FIELDG
>
>
> A script would work but ideally it would be a keyword so you could
do
> something like this?
>
> INSERT INTO TABLE2
> (SELECT MATCHING * FROM TABLE1)
> -----------------
>
> instead of having to write out
>
> INSERT INTO TABLE2
> (SELECT
> FIELDB
> FIELDA
> FIELDD
> FIELDC
> '',
> '',
> ''
> FROM TABLE1)
>
>
> Thanks for any responses, -Dan
>
>
Received on Tue Aug 05 2003 - 11:35:36 CDT

Original text of this message

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