Sqlldr when importing text content into a database table, you need to specify a CTL file (control file) through which to complete the import of the data.
1 First create a table student
create table student( stu_id number(5) primary key, stu_name varchar2(32) not null, stu_age number(3), stu_sex number(1), stu_birth date);comment on table student is ‘学生表‘;comment on column student.stu_sex is ‘学生性别,0:男,1:女‘;
Create a txt or CSV file with the following file contents
10001|tom|20|0|1993-01-01
10002|mary|18|1|1995-01-11
10003| xiaoming |19|0|1993-03-13
10004| Fang |17|1|1994-11-23
2 Creating a Student.ctl file
Load data
CHARACTERSET Al32utf8
InFile ' D:\test\student.txt '
Append into table student
Fields terminated by "|"
Trailing Nullcols
(Stu_id,stu_name,stu_age,stu_se,stu_birth date "Yyyy-mm-dd")
Parameter description:
Load data: Control file ID
CHARACTERSET: Set encoding format to prevent Chinese garbled characters
InFile: Specifying the data file path
Append: Specify the data loading method, there are four kinds of values: [(1) Insert, the default way, at the beginning of the data load requires the table is empty, (2) Append, delete the old record (with the DELETE from table statement), replace the new loaded record; (3) Replace , delete the old record, replace it with the new loaded record, (4) Truncate, delete the old record (with the TRUNCATE TABLE statement), replace the new loaded record]; Here I specify the way for append
Field terminated by: Specify separators between fields
Trailing nullcols: null is allowed when the table field does not have a corresponding value
(Stu_id,stu_name,stu_age number,stu_se Number,stu_birth Date "Yyyy-mm-dd"): Define column order
3 Performing SQLLDR Import data
sqlldr userid=shiot/123456 control=‘D:/test/student.ctl‘ log=‘D:/test/student.log‘ bad=‘D:/test/student.bad‘
Parameter description:
UserID: Specify the Oracle username/password
Control: Specifies the path to the controlling file
LOG: Specify the log file path
Bad: Specifies the error file path
Use of Oracle database SQLLDR tools