0% found this document useful (0 votes)
58 views3 pages

Class 4

1) The document shows SQL commands to create a CUSTOMERS table in a MySQL database and insert sample records. 2) It then uses Sqoop to import the table data from MySQL to HDFS directories in Hadoop and export data from HDFS back to the MySQL table. 3) Incremental imports are also demonstrated using the --incremental flag to only import new or updated records based on the check column ID since the last import.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views3 pages

Class 4

1) The document shows SQL commands to create a CUSTOMERS table in a MySQL database and insert sample records. 2) It then uses Sqoop to import the table data from MySQL to HDFS directories in Hadoop and export data from HDFS back to the MySQL table. 3) Incremental imports are also demonstrated using the --incremental flag to only import new or updated records based on the check column ID since the last import.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

https://drive.google.com/drive/folders/1mEgXcnFmjtr8lfU2oFd3IYartNFhlPok?

usp=sharing

Hi Sir, Nice Learning with you..do you have any seperate upcoming batch on BDH..i
would like to learn in the simle way as you teaching, coz i am fresher to BDH

https://community.simplilearn.com/threads/big-data-hadoop-and-spark-developer-
deepak-garg-10-may-june-1.65971/

https://community.simplilearn.com/threads/big-data-hadoop-and-spark-developer-
deepak-garg-10-may-june-1.65971/

mysql -h sqoopdb.slbdh.cloudlabs.com -u nesure11gmail –p

CREATE TABLE CUSTOMERS (


ID INT NOT NULL,
NAME VARCHAR(30) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR(25) ,
SALARY DECIMAL(18,2),
PRIMARY KEY (ID)
);
SHOW TABLES;

INSERT INTO CUSTOMERS(ID,NAME,AGE,ADDRESS,SALARY)


VALUES(1,'Sehwag',23,'Delhi', 1000.00);
INSERT INTO CUSTOMERS(ID,NAME,AGE,ADDRESS,SALARY)
VALUES(2,'Sachin',25,'Mumbai', 1200.00);
INSERT INTO CUSTOMERS(ID,NAME,AGE,ADDRESS,SALARY)
VALUES(3,'Saurav',24,'Kolkatta', 1100.00);

sqoop import \
--connect jdbc:mysql://sqoopdb.slbdh.cloudlabs.com/nesure11gmail \
--username nesure11gmail \
--password nesure11gmailoc75q \
--table CUSTOMERS \
-m 3 \
--target-dir '/user/nesure11gmail/sqoop_sql/' \
--delete-target-dir

DELETE FROM CUSTOMERS;

select * from CUSTOMERS;

sqoop export \
--connect jdbc:mysql://sqoopdb.slbdh.cloudlabs.com/deepakpec2004gmail \
--table CUSTOMERS \
--username deepakpec2004gmail \
--password deepakpec2004gmailoylgk \
-m 3 \
--export-dir '/user/deepakpec2004gmail/sqoop_sql/'

INSERT INTO CUSTOMERS(ID,NAME,AGE,ADDRESS,SALARY)


VALUES(4,'Vishnu',23,'Delhi', 1000.00);
INSERT INTO CUSTOMERS(ID,NAME,AGE,ADDRESS,SALARY)
VALUES(5,'Rajat',23,'Delhi', 1000.00);

sqoop import \
--connect jdbc:mysql://sqoopdb.slbdh.cloudlabs.com/deepakpec2004gmail \
--table CUSTOMERS \
--username deepakpec2004gmail \
--password deepakpec2004gmailoylgk \
-m 1 \
--target-dir '/user/deepakpec2004gmail/sqoop_sql/' \
--incremental append \
--check-column ID \
--last-value 3

sqoop job --create empupdatejob \


-- import \
--connect jdbc:mysql://sqoopdb.slbdh.cloudlabs.com/deepakpec2004gmail \
--username deepakpec2004gmail \
--password deepakpec2004gmailoylgk \
--table CUSTOMERS \
--m 1 \
--incremental append \
--check-column ID \
--last-value 0 \
--target-dir '/user/deepakpec2004gmail/sqoop_sql/'

sqoop job --exec empupdatejob

-----------------------------------------------------------------------------------
--

1) Connect to My SQL RDBMS


mysql -h sqoopdb.slbdh.cloudlabs.com -u deepakpec2004gmail -p
2) Create a database
CREATE DATABASE deepakpec2004gmail;
3) Create a table inside the database
CREATE TABLE CUSTOMERS (
ID INT NOT NULL,
NAME VARCHAR(30) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR(25) ,
SALARY DECIMAL(18,2),
PRIMARY KEY (ID)
);
SHOW TABLES;
4) Insert rows into the table
INSERT INTO CUSTOMERS(ID,NAME,AGE,ADDRESS,SALARY)
VALUES(1,'Sehwag',23,'Delhi', 1000.00);
INSERT INTO CUSTOMERS(ID,NAME,AGE,ADDRESS,SALARY)
VALUES(2,'Sachin',25,'Mumbai', 1200.00);
INSERT INTO CUSTOMERS(ID,NAME,AGE,ADDRESS,SALARY)
VALUES(3,'Saurav',24,'Kolkatta', 1100.00);
5) Check the rows
select * from CUSTOMERS;
mysql -h sqoopdb.slbdh.cloudlabs.com -u deepakpec2004gmail -p
Sqoop Import Command
We are going import all the CUSTOMERS data into HDFS
Sqoop Import Command
sqoop import \
--c

You might also like