How to import and export a database remotely

Source: Internet
Author: User
Tags sqlplus

Oracle Data Import and export imp/exp is equivalent to Oracle data restore and backup. The EXP command can export data from a remote database server to a local DMP file, and the IMP command can import the DMP file from a local to a distant database server. With this feature you can build two identical databases, one for testing, and one for formal use ...

Oracle data import and export imp/exp is equivalent to Oracle data restore and backup. The EXP command can export data from a remote database server to a local DMP file, and the IMP command can import the DMP file from a local to a distant database server. With this feature you can build two identical databases, one for testing and one for formal use.

  execution Environment: can be executed in SQLPLUS.EXE or DOS (command line), DOS can be executed when the installation of directory/ora81/bin in Oracle 8i is set to the global path, This directory has EXP.EXE and IMP.EXE files that are used to perform import and export.

Oracle is written in Java, SQLPLUS. EXE, EXP. EXE, IMP. EXE these two files are likely to be packaged after the class file.

SQLPLUS. EXE calls EXP.EXE, IMP. EXE to complete the import and export function.

Format:

Imp username/[email protected]_string param=value ... exp username/[email protected]_string param=value ...Note: If it is under the Sqlplus command, to add $ before the IMP or EXP command, the error will be: sp2-0734: Unknown command at the beginning "Exp Pafirc ...", if it is under the CMD Command window (if it is logged in with a sqlplus "username/password", Equivalent to the Sqlplus command window), it is not possible.

The following is an example of importing and exporting.

  Data export:

1 The database test is fully exported, user name Ora password 123456 exported to D:/daochu.dmp

Exp Ora/[email protected] file=d:/daochu.dmp full=y

2 Exporting the Ora user in the database to the SYS user's table

Exp Ora/[email protected] file=d:/daochu.dmp owner= (Ora,sys)

3 Exporting Tables Inner_notify, Notify_staff_relat in the database

Exp Aichannel/[email protected] file= d:/data/newsmgnt.dmp tables= (Inner_notify,notify_staff_relat)

4 Export the field filed1 in table table1 in the database with data beginning with "00"

Exp Ora/[email protected] file=d:/daochu.dmp tables= (table1) query=/"where filed1 like ' 0% '/"

The above is commonly used for the export, for compression, both with WinZip to the DMP file can be very good compression.

It can also be implemented by adding compress=y to the above command.

 Import of data:

1 Import the data from the D:/DAOCHU.DMP into the test database.

Imp Ora/123456[email protected] File=d:/daochu.dmp

Imp aichannel/[email protected] full=y file=file= d:/data/newsmgnt.dmp ignore=y

There may be a problem, because some tables already exist, and then it is an error, and the table is not imported.

Add Ignore=y to the back.

2 Import the table table1 in D:/daochu.dmp

Imp ora/[email protected] file=d:/daochu.dmp tables= (table1)

Basically, the above import and export is enough. In many cases, you must first delete the table and then import it.

Attention:

The operator must have sufficient permissions, and it will prompt for insufficient permissions.

Database, you can connect to the. You can use tnsping test to get the database test to connect.

  Appendix I:

Adding permissions to the import data to the user

First, start sql*puls

Second, landing with System/manager

Third, create user username identified by password (this step can be omitted if the user has already been created)

IV, GRANT create User,drop user,alter USER, create any VIEW,

DROP any view,exp_full_database,imp_full_database,

Dba,connect,resource,create SESSION to User name

V, run-cmd-into the directory where the DMP file is located,

Imp userid=ora/123456full=y file=*.dmp

or imp userid=ora/123456full=y file=filename.dmp

  Example execution:

F:/work/oracle_data/backup>imp userid=test/test full=y file=inner_notify.dmp

Screen display

Import:release 8.1.7.0.0-production on Thu February 16 16:50:05 2006

(c) Copyright: Oracle Corporation. All rights reserved.

Connected to: Oracle8i Enterprise Edition Release 8.1.7.0.0-production

With the partitioning option

Jserver Release 8.1.7.0.0-production

Export files created by export:v08.01.07 through a regular path

Import is completed in ZHS16GBK character set and ZHS16GBK NCHAR character set

The export server uses the UTF8 NCHAR character set (possible ncharset conversions)

. Importing Aichannel objects into Aichannel

. . Importing table "Inner_notify" 4 rows are imported

Prepare to enable constraints ...

The import was terminated successfully, but a warning appears.

  Appendix II:

Oracle does not allow direct changes to the table owner, which can be achieved with export/import.

Build Import9.par First,

Then, use the command as follows: Imp Parfile=/filepath/import9.par

Example Import9.par content is as follows:

Fromuser=tgpms

TOUSER=TGPMS2 (Note: Users who change the owner of the table from Fromuser to Touser,fromuser and Touser can be different)

Rows=y

Indexes=y

Grants=y

Constraints=y

buffer=409600

File==/backup/ctgpc_20030623.dmp

Log==/backup/import_20030623.log

How to import and export a database remotely

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.