Purpose: Import the data of the iostat instruction into the file Iostat.dat , and then pour the iostat data into the database by Sqlldr
Step one:u1/tiger The user to build the table Iostat
CREATE TABLE Iostat (device varchar), TPS float (mb_read_s), mb_wrtn_s float (), Mb_read float, mb_ Wrtn Float (20));
Step Two: Create a source data file
Iostat–md/dev/sda2 >/oracle/script/iostat.dat
Cat Iostat.dat
Linux 2.6.18-164.el5 (HOST2) 08/15/2014
Device:tps mb_read/s mb_wrtn/s Mb_read Mb_wrtn
Sda2 13.06 0.09 0.11 961 1194
Step three: Build a control file
Load data
InFile '/oracle/script/iostat.dat '
Append into table Iostat
Fields TERMINATED by whitespace
(DEVICE,TPS,MB_READ_S,MB_WRTN_S,MB_READ,MB_WRTN)
Note: The second line specifies the input file,
The third line specifies that the policy is appended and written to table Iostat
Line Fourth indicates that the fields of the text file are separated by spaces.
Row five specifies the correspondence between the text field and the table
Fourth step: Start importing the database
Sqlldr u1/tiger control= ' iostat.ctl ' log= '/oracle/script/iostat.log ' skip=3 bad= ' Iostat.bad '
Note:
bad file records did not successfully write to the table record.
log file records the transferred logs.
Control file when the control file is written above.
skip=3 indicates that the first three lines of the text file iostat.dat (Linux 2.6.18-164.el5 (host2) 08/15/2014 , and so on )are ignored.
Fifth step: View the results of the import
Sql> SELECT * from Iostat
DEVICE TPS mb_read_s mb_wrtn_s Mb_read Mb_wrtn
---------- ---------------------- ---------------------- ---------------------- ---------------------- ------------- ---------
sda2 18.39 0.18 0.14 877 681