[Sqoop] using Sqoop to perform DML operations on MySQL

Source: Internet
Author: User
Tags sqoop accumulo

Business Background

Use Sqoop to query, add and delete MySQL.

Business Implementation

Select operation:

sqoop eval --connect jdbc:mysql://127.0.0.1:3306/market --username admin --password 123456 --query "select end_user_id, category_id, score, last_bought_date, days_left, update_time 

The results of the implementation are as follows:

[[email protected]/home/pms/workspace/ouyangyewei/data] $sqoop eval >--connect jdbc:mysql://10.0.2.54:3307/market \>--username marketuser >--password123456>--query"Select end_user_id, category_id, score, last_bought_date, Days_left, Update_time> from the market. Period_recommend limitTen" Warning:/usr/lib/sqoop/. /accumulo does not exist! Accumulo imports would fail. Please set $ACCUMULO _home to the root of your Accumulo installation. the/ ./ the  the: $: -INFO Sqoop. Sqoop:running Sqoop Version:1.4.4-cdh5.0.2 the/ ./ the  the: $: -WARN tool. Basesqooptool:setting your password on the command-line is insecure. Consider Using-p instead. the/ ./ the  the: $: -INFO Manager. Mysqlmanager:preparing to use a MySQL streaming ResultSet.--------------------------------------------------------------------------------------------------------------| end_user_id | category_id | Score | Last_bought_date | Days_left | Update_time | --------------------------------------------------------------------------------------------------------------| 1020 | 6639 | 0.03765381553445836 | 2015-02-26 | | 2015-06-01 10:57:09.0 || 1180 | 6008 | 0.49232472007320505 | 2015-05-16 | 5 | 2015-06-01 11:00:30.0 || 1180 | 6638 | 0.12863038975524008 | 2015-05-16 | | 2015-06-04 11:04:18.0 || 1180 | 6641 | 0.016126884197067093 | 2015-05-16 | | | 2015-06-08 11:06:54.0 || 1180 | 972108 | 0.9059551911095096 | 2015-04-12 | 4 | 2015-06-01 11:00:30.0 || 1580 | 959307 | 0.015703642709355377 | 2015-04-26 | | 2015-06-07 11:20:13.0 || 1620 | 5059 | 0.03979611383975357 | 2015-03-11 | all | 2015-06-02 11:24:50.0 || 1680 | 959307 | 0.21385565120306954 | 2015-05-07 | one | 2015-06-04 11:28:21.0 || 2030 | 6638 | 0.03160084296270789 | 2015-03-09 | | | 2015-06-03 11:35:04.0 || 2110 | 6641 | 0.9888130446112331 | 2015-03-14 |-6 | 2015-06-05 11:41:16.0 |--------------------------------------------------------------------------------------------------------------

Delete operation:

sqoop eval --connect jdbc:mysql://127.0.0.1:3306/market --username admin --password 123456 --query "delete from PERIOD_RECOMMEND where update_time < ‘2015-06-01‘" 

sqoop eval, you --query can perform DML operations on MySQL by simply specifying the SQL statement in the parameters.

[Sqoop] using Sqoop to perform DML operations on MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.