Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Oracle -- copy table from one db to another db ?

Posted on 2011-02-21
4
Medium Priority
?
1,458 Views
Last Modified: 2013-12-19
I have two databases (test & dev) on the same machine (server1) and tried running the below in Oracle SQL Developer, but get errors.

How can i easily copy the test database accounting_structure_tab table into dev ?

truncate DEV.ACCOUNTING_STRUCTURE_TAB
INSERT INTO DEV.ACCOUNTING_STRUCTURE_TAB
SELECT *
from TEST.ACCOUNTING_STRUCTURE_TAB
0
Comment
Question by:finance_teacher
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 74

Expert Comment

by:sdstuber
ID: 34944508
create a database link in DEV pointing to TEST


then....  (you need "truncate table"  not "truncate")

truncate table ACCOUNTING_STRUCTURE_TAB;



INSERT INTO ACCOUNTING_STRUCTURE_TAB
SELECT *
from ACCOUNTING_STRUCTURE_TAB@your_test_db_link;

I assume the table structure is the same in both dev and test?
0
 
LVL 18

Expert Comment

by:sventhan
ID: 34944519
Do you have a DBLInk? if you do not create one.

INSERT INTO DEV.ACCOUNTING_STRUCTURE_TAB
SELECT *
from TEST.ACCOUNTING_STRUCTURE_TAB@dblink
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 34944527
if you want to do this from within a pl/sql procedure or anonymous block,  you must wrap the truncate inside an execute immediate  because trucate is ddl which isn't part of pl/sql syntax


begin

execute immediate 'truncate table ACCOUNTING_STRUCTURE_TAB';

INSERT INTO ACCOUNTING_STRUCTURE_TAB
SELECT *
from ACCOUNTING_STRUCTURE_TAB@your_test_db_link;

end;
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 34944846
There is also a sql COPY command.

The docs have the syntax.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question