您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關hadoop hive與Oracle如何互相導入數據的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
#1.在Oracle上建立要處理的表 create table SOURCE_TABLE_NAME as SELECT t.*,rownum as row_num FROM SOURCE_TABLE_NAME_O t ; alter table SOURCE_TABLE_NAME add constraint SOURCE_TABLE_NAME_P primary key (ROW_NUM); #2.在Oracle上建立處理結果表 DEST_TABLE_NAME #3.oracle導入到hadoop nohup \ sqoop import \ --hive-import \ --connect jdbc:oracle:thin:@192.168.1.14:1521:oradb1 \ --username USER1 \ --password "密碼" \ --verbose -m 32 \ --table SOURCE_TABLE_NAME \ --hive-table db_hive.SOURCE_TABLE_NAME \ --fields-terminated-by '\t' \ --lines-terminated-by '\n' & #4.計算 hive -e "drop table db_hive.DEST_TABLE_NAME ; create table db_hive.DEST_TABLE_NAME row format delimited fields terminated by '\t' STORED AS TEXTFILE as \ select \ max(Dn) as Dn, \ EutranCellTdd_uk , \ max(EutranCellTdd_name) as EutranCellTdd_name, \ max(GsmRelation) as GsmRelation, \ adj_uk, \ max(adj_name) as adj_name, \ max(EnbFunction_uk) as EnbFunction_uk, \ max(EnbFunction_name) as EnbFunction_name, \ max(ManagedElement_uk) as ManagedElement_uk, \ max(ManagedElement_name) as ManagedElement_name, \ max(omc_uk) as omc_uk, \ max(omc_name) as omc_name, \ sum(HO_ToGsmAttOutPerRelation) as HO_ToGsmAttOutPerRelation, \ sum(HO_ToGsmSuccOutPrepPerRelation) as HO_ToGsmSuccOutPrepPerRelation, \ sum(HO_ToGsmSuccOutPerRelation) as HO_ToGsmSuccOutPerRelation, \ max(VENDOR_UK) as VENDOR_UK, \ max(VENDOR_NAME) as VENDOR_NAME, \ max(city_name) as city_name \ from db_hive.SOURCE_TABLE_NAME \ group by EutranCellTdd_uk, adj_uk ;" #5.hadoop導出oracle(需要清空目標表DEST_TABLE_NAME) sqoop export \ --connect jdbc:oracle:thin:@192.168.1.14:1521:oradb1 \ --username USER1 \ --password "密碼" \ --table DEST_TABLE_NAME \ --export-dir /user/hive/warehouse/db_hive.db/DEST_TABLE_NAME \ --input-fields-terminated-by '\t' \ --input-lines-terminated-by '\n' \ --null-string '\\N' \ --null-non-string '\\N'
感謝各位的閱讀!關于“hadoop hive與Oracle如何互相導入數據”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。