217.Sqoop Export – Using update-mode – allow-insert

  • Command to merge data using update-mode
    • 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 --update-key order_date --update-mode allowinsert
  • Command to connect to mysql
    • mysql -u retail_user -h ms.itversity.com -p
  • Command to connect to a database
    • USE retail_export;
  • To validate table
    • SELECT count(1) FROM training_daily_revenue;
    • SELECT * FROM training_daily_revenue WHERE order_date LIKE '2013-07-25%' ;
    • SELECT * FROM training_daily_revenue LIMIT 10;
  • Command to truncate the table
    • TRUNCATE TABLE training_daily_revenue;
  • Command to alter table and specify primary key
    • ALTER TABLE training_daily_revenue ADD PRIMARY KEY (order_date);
  • Command to delete records from table
    • DELETE FROM training_daily_revenue WHERE order_date > '2013-12-31 00:00:00.0';
  • Command to update values in table
    • UPDATE training_daily_revenue SET revenue = 0;
  • Command to commit the changes made in table
    • COMMIT

Share this post