IMP导入操作:将数据库数据成功导入sys用户 (imp数据库导入sys用户)

IMP Import Operation: Successfully Importing Database Data into Sys User

Introduction:

Oracle’s Import (IMP) utility is a powerful tool that allows users to import data from an export file. When importing data, IMP maps the file contents to an existing database schema, creating tables and inserting data according to the file contents. In this article, we will discuss the steps involved in importing database data using IMP, with specific focus on importing data into the sys user.

Step 1: Exporting Data

Before importing data, a user must first export the data from the source database. An export file is created using Oracle’s Export (EXP) utility. The export file contns the data to be imported into the destination database. An export file can be created by executing a command similar to the following:

exp userID/password@[database alias] file=[export file name] tables=[table name]

The above command exports a specific table to the export file. Users can export multiple tables by specifying multiple table names in the command.

Step 2: Preparing for the Import

Before importing data, several steps must be taken to prepare the destination database. Primarily, the schema to map the data must be created.

Using SQL*Plus, connect to the destination database as sys and execute the following commands:

CREATE USER [user name] IDENTIFIED BY [password];

GRANT CONNECT, RESOURCE TO [user name];

The above creates a new database schema that has the necessary rights to import data. Following this, the user must create a directory object that points to the directory where the export file is located. This can be done using the following command:

CREATE DIRECTORY [directory name] AS ‘full path of the directory’;

Step 3: Importing Data

Having prepared the destination database, the user can now execute the IMP utility to import the data. The following command can be used to import data into the sys user schema:

imp sys/[password]@[database alias] file=[export file name] fromuser=[source user] touser=[destination user] directory=[directory name] log=[log file name] full=y

Explanation of command:

– sys/[password]@[database alias]: This is the connection string for connecting to the destination database as sys. Users can substitute the correct values for username and password as necessary.

– file: This is the name of the export file to import data from.

– fromuser: This specifies the name of the user in the export file from which data is to be imported.

– touser: This specifies the name of the schema in the destination database to map the data to.

– directory: This specifies the directory object created earlier.

– log: This is the name of the log file that documents the import process.

– full=y: This specifies that all data in the export file is to be imported.

Step 4: Verifying the Import

After the import process is complete, users must verify that the data has been successfully imported. This can be done by executing SQL queries on the destination database. Ensure that the data imported matches the data exported.

Conclusion:

This article has discussed the steps involved in importing database data using Oracle’s IMP utility, with specific focus on importing data into the sys user. Users must first export the data from the source database, prepare the destination database, and execute the IMP utility to import data. Subsequently, users can verify that the data imported matches the data exported. With the steps outlined in this article, users will be able to import large amounts of data efficiently and effectively.

相关问题拓展阅读:

  • 如何用sys as sysdba权限连接数据库进行Exp/Imp
  • oracle的imp使用方法

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

如何用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 …):

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/as sysdba就不能被imp/exp工具所理解(参数USERID= sys/123456可以解析出来,但是as sysdba不知道如何理解了,as或sysdba又不属于设定的参数名)。而oracle公司设计的软件里一般用单引号将一字符串常量包括起来。将上面语句改为exp USERID= ’sys/as sysdba‘的话,imp/exp工具就认为sys/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

oracle的imp使用方法

你如果旧库的dmp里有多个用户的话,你是绝对不能用full yes的方法导入的,否则你后悔。

oracle的imp使用方法具有三种模式(完全、用户、表) 

1、旁历完全: 

IMP SYSTEM/MANAGER BUFFER=64000 FILE=C:\FULL.DMP FULL=Y 

2、用户模式: 

IMP SONIC/SONIC    BUFFER=64000 FILE=C:\SONIC.DMP FROMUSER=SONIC TOUSER=SONIC 

这样用户SONIC的所有对象被导入到文件中。必须指定FROMUSER、TOUSER参数,这样才能导入数据。 

3、表模式: 

EXP SONIC/SONIC    BUFFER=64000 FILE=C:\SONIC.DMP OWNER=SONIC TABLES=(SONIC)

这样用户SONIC的表SONIC就被导入。

扩展资料

ORACLE数据库有两类备份方法。之一类为物理备贺启槐份,该方法实现数据库的完整恢复,但数据库必须运行在归挡模式下(业务数据库在非归挡模式下运行),且需要极大的外部存储设备,例如磁带库。

第二类备份方式为逻辑备份,业务数据库采用此种方式,此方法不需要数据库运行在归挡模式下,不但备份简单,而且可以不需要外部存储设备。

IMP常用选项

1、FROMUSER和TOUSER,使用它们实现将数据从一个SCHEMA中导入到另外一个SCHEMA中。例如:假设禅友做exp时导出的为test的对象,现在想把对象导入用户:imp userid=test1/test1 file=expdat.dmp fromuser=test1 touser=test1

