25 Nisan 2008 Cuma

How To Export Query Results In Mysql

Use "INTO OUTFILE" directive in your queries to export data from mysql into a text file.

mysql> select * from videos order by artist INTO OUTFILE "c:\videos.csv"
Query OK, 3269 rows affected (0.05 sec)


Use "FIELDS TERMINATED BY" directive to determine delimiter between fields.

mysql> select * from videos order by artist INTO OUTFILE "c:\videos.csv" FIELDS TERMINATED BY "|";
Query OK, 3269 rows affected (0.06 sec)


If you do not specify absolute path in "INTO OUTFILE" directive, the file will be recorded in current database's path. For example, assume that mysql is installed in "D:\dev\mysql" and the current database is "video_db"; then the path of videos.csv would be "D:\dev\mysql\data\video_db".

Hiç yorum yok: