218.Sqoop Export – Specifying Columns

  • Command to connect to mysql
    • mysql -u retail_user -h ms.itversity.com -p
  • Command to connect to a database
    • USE retail_export;
  • Command to get meta-data on table
    • DESCRIBE training_daily_revenue;
  • Command to truncate the table
    • TRUNCATE TABLE training_daily_revenue;
  • Command to alter table
    • ALTER TABLE ADD description VARCHAR(200);
  • Command to export data
    • sqoop export --connect jdbc:mysql://ms.itversity.com:3306/retail_export --username retail_user --password itversity --export-dir /apps/hive/warehouse/training_sqoop_retail.db/daily_revenue --table training_daily_revenue --columns order_date,revenue
  • To validate table
    • SELECT * FROM training_daily_revenue LIMIT 10;

Share this post