开发者

MySQL syntax problem in "SELECT * FROM INTO FILE"

开发者 https://www.devze.com 2023-01-07 21:57 出处:网络
I\'m trying to move tables between two databases and I\'m using this command that is given by MySQL :

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开发者_StackOverflow中文版 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.


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';


replace \n with \ \ n.without spaces. See if that works.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号