I have written the following query using the documentation at: Oracle Documentation to copy some data from a database/table on my production server to database/table on Sandbox server.
COPY FROM username1/passwd1@<production_IP> to username2/passwd2@<sandbox_IP> INSERT TABLE_C (*) USING
(SELECT * FROM TABLE_C WHERE COL_A = 4884);
However, I am constantly running into Connection failed error. Is there anything wrong with the query?
In a typical Oracle environment, you have TNS names set up. That’s a service to lookup the connection parameters for Oracle instances given an SID or service name. In it’s simplest form, TNS names is a file called
tnsnames.oralocated by the environment variableTNS_ADMIN(which points to the directory where the file is).Given the SIDs
PRODandSANDBOX, you can then copy the tables from the SQLPLUS command line utility:Please note that this COPY command only supports a limited set of Oracle datatypes: char, date, long, varchar2, number.
If you don’t have TNS names set up, you’ll need to know the host name or IP address, the port number and the service name. The syntax then becomes:
To determine the SID and/or service name, you best have a look into the TNSNAMES.ORA file on the database server itself. If you are able to login to the database, you can use the following queries to determine the SID and service name (but don’t ask me which is which):