Oracle 5.0 Reference Manual page 1100

Table of Contents

Advertisement

If an input line has too few fields, the table columns for which input fields are missing are set to their
default values. Default value assignment is described in
An empty field value is interpreted different from a missing field:
• For string types, the column is set to the empty string.
• For numeric types, the column is set to 0.
• For date and time types, the column is set to the appropriate "zero" value for the type. See
Section 11.1.5, "Date and Time
These are the same values that result if you assign an empty string explicitly to a string, numeric, or
date or time type explicitly in an
Treatment of empty or incorrect field values differs from that just described if the SQL mode is set to a
restrictive value. For example, if
value such as
for a numeric column results in an error, not conversion to 0. (With LOCAL, warnings
'x'
occur rather than errors, even with a restrictive
to stop transmission of the file in the middle of the operation.)
columns are set to the current date and time only if there is a
TIMESTAMP
(that is, \N) and the column is not declared to permit
default value is the current timestamp and it is omitted from the field list when a field list is specified.
regards all input as strings, so you cannot use numeric values for
LOAD DATA INFILE
columns the way you can with
strings.
values cannot be loaded using binary notation (for example, b'011010'). To work around this,
BIT
specify the values as regular integers and use the
a numeric type conversion and loads them into the
shell>
cat /tmp/bit_test.txt
2
127
shell>
mysql test
mysql>
LOAD DATA INFILE '/tmp/bit_test.txt'
->
INTO TABLE bit_test (@var1) SET b = CAST(@var1 AS UNSIGNED);
Query OK, 2 rows affected (0.00 sec)
Records: 2
Deleted: 0
mysql>
SELECT BIN(b+0) FROM bit_test;
+----------+
| bin(b+0) |
+----------+
| 10
|
| 1111111
|
+----------+
2 rows in set (0.00 sec)
On Unix, if you need
LOAD DATA
example loads a listing of the
mkfifo /mysql/data/db1/ls.dat
chmod 666 /mysql/data/db1/ls.dat
find / -ls > /mysql/data/db1/ls.dat &
mysql -e "LOAD DATA INFILE 'ls.dat' INTO TABLE t1" db1
Note that you must run the command that generates the data to be loaded and the
either on separate terminals, or run the data generation process in the background (as shown in the
preceding example). If you do not do this, the pipe will block until data is read by the
When the
LOAD DATA INFILE
format:
LOAD DATA INFILE
Types".
or
INSERT
UPDATE
sql_mode='TRADITIONAL
sql_mode
statements. All
INSERT
Skipped: 0
Warnings: 0
to read from a pipe, you can use the following technique (the
directory into the table db1.t1):
/
statement finishes, it returns an information string in the following
1080
Syntax
Section 11.1.7, "Data Type Default
statement.
[495], conversion of an empty value or a
[495]
value, because the server has no way
values, or if the
NULL
and
values must be specified as
ENUM
SET
clause to convert them so that MySQL performs
SET
column properly:
BIT
Values".
value for the column
NULL
column's
TIMESTAMP
or
ENUM
commands
mysql
process.
mysql
SET

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents