获取oracle表的元素据,拼凑hive建表语句以及需要的conf
2017-01-08 16:00
375 查看
1.获取建表语句:
2.获取字段中间用逗号隔开
3.查询表的大小(根据表大小判断是否增量或者全量迁移数据1G一下全量,1G以上增量)
可以利用java代码将上面的sql的结果拼凑成hive的建表语句,以及需要配置的conf
select t.OWNER,t.COLUMN_ID,t.COLUMN_NAME,' ', 'STRING',' ',concat(concat('COMMENT" ',t2.COMMENTS),'",') as commentname from all_tab_columns t left join all_tab_comments t1 on t.OWNER=t1.OWNER and t.TABLE_NAME=t1.TABLE_NAME left join all_col_comments t2 on t.OWNER=t2.OWNER and t.TABLE_NAME=t2.TABLE_NAME and t.COLUMN_NAME=t2.COLUMN_NAME where 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 t where t.Segment_Name='表名' Group By Segment_Name
可以利用java代码将上面的sql的结果拼凑成hive的建表语句,以及需要配置的conf
相关文章推荐
- 在Oracle中,快速获取一个部门以及它下面所有的子部门的方法。
- oracle获取自己需要的日期格式
- ^全^ 获取SQL SERVER2000/2005、MySql、Oracle元数据的SQL语句 [SQL语句来自CodeSmith]
- 关于Oracle与SqlServer中获取所有字段、主键、外键的sql语句
- Oracle 查看当前会话所执行的语句以及会话相关信息
- Oracle中获取表空间DDL语句
- ORACLE如何使用DBMS_METADATA.GET_DDL获取DDL语句
- 关于Oracle与SqlServer、Access中获取所有字段、主键、外键的sql语句
- 关于Oracle与SqlServer中获取所有字段、主键、外键的sql语句
- Oracle中ID的自动增加以及获取系统时间的小技巧
- 如何用SQL语句获取Oracle指定表的表结构
- ORACLE如何使用DBMS_METADATA.GET_DDL获取DDL语句
- 关于Oracle与SqlServer中获取所有字段、主键、外键的sql语句
- 获取数据库系统信息的SQL语句(Mysql,Oracle)
- [转]:ORACLE如何使用DBMS_METADATA.GET_DDL获取DDL语句
- 获取oracle中某一用户某一表空间下的表、列注释说明的SQL查询语句
- 如何用SQL查询语句获取Oracle表 树形结构的记录(PL/SQL )
- 原:Oracle 和 SqlServer下获取主外键表名字段名约束名的语句
- ^全^ 获取SQL SERVER2000/2005、MySql、Oracle元数据的SQL语句(2)
- 获取分页的查询语句-针对MS2005和Oracle