在 MySQL 数据库中我有 100 个表。一些表名称的结尾类似如下
123_testing
124_testing
125_testing_10
and so on
现在我想选择以 _testing
结尾的表,并将结果作为 hdfs 中的文件。
我想将表名作为文件发送到 HDFS。
我们怎样才能做到这一点。
我可以使用sqoop list-tables
,但它给出了所有表和本地计算机上的结果。我们不能用它指定 --target-dir
选项。
最佳答案
list-tables
不接受 --target-dir
参数。
表名可在 MySQL 的 information_schema
数据库中找到。此查询将获取 db_name
中以 _testing
结尾的表。
select TABLE_NAME from TABLES where TABLE_SCHEMA='db_name' and TABLE_NAME like '%_testing';
将此查询与 sqoop-import
中的 --query
参数一起使用,然后使用 --target-dir
。
关于mysql - 从 MySQL 选择表名作为文件发送到 HDFS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42659744/