[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3187
  • Last Modified:

Oracle Insert from One Table to Another Table, Same Schema

I want to copy rows from one TableA, with over a million records,  to anther TableB with identical column names, both in the same Schema.  TableB is completely emply, but has several more columns, so in effect, TableA is a subset of TableB.  How do I copy rows from Table A to the empty, Table B?  Thanks.
0
Joalkat
Asked:
Joalkat
  • 2
  • 2
1 Solution
 
ajexpertCommented:
There you go
INSERT INTO TABLEB (col1,col2,col3) SELECT * FROM TABLEA

Open in new window

0
 
JoalkatAuthor Commented:
Great!  Answered my question.
0
 
ajexpertCommented:
Points Please :)
0
 
Mark GeerlingsDatabase AdministratorCommented:
If performance is an issue, you may want to do a couple more things.

First: "alter tableb nologging"
Second: repeat that command for each index on tableb, for example: "alter index tableb_ix1 nologging"
Third: do the insert like this:
insert /*+APPEND */ into tableb (col1,col2,col3) SELECT * FROM TABLEA;

This may allow the insert to be *MUCH* faster.  You should do a backup though of the tablespace for tableb and for any indexes on tableb after the load, since the load will not be recoverable otherwise.
0
 
JoalkatAuthor Commented:
I'll shoot you the 50 points once I understand how to release.  Thanks for your patience.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now