假设一个表 table_test
col1 col2 col3 col4
1 a b c
2 d e f
3 g h i
SELECT col1, col2, col3, col4 into outfile “d:\test.txt” fields terminated by “|” lines terminated by “\r\n” FROM table_test;
这样确实能够将数据导出,但本人想在首航加上标题(列名),怎么样加?
col1 col2 col3 col4
1 a b c
2 d e f
3 g h i
SELECT col1, col2, col3, col4 into outfile “d:\test.txt” fields terminated by “|” lines terminated by “\r\n” FROM table_test;
这样确实能够将数据导出,但本人想在首航加上标题(列名),怎么样加?
解决方案
20
列名可以用union all
select “columnName1”, “columnName2” from dual
union all
select columnName1, columnName2 from table
select “columnName1”, “columnName2” from dual
union all
select columnName1, columnName2 from table