Oracle之自动化部署etl程序

自动化配置 v1.0 user权限

sql 复制代码
select upper('DSTCS_' || t.TABLE_NAME) as filename,
       'DSTCS' as src_db_name,
       'TCS' as src_schema,
       upper(t.TABLE_NAME) as src_tablename,
       null as src_where,
       t1.src_query,
       null as src_splitpk,
       'STG' as trg_schema,
       Upper('DSTCS_' || t.TABLE_NAME) as trg_table,
       'F' as trg_writemode,
       null as post_sql,
       '\0x001' as filed_delimter,
       null as sqoop_param,
       null as hive_param,
       upper('DSTCS_' || t.TABLE_NAME || '_EXT') as ext_tablename,
       t2.post_sql_impala,
       5 as map_num,
       '3' as load_type
  from user_all_tables t
  left join ( --src_query
             select t.TABLE_NAME,
                     'select ' ||
                     RTRIM(XMLAGG(XMLPARSE(CONTENT(lower(COLUMN_NAME) ||
                                                   CHR(10) || '      ,')
                                           WELLFORMED) ORDER BY COLUMN_ID).GETCLOBVAL()) ||
                     'to_char(sysdate, ''yyyy-mm-dd hh24:mi:ss'') as inserttime' ||
                     CHR(10) ||
                     '      ,to_char(sysdate, ''yyyy-mm-dd hh24:mi:ss'') as updatetime' ||
                     CHR(10) || '      ,${batchno} as batchno' || CHR(10) ||
                     '      ,${srcsys} as srcsys' || CHR(10) ||
                     ' from $${schema_dstcs}.' || lower(t.TABLE_NAME) ||
                     CHR(10) || 'where 1 = 1' as src_query
               from USER_TAB_COLUMNS t
              where t.TABLE_NAME = upper(t.TABLE_NAME)
              group by t.TABLE_NAME) t1
    on t.TABLE_NAME = t1.TABLE_NAME
  left join ( --post_sql_impala
             select t.TABLE_NAME,
                     'REFRESH $${schema_stg}.DSTCS_' || upper(t.TABLE_NAME) ||
                     '_EXT;' || CHR(10) || 'REFRESH $${schema_stg}.DSTCS_' ||
                     upper(t.TABLE_NAME) || ';' || CHR(10) || CHR(10) ||
                     'INSERT OVERWRITE TABLE $${schema_stg}.DSTCS_' ||
                     upper(t.TABLE_NAME) || CHR(10) || 'SELECT ' ||
                     RTRIM(XMLAGG(XMLPARSE(CONTENT(upper(COLUMN_NAME) ||
                                                   CHR(10) || '      ,')
                                           WELLFORMED) ORDER BY COLUMN_ID).GETCLOBVAL()) ||
                     'INSERTTIME' || CHR(10) || '      ,UPDATETIME' || CHR(10) ||
                     '      ,BATCHNO' || CHR(10) || '      ,SRCSYS' || CHR(10) ||
                     ' FROM $${schema_stg}.DSTCS_' || upper(t.TABLE_NAME) || '_EXT;' ||
                     CHR(10) || CHR(10) || 'REFRESH $${schema_stg}.DSTCS_' ||
                     upper(t.TABLE_NAME) || ';' as post_sql_impala
               from USER_TAB_COLUMNS t
              where t.TABLE_NAME = upper(t.TABLE_NAME)
              group by t.TABLE_NAME) t2
    on t.TABLE_NAME = t2.TABLE_NAME
 where t.TABLE_NAME = upper('&tanme');

自动化配置 v2.0 Dba权限

