Complete the code to import data from a MySQL database using Sqoop.
sqoop import --connect jdbc:mysql://localhost/db --username user --password pass --table [1]
The --table option specifies the database table to import. Here, employees is the correct table name.
Complete the code to specify the target directory in HDFS for the imported data.
sqoop import --connect jdbc:mysql://localhost/db --username user --password pass --table employees --target-dir [1]
The --target-dir option sets the HDFS directory where data will be stored. /user/hadoop/employees is a common path for user data.
Fix the error in the Sqoop import command to specify the number of mappers.
sqoop import --connect jdbc:mysql://localhost/db --username user --password pass --table employees --num-mappers [1]
The --num-mappers option requires a positive integer. 4 is a valid number of mappers.
Fill both blanks to import only rows where the salary is greater than 50000.
sqoop import --connect jdbc:mysql://localhost/db --username user --password pass --table employees --where "[1] [2] 50000"
The --where clause filters rows. Here, salary > 50000 selects employees with salary above 50000.
Fill all three blanks to import data and save it as a text file with tab delimiter.
sqoop import --connect jdbc:mysql://localhost/db --username user --password pass --table employees --target-dir /user/hadoop/employees --as-[1]file --fields-terminated-by '[2]' --num-mappers [3]
The --as-textfile option imports data as text files. The --fields-terminated-by '\t' sets tab as delimiter. 4 mappers speed up import.