Oracle 5.0 Reference Manual page 1095

Table of Contents

Advertisement

• Look for line boundaries at newlines.
• Do not skip over any line prefix.
• Break lines into fields at tabs.
• Do not expect fields to be enclosed within any quoting characters.
• Interpret characters preceded by the escape character "\" as escape sequences. For example,
"\t", "\n", and "\\" signify tab, newline, and backslash, respectively. See the discussion of
later for the full list of escape sequences.
ESCAPED BY
Conversely, the defaults cause
• Write tabs between fields.
• Do not enclose fields within any quoting characters.
• Use "\" to escape instances of tab, newline, or "\" that occur within field values.
• Write newlines at the ends of lines.
Note
If you have generated the text file on a Windows system, you might have to use
LINES TERMINATED BY '\r\n'
programs typically use two characters as a line terminator. Some programs,
such as WordPad, might use
such files, use
If all the lines you want to read in have a common prefix that you want to ignore, you can use
STARTING BY 'prefix_string'
include the prefix, the entire line is skipped. Suppose that you issue the following statement:
LOAD DATA INFILE '/tmp/test.txt' INTO TABLE test
FIELDS TERMINATED BY ','
If the data file looks like this:
xxx"abc",1
something xxx"def",2
"ghi",3
The resulting rows will be
does not contain the prefix.
The
IGNORE number LINES
you can use
IGNORE 1 LINES
LOAD DATA INFILE '/tmp/test.txt' INTO TABLE test IGNORE 1 LINES;
When you use
SELECT ... INTO OUTFILE
a database into a file and then read the file back into the database later, the field- and line-handling
options for both statements must match. Otherwise,
of the file properly. Suppose that you use
delimited by commas:
SELECT * INTO OUTFILE 'data.txt'
FIELDS TERMINATED BY ','
FROM table2;
To read the comma-delimited file back in, the correct statement would be:
LOAD DATA INFILE 'data.txt' INTO TABLE table2
LOAD DATA INFILE
SELECT ... INTO OUTFILE
\r
LINES TERMINATED BY
to skip over the prefix, and anything before it. If a line does not
LINES STARTING BY 'xxx';
and ("def",2). The third row in the file is skipped because it
("abc",1)
option can be used to ignore lines at the start of the file. For example,
to skip over an initial header line containing column names:
in tandem with
SELECT ... INTO OUTFILE
1075
Syntax
to act as follows when writing output:
to read the file properly, because Windows
as a line terminator when writing files. To read
'\r'.
LOAD DATA INFILE
will not interpret the contents
LOAD DATA INFILE
to write a file with fields
FIELDS
LINES
to write data from

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents