Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I want to export data from mysql to csv file, but the database stored some truncate data. when i use select into outfile, it does not work.

there some truncated data in the nick_name field, see figure below

enter image description here

when i use the folling sql to export data, vote_counter field missed in the csv file.

select user.urs, user.phone, user.last_login_ip, post.nick_name, post.vote_counter into       outfile 
'/tmp/chenyy' FIELDS TERMINATED by ',' LINES TERMINATED BY '\r\n'  from user, post

table schema is:

+--------------+------------------+------+-----+---------+----------------+
| Field        | Type             | Null | Key | Default | Extra          |
+--------------+------------------+------+-----+---------+----------------+
| id           | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| user_id      | int(10) unsigned | YES  | MUL | NULL    |                |
| title        | varchar(40)      | NO   |     | NULL    |                |
| content      | varchar(280)     | NO   |     | NULL    |                |
| pic_key      | varchar(80)      | YES  | UNI | NULL    |                |
| status       | int(10) unsigned | NO   |     | NULL    |                |
| vote_counter | int(10) unsigned | NO   |     | NULL    |                |
| post_time    | datetime         | NO   |     | NULL    |                |
| nick_name    | varchar(12)      | NO   |     | NULL    |                |
+--------------+------------------+------+-----+---------+----------------+
share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.