I'm trying to export a table from Google Cloud SQL into a CSV file using the gcloud sql export csv
command from Gcloud SDK but I don't have the option to export on top of the file also the names of the columns. Is there any workaround for this?
Thanks
I believe that this command should produce the necessary functionality:
gcloud sql export csv instance_name gs://bucket_name/ --query="SELECT 'columnname1' , 'columnname2', 'columnname3' UNION SELECT columnname1, columnname2, columnname3 FROM table_name" --database=database_name
One downside of doing it this way is you have to specify all columns. If there is a large number of those, it might be better to write some script to write the SQL query part.
A feature request has been created on your behalf. Please star it so that you could receive updates about this feature request and do not hesitate to add additional comments to provide details of the desired implementation. You can track the feature request by following this link.