Sqoop export selected columns


#1

how to sqoop export only selected columns to target table. for ex source order table got 5 columns col1,col2,col3,col4,col5 but my target got two fields col3,col1.

i tried --columns attribute which takes first two columns from source as this attribute represents the target table, is there any source attribute to define what columns to be considered ?


#2

@srinibigdata:

target table structure should match with source table
Column names should match with target table
Make sure the correct export-dir too

I tried this way and it is successful.
sqoop export
–connect jdbc:mysql://ms.itversity.com:3306/retail_export
–username retail_user
–password itversity
–export-dir /apps/hive/warehouse/vanampudi_sqoop_import.db/daily_revenue
–table daily_revenue_demo_va
–columns order_date,revenue
–input-fields-terminated-by “\001”
–num-mappers 1

Thanks
Venkat


#3

thanks venkat. i see if source and target table structure must match then it wont work the way i was trying to export.