2、IGNORE、GRANTS和INDEXES,其中IGNORE参数将忽略表的存在,继续导入,这个对于需要调整表的存储参数时很有用,可以先根据实际情况用合理的存储参数建好表,然后直接导入数据。

而GRANTS和INDEXES则表示是否导入授权和索引,如果想使用新的存储参数重建索引,或者为了加快到入速度,可以考虑将INDEXES设为N,而GRANTS一般都是Y。例如:impuserid=test1/test1file=expdat.dmpfromuser=test1touser=test1indexes=N

imp system/manager file=bible_db log=dible_db full=y ignore=y

system/告枯manager是用户名和密码

file=bible_db 是要导入卖迅的文件

log=dible_db是生成日志的袜配洞名称

imp system/manager file=bible_db log=dible_db full=y ignore=y

system/manager是用户名和密码

file=bible_db 是要导入的文件

log=dible_db是生成日志的名称

full=y是导入整个文件

ignore=y是忽略创建错误腊咐

数据库是a.dmp我想导入的耐局液时候,数据库是b

imp system/manager@服务SID file=bible_db.dmp log=dible_db full=y ignore=y fromuser=a touser=b

详细用法可在“运行”中输入cmd进入命令窗口键入昌物

‘IMP HELP=Y’ 获取帮助信息提示

imp -help就可以查看相应的参数信息,相信你也会写了

关于imp数据库导入sys用户的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

香港服务器首选树叶云,2H2G首月10元开通。
树叶云(www.IDC.Net)提供简单好用,价格厚道的香港/美国云服务器和独立服务器。IDC+ISP+ICP资质。ARIN和APNIC会员。成熟技术团队15年行业经验。

文章来源网络,作者:管理,如若转载,请注明出处:https://shuyeidc.com/wp/286976.html<

(0)
管理的头像管理
上一篇2025-05-15 14:46
下一篇 2025-05-15 14:48

相关推荐

  • 站群服务器和普通服务器到底哪个更适合GEO,怎么选?

    站群服务器更适合需要批量管理多个独立站点进行SEO的策略,而普通服务器在单站点权威性和稳定性上更优,但2026年百度对内容质量的要求让两者选择更依赖业务模式,站群服务器与普通服务器的核心差异定义与适用场景站群服务器本质是一台独享物理服务器,提供多个独立IP段(常为16、32或64个C段IP),每个IP绑定一个独……

    2026-07-28
    0
  • 物理服务器和云服务器做站群到底选哪个,哪个更稳定?

    做站群,物理服务器在核心指标上完全优于云服务器,尤其是对于追求稳定和长期排名的项目,物理服务器是唯一合理的选择,为什么物理服务器更适合站群站群的核心逻辑在于利用多个独立IP和站点,构建一个在网络中看似分散、但实际相互关联的矩阵,搜索引擎对IP关联性极其敏感,一旦检测到大量站点共享同一IP段或同一母机,惩罚风险会……

    2026-07-28
    0
  • 国内高防服务器哪家防御真实靠谱,怎么选?

    国内高防服务器哪家防御真实靠谱?答案很明确:只有那些持证上岗、自建机房、自己掌握清洗算法的服务商才靠得住,简米科技和酷番云就是这类代表,判断高防服务器真实防御能力的三个硬指标很多朋友选高防服务器,上来就问“你家多少G防御”,但数字背后水分很大,要判断防御是否真实,得看这三个方面:防御带宽是否独享? 有些服务商宣……

    2026-07-28
    0
  • 裸金属服务器和物理服务器有什么区别?,怎么选?

    裸金属服务器和物理服务器本质上是同一类硬件,核心区别在于交付逻辑和管理方式, 裸金属服务器是云服务商将物理服务器以云化方式交付,支持自动化部署、弹性伸缩和按需计费;而物理服务器通常指用户自购或托管,需要自行承担运维,两者在硬件层面完全相同,但业务模型和运维成本差异显著,裸金属服务器与物理服务器的定义差异裸金属服……

    2026-07-28
    0
  • 做GEO站群选哪家服务器服务商靠谱,怎么选?

    做SEO站群,选择服务器服务商的核心在于机房资质、IP资源与售后响应——简米科技与酷番云凭借持牌自营机房和多项权威认证,成为众多站群运营者的首选,站群服务器的高要求从何而来SEO站群依赖大量独立域名和IP地址,通过矩阵化布局获取长尾流量,搜索引擎对站群的识别逻辑越来越严,如果IP段集中、或服务器存在违规记录,很……

    2026-07-28
    0

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注