検索
ホームページデータベースmysql チュートリアル如何用sys as sysdba权限连接数据库进行Exp/Imp

如何用sys as sysdba权限连接数据库进行Exp/Imp

Jun 07, 2016 pm 03:47 PM
expsysデータベース権限行為接続する

如何用sys as sysdba权限连接数据库进行Exp/Imp Windows: exp 'sys/change_on_install@instance as sysdba' tables=scott.emp Unix or Linux (you need to 'escape' the single quote): exp /'sys/change_on_install@instance as sysdba/' tables=scott.emp

如何用sys as sysdba权限连接数据库进行Exp/Imp




Windows:
exp 'sys/change_on_install@instance as sysdba' tables=scott.emp

 

Unix or Linux (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



小结:

1、USERID 必须是命令行中的第一个参数。(如imp help=y里显示的内容)

所以如exp ‘ as sysdba’等价于exp  USERID=‘as sysdba’,即可以省略USERID不写。


2、imp/exp命令里参数与参数间的间隔是用空格来区分的(等号两边的空格不算),于是像如下语句:exp  USERID= sys/123456 as sysdba就不能被imp/exp工具所理解(参数USERID= sys/123456可以解析出来,但是as sysdba不知道如何理解了,as或sysdba又不属于设定的参数名)。而oracle公司设计的软件里一般用单引号将一字符串常量包括起来。将上面语句改为exp  USERID= ’sys/123456 as sysdba‘的话,imp/exp工具就认为sys/123456 as sysdba整体是一个字符串,故而就是参数USERID的一个值。



3.
如果是写在参数文件中,则连接字符串需要用双引号了:

    USERID=" as sysdba"  

 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

注释:imp/exp(

impdp/expdp

)默认目录是什么,即parfile=exp.par里的文件exp.par在什么目录下?
附加:

impdp/expdp

)默认目录是什么

(5)、数据泵如何决定文件的路径

5.1 如果目录对象是文件标示符的一部分,那么目录对象指定的路径就需要使用。在目录MY_DIR创建dump文件的示例:

> expdp scott/tiger DUMPFILE=my_dir:expdp_s.dmp NOLOGFILE=Y

5.2 如果目录对象不代表一个文件,那么就需要使用DIRECTORY变量命名的目录对象。目录MY_DIR中创建dump文件,目录MY_DIR_LOG中创建日志文件的示例:

> expdp scott/tiger DIRECTORY=my_dir DUMPFILE=expdp_s.dmp \ 
LOGFILE=my_logdir:expdp_s.log

5.3 如果没有明确目录对象,也没有以DIRECTORY变量命名的目录对象,那么环境变量DATA_PUMP_DIR将会使用。环境变量是在在运行导出和导入数据泵应用的客户端系统中使用操作系统命令定义的,分配给基于客户端环境变量的取值必须和基于服务端的目录对象一致,且必须首先在服务器端建立

目录MY_DIR中创建dump文件和MY_DIR_LOG中创建日志文件的示例:

在使用expdp的客户端机器上,设定环境变量:

-- On windows, place all expdp parameters on one single line:

C:\> set DATA_PUMP_DIR=MY_DIR  
C:\> expdp scott/tiger@my_db_alias DUMPFILE=expdp_s.dmp 
LOGFILE=my_logdir:expdp_s.log

注意环境变量DATA_DUMP_DIR对应的目录名称是大小写敏感的。设定错误的DATA_PUMP_DIR环境变量会报错,例如:DATA_PUMP_DIR=My_Dir:

ORA-39002: invalid operation 
ORA-39070: Unable to open the log file. 
ORA-39087: directory name My_Dir is invalid

5.4 如果之前三种情况都没有创建目录对象,作为一个具有权限的用户(例如具有EXP_FULL_DATABASE或IMP_FULL_DATABASE角色),那么数据泵试图使用默认的基于服务器端的目录对象,DATA_PUMP_DIR。理解数据泵不会创建DATA_PUMP_DIR目录对象是非常重要的。仅当授权用户未使用任何之前提到的机制创建的目录对象时,才会尝试使用DATA_PUMP_DIR。这个默认的目录对象必须首先由DBA创建。不要将这个和同名的基于客户端的环境变量相混淆。

