exp/imp three modes - full, user, table (transfer)

exp/imp three modes - full, user, table

ORACLE database has two types of backup methods. The first type is physical backup, this method realizes the complete recovery of the database, but the database must run in archive mode (the business database runs in non-archive mode), and requires a huge external storage device, such as a tape library; The second type of backup method is logical backup. This method is used for business databases. This method does not require the database to run in archive mode. Not only is the backup simple, but also external storage devices are not required.
  
Database logical backup method
  
The logical backup of the ORACLE database is divided into three modes: table backup, user backup and full backup.

Basic syntax and examples:
1. EXP:
There are three main ways (complete, user, table)

1. Complete:
EXP SYSTEM/MANAGER BUFFER=64000 FILE=C:\FULL.DMP FULL=Y
Backup complete database. The business database does not use this backup method. The backup command is:
exp icdmain/icd rows=y indexes=n compress=n buffer=65536 feedback=100000 full=y file=exp_.dmp log=exp.log
If you want to perform a full export, you must have special permissions!
Otherwise, it will Error: EXP-00023: must be a DBA to do Full Database or Tablespace export

2. User mode:
EXPSONIC/SONIC BUFFER=64000 FILE=C:\SONIC.DMP OWNER=SONIC
In this way all objects of the user SONIC are output to the file.
Back up all objects in a user mode. Business databases usually use this backup method. If backing up to a local file, use the following command:
exp icdmain/icd owner=icdmain rows=y indexes=n compress=n buffer=65536 feedback=100000 file=exp.dmp log=exp.log
If backing up directly to a tape device, use The following command:
exp icdmain/icd owner=icdmain rows=y indexes=n compress=n buffer=65536 feedback=100000 volsize=0 file=/dev/rmt0 log=exp.log
Note: If there is space on the disk, it is recommended to back it up to the disk , and then copy to tape. If the amount of database data is small, this method can be used for backup.
  Another: export statement such as remote server library and no local configuration:
exp logquery/[email protected]/orcl file=d:\logquery.dmp owner=
logquery

3. Table mode:
EXP SONIC/SONIC BUFFER=64000 FILE= C:\SONIC.DMP OWNER=SONIC TABLES=(SONIC)
In this way, the SONIC table of the user SONIC will be exported, and the specified object (table) in a user mode will be
backed up . Business databases usually use this backup method. To back up to a local file, use the following command:
exp icdmain/icd rows=y indexes=n compress=n buffer=65536 feedback=100000 volsize=0 file=exp.dmp log=exp.log tables=tab1,tab2,tab3
If you want to backup directly to a tape device, use the following command:
exp icdmain/icd rows=y indexes=n compress=n buffer=65536 feedback=100000 volsize=0 file=/dev/rmt0 log=exp.log tables=tab1,tab2,tab3
Note: When disk space allows, You should back up to a local server before copying to tape. For speed reasons, try not to back up directly to tape devices.

2. IMP:
has three modes (complete, user, table)
1. Complete:
IMP SYSTEM/MANAGER BUFFER=64000 FILE=C:\FULL.DMP FULL=Y
If the backup mode is full mode, use the following recovery methods:
imp system/manager rows=y indexes=n commit=y buffer=65536 feedback=100000 ignore=y volsize=0 full=y file=exp.dmp log=imp.log


2. User mode:
IMP SONIC/SONIC BUFFER=64000 FILE =C:\SONIC.DMP FROMUSER=SONIC TOUSER=SONIC
This way all objects of the user SONIC are imported into the file. The FROMUSER and TOUSER parameters must be specified so that data can be imported.
This method will restore according to the data backed up in user mode.
2.1. Restoring the entire contents of the backup data
If restoring from a local file, use the following command:
imp icdmain/icd fromuser=icdmain touser=icdmain rows=y indexes=n commit=y buffer=65536 feedback=100000 ignore=n file=exp. dmp log=imp.log
To restore from a tape device, use the following command:
imp icdmain/icd fromuser=icdmain touser=icdmain rows=y indexes=n commit=y buffer=65536 feedback=100000 ignore=n volsize=0 file=/ dev/rmt0 log=imp.log
2.2. Restore the specified table in the backup data
If restoring from the local file, use the following command:
imp icdmain/icd fromuser=icdmain touser=icdmain rows=y indexes=n commit=y buffer=65536 feedback =100000 ignore=n volsize=0 file=exp.dmp log=imp.log tables=t1,t2,t3;

