สามารถทำได้ด้วยคำสั่ง SELECT ... INTO OUTFILE สาธิตได้จากตัวอย่าง:
ตัวอย่าง
สมมติมีข้อมูลต่อไปนี้จากตาราง 'Student_info':
mysql> SELECT * FROM Student_info; +------+---------+------------+------------+ | id | Name | Address | Subject | +------+---------+------------+------------+ | 101 | YashPal | Amritsar | History | | 105 | Gaurav | Chandigarh | Literature | | 125 | Raman | Shimla | Computers | | 130 | Ram | Jhansi | Computers | | 132 | Shyam | Chandigarh | Economics | | 133 | Mohan | Delhi | Computers | +------+---------+------------+------------+ 6 rows in set (0.07 sec)
คิวรีต่อไปนี้ส่งออกข้อมูลทั้งหมดจาก 'Student_info' ไปไฟล์ 'student.txt':
mysql> SELECT * FROM student_info INTO OUTFILE 'C:/mysql/bin/mysql-files/student.txt'; Query OK, 6 rows affected (0.01 sec)
คิวรีข้างต้นจะสร้างไฟล์ 'Student.txt' และส่งออกข้อมูลทั้งหมดจาก 'Student_info' ไปในไฟล์