首先,清空DATA_PUMP_DIR环境变量:

C:\> set DATA_PUMP_DIR=

创建DATA_PUMP_DIR的目录:

CONNECT SYSTEM/MANAGER   
CREATE OR REPLACE DIRECTORY data_pump_dir AS 'D:\DataPump';   
GRANT read, write ON DIRECTORY data_pump_dir TO scott;

-- On windows, place all expdp parameters on one single line: 

C:\> expdp system/manager@my_db_alias DUMPFILE=expdp_s.dmp  
LOGFILE=expdp_s.log SCHEMAS=scott

如果SCOTT用户不是授权用户,不能使用默认的DATA_PUMP_DIR。

ORA-39002: invalid operation 
ORA-39070: Unable to open the log file. 
ORA-39145: directory object parameter must be specified and non-null

用户SCOTT的解决方法:如上面5.3,SCOTT可以设置环境变量DATA_PUMP_DIR为MY_DIR:

-- On windows, place all expdp parameters on one single line:

C:\> set DATA_PUMP_DIR=MY_DIR
C:\> expdp scott/tiger@my_db_alias DUMPFILE=expdp_s.dmp 
LOGFILE=expdp_s.log SCHEMAS=scott

或者这种特定场景下,用户SCOTT也可以有目录DATA_PUMP_DIR的读和写权限:

-- On windows, place all expdp parameters on one single line: 

C:\> set DATA_PUMP_DIR=DATA_PUMP_DIR
C:\> expdp scott/tiger@my_db_alias DUMPFILE=expdp_s.dmp 
LOGFILE=expdp_s.log SCHEMAS=scott


参考:http://blog.csdn.net/bisal/article/details/24667609




=============================================

Oracle exp备份使用sysdba进行导出和导入的操作

2010-03-29 16:16 佚名 博客园 字号:T | T

如何用sys as sysdba权限连接数据库进行Exp/Imp

如果你在Oracle exp备份的实际应用方面,你是否存在一些不解之处,以下的文章主要是通过对Oracle exp备份的实际应用的。 方案的介绍,来解答你在@@@@@@在实际操作方面的问题。

AD:51CTO学院:IT精品课程在线看!

我们在一些相关的书籍或是网上的相关资料对Oracle exp备份(导出/导入备份)使用sysdba进行导出和导入的实际操作步骤都有相关的介绍,以下的文章就对Oracle exp备份的实际操作步骤的本人的idea。

1. 命令行方式:

A: Windows平台:

C:

<ol><li><span><span>\</span><span>></span><span> exp<span><strong> ‘</strong></span>as sysdba' </span><span>tables</span><span>=</span><span>scott</span><span>.emp </span><span>file</span><span>=e:\emp.dmp  </span></span></li></ol>

B: Unix & Linux平台(这时的"'"需要用到转义字符"\"):

<ol><li><span><span>$ exp \'sys/change_on_install@instance as sysdba\<br>' </span><span>tables</span><span>=</span><span>scott</span><span>.emp </span><span>file</span><span>=/home/oracle/emp.dmp </span></span></li></ol>

C:Oracle exp备份(导出/导入备份)使用sysdba进行导出和导入时。你需要在表空间导入和导出

<ol>
<li><span><span>$ imp \'usr/pwd@instance as sysdba\'<br> </span><span>tablespaces</span><span>=</span><span>xx</span><span> </span><span>transport_tablespace</span><span>=</span><span>y</span><span> </span></span></li>
<li>
<span>file</span><span>=</span><span>xxx</span><span>.dmp </span><span>datafiles</span><span>=</span><span>xxx</span><span>.dbf </span>
</li>
</ol>

2. 交互输入方式: exp tables=scott.emp --不输入连接字符串,直接回车

<ol><li><span><span>Export: Release 10.2.0.3.0 - Production on Fri<br> Jun 25 07:39:46 2004 Copyright (c) 1982, 2005,<br> Oracle. All rights reserved. </span></span></li></ol>

Username: as sysdba --输入连接字符串.

3.如果是写在参数文件中,则连接字符串需要用双引号了:

<ol><li><span><span><span>USERID</span><span>=</span><span>" as sysdba"</span><span>  </span></span></span></li></ol>

以上就是对Oracle exp备份(导出/导入备份)使用sysdba进行导出和导入相关的内容的介绍,望你会有所收获。

【编辑推荐】

  1. 3月第4周要闻回顾:Chrome续写传奇 Oracle舍我其谁
  2. Oracle宣布GlassFish路线图 定位为“部门内部”使用
  3. Oracle优化CPU使用的实际操作方案详解
  4. Oracle Spatial 与 ArcSDE在实际应用中的区别
  5. Oracle Spatial在实际应用中的六大功能体现

 ============================================================

 如何用sys as sysdba权限连接数据库进行EXP/IMP 2008-07-01 08:55:36

分类: Oracle

使用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-00108: invalid positional parameter value 'as'
EXP-00019: failed to process parameters, type 'EXP HELP=Y' for help
EXP-00000: Export terminated unsuccessfully

Or:

LRM-00108: invalid positional parameter value 'sysdba'

Or:

LRM-00108: Message 108 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-00105: 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):

