Database Reference
In-Depth Information
16 (
17 data_dir:'base'
18 )
19 )
20 /
Table created.
Select from the external table:
EODA@ORA12CR1> select * from csv2;
You can see from the output that only two rows are returned, the ones that contain the string of base2 :
COL1 COL2
-------------------- --------------------
base2a col1 base2a col2
base2b col1 base2b col2
FINDING the LarGeSt FILeS
When dealing with disk space issues, sometimes it's handy to display the top N largest files in a directory tree.
You can use a preprocessing external table to accomplish this task. First, create two directory objects:
EODA@ORA12CR1> create or replace directory exec_dir as '/orahome/oracle/bin';
EODA@ORA12CR1> create or replace directory data_dir as '/';
then create a shell (place it in /orahome/oracle/bin ) script named flf.bsh with the following code:
#!/bin/bash
/usr/bin/find $1 -ls|/bin/sort -nrk7|/usr/bin/head -10|/bin/awk '{print $11,$7}'
Make flf.bsh executable:
$ chmod +x flf.bsh
now create an external table with the PREPROCESSOR directive:
create table flf (fname varchar2(200), bytes number)
organization external (
type oracle_loader
default directory exec_dir
access parameters
( records delimited by newline
preprocessor exec_dir:'flf.bsh'
fields terminated by whitespace ldrtrim)
location (data_dir:'u01'));
Search WWH ::




Custom Search