Reputation: 145
For example:
COPY INTO @my_stage/my_test.csv
FROM (select * from my_table)
FILE_FORMAT = (TYPE = CSV)
OVERWRITE=TRUE SINGLE=TRUE
will result in a csv but does not include column headers. If it is not possible with a copy into statement, is there perhaps any non-obvious technique that might accomplish this?
Thanks in advance.
Upvotes: 11
Views: 9237
Reputation: 5273
To supplement @Jiaxing's answer, the Snowflake HEADER
feature also allows you to explicitly define your column names by naming the columns via AS
:
COPY INTO @my_stage/my_test.csv
FROM (
SELECT
column1 AS "Column 1",
column2 AS "Column 2"
FROM my_table
) FILE_FORMAT = (TYPE = CSV)
HEADER=TRUE
Upvotes: 2
Reputation: 302
Snowflake has added this feature. You can simply add an option HEADER=TRUE
:
COPY INTO @my_stage/my_test.csv
FROM (select * from my_table)
FILE_FORMAT = (TYPE = CSV)
OVERWRITE=TRUE SINGLE=TRUE HEADER=TRUE
Upvotes: 12
Reputation: 4729
We've seen this request before, and it's on our roadmap. If it's high priority for you, please contact Snowflake support.
If you're looking for a workaround, it's hard to come up with a truly generic one.
But I hope Snowflake will add this functionality in the not-so-far future.
Upvotes: 4