INSERT INTO EXTERNAL CSV Examples
1. Write the contents of the sales table to a file named sales_fact.csv in HDFS location. Indicate null values with the text NULL, separate fields with a comma, and separate records with \n.
INSERT INTO EXTERNAL CSV 'hdfs://mydatanode:8020/Actian/tmp/sales_fact.csv' SELECT * FROM sales WITH NULL_MARKER='NULL', FIELD_SEPARATOR=',', RECORD_SEPARATOR='\n'
2. Export data in the MY_TABLE table to a file named "mytable" using relative path, and insert the text THIS IS NULL for null values:
INSERT INTO EXTERNAL CSV '/tmp/mytable.csv' SELECT * FROM my_table WITH NULL_MARKER='"THIS IS NULL"'
3. Export data in the supplier table to a file named supplier.csv in HDFS location, and insert the text NULL for null values:
INSERT INTO EXTERNAL CSV 'hdfs://your.domain.com:8020/tmp/supplier.csv' SELECT * FROM supplier WITH NULL_MARKER='NULL'