有这样一个文件users.txtuser001中文 e10adc3949ba59abbe56e057f20f883e NULL
user002 e10adc3949ba59abbe56e057f20f883e NULL
user003 e10adc3949ba59abbe56e057f20f883e NULL
user004 e10adc3949ba59abbe56e057f20f883e NULL
user005 e10adc3949ba59abbe56e057f20f883e NULL
user006 e10adc3949ba59abbe56e057f20f883e NULL
user007 e10adc3949ba59abbe56e057f20f883e NULL
user008 e10adc3949ba59abbe56e057f20f883e NULL
user009 e10adc3949ba59abbe56e057f20f883e NULL
user010 e10adc3949ba59abbe56e057f20f883e NULL
user008 e10adc3949ba59abbe56e057f20f883e NULL
user009 e10adc3949ba59abbe56e057f20f883e NULL
user010 e10adc3949ba59abbe56e057f20f883e NULL用下面的语句导入到users表中,LOAD DATA LOCAL INFILE "D:/users.txt"
     INTO TABLE users 
     FIELDS TERMINATED BY "\t" ENCLOSED BY ""
     LINES TERMINATED BY "\n" STARTING BY "" (username, password, avatar)
但是有个问题,被导入的数据,其中NULL值,被做为字符串"NULL"导了进去,
有没有办法把NULL这一列做为mysql的NULL,而不是字符串null导入?

解决方案 »

  1.   

    导入后,再UPDATE 此字段为NULL不行?
      

  2.   

    不行啊, 那么多列,不知道是哪个列有null值啊,update也没法写啊
      

  3.   

    更新呗
    update tb  set col1=xxx where col1 = 'NULL'
    update tb  set col2=xxx where col2 = 'NULL'
    update tb  set col3=xxx where col3 = 'NULL'
      

  4.   


    不是啊,users.txt是程序自动生成的,内容不是己知的~~
      

  5.   

    LOAD DATA LOCAL INFILE "D:/users.txt"
    INTO TABLE users 
    FIELDS TERMINATED BY "\t" ENCLOSED BY ""                
    LINES TERMINATED BY "\n" STARTING BY "" 
    (username, password, @x)
    set avatar=if(@x='NULL',null,@x);
      

  6.   

    关于LOAD DATA LOCAL INFILE [ :40分]
    ihelloworld (ihelloworld)
      '截至2011-12-30 13:47:56  用户结帖率0.00%  
    当您的问题得到解答后请及时结贴.
    http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
    http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
    http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html8、如何给分和结贴?
    http://community.csdn.net/Help/HelpCenter.htm#结帖