外部表的另一种用途 数据迁移
不用exp/imp,expdp/impdp来不同平台间迁移数据表
由于条件所限,我的操作在两台linux机器上,不同平台的操作方法一样
首先导出第一台机器上的数据
[oracle@nsisdb application]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on 星期二 8月 5 14:38:03 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
[@more@]外部表的另一种用途 数据迁移
不用exp/imp,expdp/impdp来不同平台间迁移数据表
由于条件所限,我的操作在两台linux机器上,不同平台的操作方法一样
首先导出第一台机器上的数据
[oracle@nsisdb application]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on 星期二 8月 5 14:38:03 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL> create or replace directory tmp as '/application/tmp';
目录已创建.
注意创建目录的拥有者必须是oracle
SQL> create table all_objects_unload
2 organization external
3 (type oracle_datapump
4 default directory tmp
5 location('allobjectgu.dat')
6 )
7 as
8 select * from all_objects
9 /
表已创建.
这里的查询可以是任何查询,本地导出数据文件名字.dat文件也可以起任何名字
这时在/application/tmp下会有两个文件:一个日志文件ALL_OBJECTS_UNLOAD_29285.log;一个数据文件allobjectgu.dat
[oracle@nsisdb tmp]$ ls -lrt
总用量 5104
-rw-r--r-- 1 oracle oinstall 41 8月 5 14:44 ALL_OBJECTS_UNLOAD_29285.log
-rw-r----- 1 oracle oinstall 5201920 8月 5 14:44 allobjectgu.dat
通过FTP工具把数据文件allobjectgu.dat传到另一台机器的/application/gu目录下
[oracle@nsistestdb gu]$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on 星期二 8月 5 14:58:36 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
--创建目录
SQL> create or replace directory tmp as '/application/gu';
目录已创建。
--创建表指向数据文件
SQL> create table gu
2 (owner varchar2(30),
3 object_name varchar2(30),
4 object_id number,
5 data_object_id number,
6 object_type varchar2(19),
7 created date,
8 last_ddl_time date,
9 timestamp varchar2(19),
10 status varchar2(7),
11 temporary varchar2(1),
12 generated varchar2(1),
13 secondary varchar2(1)
14 )
15 organization external
16 (type oracle_datapump
17 default directory tmp
18 location ('allobjectgu.dat')
19 )
20 /
表已创建。
--查询外部表
SQL> select count(*) from gu;
COUNT(*)
----------
53090
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7490392/viewspace-1008556/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/7490392/viewspace-1008556/