Details:
File path (Linux server) :/aaa/BBB/config load. The CTL
/aaa/BBB check. CTL
/aaa/BBB newData. Dat
The load in the config folder. The CTL is SQL Loader control file, first determine the check. CTL exists if already exists for newData. Dat is Ready. At that time call
Data in the load. The CTL newData. Dat is loaded into the database,
Requires the use of Linux command to write a to determine whether a file exists and call the load of the CTL shell script,
Asked the great spirit, need specific script and comments in detail, the database link accounts and data file content to write,
CodePudding user response:
#!/bin/sh# shell script execution log
Fdate=` date + % Y H % m % d % % m % S `
LOG_FILE=/aaa/BBB/config/shelltask_ ${fdate}. The log
Echo & gt;> $LOG_FILE
Chmod 666 $LOG_FILE
Echo====started on ` date `====& gt;> $LOG_FILE
Echo & gt;> $LOG_FILE
If [- e/aaa/BBB/check. CTL]; Then
Echo "exists heck. CTL, data ready, start the load data!"> The ${LOG_FILE}
SQLLDR userid=LZJ/LZJ control=/aaa/BBB/config/load. The CTL log="/aaa/BBB/config/loaddatalog1 log"
The exit 1
Fi
The exit 0
CodePudding user response:
Control files: the load. The content of the CTL:The load data
Infile '/aaa/BBB/newData dat'
# t_test1 store data tables, note will truncate to empty the original data to guide, data file field delimiter modified according to actual condition, table field type to match and the given data file,
TRUNCATE into table t_test1
Fields terminated by '|' TRAILING NULLCOLS
(field1, field2, field3, field4 field5, field6, field7)
The sample data file content:
The test | test | aasdf | | SDFSDF | asdf | | sadfsdfsd | asdfad |
The test | test | aasdf | | SDFSDF | asdf | | sadfsdfsd | asdfad |
The test | test | aasdf | | SDFSDF | asdf | | sadfsdfsd | asdfad |
The test | test | aasdf | | SDFSDF | asdf | | sadfsdfsd | asdfad |
Test1234 | test | aasdf | | SDFSDF | asdf | | sadfsdfsd | asdfad |
CodePudding user response:
Should refer to this can be done, on the Internet has a lot of articles sqlloaderCodePudding user response: