Use exp_imp to remotely operate the database, and attach Oracle Data to import and export the imp/exp export solution.

Source: Internet
Author: User

Remotely operate databases with exp/imp

Keyword: exp/IMP Remote Operation

In:
1. Modify the tnsnames. ora file (Alternatively, step 1 can be omitted. The formula is exp [IMP] address/Data Processing Instance name file = path. dmp [If imp is used, add full = y].)
Add the name of the remote server:

SQL code

192.168.1.117 = (description = (address_list = (address = (Protocol = TCP) (host = 192.168.1.117) (Port = 1521) (CONNECT_DATA = (SERVICE_NAME = orcl )))

192.168.1.117 =

(Description =

(Address_list =

(Address = (Protocol = TCP) (host = 192.168.1.117) (Port = 1521 ))

)

(CONNECT_DATA =

(SERVICE_NAME = orcl)

)

)

 
Ii. test whether the remote server is smooth
After entering cmd, execute the command: tnsping 192.168.1.117. If the connection is normal, return to the following interface:

SQL code

C: \ Documents ents and Settings \ Administrator> tnsping 192.168.1.117 TNS Ping utility for 32-bit windows: Version 10.2.0.1.0-production on-2009 09:06:53 copyright (c) 1997,200 5, Oracle. all rights reserved. used parameter file: e: \ oracle \ product \ 10.2.0 \ db_1 \ Network \ admin \ sqlnet. ora has used the tnsnames adapter to parse the alias attempting to contact (description = (address_list = (address = (Protocol = TCP) (host = 192.168.1.117) (Port = 1521 ))) (CONNECT_DATA = (SERVICE_NAME = orcl) OK (50 ms)

C: \ Documents ents and Settings \ Administrator> tnsping 192.168.1.117

 

TNS Ping utility for 32-bit windows: Version 10.2.0.1.0-production on-2009 09:06:53

 

Copyright (c) 1997,200 5, Oracle. All rights reserved.

 

Used parameter files:

E: \ oracle \ product \ 10.2.0 \ db_1 \ Network \ admin \ sqlnet. ora

 

 

Alias resolved using tnsnames Adapter

Attempting to contact (description = (address_list = (address = (Protocol = TCP) (host = 192.168.1.117) (Port = 1521) (CONNECT_DATA = (SERVICE_NAME =

Orcl )))

OK (50 ms)

 
Iii. Remote database operations
Export:

SQL code

Exp username/password@192.168.1.117 file = c: \ path for local database backup

Exp username/password@192.168.1.117 file = c: \ path for local database backup

 
Import:

SQL code

IMP username/password@192.168.1.117 file = file to import remote database full = y

IMP username/password@192.168.1.117 file = file to import remote database full = y

Okay, it's done! In this way, you no longer need to log on to the server remotely.

 

 

 

Import and Export Oracle Data imp/exp
Function: Oracle Data Import/Export imp/exp is equivalent to Oracle data restoration and backup.
 
In most cases, you can use ORACLE data import and export to back up and restore data (without causing data loss ).
Oracle has a benefit. Although your computer is not a server, you have installed an Oracle client and established a connection.
(Add the correct service name through net configuration assistant. In fact, you can think that the client and server have repaired the path, and then the data can be pulled)
In this way, you can export data locally, although the server may be far away from you.
You can also import the DMP file locally to a database server in a distance.
With this function, you can build two identical databases, one for testing and the other for formal use.
 
Execution environment: it can be executed in sqlplus. EXE or DoS (command line,
During dos execution, the installation directory \ $ ora10g \ bin in Oracle 8i is set to a global path,
The exp. EXE and imp. EXE files in this directory are used for import and export.
Oracle is written in Java. I think the sqlplus. EXE, exp. EXE, and imp. EXE files are packaged class files.
Sqlplus. EXE calls exp. EXE and imp. EXE to complete the import and export functions.
 
The following describes the Import and Export instances. You can import and export instances to the Import and Export instances, because the import and export operations are very simple.
Data export:
1. Export the database test completely, and the username System Password Manager is exported to D: \ daochu. dmp.
Exp system/manager @ test file = D: \ daochu. dmp full = y
2. Export the tables of system users and SYS users in the database
Exp system/manager @ test file = D: \ daochu. dmp owner = (system, sys)
3. Export tables Table1 and Table2 in the database
Exp system/manager @ test file = D: \ daochu. dmp tables = (Table1, table2)
4. Export the data with the field filed1 in table 1 in the database starting with "00"
Exp system/manager @ test file = D: \ daochu. dmp tables = (Table1) query = \ "where filed1 like '201312 '\"

The above is a commonly used export. I am not very concerned about compression. I can use WinZip to compress the DMP file.
However, add compress = Y to the command above.

Data Import
1. import data from D: \ daochu. dmp to the test database.
IMP system/manager @ test file = D: \ daochu. dmp
The above may be a problem, because some tables already exist, and then it will report an error, the table will not be imported.
Add ignore = Y to the end.
2. Import table 1 in D: \ daochu. dmp
IMP system/manager @ test file = D: \ daochu. dmp tables = (Table1)
 
The preceding import and export operations are sufficient. In many cases, I completely delete the table and then import it.
 
Note:
If you have sufficient permissions, the system will prompt you.
Databases can be connected. You can use tnsping test to obtain whether the database test can be connected.

 

Data export:
Exp hkb/hkb @ boss_14 full = y file = c: \ orabackup \ hkbfull. dmp log = c: \ orabackup \ hkbfull. log;

Note: The data of the current user is exported. If the current user has DBA permissions, all data is exported!

Import data between users with the same name:
IMP hkb/hkb @ Xe file = c: \ orabackup \ hkbfull. dmp log = c: \ orabackup \ hkbimp. Log full = y

Data Import between different names:
IMP system/test @ Xe fromuser = hkb touser = hkb_new file = C: \ orabackup \ hkbfull. dmp

Log = c: \ orabackup \ hkbimp. log;

Use of Export and Import wildcards:

To export a table in the format of table_1, table_2, and table_3, there are 300 such tables in the database. Do you need to write one statement? It's a waste of effort. You don't have to worry about it. Oracle provides wildcards to meet these needs:

Exp system/test@192.168.1.198/orcl file = D: \ exp_test.dmpTables = TABLE _ %Log = exp_test.log

You can use the tables = TABLE % option to export all table names starting with table. However, this problem occurs again, so that all the 300 tables will be exported, and I just want to export a part of the data like a TABLE_50-TABLE_100?

At this time, we need to use SQL to dynamically generate your exp command:

Select 'exp file = D: \ exp_test.dmptables = 'from dual
Union all select tname | ',' from tab where lower (tname) Like 'table \ _ % 'escape' \ 'and (substr (tname, 7) between '50' and '99' or substr (tname, 7) = '123 ')
Union all select 'null' from dual;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.