【问题标题】:How can i Import all (and only) Tables of a specific User from a Oracle DB with Sqoop into Hive如何使用 Sqoop 将特定用户的所有(且仅)表从 Oracle 数据库导入 Hive
【发布时间】:2013-01-17 14:35:54
【问题描述】:

我有一个包含大量表(超过 600 个)的数据库,并希望使用 sqoop 将所有表导入 Hive。这就是我使用的命令:

./sqoop import-all-tables --connect jdbc:oracle:thin:@//185.2.252.52:1521/orcl --username TEST --password test

导入总是失败,因为 sqoop 尝试导入一些不属于用户的 oracle 系统表。

    ./sqoop list-tables --connect jdbc:oracle:thin:@//185.2.252.52:1521/orcl --username TEST --password test

list-tables 列出了与以下 sql 查询相同的表:

select * from all_tables;

相反,我想列出并导入(我猜它是相同的表)此查询将使用的相同表:

select * from user_tables;

有没有办法限制通过 sqoop 导入表?如果没有,有没有办法以某种方式配置用户权限,以便“select * from all_tables”会给我与“select * from user_tables”相同的表??

谢谢

【问题讨论】:

    标签: oracle hive sqoop


    【解决方案1】:

    在指向USER_TABLES 视图的架构中创建一个名为ALL_TABLES 的同义词。

    SQL> select count(*) from all_tables;
    
      COUNT(*)
    ----------
          2769
    
    SQL> select count(*) from user_tables;
    
      COUNT(*)
    ----------
            24
    
    SQL> create synonym all_tables for user_tables;
    
    Synonym created.
    
    SQL> select count(*) from all_tables;
    
      COUNT(*)
    ----------
            24
    
    SQL>
    

    这应该会欺骗脚本,除非它明确地将 ALL_TABLES 视图与其所有者限定(例如:SYS.ALL_TABLES)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-17
      • 1970-01-01
      • 1970-01-01
      • 2023-03-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多