Monday, December 31, 2007
Export Mysql database tables to CSV .txt files
This is how we can achieve the same.
Suppose mysql DB FAN got table called DETAILS with the following contents:
mysql> select * from FAN.DETAILS;
+----------+------------+------+--------------------+
| fan_name | time | rpm | status |
+----------+------------+------+--------------------+
| FAN1 | 1195699322 | 4566 | Moderate Condition |
| FAN12 | 1195699112 | 3562 | Bad Condition |
| FAN11 | 1195699321 | 5676 | Good Condition |
| FAN15 | 1195699117 | 8923 | Good Condition |
+----------+------------+------+--------------------+
4 rows in set (0.00 sec)
$ ./mysqldump.exe -u root --fields-terminated-by=, --tab=/tmp --tables FAN
It will create DETAILS.txt under tmp dir (will create individual .txt CSV files for each table)
$ cat /tmp/DETAILS.txt
FAN1,1195699322,4566,Moderate Condition
FAN12,1195699112,3562,Bad Condition
FAN11,1195699321,5676,Good Condition
FAN15,1195699117,8923,Good Condition
Subscribe to:
Post Comments (Atom)
© Jadu Saikia www.UNIXCL.com
No comments:
Post a Comment