1. 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.


2. 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.0 - Production on Fri Jun 25 07:39:46 2004
Copyright (c) 1982, 2004, Oracle. All rights reserved.

Username: sys/change_on_install@instance as sysdba

Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit Production
... etc.


3. 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:


1. 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

2. 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

3. The export parameters FLASHBACK_SCN and FLASHBACK_TIME cannot be used if the user that invoked the export is connected AS SYSDBA.

4. Known issues:
Bug 1616035 "EXPORT FAILED WITH ORA-1031 WHEN LOGIN AS SYSDBA" (not a public bug; fixed in 8.1.7.3 and higher)
Bug 2936288 "ORA-1925 OCCURS WHEN IMPORTING AS SYS ACCOUNT"
Bug 2996947 "EXP DID NOT RAISE ERROR WHEN SYSDBA EXPORTS WITH CONSISTENT=Y" (not a public bug; fixed in Oracle10g and higher)

References

Bug 2936288 - Ora-1925 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-00108 and EXP-00019
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-00079 or EXP-00080 Warning (Data in Table xxx is Protected) During Export


参考:exp sysdba     百度


声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
MySQLのデータベースアップグレードをどのように処理しますか?MySQLのデータベースアップグレードをどのように処理しますか?Apr 30, 2025 am 12:28 AM

MySQLデータベースをアップグレードする手順には次のものがあります。1。データベースをバックアップします。2。現在のMySQLサービスを停止します。3。MySQLの新しいバージョンをインストールします。アップグレードプロセス中に互換性の問題が必要であり、Perconatoolkitなどの高度なツールをテストと最適化に使用できます。

MySQLに使用できるさまざまなバックアップ戦略は何ですか?MySQLに使用できるさまざまなバックアップ戦略は何ですか?Apr 30, 2025 am 12:28 AM

MySQLバックアップポリシーには、論理バックアップ、物理バックアップ、増分バックアップ、レプリケーションベースのバックアップ、クラウドバックアップが含まれます。 1. Logical BackupはMySqldumpを使用してデータベースの構造とデータをエクスポートします。これは、小さなデータベースとバージョンの移行に適しています。 2.物理バックアップは、データファイルをコピーすることで高速かつ包括的ですが、データベースの一貫性が必要です。 3.インクリメンタルバックアップは、バイナリロギングを使用して変更を記録します。これは、大規模なデータベースに適しています。 4.レプリケーションベースのバックアップは、サーバーからバックアップすることにより、生産システムへの影響を減らします。 5. Amazonrdsなどのクラウドバックアップは自動化ソリューションを提供しますが、コストと制御を考慮する必要があります。ポリシーを選択するときは、データベースサイズ、ダウンタイム許容度、回復時間、および回復ポイントの目標を考慮する必要があります。

MySQLクラスタリングとは何ですか?MySQLクラスタリングとは何ですか?Apr 30, 2025 am 12:28 AM

mysqlclusteringenhancesdatabaserobustnessnessnessnessnessnistandistributiondistributingdataacrossmultiplenodes.itesthendbenginefordatareplication andfaulttolerance、保証highavailability.setupinvolvesconfiguringmanagement、data、ssqlnodes、carefulmonitoringringandpe

