1. mysql怎麼將表導出excel格式
由於工作需要,經常需要將mysql資料庫中的數據導出到excel表格,或者需要將excel表格數據導入專到mysql資料庫,我的方法屬是先將它們都轉換成一種中間數據格式csv(execl數據可以直接導出為csv格式,csv格式也可以直接用excel打開)。下面介紹一下操作步驟:
csv導入mysql
load
data
infile
'C:\\Users\\UserName\\Desktop\\test.csv'
into
table
`table`
fields
terminated
by
','
optionally
enclosed
by
'"'
escaped
by
'"'
lines
terminated
by
'\n';
mysql導入csv
select
*
from
`table`
load
data
infile
'C:\\Users\\UserName\\Desktop\\test.csv'
fields
terminated
by
','
optionally
enclosed
by
'"'
escaped
by
'"'
lines
terminated
by
'\n';
如果亂碼,可用相關編輯器打開.csv文件,另存為utf-8的csv
2. mysql將查詢結果導出到excel