There should be a lot of ways to import data into Oracle, and there are different ways to import different requirements, and the recent use of Oracle's SQLLDR command to import database data feels like a pretty good technical point. Using the SQLLDR command to import a text file into Oracle takes roughly two steps:
First step: Write the CTL control file
Load Data--loading (in the second step, the source location of the data file is specified)
CHARACTERSET ' UFT8 '--Import Character set format
Append-This attribute means that the original data in the database is appended to its own data, without changing the original data, interested can also learn about other properties such as replace
into table Int_demo_student_b--Tables for inserting databases
Fields terminated by X ' 1 B '--delimiter for splitting the corresponding attribute data in the data file I used the ESC key to split, and the X ' 09 ' equals the comma split
TRAILING nullcols--Empty column assignment, if not add this attribute, when the data file has a null value, will skip the null value, so the import data is misplaced, so add this property can avoid null dislocation
(
stu_id,--Fields, order of fields and database in the same order
Stu_name,
Stu_class,
Stu_age,
Stu_sex,
Stu_subject,
Comment Char (260),---intercept operation, when doing import, the CTL import belongs to the file stream import, when the field character length exceeds 255 bits will import failure, if you need to add this attribute to constrain the import failed
IMPORT_FLAG constant "0",--default assignment, if the original data file does not have a field, and you need to add a field in your database table, you need to added a default value constant
ERR_MSG constant ""
)
Step two: Use the cmd Command window to enter commands SQLLDR command run and press ENTER at the end
SQLLDR userid = username/password @ database name data= data file Address control = CTL Control file Address bad = d:/Bad.bad error logs log =d:/log.log log Recording
You can also enter rows Deirect silent errors and other conditions in the command to limit the number of rows imported, and you can be interested in knowing
At present, the address data are fixed, in the actual application will be defined by defining variables to use, so that can be reused.
Use of the Oracle Database SQLLDR command