MySQLのパフォーマンスのためにデータベーススキーマ設計を最適化するにはどうすればよいですか?MySQLのパフォーマンスのためにデータベーススキーマ設計を最適化するにはどうすればよいですか?Apr 30, 2025 am 12:27 AM

MySQLのデータベーススキーマ設計の最適化は、次の手順を通じてパフォーマンスを改善できます。1。インデックス最適化:一般的なクエリ列にインデックスを作成し、クエリのオーバーヘッドのバランスをとり、更新を挿入します。 2。テーブル構造の最適化:正規化または反通常化によりデータ冗長性を削減し、アクセス効率を改善します。 3。データ型の選択:Varcharの代わりにINTなどの適切なデータ型を使用して、ストレージスペースを削減します。 4。パーティション化とサブテーブル:大量のデータボリュームの場合、パーティション化とサブテーブルを使用してデータを分散させてクエリとメンテナンスの効率を改善します。

MySQLのパフォーマンスをどのように最適化できますか?MySQLのパフォーマンスをどのように最適化できますか?Apr 30, 2025 am 12:26 AM

tooptimizemysqlperformance、soflowthesesteps:1)properindexingtospeedupqueries、2)useexplaintoanalyzeandoptimize Queryperformance、3)AductServerContingSettingStingsinginginnodb_buffer_pool_sizeandmax_connections、4)

データ処理と計算にMySQL関数を使用する方法データ処理と計算にMySQL関数を使用する方法Apr 29, 2025 pm 04:21 PM

MySQL関数は、データ処理と計算に使用できます。 1.基本的な使用には、文字列処理、日付計算、数学操作が含まれます。 2。高度な使用法には、複数の関数を組み合わせて複雑な操作を実装することが含まれます。 3.パフォーマンスの最適化では、Where句での機能の使用を回避し、GroupByおよび一時テーブルを使用する必要があります。

MySQLにデータを挿入する効率的な方法MySQLにデータを挿入する効率的な方法Apr 29, 2025 pm 04:18 PM

MySQLでデータを挿入するための効率的な方法には、次のものが含まれます。1。insertInto ...値構文、2。LoadDatainFileコマンドの使用、3。トランザクション処理の使用、4。バッチサイズの調整、5。Insurtignoreまたは挿入の使用...

フィールドをMySQLテーブルに追加および削除する手順フィールドをMySQLテーブルに追加および削除する手順Apr 29, 2025 pm 04:15 PM

MySQLでは、AlterTabletable_nameaddcolumnnew_columnvarchar(255)afterexisting_columnを使用してフィールドを追加し、andtabletable_namedopcolumncolumn_to_dropを使用してフィールドを削除します。フィールドを追加するときは、クエリのパフォーマンスとデータ構造を最適化する場所を指定する必要があります。フィールドを削除する前に、操作が不可逆的であることを確認する必要があります。オンラインDDL、バックアップデータ、テスト環境、および低負荷期間を使用したテーブル構造の変更は、パフォーマンスの最適化とベストプラクティスです。

See all articles

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

Video Face Swap

Video Face Swap

完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

ホットツール

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

AtomエディタMac版ダウンロード

AtomエディタMac版ダウンロード

最も人気のあるオープンソースエディター

SecLists

SecLists

SecLists は、セキュリティ テスターの究極の相棒です。これは、セキュリティ評価中に頻繁に使用されるさまざまな種類のリストを 1 か所にまとめたものです。 SecLists は、セキュリティ テスターが必要とする可能性のあるすべてのリストを便利に提供することで、セキュリティ テストをより効率的かつ生産的にするのに役立ちます。リストの種類には、ユーザー名、パスワード、URL、ファジング ペイロード、機密データ パターン、Web シェルなどが含まれます。テスターはこのリポジトリを新しいテスト マシンにプルするだけで、必要なあらゆる種類のリストにアクセスできるようになります。

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

EditPlus 中国語クラック版

EditPlus 中国語クラック版

サイズが小さく、構文の強調表示、コード プロンプト機能はサポートされていません