I'm working with Oracle databases and quite often I have to copy
some data from one database to another.
Unfortunately it's not as easy as one might think. Even though there
are a few tools that can export and import Oracle data, none
of them works the way I'd want it to.
For example, imp and exp tools store tablespace information in binary dump format and it's not possible to import tables to different tablespace than those of original tables.
So I've decided to create a simple script that copies tables between databases. It's very simple and it's not finished, but after some simple tweaks you should be able to adjust it to your needs.
Script is written in python and uses cx_Oracle library.
You can download script here: ocp.py.
Usage is:
ocp.py source_db target_db table_name
Where:
- source_db - source db connection string
- target_db - target db connection string
- table_name - table name
Database connection can be in two forms:
- usual SQL*Plus connection string (scott/tiger@xe) which requires you to have database name defined in tnsnames.ora or
- special format username/password@host:port:sid, for example: scott/tiger@localhost:1521:xe
$Id: oracle-table-copy-script.html,v 1.4 2009/02/02 14:37:36 maciej Exp $