3. Table mode:
IMP SONIC/SONIC BUFFER=64000 FILE=C:\SONIC.DMP OWNER=SONIC TABLES=(SONIC)
so that the table SONIC of user SONIC is imported.
This method will restore according to the data backed up in table mode. 
3.1 Restore the entire contents of backup data
       imp icdmain/icd fromuser=icdmain touser=icdmain rows=y indexes=n commit=y buffer=65536 feedback=100000 ignore=n file=exp.dmp log=imp.log
If restoring from tape device , use the following command:
imp icdmain/icd fromuser=icdmain touser=icdmain rows=y indexes=n commit=y buffer=65536 feedback=100000 ignore=n volsize=0 file=/dev/rmt0 log=imp.log
3.2 Restore backup Specified table in data:
If restoring from a local file, use the following command:
imp icdmain/icd fromuser=icdmain touser=icdmain rows=y indexes=n commit=y buffer=65536 feedback=100000 ignore=n file=exp.dmp log =imp.log tables=t1,t2,t3
To restore from a tape device, use the following command:
imp icdmain/icd fromuser=icdmain touser=icdmain rows=y indexes=n commit=y buffer=65536 feedback=100000 ignore=n volsize=0 file=/dev/rmt0 
log=imp.log tables=t1,t2,t3

3 、Character set description:
Export side:
The character set of the client should be set to be the same as the character set of the database

Check the character set of the database:
SQL> select userenv('language') from dual;

USERENV('LANGUAGE')
----- -------------------------------------------------- -------------------------
AMERICAN_AMERICA.AL32UTF8

View the character set of the client (operating system):
echo $NLS_LANG
Modify the client character set:
export NLS_LANG =AMERICAN_AMERICA.AL32UTF8
Export conversion process
    During the Export process, if the source database character set is inconsistent with the Export user session character set, character set conversion will occur, and the Export user session character set will be stored in the first few bytes of the export file. ID number. Data loss may occur during this conversion process.
Example: If the source database uses ZHS16GBK, and the Export user session character set uses US7ASCII, since ZHS16GBK is a 16-bit character set and US7ASCII is a 7-bit character set, during this conversion process, Chinese characters cannot find equivalent characters in US7ASCII , so all Chinese characters will be lost and become "??" form, so the Dmp file generated after conversion has lost data.
Therefore, if you want to export the source database data correctly, the user session character set should be equal to the source database character set or a superset of the source database character set during the Export process.

Import side:
1. The character set of the oracel server side;
2. The character set of the oracle client side ;
3. The character set of the dmp file.
When doing data import, these three character sets need to be consistent to import correctly.
Import conversion process
    (1) Determine the character set environment of the export database.
             By reading the header of the export file, the character set settings of the export file can be obtained.
    (2) Determine the character set of the import session, that is, the NLS_LANG environment variable used by the import session.
    (3) IMP Read the export file
             Read the character set ID of the export file, and compare it with the NLS_LANG of the import process
    (4) If the character set of the export file is the same as the character set of the import session, then no conversion is required in this step, if it is different, it needs to be Convert the data to the character set used by the importing Session. It can be seen that two character set conversions occur in the process of importing data into the database

    The first time: the conversion between the character set of the import file and the character set used by the import session. If the conversion process cannot be completed correctly, the import process of Import to the target database cannot be completed.
    The second time: import the conversion between the Session character set and the database character set.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326698949&siteId=291194637