Syntax to Sqoop import 5 out of 100 tables present in database - don't use exclude keyword?

懵懂的女人 提交于 2019-12-13 09:11:15

问题


I have 100 tables in a database. I want to import only 5 tables. I can't/don't use "-- exclude" command


回答1:


This can be done by shell script.

1)Prepare a input file which has list of 5 DBNAME.TABLENAME 
2)The shell script will have this file as input, iterate line by line and execute sqoop statement for each line.
while read line;
do

    DBNAME=`echo $line | cut -d'.' -f1` 
    tableName=`echo $line | cut -d'.' -f2`


    sqoop import -Dmapreduce.job.queuename=$RM_QUEUE_NAME --connect '$JDBC_URL;databaseName=$DBNAME;username=$USERNAME;password=$PASSWORD' --table $tableName  --target-dir $DATA_COLLECTOR/$tableName  --fields-terminated-by '\001'  -m 1 

done<inputFile


来源:https://stackoverflow.com/questions/50469413/syntax-to-sqoop-import-5-out-of-100-tables-present-in-database-dont-use-exclu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!