importing existing user data with impdp

expdp/impdp  
impdp import If there is a user table space before, delete all the original user table space
Step 1: delete user
drop user ×× cascade
Description: Delete the user, only delete the schema objects under the user, it will not be deleted the corresponding tablespace.
Step 2: Delete tablespace
DROP TABLESPACE tablespace_name INCLUDING CONTENTS AND DATAFILES;

check which tablespace the user belongs to
select username,default_tablespace from dba_users where username='SCOTT';--username needs to be uppercase

Create user-specified

tablespace create tablespace PERSONAL_DATA
datafile 'D: \app\Administrator\oradata\orcl\PERSONAL_DATA.dbf'
SIZE 1024M AUTOEXTEND ON ;//Create a table space, it is best to put it in the oracle package so as not to be deleted


CREATE USER CL IDENTIFIED BY 123456
DEFAULT TABLESPACE PERSONAL_DATA ;//Create a user specified Tablespace

GRANT DBA, RESOURCE, CONNECT TO CL;//Authorization

When importing, the tablespace of the imported user should be the same as the tablespace of the original user;

expdp/impdp import and export
1. Create a logical directory, this command will not create a real directory in the operating system, it is best to create it by an administrator such as system.
create directory dpdata1 as 'd:\test\dump';

Second, check the administrator directory (also check whether the operating system exists, because Oracle does not care whether the directory exists, if it does not exist, an error occurs)
select * from dba_directories;

3. Give the scott user the operation authority in the specified directory, preferably given by administrators such as system.
grant read,write on directory dpdata1 to scott;

4. Export data
1) By user guide
expdp scott/tiger@orcl DIRECTORY=dpdata1 schemas=scott dumpfile=expdp.dmp;
2) Parallel process parallel
expdp scott/tiger@orcl directory= dpdata1 dumpfile=scott3.dmp parallel=40 job_name=scott3
3) Import
expdp scott/tiger@orcl TABLES=emp,dept dumpfile=expdp.dmp DIRECTORY=dpdata1;
4) Import by query condition
expdp scott/tiger@orcl directory=dpdata1 dumpfile=expdp.dmp Tables=emp query='WHERE deptno=20';
5) Import
expdp system/manager DIRECTORY=dpdata1 DUMPFILE=tablespace.dmp TABLESPACES=temp,example;
6) Import the entire database
expdp system/manager DIRECTORY=dpdata1 DUMPFILE=full.dmp FULL=y;

5. Restore data

1) Import to the specified user
impdp scott/tiger DIRECTORY=logical path name DUMPFILE=expdp.dmp SCHEMAS=user;

Change the user name exported by A to B
impdp B/B DIRECTORY=impdp_dir DUMPFILE=A.dmp SCHEMAS=A REMAP_SCHEMA=A:B

2) Change the owner of the table
impdp system/manager DIRECTORY=dpdata1 DUMPFILE=expdp. dmp TABLES=scott.dept REMAP_SCHEMA=scott:system;
3) Import tablespace
impdp system/manager DIRECTORY=dpdata1 DUMPFILE=tablespace.dmp TABLESPACES=example;
4) Import database
impdb system/manager DIRECTORY=dump_dir DUMPFILE=full.dmp FULL=y;
5) Append data
impdp system/manager DIRECTORY=dpdata1 DUMPFILE=expdp.dmp SCHEMAS=system TABLE_EXISTS_ACTION=append;

system settings advanced settings that
character set The problem is to create a new variable in the environment variable

Name                    :
NLS_LANG
Value:
SIMPLIFIED CHINESE_CHINA.ZHS16GBK

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326485149&siteId=291194637