sql 复制代码
select upper('DSTCS_' || t.TABLE_NAME) as filename,
       'DSTCS' as src_db_name,
       'TCS' as src_schema,
       upper(t.TABLE_NAME) as src_tablename,
       null as src_where,
       t1.src_query,
       null as src_splitpk,
       'STG' as trg_schema,
       Upper('DSTCS_' || t.TABLE_NAME) as trg_table,
       'F' as trg_writemode,
       null as post_sql,
       '\0x001' as filed_delimter,
       null as sqoop_param,
       null as hive_param,
       upper('DSTCS_' || t.TABLE_NAME || '_EXT') as ext_tablename,
       t2.post_sql_impala,
       5 as map_num,
       '3' as load_type
  from all_tables t
  left join ( --src_query
             select t.TABLE_NAME,
                     'select ' ||
                     RTRIM(XMLAGG(XMLPARSE(CONTENT(lower(COLUMN_NAME) ||
                                                   CHR(10) || '      ' || ',')
                                           WELLFORMED) ORDER BY COLUMN_ID).GETCLOBVAL()) ||
                     'to_char(sysdate, ''yyyy-mm-dd hh24:mi:ss'') as inserttime' ||
                     CHR(10) ||
                     '      ,to_char(sysdate, ''yyyy-mm-dd hh24:mi:ss'') as updatetime' ||
                     CHR(10) || '      ,${batchno} as batchno' || CHR(10) ||
                     '      ,${srcsys} as srcsys' || CHR(10) ||
                     ' from $${schema_dstcs}.' || lower(t.TABLE_NAME) ||
                     CHR(10) || 'where 1 = 1' as src_query
               from all_tab_columns t
              where t.TABLE_NAME = upper(t.TABLE_NAME)
              group by t.TABLE_NAME) t1
    on t.TABLE_NAME = t1.TABLE_NAME
  left join ( --post_sql_impala
             select t.TABLE_NAME,
                     'REFRESH $${schema_stg}.DSTCS_' || upper(t.TABLE_NAME) ||
                     '_EXT;' || CHR(10) || 'REFRESH $${schema_stg}.DSTCS_' ||
                     upper(t.TABLE_NAME) || ';' || CHR(10) || CHR(10) ||
                     'INSERT OVERWRITE TABLE $${schema_stg}.DSTCS_' ||
                     upper(t.TABLE_NAME) || CHR(10) || 'SELECT ' ||
                     RTRIM(XMLAGG(XMLPARSE(CONTENT(upper(COLUMN_NAME) ||
                                                   CHR(10) || '      ' || ',')
                                           WELLFORMED) ORDER BY COLUMN_ID).GETCLOBVAL()) ||
                     'INSERTTIME' || CHR(10) || '      ,UPDATETIME' || CHR(10) ||
                     '      ,BATCHNO' || CHR(10) || '      ,SRCSYS' || CHR(10) ||
                     ' FROM $${schema_stg}.DSTCS_' || upper(t.TABLE_NAME) || '_EXT;' ||
                     CHR(10) || CHR(10) || 'REFRESH $${schema_stg}.DSTCS_' ||
                     upper(t.TABLE_NAME) || ';' as post_sql_impala
               from all_tab_columns t
              where t.TABLE_NAME = upper(t.TABLE_NAME)
              group by t.TABLE_NAME) t2
    on t.TABLE_NAME = t2.TABLE_NAME
 where t.TABLE_NAME = upper('&tanme')
   and t.OWNER = UPPER('&owner');

稽核1-数据量核对 自动化 v1.0

sql 复制代码
select (select to_char(nvl(max(to_number(a.sk_measure)), 0))
          from dc_ctl.ctl_audit_param a) + row_number() over(partition by 1 order by 1) as sk_measure,
       lower(t.src_tablename) as measure_name,
       '数量总量校对' as measure_desc,
       'STG_' || Upper(t.src_db_name) || '_RH_CNT' as data_set,
       Upper(t.src_db_name) as srcsys,
       Upper(t.src_db_name) as src_db,
       'STG' as trg_db,
       'SELECT COUNT(*) FROM $${schema_dstcs}.' || Upper(t.src_tablename) as src_sql,
       'REFRESH $${schema_stg}.' || Upper(t.trg_table) || ';' || CHR(10) ||
       'SELECT COUNT(*) FROM $${schema_stg}.' || Upper(t.trg_table) as trg_sql,
       'RH' as rule,
       0 as err_val,
       0 as err_type,
       'ERROR' as treatment_type,
       1 as dk_active,
       3 as exec_type
  from dc_ctl.ctl_load_config t
 where t.src_db_name = 'DSTCS'
 order by t.src_tablename;
相关推荐
城下秋草5 小时前
手机软件和电脑软件测试的区别
功能测试·智能手机·自动化
两张不够花5 小时前
ansible自动化运维(一)简介及清单,模块
运维·自动化·ansible
chushiyunen7 小时前
oracle操作xml笔记
xml·笔记·oracle
码农不惑8 小时前
Debedium如何忽略Oracle的purge命令
java·数据库·oracle·debezium
编程修仙8 小时前
数据库表的CRUD
数据库·oracle
weixin_SAG13 小时前
21天掌握javaweb-->第12天:Spring Boot项目优化与安全性
数据库·spring boot·oracle
LaLaLa_OvO17 小时前
ORACLE SQL思路: 多行数据有相同字段就合并成一条数据 分页展示
数据库·sql·oracle
fmc12110417 小时前
【1】数据分析基础(一些概念)
服务器·数据库·oracle
焚琴煮鹤的熊熊野火18 小时前
数据仓库实验一 建立警务数据仓库完成ETL
数据仓库·etl