[root@kvm8 ~]# mysql -s -uroot -p123qwe mysql> use dyw; mysql>
SELECT ... INTO OUTFILE 匯出資料到檔案。
mysql> select * from animals
-> into outfile '/tmp/animals.txt';
mysql>
mysql> select * from animals into outfile '/tmp/animals.txt'; ERROR 1086 (HY000): File '/tmp/animals.txt' already exists mysql>
[root@kvm8 ~]# cat /tmp/animals.txt 2 cat 4 3 chicken 2 1 dog 4
SELECT ... INTO OUTFILE 並指定格式匯出資料到檔案。
mysql> select * from animals into outfile '/tmp/animals1.txt'
-> fields terminated by ',' enclosed by '"'
-> lines terminated by '\r\n';
[root@kvm8 ~]# cat /tmp/animals1.txt "2","cat","4" "3","chicken","2" "1","dog","4"