因工作需要初步研究了ORACLE的外部表,研究过程如下
1。操作系统上有文件
[ora10g@hzmc tmp]$ ls -rtl /tmp/testloit_100w.log
-rw-r--r-- 1 root root 15000000 Jun 25 15:19 /tmp/testloit_100w.log
2。打开文件,文件格式如下,第一列表示afn,第二列表示dba
007c 1f2d44d0
0031 0c4d30f9
000c 033c253f
0007 01d780f4
0035 0d614019
。。。
3。在ORACLE test用户下,创建外部表目录,并创建外部表
4。现在可以查询sort_table表,其实这表内容是从外部文件里读进来的
5。对外部表进行各种操作
a。将外部表中的内容读进ORACLE真正的表
b。对ORACLE表格进行排序去重操作
1。操作系统上有文件
[ora10g@hzmc tmp]$ ls -rtl /tmp/testloit_100w.log
-rw-r--r-- 1 root root 15000000 Jun 25 15:19 /tmp/testloit_100w.log
2。打开文件,文件格式如下,第一列表示afn,第二列表示dba
007c 1f2d44d0
0031 0c4d30f9
000c 033c253f
0007 01d780f4
0035 0d614019
。。。
3。在ORACLE test用户下,创建外部表目录,并创建外部表
create or replace directory TESTDIR AS '/tmp';
create table test_sort
(afn varchar2(8),dba varchar2(8) )
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY TESTDIR
access parameters( records delimited by '\n'
nologfile
fields terminated by ' ' lrtrim
missing field values are null)
LOCATION ('testloit_100w.log'))
REJECT LIMIT UNLIMITED;
4。现在可以查询sort_table表,其实这表内容是从外部文件里读进来的
select * from sort_table;
5。对外部表进行各种操作
a。将外部表中的内容读进ORACLE真正的表
create table testsort as select * from test_sort where rownum=0
b。对ORACLE表格进行排序去重操作
insert into testsort
select distinct afn,DBMS_UTILITY.data_block_address_block (TO_NUMBER (LTRIM (dba, '0x'),'xxxxxxxx')) from test_sort