擷取oracle表的元素據,拼湊hive建表語句以及需要的conf____oracle

來源:互聯網
上載者:User

1.擷取建表語句:

select t.OWNER,t.COLUMN_ID,t.COLUMN_NAME,' ', 'STRING',' ',concat(concat('COMMENT" ',t2.COMMENTS),'",') as commentnamefrom all_tab_columns t left join all_tab_comments t1on t.OWNER=t1.OWNERand t.TABLE_NAME=t1.TABLE_NAMEleft join all_col_comments t2on t.OWNER=t2.OWNERand t.TABLE_NAME=t2.TABLE_NAMEand t.COLUMN_NAME=t2.COLUMN_NAMEwhere t.TABLE_NAME='表名'order by t.OWNER,t.TABLE_NAME,COLUMN_ID;

2.擷取欄位中間用逗號隔開

select wm_concat(COLUMN_NAME) from (select t.COLUMN_NAME from all_tab_columns t where t.TABLE_NAME='表名'and t.OWNER='屬主'order by t.OWNER,t.TABLE_NAME,COLUMN_ID)

3.查詢表的大小(根據表大小判斷是否增量或者全量遷移資料1G一下全量,1G以上增量)

Select Segment_Name, to_char( Sum(bytes) / 1024 / 1024/1024,'FM999999.99') From dba_segments twhere t.Segment_Name='表名'Group By Segment_Name

可以利用java代碼將上面的sql的結果拼湊成hive的建表語句,以及需要配置的conf

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.