问题
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