oracle impdp导入数据时用户建立

概述:我们在进行导入dmp数据时,以前在使用imp导入时是需要目标库中创建好表空间和用户并充分授权是吧!那imp的进阶工具impdp呢?

实验:

imp工具帮助手册使用:

oracle@host01 ~]$ impdp help=y
Import: Release 12.1.0.2.0 - Production on Tue May 22 15:55:02 2018
Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

The Data Pump Import utility provides a mechanism for transferring data objects
between Oracle databases. The utility is invoked with the following command:
     Example: impdp scott/tiger DIRECTORY=dmpdir DUMPFILE=scott.dmp
You can control how Import runs by entering the 'impdp' command followed
by various parameters. To specify parameters, you use keywords:
     Format:  impdp KEYWORD=value or KEYWORD=(value1,value2,...,valueN)
     Example: impdp scott/tiger DIRECTORY=dmpdir DUMPFILE=scott.dmp
USERID must be the first parameter on the command line.
-----------------------------------------------------------------------------
The available keywords and their descriptions follow. Default values are listed within square brackets.
ABORT_STEP
Stop the job after it is initialized or at the indicated object.
Valid values are -1 or N where N is zero or greater.
N corresponds to the object's process order number in the master table.
ACCESS_METHOD
Instructs Import to use a particular method to load data.
Valid keyword values are: [AUTOMATIC], CONVENTIONAL, DIRECT_PATH
and EXTERNAL_TABLE.
ATTACH
Attach to an existing job.
For example, ATTACH=job_name.
CLUSTER
Utilize cluster resources and distribute workers across the Oracle RAC [YES].
CONTENT
Specifies data to load.
Valid keywords are: [ALL], DATA_ONLY and METADATA_ONLY.
DATA_OPTIONS
Data layer option flags.
Valid keywords are: DISABLE_APPEND_HINT and SKIP_CONSTRAINT_ERRORS.
DIRECTORY
Directory object to be used for dump, log and SQL files.
DUMPFILE
List of dump files to import from [expdat.dmp].
For example, DUMPFILE=scott1.dmp, scott2.dmp, dmpdir:scott3.dmp.
ENCRYPTION_PASSWORD
Password key for accessing encrypted data within a dump file.
Not valid for network import jobs.
ENCRYPTION_PWD_PROMPT
Specifies whether to prompt for the encryption password [NO].
Terminal echo will be suppressed while standard input is read.
ESTIMATE
Calculate network job estimates.
Valid keywords are: [BLOCKS] and STATISTICS.
EXCLUDE
Exclude specific object types.
For example, EXCLUDE=SCHEMA:"='HR'".
FLASHBACK_SCN
SCN used to reset session snapshot.
FLASHBACK_TIME
Time used to find the closest corresponding SCN value.
FULL
Import everything from source [YES].
HELP
Display help messages [NO].
INCLUDE
Include specific object types.
For example, INCLUDE=TABLE_DATA.
JOB_NAME
Name of import job to create.
KEEP_MASTER
Retain the master table after an import job that completes successfully [NO].
LOGFILE
Log file name [import.log].
LOGTIME
Specifies that messages displayed during import operations be timestamped.
Valid keyword values are: ALL, [NONE], LOGFILE and STATUS.
MASTER_ONLY
Import just the master table and then stop the job [NO].
METRICS
Report additional job information to the import log file [NO].
NETWORK_LINK
Name of remote database link to the source system.
NOLOGFILE
Do not write log file [NO].
PARALLEL
Change the number of active workers for current job.
PARFILE
Specify parameter file.
PARTITION_OPTIONS
Specify how partitions should be transformed.
Valid keywords are: DEPARTITION, MERGE and [NONE].
QUERY
Predicate clause used to import a subset of a table.
For example, QUERY=employees:"WHERE department_id > 10".
REMAP_DATA
Specify a data conversion function.
For example, REMAP_DATA=EMP.EMPNO:REMAPPKG.EMPNO.
REMAP_DATAFILE
Redefine data file references in all DDL statements.


