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

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

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

      1. <i id='PFgh8'><tr id='PFgh8'><dt id='PFgh8'><q id='PFgh8'><span id='PFgh8'><b id='PFgh8'><form id='PFgh8'><ins id='PFgh8'></ins><ul id='PFgh8'></ul><sub id='PFgh8'></sub></form><legend id='PFgh8'></legend><bdo id='PFgh8'><pre id='PFgh8'><center id='PFgh8'></center></pre></bdo></b><th id='PFgh8'></th></span></q></dt></tr></i><div id='PFgh8'><tfoot id='PFgh8'></tfoot><dl id='PFgh8'><fieldset id='PFgh8'></fieldset></dl></div>
        <tfoot id='PFgh8'></tfoot>
      2. MySql 加载数据本地语法?

        时间:2023-10-11

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

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

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

                • <bdo id='se3wU'></bdo><ul id='se3wU'></ul>
                • 本文介绍了MySql 加载数据本地语法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个使用管道'|'的文本文件result.txt"分离字段.我使用了 PhpMyAdmin 并通过指定使用CSV 负载数据"并告诉它字段应该用|"分隔来成功地将它导入到我的表中.

                  I have a text file "result.txt" that used pipes '|' to separate out the fields. I used PhpMyAdmin and successfully imported it to my table by specifying using "CSV LOAD DATA" and telling it the fields should be separated by '|'.

                  PhpMyAdmin 也给出了完整的查询,所以我复制了它并粘贴到我的 php 脚本中,如下所示:

                  PhpMyAdmin also gave the full query for it, so I copied it and paste it into my php script, which looked like this:

                   mysql_query("LOAD DATA LOCAL INFILE 'C:/wamp/www/TouchStone/result.txt' INTO TABLE customer_change FIELDS TERMINATED BY '|' ESCAPED BY '\' LINES TERMINATED BY '
                  ' ")
                   or die(mysql_error());
                  

                  我总是会收到错误提示:

                  I will always receieve error saying:

                  您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在第 2 行的 ''' 附近使用的正确语法

                  You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''' at line 2

                  我想知道,因为我复制了 phpmyadmin 生成的完全相同的查询,我认为它肯定会在这里工作.但是为什么会出现这样的错误呢?

                  I was wondering, since I copied exactly the same query generated by phpmyadmin, I think it will definitely work here. But why will such error happen?

                  我尝试修剪查询以仅包含FIELDS TERMINATED BY"并且它起作用了.但是以这种方式填充的数据库将包含不正确的数据.所以我真的很想知道为什么原来的较长查询会失败?

                  I tried trimming the query to contain only "FIELDS TERMINATED BY " and it worked. But the database populated this way will contain incorrect data. So I am really wishing to learn why would the original longer query would fail?

                  谢谢.

                  推荐答案

                  您正在使用双引号字符串,因此 将被视为文字回车和换行人物.您还需要对它们进行双重转义:\r\n.

                  You're using a double-quoted string, so the will be seen as literal carriage return and line feed characters. You'll need to double-escape them as well: \r\n.

                  错误消息中的第 2 行"证明了这一点 - 如果您的查询没有实际的第二行,但由于嵌入的换行符/回车,一旦它到达 MySQL.

                  The "on line 2" in the error message is evidence of this - there's no actual second line if your query, but because of the embedded newline/carriage return, there is once it gets to MySQL.

                  这篇关于MySql 加载数据本地语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在指定的日期范围内在 SQL 中更新/插入随机日期 下一篇:如何将表从mysql数据库导出到excel?

                  相关文章

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

                        <bdo id='UVDFU'></bdo><ul id='UVDFU'></ul>
                    2. <small id='UVDFU'></small><noframes id='UVDFU'>

                      <tfoot id='UVDFU'></tfoot>