MySQL“SELECT * FROM INTO FILE”中的语法问题
我正在尝试在两个数据库之间移动表,并且我正在使用 MySQL 提供的命令:
SELECT *
INTO OUTFILE '/tmp/result.txt'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table;
正如 MySQL 开发手册中所写的那样。我正在使用 MySQL 5.1。
错误 :
错误代码:1064 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行“\n”附近使用的正确语法)
每次运行它时都会遇到问题。它说由于 '\n' 而存在语法错误?这个问题的解决办法是什么?我正在使用 MySQL Workbench 来查询数据库。我尝试了命令行,它给出了同样的错误。
请不要建议替代方案,我只是想让这个方法起作用。
I'm trying to move tables between two databases and I'm using this command that is given by MySQL :
SELECT *
INTO OUTFILE '/tmp/result.txt'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table;
As it is written in the MySQL Dev Manual. I'm using MySQL 5.1.
Error :
Error Code: 1064 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 '\n'' at line 1)
I'm getting a problem every time I run it. It it says that there is a syntax error becasue of '\n' ? What is the solution to this problem ? I'm using MySQL Workbench to query the database. I tried the command line, IT gives the same error.
Please don't suggest alternatives, I just want this method to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 MySQL 文档,您的表引用不合适。
<代码>选择*
来自测试表
INTO OUTFILE '/tmp/result.txt'
以“,”结尾的字段
可选地用“””括起来
行以 '\n' 结尾;
Your table reference is out of place, as per the MySQL Documentation.
SELECT *
FROM test_table
INTO OUTFILE '/tmp/result.txt'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n';
将 \n 替换为 \\ n.不带空格。看看是否有效。
replace \n with \ \ n.without spaces. See if that works.