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: copy one table to an other

Re: copy one table to an other

From: Preston Kemp <dontwantany_at_nowhere.invalid>
Date: Tue, 10 May 2005 13:37:22 GMT
Message-ID: <mO2ge.506$hn5.463@newsfe2-win.ntli.net>


Preston Kemp wrote:

> Vince wrote:
>
> > hi there!
> > I have to copy data from one table to another..like this:
> >
> > insert into mytable2 select * from mytable1;
> >
> > but number of columns of mytable2 is greater than those of mytable1,
> > so I get the : ORA-00947: not enough values
> >
> > is there any way to proceed without having to enumerate all the
> > columns ?
> > the column in plus is a ID column with an autoincrement (trigger)
> > which is not in mytable1.
>
> One way would be to create a view as select * from mytable1, then do
>
> insert into mytable2 select v.*,null from myview v

Bad form etc but that does of course assume the extra column in mytable2 is at the end. If it's at the start, switch the "v.*" & "null" in the select. If it's in the middle, you'll need to list the columns in the select when you create the view, including the 'null as "colname"' in the appropriate position.

-- 
Preston.
Received on Tue May 10 2005 - 08:37:22 CDT

Original text of this message

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