oracle11g database import and export methods Tutorial

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: HTTPS: //blog.csdn.net/xinxiaoyonng/article/details/79436673
oracle11g database import and export:
①: the traditional way --exp (Export) and (imp) Import:
②: Data Pump Export way --expdp and (impdp) import;
③: third-party tools --PL / sql Develpoer;
First, what is a database import and export?
oracle11g database import / export, is what we usually refer to oracle data restore / backup.
Import database: .dmp format file into the database from a local server (local database test oracle);
Database Export: the data (data in the local database and test oracle) database server, and exported to a file format generated locally .dmp .
.dmp format: oracle is a file format data (such as video format is .mp4, .mp3 format music);
two, both advantages and disadvantages Description:
1.exp / IMP:
Advantages: writing code easy to understand, from the local you can directly import, do not operate in the server, reduce the difficulty of reducing operating on the server will ensure the security of the data files on the server.
Disadvantages: import and export of such relatively slow, less time appropriate database data. If the file is more than a few G, the public computer performance, at least about 4 to 5 hours.
2.expdp / impdp:
advantages: relatively fast import and export, the data files of several G is generally about 1 to 2 hours.
Disadvantages: Code is relatively easy to understand, in order to achieve import and export operations, you must create a logical directory (not a real directory) on the server. We all know the importance of the database server, so the above operation must be prudent. So this approach generally consists of a professional staff to complete the program (not necessarily a DBA (database administrator) to dry, small and medium companies may not have DBA).
3.PL/sql Develpoer:
advantages: Import Export command encapsulates, without manually entering each command. Convenient and improve efficiency.
Disadvantages: long application will rely on their produce, lower understanding of the principles of the code execution.
Third, with particular emphasis on:
the target database: the data to be imported database (usually the official database project);
Source database: data derived from the database (usually the test database on the project);
1. target database to the source database with the same name table space.
2. target data during import, the same user name as much as possible (thus ensuring the same user's privilege level).
3. Before making each target database data import, data backup should be prepared to prevent data loss.
4. Data Pump, the server must now establish available logical directory and checking availability.
The import and export to figure out different versions or the same version (version oracle11g Oracle10g version).
6. Before introducing the target data, clear data overwrite (replace), or only partially insert new data or replacement data table.
7. Determine whether the target database disk space is sufficient to accommodate the new data, the need to expand the table space.
8. Note that if the import and export the same characters, the character set is only a general Oracle database, and is fixed, do not generally alter.
9. Export Format Description:
   Dmp format: .dmp is a binary file, cross-platform, but also includes rights, good efficiency; 
   Sql format: .sql format files, text editor can be used to view, better versatility, efficiency is not as good as the first one kind,
for small amount of data import and export. In particular, note that the table can not have a big field (blob, clob, long), if any, will complain; 
   Pde format: .pde file format, .pde for the PL / SQL Developer's own file format, only with PL / SQL Developer tool
import and export, can not be viewed using a text editor;
10. the account authority determines the operator.
Fourth, the method of both import and export:
1, the conventional method:
general commands: exp (imp) username / password @ SERVICENAME: 1521 file = "e: \ temp.dmp" full = y;
Database Export Example:

 

exp xinxiaoyong/[email protected]:1521 file="e:\temp.dmp" full = y;

exp: Export command, will be written on export.
imp: Import command to import shall be written, each operation, the two can only choose one execution.
username: Exporting data user name will be written;
password: Export password data will be written;
@: Address Symbol, will write;
SERVICENAME: the Oracle service name, will be written;
1521: port number 1521 is the default can not write, write a non-default;
file = "E: \ temp.dmp": file storage path address will be written;
full = the y-: represents the whole database export. Can not write, the default is no, the user only export the object;
Method segments:
1. Fully import and export:
exp (IMP) username / password @ SERVICENAME: 1521 File = "E: \ temp.dmp" Full = Y;
2. import and export table portion of the user table:
exp (IMP) username / password @ SERVICENAME: 1521 File = "E: \ temp.dmp" tabels = (table1, Table2, table3, ...);
3. tablespace tablespaces import and export:
// database instance can have a N tablespaces (tablespace), a space under the table can have N tables (table).
exp (IMP) username / password @ SERVICENAME: 1521 File = "E: \ temp.dmp" the Tablespaces = (TABLESPACE1, tablespace2, tablespace3, ...);
4. username username objects import and export:
exp (IMP) username / @ SERVICENAME password: 1521 File = "E: \ temp.dmp" owner (username1, USERNAME2, USERNAME3);
2, data pump method:
Create Directory:
the expdp (the impdp) username / password @ SERVICENAME: 1521 schemas the dumpfile = username = file1 .dmp logfile = file1.log directory = testdata1 remap_schema = test: test;
database export example:
the expdp xinxiaoyong/[email protected]: 1521 schemas = xinxiaoyong the dumpfile = test.dmp 
logfile = the test.log Directory = testdata1;

exp: Export command, will be written on export.
imp: Import command to import shall be written, each operation, the two can only choose one execution.
username: Exporting data user name will be written;
password: Export password data will be written;
@: Address Symbol, will write;
SERVICENAME: the Oracle service name, will be written;
1521: port number 1521 is the default can not write, write a non-default;
schemas: export operation username;
dumpfile: the exported file;
logfile: log file is exported, you can not write;
Directory: created folder name;
remap_schema = source database user name: target database user name, not both will be written, the same can be omitted;
1. Check the table space:
the SELECT * from dba_tablespaces;
2. View management administrator directory (while viewing the operating system exists because Oracle does not care whether the directory exists, if does not exist, an error).
* dba_directories from the SELECT;
3. Create a logical directory, the command does not create a true directory in the operating system, such as system administrator to create the best. 
Directory testdata1 AS Create 'D: \ Test \ the dump';
4. xinxiaoyong user to impart operation privilege in the specified directory, etc. as system administrator preferably imparted.
// xinxiaoyong user name (user password is 123456)
Grant the Read, ON Directory testdata1 the Write to xinxiaoyong;
5. Export Data

 

 

1) by user guide expdp xinxiaoyong / 123456 @ orcl schemas = xinxiaoyong dumpfile expdp.dmp directory = testdata1 =;

