900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > oracle导入和导出 以及报错的处理包括高版本的dmp导入到低版本

oracle导入和导出 以及报错的处理包括高版本的dmp导入到低版本

时间:2019-01-02 22:11:05

相关推荐

oracle导入和导出 以及报错的处理包括高版本的dmp导入到低版本

导入命令

imp 用户名/密码@你在tnsnames.ora中配置的服务名字 fromuser=你原来导出的用户名 touser=你现在要导入到那个用户 file=dmp文件所在位置

imp znsh/znsh@orcl fromuser=heimdall touser=znsh file=d:\aa.dmp

如果导入时,数据表已经存在,将报错,对该表不会进行导入;加上ignore=y即可,表示忽略现有表,在现有表上追加记录。

imp znsh/znsh@orcl fromuser=heimdall touser=znsh file=d:\aa.dmp ignore=y

导出命令:

exp 用户名/密码@你在tnsnames.ora中配置的服务名字 file=dmp文件所在位置 owner=需要导出的用户名

exp heimdall/heimdall@orcl file=d:\aa.dmp owner=heimdall

如果是数据库服务并不在你的本地,而是其他服务器上的,

只需要在你本地的 tnsnames.ora 的配置文件中配置的服务名就可以了。如你配置了一个服务名叫db199

现在要到处199上的数据

exp heimdall/heimdall@db199 file=d:\aa.dmp owner=heimdall ;

-----------------------数据导入可能遇到问题,以下有些解决方案

将oracle 11g导出的dmp文件导入到oracle10g

1.进行导入表操作,提示:

IMP-00010: 不是有效的导出文件, 头部验证失败

IMP-00000: 未成功终止导入

2.从网上查阅,oracle数据11g到10g是有问题的,一般由oracle10g客户端去连oracle11g进行导出数据操作然后导入到oracle10g,如果手中只有oracle11g的dmp文件,怎么办

3.从网上查阅,头部验证失败是由于版本号不同所致,经试验可以通过如下方法进行修改:

用notepad++工具打开dmp文件,可以看到头部信息 --TEXPORT:V11.01.00,即为源数据库的版本号,将其修改为目的数据库的版本号,如本机为10.02.01

4.再次进行导入操作,导入成功

导到大表之后,卡住不动了,等是要等的,不过等了一个小时还没有好,尝试如下设置

1、查看当前使用的游标数

select count(*) from v$open_cursor

2、查看数据库设置的游标数

show parameter open_cursors; --这条语句需要再plsql的命令窗口执行,而不是sql窗口

3、如果当前使用的游标数大于数据库设置的游标数,那么修改游标数大小

alter system set open_cursors=3000 scope=both;

imp 导入数据时可否排除其中一张表不导入

在IMP进行数据导入时,能不能把不想导的一张或几张表不进行导入

Oracle9i及以前的imp,exp工具只能选择表导入导出,不能排除表,在Oracle10g中的expdp和impdp增加了exclude参数,允许排除某些不导入的表,对象类型等

在exp的版本中有两种方法排除表的导入和导出

方法一:

加tables=(table1,table2,...,tablen)参数可导入指定表

应该只能指定表,不能排除表

方法二:

在要导入的用户下把你不需要的表建起来,只要是同名

导入时,加上ignore=n参数,这个表报错,就不会导入此表了

在expdp版本中

可以使用子句INCLUDE=TABLE:"LIKE 'TAB%'"来仅导出那些名称以 TAB 开头的表。类似地,您可以使用结构INCLUDE=TABLE:"NOT LIKE 'TAB%'"来排除所有名称以 TAB 开头的表。作为另一种选择,您可以使用EXCLUDE参数来排除特定的对象。

虽然expdp -help指明了exclude的语法:exclude=table:emp

但实际上会出错。

正确的语法是exclude=table:"in ('EMP')"

例子:

C:>expdp oracle/oracle directory=testexpdp dumpfile=zzw_temp3.dmp exclude=TABLE

:"IN('TEST2')"

这是可以的

C:>expdp oracle/oracle directory=testexpdp dumpfile=zzw_temp3.dmp exclude=TABLE

:"IN ('TEST2','ZZW_TEMP2')"

但这是不行的,当排除多个表的时候不行,报ORA-39071: EXCLUDE 值的格式错误

需要增加转义字符,应该这样

C:>expdp oracle/oracle directory=testexpdp dumpfile=zzw_temp3.dmp exclude=TAB

LE:"IN ('TEST2','ZZW_TEMP2')"

归纳总结:

1.表名要大写

2.排除多表的时候要注意使用转义字符

3.排除表的时候,使用了exclude参数,就不要再使用schemas参数,如果有了schemas参数将对应的用户方案的全部对象导出

</pre><pre code_snippet_id="1667518" snippet_file_name="blog_0430_13_3489885" name="code" class="sql">

</pre><pre code_snippet_id="1667518" snippet_file_name="blog_0430_13_3489885" name="code" class="sql">

</pre><pre code_snippet_id="1667518" snippet_file_name="blog_0430_13_3489885" name="code" class="sql">

</pre><pre code_snippet_id="1667518" snippet_file_name="blog_0430_13_3489885" name="code" class="sql">

</pre><pre code_snippet_id="1667518" snippet_file_name="blog_0430_13_3489885" name="code" class="sql">

</pre><pre code_snippet_id="1667518" snippet_file_name="blog_0430_13_3489885" name="code" class="sql">

1、创建DIRECTORY

create directory dir_dp as 'D:\oracle\dir_dp';

2、授权

Grant read,write on directory dir_dp to lttfm;

(通过网络,1/2步骤省略)

--查看目录及权限

SELECT privilege, directory_name, DIRECTORY_PATH FROM user_tab_privs t, all_directories d

WHERE t.table_name(+) = d.directory_name ORDER BY 2, 1;

--directory_name 用这个name参数就可以

--impdp gwm/gwm@fgisdb schemas=gwm dumpfile =expdp_test.dmp logfile=expdp_test.log directory=dir_dp job_name=my_job

3、不通过expdp的步骤生成dmp文件而直接导入的方法:

--从源数据库中向目标数据库导入表p_street_area

impdp gwm/gwm directory=dir_dp NETWORK_LINK=igisdb schemas=gwm logfile=p_street_area.log

(tables=p_street_area, job_name=my_job可以不用)

igisdb是目的数据库与源数据的链接名,dir_dp是目的数据库上的目录

4、更换表空间

采用remap_tablespace参数

--导出gwm用户下的所有数据

expdp system/orcl directory=data_pump_dir dumpfile=gwm.dmp SCHEMAS=gwm

注:如果是用sys用户导出的用户数据,包括用户创建、授权部分,用自身用户导出则不含这些内容

--以下是将gwm用户下的数据全部导入到表空间gcomm(原来为gmapdata表空间下)下

impdp system/orcl directory=data_pump_dir dumpfile=gwm.dmp remap_tablespace=gmapdata:gcomm

在实际使用中,如果写在参数文件中,则不存在语法错误;但如果要在命令行中直接写的话,就必须加上转义字符:

Windows :

D:\> expdp system/manager DIRECTORY=my_dir DUMPFILE=exp_tab.dmp LOGFILE=exp_tab.log SCHEMAS=scott INCLUDE=TABLE:\”IN (’EMP’, ‘DEP’)\”

Unix :

% expdp system/manager DIRECTORY=my_dir DUMPFILE=exp_tab.dmp LOGFILE=exp_tab.log SCHEMAS=scott INCLUDE=TABLE:\”IN \(\’EMP\’, \’DEP\’\)\”

CREATE OR REPLACE DIRECTORY dir_dump AS '/archlog/backup/';

GRANT read,write ON DIRECTORY dir_dump TO public;

alter system set sga_max_size=5120M scope=spfile;

alter system set sga_target=5120M scope = spfile;

alter system set pga_aggregate_target=1500m scope=spfile;

alter system set sga_max_size=2048M scope=spfile;

alter system set sga_target=2048M scope = spfile;

create pfile='C:\oracle\product\10.2.0\admin\jssi\pfile\init.ora' from spfile;

startup pfile='C:\oracle\product\10.2.0\admin\jssi\pfile\init.ora.830235649';

Select Privilege, Directory_Name, Directory_Path

From User_Tab_Privs t, All_Directories d

Where t.Table_Name(+) = d.Directory_Name

Order By 2, 1

expdp phrep/phrep schemas=phrep directory=dir_dump dumpfile =phrep.dmp logfile=phrep.log job_name=phrep_job;

expdp phrep/phrep schemas=phrep directory=dir_dump dumpfile =phrep.dmp logfile=phrep.log job_name=phrep_job;

expdp phsi/phsi#zqzb001 schemas=phsi directory=dir_dump dumpfile =phsi.dmp logfile=phsi.log job_name=phsinew_job;

expdp sjqy/sjqy schemas=sjqy directory=dir_dump dumpfile =sjqy.dmp job_name=sjqy_job;

expdp /'/ as sysdba/' directory=backup full=y dumpfile=fullexp.dmp logfile=fullexp.log parallel=2 schemas=dave,bl version='10.2.0.1.0';

impdp unilg/*** dumpfile=catalogtbs.dmp directory=dump_dir transport_datafiles='D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\catalogtbs01.dbf' version='10.2.0.1.0';

Export: Release 11.2.0.1.0 - Production on Wed Apr 16 22:02:10

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

The Data Pump export utility provides a mechanism for transferring data objects

between Oracle databases. The utility is invoked with the following command:

Example: expdp scott/tiger DIRECTORY=dmpdir DUMPFILE=scott.dmp

You can control how Export runs by entering the 'expdp' command followed

by various parameters. To specify parameters, you use keywords:

Format: expdp KEYWORD=value or KEYWORD=(value1,value2,...,valueN)

Example: expdp scott/tiger DUMPFILE=scott.dmp DIRECTORY=dmpdir SCHEMAS=scott

or TABLES=(T1:P1,T1:P2), if T1 is partitioned table

USERID must be the first parameter on the command line.

------------------------------------------------------------------------------

The available keywords and their descriptions follow. Default values are listed within square brackets.

ATTACH

Attach to an existing job.

For example, ATTACH=job_name.

COMPRESSION

Reduce the size of a dump file.

Valid keyword values are: ALL, DATA_ONLY, [METADATA_ONLY] and NONE.

CONTENT

Specifies data to unload.

Valid keyword values are: [ALL], DATA_ONLY and METADATA_ONLY.

DATA_OPTIONS

Data layer option flags.

Valid keyword values are: XML_CLOBS.

DIRECTORY

Directory object to be used for dump and log files.

DUMPFILE

Specify list of destination dump file names [expdat.dmp].

For example, DUMPFILE=scott1.dmp, scott2.dmp, dmpdir:scott3.dmp.

ENCRYPTION

Encrypt part or all of a dump file.

Valid keyword values are: ALL, DATA_ONLY, ENCRYPTED_COLUMNS_ONLY, METADATA_ONLY and NONE.

ENCRYPTION_ALGORITHM

Specify how encryption should be done.

Valid keyword values are: [AES128], AES192 and AES256.

ENCRYPTION_MODE

Method of generating encryption key.

Valid keyword values are: DUAL, PASSWORD and [TRANSPARENT].

ENCRYPTION_PASSWORD

Password key for creating encrypted data within a dump file.

ESTIMATE

Calculate job estimates.

Valid keyword values are: [BLOCKS] and STATISTICS.

ESTIMATE_ONLY

Calculate job estimates without performing the export.

EXCLUDE

Exclude specific object types.

For example, EXCLUDE=SCHEMA:"='HR'".

FILESIZE

Specify the size of each dump file in units of bytes.

FLASHBACK_SCN

SCN used to reset session snapshot.

FLASHBACK_TIME

Time used to find the closest corresponding SCN value.

FULL

Export entire database [N].

HELP

Display Help messages [N].

INCLUDE

Include specific object types.

For example, INCLUDE=TABLE_DATA.

JOB_NAME

Name of export job to create.

LOGFILE

Specify log file name [export.log].

NETWORK_LINK

Name of remote database link to the source system.

NOLOGFILE

Do not write log file [N].

PARALLEL

Change the number of active workers for current job.

PARFILE

Specify parameter file name.

QUERY

Predicate clause used to export 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.

REUSE_DUMPFILES

Overwrite destination dump file if it exists [N].

SAMPLE

Percentage of data to be exported.

SCHEMAS

List of schemas to export [login schema].

SOURCE_EDITION

Edition to be used for extracting metadata.

STATUS

Frequency (secs) job status is to be monitored where

the default [0] will show new status when available.

TABLES

Identifies a list of tables to export.

For example, TABLES=HR.EMPLOYEES,SH.SALES:SALES_1995.

TABLESPACES

Identifies a list of tablespaces to export.

TRANSPORTABLE

Specify whether transportable method can be used.

Valid keyword values are: ALWAYS and [NEVER].

TRANSPORT_FULL_CHECK

Verify storage segments of all tables [N].

TRANSPORT_TABLESPACES

List of tablespaces from which metadata will be unloaded.

VERSION

Version of objects to export.

Valid keyword values are: [COMPATIBLE], LATEST or any valid database version.

------------------------------------------------------------------------------

The following commands are valid while in interactive mode.

Note: abbreviations are allowed.

ADD_FILE

Add dumpfile to dumpfile set.

CONTINUE_CLIENT

Return to logging mode. Job will be restarted if idle.

EXIT_CLIENT

Quit client session and leave job running.

FILESIZE

Default filesize (bytes) for subsequent ADD_FILE commands.

HELP

Summarize interactive commands.

KILL_JOB

Detach and delete job.

PARALLEL

Change the number of active workers for current job.

REUSE_DUMPFILES

Overwrite destination dump file if it exists [N].

START_JOB

Start or resume current job.

Valid keyword values 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 keyword values are: IMMEDIATE.

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。