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
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
你如果旧库的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用户的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。
成都创新互联科技有限公司,是一家专注于互联网、IDC服务、应用软件开发、网站建设推广的公司,为客户提供互联网基础服务!
创新互联(www.cdcxhl.com)提供简单好用,价格厚道的香港/美国云服务器和独立服务器。创新互联——四川成都IDC机房服务器托管/机柜租用。为您精选优质idc数据中心机房租用、服务器托管、机柜租赁、大带宽租用,高电服务器托管,算力服务器租用,可选线路电信、移动、联通机房等。
分享文章:IMP导入操作:将数据库数据成功导入sys用户(imp数据库导入sys用户)
链接地址:http://www.shufengxianlan.com/qtweb/news13/391713.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联