主题:
Oracle导入导出之大字段从10g导出并导入11g
作者:
基毛飞上天
场景:
今天有个客户跟我说:怎么将Oracle 10g的LOB表导出来,并导入到Oracle 11g。为什么无法使用IMPDP工具导入呢?
思路:
Oracle 10g 只有EXP/IMP工具。而EXP/IMP的工具都是一套的,所以,在Oracle 11g是不能使用IMPDP工具对EXP导出的DMP文件进行导入。
演示如下:
第一节:先在Oracle10g创建一个LOB表,然后通过EXP工具导出DMP文件。
第二节:把DMP文件传到Oracle11g的主机上,通过IMPDP工具测试导入。
第三节:Oracle11g通过IMP工具成功导入。
点击( 此处 )折叠或打开
SQL
>
conn hr
/
hr
Connected
.
SQL
>
CREATE
TABLE
MA_LOB_DUMP
(
n
NUMBER
,
c
CLOB
)
lob
(
c
)
STORE
AS
MA_SEG
(
TABLESPACE
users
CHUNK 4096
NOCACHE LOGGING
STORAGE
(
MAXEXTENTS
5
)
)
;
2 3 4 5 6
Table created .
点击( 此处 )折叠或打开
SQL
>
insert
into
MA_LOB_DUMP
values
(
1
,
'12'
)
;
1
row
created
.
SQL
>
insert
into
MA_LOB_DUMP
values
(
1
,
'123'
)
;
1
row
created
.
SQL
>
insert
into
MA_LOB_DUMP
values
(
2
,
'2345'
)
;
1
row
created
.
SQL
>
insert
into
MA_LOB_DUMP
values
(
3
,
'asdsada'
)
;
1
row
created
.
SQL
>
commit
;
Commit complete .
点击( 此处 )折叠或打开
SQL
>
select
*
from
MA_LOB_DUMP
;
N
C
---------- ----------------- ------ -
1 12
1 123
2 2345
3 asdsada
点击( 此处 )折叠或打开
SQL
>
select
TABLE_NAME
,
SEGMENT_NAME
,
TABLESPACE_NAME
from
user_lobs
where
table_name
=
'MA_LOB_DUMP'
;
TABLE_NAME SEGMENT_NAME TABLESPACE_NAME
----------------- ------------- ------------------------------
MA_LOB_DUMP MA_SEG USERS
点击( 此处 )折叠或打开
[
oracle
@
rhel
-
ORCL
dump
]
$
exp
hr
/
hr
file
=
/
home
/
oracle
/
dump
/
ora10gCLOB
.
dmp tables
=
MA_LOB_DUMP
Export
:
Release
10
.
2
.
.
1
.
0
-
Production
on
Wed Jan 24 16
:
30
:
25 2018
Copyright
(
c
)
1982
,
2005
,
Oracle
.
All
rights reserved
.
Connected
to
:
Oracle
Database
10g Enterprise Edition
Release
10
.
2
.
.
1
.
0
-
64bit Production
With
the Partitioning
,
OLAP
and
Data
Mining options
Export done
in
US7ASCII character
set
and
AL16UTF16 NCHAR character
set
server uses AL32UTF8 character
set
(
possible charset conversion
)
About
to
export specified tables via Conventional Path
.
.
.
.
.
exporting
table
MA_LOB_DUMP 4
rows
exported
Export terminated successfully without warnings
.
[
oracle
@
rhel
-
ORCL
dump
]
$
ls
ora10gCLOB
.
dmp
[ oracle @ rhel - ORCL dump ] $
6. 将dmp文件传到Oracle11g的主机上,创建目录对象,并对hr和oe用户解锁
点击( 此处 )折叠或打开
SQL
>
create
directory
oradump
as
'/home/oracle/dump'
;
Directory
created
.
SQL
>
grant
read
,
write
on
directory
oradump
to
public
;
Grant succeeded .
SQL
>
alter
user
oe
identified
by
"oe"
account unlock
;
User
altered
.
SQL
>
alter
user
hr
identified
by
"hr"
account unlock
;
User altered .
7. 尝试使用impdp工具导入
点击( 此处 )折叠或打开
[
oracle
@
rhel
-
ORCL
dump
]
$
impdp system
/
oracle
directory
=
oradump dumpfile
=
ora10gCLOB
.
dmp logfile
=
ora10gCLOB
.
log
REMAP_SCHEMA
=
hr
:
oe REMAP_TABLESPACE
=
users
:
testlob ignore
=
y
Import
:
Release
11
.
2
.
.
3
.
0
-
Production
on
Wed Jan 24 16
:
41
:
41 2018
Copyright
(
c
)
1982
,
2011
,
Oracle
and
/
or
its affiliates
.
All
rights reserved
.
UDI
-
28002
:
operation generated ORACLE error 28002
ORA
-
28002
:
the
password
will expire within 7 days
Connected
to
:
Oracle
Database
11g Enterprise Edition
Release
11
.
2
.
.
3
.
0
-
Production
With
the Partitioning
,
OLAP
,
Data
Mining
and
Real
Application Testing options
ORA
-
39001
:
invalid argument
value
ORA
-
39000
:
bad
dump
file
specification
ORA - 39143 : dump file "/home/oracle/dump/ora10gCLOB.dmp" may be an original export dump fi
8. 使用imp工具导入
点击( 此处 )折叠或打开
[
oracle
@
rhel
-
ORCL
dump
]
$
imp hr
/
hr
file
=
/
home
/
oracle
/
dump
/
ora10gCLOB
.
dmp
log
=
ora10gCLOB
.
log
REMAP_SCHEMA
=
hr
:
oe REMAP_TABLESPACE
=
users
:
testlob ignore
=
y
LRM
-
00101
:
unknown parameter name
'REMAP_SCHEMA'
IMP
-
00022
:
failed
to
process parameters
,
type
'IMP HELP=Y'
for
help
IMP
-
00000
:
Import terminated unsuccessfully
[
oracle
@
rhel
-
ORCL
dump
]
$
imp hr
/
hr
file
=
/
home
/
oracle
/
dump
/
ora10gCLOB
.
dmp
log
=
ora10gCLOB
.
log
fromuser
=
hr touser
=
oe tablespaces
=
testlob ignore
=
y
Import
:
Release
11
.
2
.
.
3
.
0
-
Production
on
Wed Jan 24 16
:
50
:
42 2018
Copyright
(
c
)
1982
,
2011
,
Oracle
and
/
or
its affiliates
.
All
rights reserved
.
Connected
to
:
Oracle
Database
11g Enterprise Edition
Release
11
.
2
.
.
3
.
0
-
Production
With
the Partitioning
,
OLAP
,
Data
Mining
and
Real
Application Testing options
Export
file
created
by
EXPORT
:
V10
.
02
.
01 via conventional path
import done
in
US7ASCII character
set
and
AL16UTF16 NCHAR character
set
import server uses AL32UTF8 character
set
(
possible charset conversion
)
IMP
-
00007
:
must be a DBA
to
import objects
to
another
user
's account
IMP-00000: Import terminated unsuccessfully
[oracle@rhel-ORCL dump]$imp system/oracle file=/home/oracle/dump/ora10gCLOB.dmp log=ora10gCLOB.log fromuser=hr touser=oe tablespaces=testlob ignore=y
Import: Release 11.2.0.3.0 - Production on Wed Jan 24 16:51:16 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
IMP-00058: ORACLE error 28002 encountered
ORA-28002: the password will expire within 7 days
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export file created by EXPORT:V10.02.01 via conventional path
Warning: the objects were exported by HR, not by you
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses AL32UTF8 character set (possible charset conversion)
. importing HR's objects
into
OE
.
.
importing
table
"MA_LOB_DUMP"
4
rows
imported
Import terminated successfully with warnings .
9. Oracle11g OE用户检查数据
点击( 此处 )折叠或打开
SQL
>
conn oe
/
oe
Connected
.
SQL
>
select
*
from
MA_LOB_DUMP
;
N C
--------- ----------
1 12
1 123
2 2345
3 asdsada
10. Oracle11g检查LOB段的表空间
点击( 此处 )折叠或打开
-- 用户的默认表空间
SQL
>
select
USERNAME
,
DEFAULT_TABLESPACE
from
user_users
;
USERNAME DEFAULT_TABLESPACE
------------------------------ ------------------------------
OE TESTLOB
-- TABLE段的默认表空间是USERS
SQL
>
select
TABLE_NAME
,
TABLESPACE_NAME
from
user_tables
where
table_name
=
'MA_LOB_DUMP'
;
TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
MA_LOB_DUMP USERS
-- 移动TABLE到表空间TESTLOB
SQL
>
alter
table
MA_LOB_DUMP move
tablespace
TESTLOB
;
Table
altered
.
SQL
>
select
TABLE_NAME
,
TABLESPACE_NAME
from
user_tables
where
table_name
=
'MA_LOB_DUMP'
;
TABLE_NAME TABLESPACE_NAME
------------------------------ ------------------------------
MA_LOB_DUMP TESTLOB
-- LOB段的默认表空间是USERS
SQL
>
select
TABLE_NAME
,
TABLESPACE_NAME
,
SECUREFILE
from
user_lobs
where
table_name
=
'MA_LOB_DUMP'
;
TABLE_NAME TABLESPACE_NAME SEC
------------- ----------------- ------------------------------ ---
MA_LOB_DUMP USERS NO
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31092650/viewspace-2155768/ ,如需转载,请注明出处,否则将追究法律责任。