Join the discussion
Question 30/34
CORRECT TEXT
Problem Scenario 10 : You have been given following mysql database details as well as other info.
user=retail_dba
password=cloudera
database=retail_db
jdbc URL = jdbc:mysql://quickstart:3306/retail_db
Please accomplish following.
1. Create a database named hadoopexam and then create a table named departments in it, with following fields. department_id int, department_name string e.g. location should be
hdfs://quickstart.cloudera:8020/user/hive/warehouse/hadoopexam.db/departments
2. Please import data in existing table created above from retaidb.departments into hive table hadoopexam.departments.
3. Please import data in a non-existing table, means while importing create hive table named hadoopexam.departments_new
Problem Scenario 10 : You have been given following mysql database details as well as other info.
user=retail_dba
password=cloudera
database=retail_db
jdbc URL = jdbc:mysql://quickstart:3306/retail_db
Please accomplish following.
1. Create a database named hadoopexam and then create a table named departments in it, with following fields. department_id int, department_name string e.g. location should be
hdfs://quickstart.cloudera:8020/user/hive/warehouse/hadoopexam.db/departments
2. Please import data in existing table created above from retaidb.departments into hive table hadoopexam.departments.
3. Please import data in a non-existing table, means while importing create hive table named hadoopexam.departments_new
Correct Answer:
See the explanation for Step by Step Solution and configuration.
Explanation:
Solution :
Step 1 : Go to hive interface and create database.
hive
create database hadoopexam;
Step 2. Use the database created in above step and then create table in it. use hadoopexam; show tables;
Step 3 : Create table in it.
create table departments (department_id int, department_name string);
show tables;
desc departments;
desc formatted departments;
Step 4 : Please check following directory must not exist else it will give error, hdfs dfs -Is
/user/cloudera/departments
If directory already exists, make sure it is not useful and than delete the same.
This is the staging directory where Sqoop store the intermediate data before pushing in hive table.
hadoop fs -rm -R departments
Step 5 : Now import data in existing table
sqoop import \
-connect jdbc:mysql://quickstart:3306/retail_db \
~ username=retail_dba \
-password=cloudera \
--table departments \
-hive-home /user/hive/warehouse \
-hive-import \
-hive-overwrite \
-hive-table hadoopexam.departments
Step 6 : Check whether data has been loaded or not.
hive;
use hadoopexam;
show tables;
select" from departments;
desc formatted departments;
Step 7 : Import data in non-existing tables in hive and create table while importing.
sqoop import \
-connect jdbc:mysql://quickstart:3306/retail_db \
--username=retail_dba \
~ password=cloudera \
-table departments \
-hive-home /user/hive/warehouse \
-hive-import \
-hive-overwrite \
-hive-table hadoopexam.departments_new \
-create-hive-table
Step 8 : Check-whether data has been loaded or not.
hive;
use hadoopexam;
show tables;
select" from departments_new;
desc formatted departments_new;
Explanation:
Solution :
Step 1 : Go to hive interface and create database.
hive
create database hadoopexam;
Step 2. Use the database created in above step and then create table in it. use hadoopexam; show tables;
Step 3 : Create table in it.
create table departments (department_id int, department_name string);
show tables;
desc departments;
desc formatted departments;
Step 4 : Please check following directory must not exist else it will give error, hdfs dfs -Is
/user/cloudera/departments
If directory already exists, make sure it is not useful and than delete the same.
This is the staging directory where Sqoop store the intermediate data before pushing in hive table.
hadoop fs -rm -R departments
Step 5 : Now import data in existing table
sqoop import \
-connect jdbc:mysql://quickstart:3306/retail_db \
~ username=retail_dba \
-password=cloudera \
--table departments \
-hive-home /user/hive/warehouse \
-hive-import \
-hive-overwrite \
-hive-table hadoopexam.departments
Step 6 : Check whether data has been loaded or not.
hive;
use hadoopexam;
show tables;
select" from departments;
desc formatted departments;
Step 7 : Import data in non-existing tables in hive and create table while importing.
sqoop import \
-connect jdbc:mysql://quickstart:3306/retail_db \
--username=retail_dba \
~ password=cloudera \
-table departments \
-hive-home /user/hive/warehouse \
-hive-import \
-hive-overwrite \
-hive-table hadoopexam.departments_new \
-create-hive-table
Step 8 : Check-whether data has been loaded or not.
hive;
use hadoopexam;
show tables;
select" from departments_new;
desc formatted departments_new;
Add Comments
- Other Question (34q)
- Q1. CORRECT TEXT Problem Scenario 29 : Please accomplish the following exercises using HDFS co...
- Q2. CORRECT TEXT Problem Scenario 59 : You have been given below code snippet. val x = sc.para...
- Q3. CORRECT TEXT Problem Scenario 25 : You have been given below comma separated employee info...
- Q4. CORRECT TEXT Problem Scenario 50 : You have been given below code snippet (calculating an ...
- Q5. CORRECT TEXT Problem Scenario 95 : You have to run your Spark application on yarn with eac...
- Q6. CORRECT TEXT Problem Scenario 48 : You have been given below Python code snippet, with int...
- Q7. CORRECT TEXT Problem Scenario 37 : ABCTECH.com has done survey on their Exam Products feed...
- Q8. CORRECT TEXT Problem Scenario 40 : You have been given sample data as below in a file call...
- Q9. CORRECT TEXT Problem Scenario 9 : You have been given following mysql database details as ...
- Q10. CORRECT TEXT Problem Scenario 34 : You have given a file named spark6/user.csv. Data is gi...
- Q11. CORRECT TEXT Problem Scenario 41 : You have been given below code snippet. val aul = sc.pa...
- Q12. CORRECT TEXT Problem Scenario 53 : You have been given below code snippet. val a = sc.para...
- Q13. CORRECT TEXT Problem Scenario 51 : You have been given below code snippet. val a = sc.para...
- Q14. CORRECT TEXT Problem Scenario 2 : There is a parent organization called "ABC Group Inc", w...
- Q15. CORRECT TEXT Problem Scenario 19 : You have been given following mysql database details as...
- Q16. CORRECT TEXT Problem Scenario 56 : You have been given below code snippet. val a = sc.para...
- Q17. CORRECT TEXT Problem Scenario 93 : You have to run your Spark application with locally 8 t...
- Q18. CORRECT TEXT Problem Scenario 32 : You have given three files as below. spark3/sparkdir1/f...
- Q19. CORRECT TEXT Problem Scenario 18 : You have been given following mysql database details as...
- Q20. CORRECT TEXT Problem Scenario 22 : You have been given below comma separated employee info...
- Q21. CORRECT TEXT Problem Scenario 80 : You have been given MySQL DB with following details. us...
- Q22. CORRECT TEXT Problem Scenario 78 : You have been given MySQL DB with following details. us...
- Q23. CORRECT TEXT Problem Scenario 4: You have been given MySQL DB with following details. user...
- Q24. CORRECT TEXT Problem Scenario 20 : You have been given MySQL DB with following details. us...
- Q25. CORRECT TEXT Problem Scenario 68 : You have given a file as below. spark75/f ile1.txt File...
- Q26. CORRECT TEXT Problem Scenario 90 : You have been given below two files course.txt id,cours...
- Q27. CORRECT TEXT Problem Scenario 27 : You need to implement near real time solutions for coll...
- Q28. CORRECT TEXT Problem Scenario 81 : You have been given MySQL DB with following details. Yo...
- Q29. CORRECT TEXT Problem Scenario 74 : You have been given MySQL DB with following details. us...
- Q30. CORRECT TEXT Problem Scenario 10 : You have been given following mysql database details as...
- Q31. CORRECT TEXT Problem Scenario 79 : You have been given MySQL DB with following details. us...
- Q32. CORRECT TEXT Problem Scenario 45 : You have been given 2 files , with the content as given...
- Q33. CORRECT TEXT Problem Scenario 36 : You have been given a file named spark8/data.csv (type,...
- Q34. CORRECT TEXT Problem Scenario 5 : You have been given following mysql database details. us...
