I have a 1 GB table, I need to output the db to multiple csv files based on column value. For instance:
c1 | c2 | c3
1 | a | 100
2 | b | 102
3 | a | 103
4 | b | 104
to be:
a.csv
1 | a | 100
3 | a | 103
b.csv
2 | b | 102
4 | b | 104
considering the size of table, what's the most efficient way to do this?
Update:
so far I have been able to do select * from table_name order by c2; and .mode csv .out a.csv select * from table_name; on a smaller sample of the dataset. I was wondering what are alternative except looping through all item manually.