exp & imp 的一些小心得

本文记录了使用Oracle数据库的exp&imp工具进行数据备份和恢复的过程。遇到的问题包括权限不足导致无法导入数据,以及如何正确设置参数以确保数据能够被正确导入到指定用户下。

     今天试着用exp&imp备份及恢复文件。

      具体用法我就不多说了,我只是想说一下,imp时的权限问题。

      先用exp备份

SQL> ho exp cyco/hummer2008

Export: Release 
10.2.0.1.0 - Production on Thu Mar 6 23:01:10 2008

Copyright (c) 
19822005, Oracle.  All rights reserved.


Connected 
to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Produc
tion
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engin
e options
Enter array 
fetch buffer size: 4096 >

Export 
file: EXPDAT.DMP > H:/Databases/oracle/Backup/init_cyco.dmp//优快云居然把/解释成了转义符

(
2)U(sers), or (3)T(ables): (2)U > t

Export 
table data (yes/no): yes >

Compress extents (yes
/no): yes >

Export done 
in ZHS16GBK character set and AL16UTF16 NCHAR character set

About 
to export specified tables via Conventional Path ...
Table(T) or Partition(T:P) to be exported: (RETURN to quit) > users

. . exporting 
table                          USERS          2 rows exported
Table(T) or Partition(T:P) to be exported: (RETURN to quit) >

Export terminated successfully without warnings.

再执行      

SQL> ho imp cyco/hummer2008

Import: Release 
10.2.0.1.0 - Production on Thu Mar 6 21:55:39 2008

Copyright (c) 
19822005, Oracle.  All rights reserved.


Connected 
to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Produc
tion
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engin
e options

Import 
file: EXPDAT.DMP > H:/Databases/oracle/Backup/init_cyco.dmp

Enter 
insert buffer size (minimum is 819230720>

Export 
file created by EXPORT:V10.02.01 via conventional path
import done 
in ZHS16GBK character set and AL16UTF16 NCHAR character set
List contents 
of import file only (yes/no): no >

Ignore 
create error due to object existence (yes/no): no > yes

Import grants (yes
/no): yes >

Import 
table data (yes/no): yes >

Import entire export 
file (yes/no): no >
Username: cyco

Enter 
table(T) or partition(T:P) names. Null list means all tables for user
Enter 
table(T) or partition(T:P) name or . if done: users

Enter 
table(T) or partition(T:P) name or . if done:

. importing CYCO
's objects into CYCO
. importing CYCO
's objects into CYCO
IMP
-00017: following statement failed with ORACLE error 1031:
 "
CREATE TABLE "USERS" ("USERNAME" VARCHAR2(10NOT NULL ENABLE)  PCTFREE 10 "
 "PCTUSED 
40 INITRANS 1 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELI"
 "ST GROUPS 
1 BUFFER_POOL DEFAULT) TABLESPACE "ALASKA" LOGGING NOCOMPRESS"
IMP
-00003: ORACLE error 1031 encountered
ORA
-01031: insufficient privileges
Import terminated successfully 
with warnings.

 

从ORA-01031: insufficient privileges看出是没有权限,怎么会对自己份备的表没有权限呢?(这个问题想问下大家的!!!明明导出时选好了grant >yes)

ORA-01031: insufficient privileges

接着用sys用户来备份,代码如下:

SQL> ho imp 'sys/hummer2008 as sysdba'

Import: Release 
10.2.0.1.0 - Production on Thu Mar 6 21:58:07 2008

Copyright (c) 
19822005, Oracle.  All rights reserved.


Connected 
to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Produc
tion
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engin
e options

Import 
file: EXPDAT.DMP > H:/Databases/oracle/Backup/init_cyco.dmp

Enter 
insert buffer size (minimum is 819230720>

Export 
file created by EXPORT:V10.02.01 via conventional path

Warning: the objects were exported 
by CYCO, not by you

import done 
in ZHS16GBK character set and AL16UTF16 NCHAR character set
List contents 
of import file only (yes/no): no >

Ignore 
create error due to object existence (yes/no): no > yes

Import grants (yes
/no): yes >

Import 
table data (yes/no): yes >

Import entire export 
file (yes/no): no >
Username: cyco

Enter 
table(T) or partition(T:P) names. Null list means all tables for user
Enter 
table(T) or partition(T:P) name or . if done: users

Enter 
table(T) or partition(T:P) name or . if done:

. importing CYCO
's objects into SYS
. importing CYCO
's objects into SYS
. . importing 
table                        "USERS"          2 rows imported
Import terminated successfully without warnings.

看来成功了,

SQL> select * from users;

no rows selected

怎么会没有记录呢?

细看上面的运行记录,importing CYCO's objects into SYS  原来,导入到sys用户下了。原来默认的touser参数就是运行imp的用户名,本例中是sys。

建议大家运行时用一整条命令的方法,最好以sys的身份运行,以免受错。

imp 'sys/hummer2008  as sysdba' fromuser=cyco touser=cyco rows=y indexes=commit=y buffer=65536 feedback=100000 ignore=file=H:/Databases/oracle/Backup/init_cyco.dmp log=H:/Databases/oracle/Backup/init_cyco.log tables=users

 

还有,网上找的一些命令中的 volsize=0 这个参数是不能用的,否则会提示
IMP-00022: failed to process parameters, type 'IMP HELP=Y' for help
IMP-00000: Import terminated unsuccessfully

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值