SQL: September 2008 Archives

Export from MySQL to CSV

user-pic
Vote 0 Votes

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 那台機器

Recent Entries

About this Archive

This page is an archive of entries in the SQL category from September 2008.

SQL: July 2008 is the previous archive.

SQL: December 2008 is the next archive.

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

Monthly Archives