txt文件导入到mysql中

来源:互联网 发布:华为网盘网络连接失败 编辑:程序博客网 时间:2024/05/18 00:23

    mysql库中已有表demo(id, word)

    1、首先,删除id字段

    2、然后将放在D盘的txt文件插入

         load data local infile 'd:/name.txt' into table demo(word);

     3、将id恢复

        alter table `demo` add column `id` int not null auto_increment primary key comment '主键' first;

     前提:txt文件中的内容是一行一行的。

      备注:貌似不用删除ID也行。

原创粉丝点击