Export from MySQL to CSV

| | Comments (0)

Export from MySQL to CSV
這篇提到的轉 CSV 方法滿不錯的
方法一
mysql -uusername -ppassword dbname -B -e "select * from tablename`;" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > filename.csv
方法二
SELECT * INTO OUTFILE '/tmp/filename.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM tablename;
此方法是存在 Server 那台機器

Leave a comment

March 2009

Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

About this Entry

This page contains a single entry by Pank published on September 11, 2008 11:41 AM.

cwrsync was the previous entry in this blog.

IGMP Proxy is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.