At 12:32 -0500 2/7/03, Bhavin Vyas wrote:
>Hi,
>I have a table Log described as such:
>
>+----------+-----------+------+-----+---------+-------+
>| Field | Type | Null | Key | Default | Extra |
>+----------+-----------+------+-----+---------+-------+
>| rec | int(1) | YES | | NULL | |
>| time | int(10) | | | 0 | |
>| ct | char(100) | YES | | NULL | |
>+----------+-----------+------+-----+---------+-------+
>
>Notice that default for ct is NULL.
>Now I have a ^ separated line in my file which I am loading via LOAD FILE.
>This line MAY or MAY NOT have the corresponding ct value. So,
>it could either be ....^www.yahoo.com^(ct value) or .....^^.....(no ct
>value).
>I would like that when there is no ct value present in the line,
>the ct value in Log table should stay as the default NULL....but it is not.
>The value becomes '' i.e. a zero length string.
>
>Any ideas on how can I keep it as NULL?
You can't "keep it" as NULL, because an empty string *isn't* NULL.
It's an empty string, and MySQL is loading it correctly.
If you want it to load NULL, change those empty strings to \N (backslash
capital-N). MySQL will interpret that sequence as NULLL and load
NULL into your
table.
For more information, see the manual:
http://www.mysql.com/doc/en/LOAD_DATA.html
>
>Any help is much appreciated.
>Thanks in advance,
>
>Bhavin.
>
>sql, mysql, query.