转 : 如何用sys as sysdba权限连接数据库进行EXP/IMP

使用sys as sysdba权限进行EXP/IMP与其它用户稍有不同,详细内容如下(摘自metalink)

Applies to: 

Oracle Server - Enterprise Edition - Version: 8.1.7.0 to 10.2.0.0
Oracle Server - Personal Edition - Version: 8.1.7.0 to 10.2.0.0
Oracle Server - Standard Edition - Version: 8.1.7.0 to 10.2.0.0
Information in this document applies to any platform. Goal This document demonstrates how to connect AS SYSDBA when starting an export or import. Incorrect usage of single or double quotes can result in errors such as: LRM-: invalid positional parameter value 'as'
EXP-: failed to process parameters, type 'EXP HELP=Y' for help
EXP-: Export terminated unsuccessfully Or: LRM-: invalid positional parameter value 'sysdba' Or: LRM-: Message not found; No message file for product=ORACORE, facility=LRM Solution SYSDBA is used internally in the Oracle database and has specialized functions. Its behavior is not the same as for generalized users. For example, the SYS user cannot do a transaction level consisent read (read-only transaction). Queries by SYS will return changes made during the transaction even if SYS has set the transaction to be READ ONLY. Therefore export parameters like CONSISTENT, OBJECT_CONSISTENT, FLASHBACK_SCN, and FLASHBACK_TIME cannot be used.
Starting with Oracle10g, the export shows a warning that the export is not consistent when the export is started with CONSISTENT=Y and connects to the database with the user SYS (or as SYSDBA): EXP-: parameter CONSISTENT is not supported for this user Note that Oracle automatically provides read consistency to a query so that all the data that the query sees comes from a single point in time (statement-level read consistency). For export this means that the export of table data is consistent. However, if a table contains nested tables, the outer table and each inner table are exported as separate transactions. And if a table is partitioned, each partition is exported as a separate transaction. If a nested table or a partitioned table was updated during the export, the data that is exported while connected as the SYS schema could be inconsistent. Typically, there is no need to invoke Export or Import as SYSDBA, except in the following situations:
- at the request of Oracle technical support;
- when exporting a transportable tablespace set with the old-style export utility (Oracle9i and Oracle8i);
- when importing a transportable tablespace set with the old-style import utility (Oracle10g, Oracle9i, and Oracle8i). The examples below are based on:
- the export of table emp, owned by the demo schema scott.
- schema SYS with the password: change_on_install.
- alias 'instance' that is specified in the tnsnames.ora file and used for a connect to the database. To invoke Export or Import as SYSDBA, use the following syntax (this syntax is similar when invoking import and the syntax has not changed with the new Oracle10g Export DataPump and Import DataPump utilities): . Command line.
Enclose the connect string with a single quote character: Windows:
exp 'sys/change_on_install@instance as sysdba' tables=scott.emp Unix (you need to 'escape' the single quote):
exp \'sys/change_on_install@instance as sysdba\' tables=scott.emp VMS (use [double_quote][single_quote]...[single_quote][double_quote]):
exp "'sys/change_on_install@instance as sysdba'" tables=scott.emp Note that this VMS syntax is also a valid syntax on Unix and on Windows. . Interactive
Do not specify any connect string on the command line, so you will be prompted to enter it. E.g.: % exp tables=scott.emp Export: Release 10.1.0.2. - Production on Fri Jun ::
Copyright (c) , , Oracle. All rights reserved. Username: sys/change_on_install@instance as sysdba Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2. - 64bit Production
... etc. . Parameter file.
You can also specify the username in the parameter file. In this situation, you have to enclose the connect string with a double quote character. However, to prevent possible security breaches we advice you to stop using the USERID parameter in a parameter file. Contents of file exp.par: USERID="sys/change_on_install@instance as sysdba"
TABLES=scott.emp Run export with: exp parfile=exp.par Remarks: . If you have setup operating system authentication, it is not necessary to specify the SYS schema name, and password. E.g: exp "'/@instance as sysdba'" tables=scott.emp . In addition, if you have set the environment variable TWO_TASK (on Unix) or LOCAL (on Windows) or on the server where the database is installed you have set ORACLE_HOME and ORACLE_SID, it is not necessary to specify the @instance. E.g: exp "'/ as sysdba'" tables=scott.emp . The export parameters FLASHBACK_SCN and FLASHBACK_TIME cannot be used if the user that invoked the export is connected AS SYSDBA. . Known issues:
Bug "EXPORT FAILED WITH ORA-1031 WHEN LOGIN AS SYSDBA" (not a public bug; fixed in 8.1.7.3 and higher)
Bug "ORA-1925 OCCURS WHEN IMPORTING AS SYS ACCOUNT"
Bug "EXP DID NOT RAISE ERROR WHEN SYSDBA EXPORTS WITH CONSISTENT=Y" (not a public bug; fixed in Oracle10g and higher) References Bug - Ora- Occurs When Importing As Sys Account
Note 112269.1 - How to set Unix env. variable TWO_TASK and Windows NT counterpart, LOCAL
Note 130332.1 - Export / Import Connecting "AS SYSDBA" Fails with LRM- and EXP-
Note 204334.1 - Parameters FLASHBACK_SCN And FLASHBACK_TIME: Point In Time Export
Note 228482.1 - Schema's CTXSYS, MDSYS and ORDSYS are Not Exported
Note 277606.1 - How to Prevent EXP- or EXP- Warning (Data in Table xxx is Protected) During Export

####expdp

expdp \' / as sysdba \' directory=DATA_PUMP_DIR dumpfile=tpsp20121126.dmp logfile=tpsp20121126.log tables= scott.emp,scott.dept

impdp \' / as sysdba \'  directory=DATA_PUMP_DIR dumpfile=tpsp20121126.dmp logfile=imptpsp20121126.log remap_schema=SCOTT:SCOTT1

上一篇:面试官:亿级流量架构分布式事务如何实现?我懵了。。


下一篇:python 移动文件夹