2) the expdp xinxiaoyong parallel processes Parallel / 123456 @ ORCL Directory testdata1 the dumpfile = = 40 = xinxiaoyong3.dmp Parallel job_name = xinxiaoyong3
. 3) Table directing expdp xinxiaoyong / 123456 @ orcl tables = emp, dept dumpfile = expdp.dmp directory = testdata1 ;
4) press query xinxiaoyong guide the expdp / 123456 @ = testdata1 ORCL Directory tables the dumpfile expdp.dmp = = = EMP query '= 20 is the WHERE DEPTNO';
. 5) table spatial derivative expdp system / manager directory = testdata1 dumpfile = tablespace. dmp tablespaces = temp, example;
6) System guide the entire database the expdp / Directory Manager testdata1 the dumpfile = FULL = Y = full.dmp;
6. The Restore Data
1) leads to a user specified xinxiaoyong the impdp / 123456 = testdata1 the dumpfile = expdp.dmp Directory schemas = xinxiaoyong;
2) System changes the impdp table owner / Directory Manager testdata1 the dumpfile = = = expdp.dmp tables xinxiaoyong.dept remap_schema = xinxiaoyong: System;
. 3) introducing System tablespace the impdp / Directory Manager = testdata1 the dumpfile = tablespace.dmp the tablespaces = Example;
. 4) import database impdb system / manager directory = dump_dir dumpfile = full.dmp FULL = y;
5) System additional data the impdp / Directory Manager testdata1 the dumpfile = = = expdp.dmp schemas System TABLE_EXISTS_ACTION;
. 3, PLSQL method:
log plsql tool, the user has used the user to export permission (exp_full_database, dba, etc.) for the source database. 
  1. Export construction of the table statement (including storage structure) 

 

 

  Deriving tools -> export user object, select an object to be exported, and to export .sql format wait export is complete, as shown below:

 

                                            

 

Export data files;
   2. deriving tools -> export tables, and export format selection table to be exported to export. 

 

   Export to dmp format, as shown below:

 

Export to sql format, as shown below: 

 

Export to pde format, as shown below: 

 

 

            Tip Description: Using third-party tools, then export and import the entire database, time-consuming, there must be sufficient

 

                        Time to operation (large amount of data, then take several hours).

 

3. Construction Import table statement 
   introducing step tools-> import tables-> SQL Inserts .sql import file 
4. import data; 
   Tools-> Import talbes, then dmp file import or export data sql file format selected in accordance with,
or pde file. 
   Tip: Before you import the best to delete the previous table, except of course to import another database. 
      In addition, when the progress bar has been found stuck in a point, but when you export the file is no longer increases, even when the program is prompted to import
does not respond, do not think the program card dead, the import and export is relatively slow, as long as no error tips ,

 

Or import is complete, do not stop the program.

Tip: Create a database, table space here to skip, focuses on import and export data in this article, if this feels a little missing, do please forgive me. Due to the limited level, this document is for reference purposes only. Such as the code has mistakes, please forgive me. If you have a better development experience, thanks to reply. Thanks for watching! ! ! ;
----------------
Disclaimer: This article is CSDN blogger "xinxiaoyong 'original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source and this link statement.
Original link: https: //blog.csdn.net/xinxiaoyonng/article/details/79436673

Guess you like

Origin www.cnblogs.com/mrcln/p/11640829.html
Recommended