Database Reference
In-Depth Information
So, now that I have the script and the directory, I am ready to create the external table. As you can see from the
following code, all I need to do is have the external table skip the first record and then parse each subsequent line,
using white space as a delimiter. This is something an external table can do easily, as shown next:
EODA@ORA12CR1>create table df
2 (
3 fsname varchar2(100),
4 blocks number,
5 used number,
6 avail number,
7 capacity varchar2(10),
8 mount varchar2(100)
9 )
10 organization external
11 (
12 type oracle_loader
13 default directory exec_dir
14 access parameters
15 (
16 records delimited
17 by newline
18 preprocessor
19 exec_dir:'run_df.bsh'
20 skip 1
21 fields terminated by
22 whitespace ldrtrim
23 )
24 location
25 (
26 exec_dir:'run_df.bsh'
27 )
28 )
29 /
Table created.
With the df external table created, I can now review the df output easily in a query, as shown next:
EODA@ORA12CR1> select * from df;
FSNAME BLOCKS USED AVAIL CAPACITY MOUNT
-------------------- ---------- ---------- ---------- ---------- ------------------------------
orapool1/ora01 629145600 382371882 246773718 61% /ora01
orapool2/ora02 629145600 429901326 199244274 69% /ora02
orapool1/ora03 629145600 415189808 213955792 66% /ora03
orapool2/ora04 629145600 343152974 285992626 55% /ora04
hopefully, you see how this approach could work easily for ps , ls , du , and so on—all the UniX/Linux utilities
could easily be considered “tables” now!
Tip
 
Search WWH ::




Custom Search