REMAP_SCHEMA
Objects from one schema are loaded into another schema.
REMAP_TABLE
Table names are remapped to another table.
For example, REMAP_TABLE=HR.EMPLOYEES:EMPS.
REMAP_TABLESPACE
Tablespace objects are remapped to another tablespace.
REUSE_DATAFILES
Tablespace will be initialized if it already exists [NO].
SCHEMAS
List of schemas to import.
SERVICE_NAME
Name of an active Service and associated resource group to constrain Oracle RAC resources.
SKIP_UNUSABLE_INDEXES
Skip indexes that were set to the Index Unusable state
SOURCE_EDITION
Edition to be used for extracting metadata.
SQLFILE
Write all the SQL DDL to a specified file.
STATUS
Frequency (secs) job status is to be monitored where
the default [0] will show new status when available.
STREAMS_CONFIGURATION
Enable the loading of Streams metadata [YES].
TABLE_EXISTS_ACTION
Action to take if imported object already exists.
Valid keywords are: APPEND, REPLACE, [SKIP] and TRUNCATE.
TABLES
Identifies a list of tables to import.
For example, TABLES=HR.EMPLOYEES,SH.SALES:SALES_1995.
TABLESPACES
Identifies a list of tablespaces to import.
TARGET_EDITION
Edition to be used for loading metadata.
TRANSFORM
Metadata transform to apply to applicable objects.
Valid keywords are: DISABLE_ARCHIVE_LOGGING, INMEMORY, INMEMORY_CLAUSE,
LOB_STORAGE, OID, PCTSPACE, SEGMENT_ATTRIBUTES, STORAGE, and
TABLE_COMPRESSION_CLAUSE.
TRANSPORTABLE
Options for choosing transportable data movement.
Valid keywords are: ALWAYS and [NEVER].
Only valid in NETWORK_LINK mode import operations.
TRANSPORT_DATAFILES
List of data files to be imported by transportable mode.
TRANSPORT_FULL_CHECK
Verify storage segments of all tables [NO].
Only valid in NETWORK_LINK mode import operations.
TRANSPORT_TABLESPACES
List of tablespaces from which metadata will be loaded.
Only valid in NETWORK_LINK mode import operations.
VERSION
Version of objects to import.
Valid keywords are: [COMPATIBLE], LATEST, or any valid database version.
Only valid for NETWORK_LINK and SQLFILE.
VIEWS_AS_TABLES
Identifies one or more views to be imported as tables.
For example, VIEWS_AS_TABLES=HR.EMP_DETAILS_VIEW.
Note that in network import mode, a table name may be appended
to the view name.
------------------------------------------------------------------------------
The following commands are valid while in interactive mode.
Note: abbreviations are allowed.
CONTINUE_CLIENT
Return to logging mode. Job will be restarted if idle.
EXIT_CLIENT
Quit client session and leave job running.
HELP
Summarize interactive commands.
KILL_JOB
Detach and delete job.
PARALLEL
Change the number of active workers for current job.
START_JOB
Start or resume current job.
Valid keywords are: SKIP_CURRENT.
STATUS
Frequency (secs) job status is to be monitored where
the default [0] will show new status when available.
STOP_JOB
Orderly shutdown of job execution and exits the client.
Valid keywords are: IMMEDIATE.


sqlplus sys/oracle@db11g as sysdba;

SQL*Plus: Release 12.1.0.2.0 Production on Tue May 22 15:58:48 2018
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SYS@AS SYSDBA@db11g> drop user cube cascade;
User dropped.
SYS@AS SYSDBA@db11g> create user cube identified by cube default tablespace users;
User created.
SYS@AS SYSDBA@db11g> grant connect,resource,unlimited tablespace to cube;
Grant succeeded.
SYS@AS SYSDBA@db11g> conn cube/cube@db11g;
Connected.
CUBE@@db11g> create table test (id int);

Table created.

CUBE@@db11g> insert into test values (1);
1 row created.
CUBE@@db11g> commit;

Commit complete.

SYS@AS SYSDBA@pdbprod4> select username from dba_users where username='CUBE';
no rows selected

SYS@AS SYSDBA@pdbprod4> select TABLESPACE_NAME from dba_tablespaces;
TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
TEMP
USERS
EXAMPLE
5 rows selected.


[oracle@host01 admin]$ impdp \'sys/oracle@host01:1521/PDBPROD4.example.com as sysdba\' directory=xtts  logtime=all parallel=4 NETWORK_LINK=DB11g schemas=cube logfile=imp11g.log 


Import: Release 12.1.0.2.0 - Production on Tue May 22 16:04:50 2018


Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.


Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
22-MAY-18 16:04:56.390: Starting "SYS"."SYS_IMPORT_SCHEMA_04":  "sys/********@host01:1521/PDBPROD4.example.com AS SYSDBA" directory=xtts logtime=all parallel=4 NETWORK_LINK=DB11g schemas=cube logfile=imp11g.log 
22-MAY-18 16:04:57.859: Estimate in progress using BLOCKS method...
22-MAY-18 16:04:59.981: Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
22-MAY-18 16:04:59.997: Total estimation using BLOCKS method: 64 KB
22-MAY-18 16:05:00.513: Processing object type SCHEMA_EXPORT/USER
22-MAY-18 16:05:00.743: Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
22-MAY-18 16:05:00.817: Processing object type SCHEMA_EXPORT/ROLE_GRANT
22-MAY-18 16:05:00.902: Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
22-MAY-18 16:05:01.473: Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
22-MAY-18 16:05:10.366: Processing object type SCHEMA_EXPORT/TABLE/TABLE
22-MAY-18 16:05:12.816: . . imported "CUBE"."TEST"                                    1 rows

22-MAY-18 16:05:14.782: Job "SYS"."SYS_IMPORT_SCHEMA_04" successfully completed at Tue May 22 16:05:14 2018 elapsed 0 00:00:21

SYS@AS SYSDBA@pdbprod4> select * from cube.test;


        ID
----------
         1


1 row selected.


SYS@AS SYSDBA@pdbprod4> select PRIVILEGE from dba_tab_privs where  GRANTEE='CUBE';
no rows selected
SYS@AS SYSDBA@pdbprod4> 
SYS@AS SYSDBA@pdbprod4> select GRANTED_ROLE from dba_role_privs where  GRANTEE='CUBE';
GRANTED_ROLE
--------------------------------------------------------------------------------
RESOURCE
CONNECT
2 rows selected.
SYS@AS SYSDBA@pdbprod4> select PRIVILEGE from dba_sys_privs where GRANTEE='CUBE';
PRIVILEGE
----------------------------------------
UNLIMITED TABLESPACE

1 row selected.


总结:impdp在数据导入的时候用户将会自行创建并进行与源库相同的权限授权,但是如果目标库没有对应的表空间将会报错并且数据无法导入,但是可以做表空间转换至目标库已经存在的表空间中。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值