1. <i id='1k91W'><tr id='1k91W'><dt id='1k91W'><q id='1k91W'><span id='1k91W'><b id='1k91W'><form id='1k91W'><ins id='1k91W'></ins><ul id='1k91W'></ul><sub id='1k91W'></sub></form><legend id='1k91W'></legend><bdo id='1k91W'><pre id='1k91W'><center id='1k91W'></center></pre></bdo></b><th id='1k91W'></th></span></q></dt></tr></i><div id='1k91W'><tfoot id='1k91W'></tfoot><dl id='1k91W'><fieldset id='1k91W'></fieldset></dl></div>
      <bdo id='1k91W'></bdo><ul id='1k91W'></ul>
    <legend id='1k91W'><style id='1k91W'><dir id='1k91W'><q id='1k91W'></q></dir></style></legend>

  2. <small id='1k91W'></small><noframes id='1k91W'>

      <tfoot id='1k91W'></tfoot>

    1. 使用 LOAD DATA INFILE 导入 MySQL 表时如何跳过 CSV 文件中的列?

      How to skip columns in CSV file when importing into MySQL table using LOAD DATA INFILE?(使用 LOAD DATA INFILE 导入 MySQL 表时如何跳过 CSV 文件中的列?)

      <legend id='MOJ1g'><style id='MOJ1g'><dir id='MOJ1g'><q id='MOJ1g'></q></dir></style></legend>

      <small id='MOJ1g'></small><noframes id='MOJ1g'>

          <tbody id='MOJ1g'></tbody>

        <tfoot id='MOJ1g'></tfoot>
        1. <i id='MOJ1g'><tr id='MOJ1g'><dt id='MOJ1g'><q id='MOJ1g'><span id='MOJ1g'><b id='MOJ1g'><form id='MOJ1g'><ins id='MOJ1g'></ins><ul id='MOJ1g'></ul><sub id='MOJ1g'></sub></form><legend id='MOJ1g'></legend><bdo id='MOJ1g'><pre id='MOJ1g'><center id='MOJ1g'></center></pre></bdo></b><th id='MOJ1g'></th></span></q></dt></tr></i><div id='MOJ1g'><tfoot id='MOJ1g'></tfoot><dl id='MOJ1g'><fieldset id='MOJ1g'></fieldset></dl></div>
          • <bdo id='MOJ1g'></bdo><ul id='MOJ1g'></ul>
                本文介绍了使用 LOAD DATA INFILE 导入 MySQL 表时如何跳过 CSV 文件中的列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我有一个有 11 列的 CSV 文件,我有一个有 9 列的 MySQL 表.

                I've got a CSV file with 11 columns and I have a MySQL table with 9 columns.

                CSV 文件如下所示:

                The CSV file looks like:

                col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11
                

                MySQL 表如下所示:

                and the MySQL table looks like:

                col1, col2, col3, col4, col5, col6, col7, col8, col9
                

                我需要将 CSV 文件的第 1-8 列直接映射到 MySQL 表的前 8 列.然后我需要跳过 CSV 文件中接下来的两列,然后将 CSV 文件的第 11 列映射到 MySQL 表的第 9 列.

                I need to map the columns 1-8 of CSV file directly to the first 8 columns of the MySQL table. I then need to skip the next two columns in the CSV file and then map column 11 of CSV file to column 9 of MySQL table.

                目前我正在使用以下 SQL 命令:

                At the moment I am using the following SQL command:

                LOAD DATA LOCAL INFILE 'filename.csv' INTO TABLE my_table
                FIELDS TERMINATED BY ','
                ENCLOSED BY ''
                LINES TERMINATED BY '\n'
                

                但是上面的代码将CSV文件的前9列映射到了MySQL表的9列.

                But the above code maps the first 9 columns of CSV file to the 9 columns in the MySQL table.

                推荐答案

                来自 Mysql 文档:

                您还可以通过以下方式丢弃输入值将其分配给用户变量和不将变量分配给表列:

                You can also discard an input value by assigning it to a user variable and not assigning the variable to a table column:

                LOAD DATA INFILE 'file.txt'  
                INTO TABLE t1 (column1, @dummy, column2, @dummy, column3);
                

                这篇关于使用 LOAD DATA INFILE 导入 MySQL 表时如何跳过 CSV 文件中的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)
                MySQL GROUP BY DateTime +/- 3 seconds(MySQL GROUP BY DateTime +/- 3 秒)

                <small id='Jju6E'></small><noframes id='Jju6E'>

                      <tbody id='Jju6E'></tbody>

                  • <legend id='Jju6E'><style id='Jju6E'><dir id='Jju6E'><q id='Jju6E'></q></dir></style></legend>

                        <i id='Jju6E'><tr id='Jju6E'><dt id='Jju6E'><q id='Jju6E'><span id='Jju6E'><b id='Jju6E'><form id='Jju6E'><ins id='Jju6E'></ins><ul id='Jju6E'></ul><sub id='Jju6E'></sub></form><legend id='Jju6E'></legend><bdo id='Jju6E'><pre id='Jju6E'><center id='Jju6E'></center></pre></bdo></b><th id='Jju6E'></th></span></q></dt></tr></i><div id='Jju6E'><tfoot id='Jju6E'></tfoot><dl id='Jju6E'><fieldset id='Jju6E'></fieldset></dl></div>

                        <tfoot id='Jju6E'></tfoot>

                        • <bdo id='Jju6E'></bdo><ul id='Jju6E'></ul>