Table of Contents
Applies to:
Goal
Solution
References
Home Database Mysql Tutorial 如何用sys as sysdba权限连接数据库进行Exp/Imp

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

Jun 07, 2016 pm 03:47 PM
exp sys database Permissions conduct connect

如何用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>
Copy after login

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>
Copy after login

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>
Copy after login

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>
Copy after login

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

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

<ol><li><span><span><span>USERID</span><span>=</span><span>" as sysdba"</span><span>  </span></span></span></li></ol>
Copy after login

以上就是对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     百度


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Enable root permissions with one click (quickly obtain root permissions) Enable root permissions with one click (quickly obtain root permissions) Jun 02, 2024 pm 05:32 PM

It allows users to perform more in-depth operations and customization of the system. Root permission is an administrator permission in the Android system. Obtaining root privileges usually requires a series of tedious steps, which may not be very friendly to ordinary users, however. By enabling root permissions with one click, this article will introduce a simple and effective method to help users easily obtain system permissions. Understand the importance and risks of root permissions and have greater freedom. Root permissions allow users to fully control the mobile phone system. Strengthen security controls, customize themes, and users can delete pre-installed applications. For example, accidentally deleting system files causing system crashes, excessive use of root privileges, and inadvertent installation of malware are also risky, however. Before using root privileges

How does Go language implement the addition, deletion, modification and query operations of the database? How does Go language implement the addition, deletion, modification and query operations of the database? Mar 27, 2024 pm 09:39 PM

Go language is an efficient, concise and easy-to-learn programming language. It is favored by developers because of its advantages in concurrent programming and network programming. In actual development, database operations are an indispensable part. This article will introduce how to use Go language to implement database addition, deletion, modification and query operations. In Go language, we usually use third-party libraries to operate databases, such as commonly used sql packages, gorm, etc. Here we take the sql package as an example to introduce how to implement the addition, deletion, modification and query operations of the database. Assume we are using a MySQL database.

How does Hibernate implement polymorphic mapping? How does Hibernate implement polymorphic mapping? Apr 17, 2024 pm 12:09 PM

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

An in-depth analysis of how HTML reads the database An in-depth analysis of how HTML reads the database Apr 09, 2024 pm 12:36 PM

HTML cannot read the database directly, but it can be achieved through JavaScript and AJAX. The steps include establishing a database connection, sending a query, processing the response, and updating the page. This article provides a practical example of using JavaScript, AJAX and PHP to read data from a MySQL database, showing how to dynamically display query results in an HTML page. This example uses XMLHttpRequest to establish a database connection, send a query and process the response, thereby filling data into page elements and realizing the function of HTML reading the database.

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

Introduction to how to set everyone permissions on win7 computer Introduction to how to set everyone permissions on win7 computer Mar 26, 2024 pm 04:11 PM

1. Take e-disk as an example. Open [Computer], and click [eDisk], right-click [Properties]. As shown in the figure: 2. In the [Window] page, switch the interface to the [Security] option, and click the [Edit] option below. As shown in the figure: 3. In the [Permissions] option, click the [Add] option. As shown in the figure: 4. The users and groups window pops up and click the [Advanced] option. As shown in the figure: 5. Click to expand the [Find Now] - [Everyone] options in order. When completed, click OK. As shown in the figure: 6. When you see that the user [everyone] has been added to [Group or User] on the [E Disk Permissions] page, select [everyone] and check the box in front of [Full Control]. After the setting is completed, Just press [OK]

See all articles