Oracle external table to read the pre-processed file output from a os process monitoring command and perform aggregation or analytics to get more intelligence
Reference: https://asktom.oracle.com/Misc/oramag/preprocess-external-tables.html
YouTube:
Step1) Ensure you have the file which we wanted to process using oracle external table is ready already
Step2) Frame external table command from the output of the file present in os
Example:
create table indata1
(
cust_id number,
cust_name varchar2(20),
credit_limit number(10)
)
organization external
(
type oracle_loader
default directory etl_dir
access parameters
(
records delimited by newline
fields terminated by ","
)
location ('indata1.txt')
)
/
Actual:
create directory ospsw_data as '/home/oracle/dba/OSpsstat';
create table ospsw
(
sampltm date,
osusr varchar2(50),
ospid number,
osppid number,
prprty number,
pcpu varchar2(10),
pmem varchar2(10),
vsz number,
rss number,
wchain varchar2(50),
processstat varchar2(3),
processstart varchar2(20),
processdur varchar2(20),
processcmd varchar2(1000)
)
organization external
(
type oracle_loader
default directory ospsw_data
access parameters
(
records delimited by newline
fields terminated by ","
(
sampltm date "dd/mon/yyyy hh24:mi:ss",
osusr char(50),
ospid char(10),
osppid char(10),
prprty char(10),
pcpu char(20),
pmem char(20),
vsz char(20),
rss char(20),
wchain char(50),
processstat char(3),
processstart char(20),
processdur char(20),
processcmd char(1000)
)
)
location ('processed_ps2.out')
)
/
Output:
step 3) Start querying the data and start to perform analytical/aggregation functions
Errors to be aware:
This is because of usage of number data type in the access delimiter definition which isn’t accepted by oracle it seems.
No comments:
Post a Comment