使用 SELECT INTO OUTFILE 时包含标题?

2021-11-20 00:00:00 mysql into-outfile

是否可以在使用 MySQL INTO OUTFILE 时以某种方式包含标题?

Is it possible to include the headers somehow when using the MySQL INTO OUTFILE?

推荐答案

您必须自己对这些标题进行硬编码.类似的东西:

You'd have to hard code those headers yourself. Something like:

SELECT 'ColName1', 'ColName2', 'ColName3'
UNION ALL
SELECT ColName1, ColName2, ColName3
    FROM YourTable
    INTO OUTFILE '/path/outfile'

相关文章