PBI_CREATE.sql 5.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. set feed off
  2. set pages 0
  3. set lines 9999 long 99999 head off
  4. set trimspool on
  5. set wrap on
  6. col text format a9999
  7. spool create_miro.sql
  8. select 'spool create_miro.log'
  9. from dual
  10. /
  11. -------------------------------------- CREATE TABLESPACE -----------------------------------------------------
  12. create tablespace PBITS_01 datafile '+DATA' size 20G;
  13. /
  14. create tablespace RPRT_01 datafile '+DATA' size 20G
  15. /
  16. -------------------------------------- CREATE USERS -----------------------------------------------------
  17. create user CCB1REP identified by CCB1REP default tablespace PBITS_01;
  18. /
  19. create user MIRO identified by miro default tablespace PBITS_01;
  20. /
  21. create user REPORTER identified by reporter default tablespace RPRT_01;
  22. /
  23. -------------------------------------- GRANT USERS -----------------------------------------------------
  24. grant connect, resource to CCB1REP;
  25. /
  26. grant connect, resource, create view to MIRO;
  27. /
  28. grant connect, resource, create view, create table, create procedure to REPORTER;
  29. /
  30. -------------------------------------- TABLE GRANTS -----------------------------------------------------
  31. /
  32. select 'grant select on '||owner||'.'||table_name||' to CCB1REP with grant option;' from all_tables where owner in ('CCBADM','MDMADM');
  33. /
  34. select 'grant select on '||owner||'.'||table_name||' to MIRO with grant option;' from all_tables where owner in ('CCBADM','MDMADM');
  35. /
  36. select 'grant select on '||owner||'.'||table_name||' to REPORTER with grant option;' from all_tables where owner in ('CCBADM','MDMADM');
  37. /
  38. -------------------------------------- VIEW CREATION/GRANTS ----------------------------------------------------
  39. select case
  40. when owner='MDMADM' and table_name like 'CI_%_CHAR' --and table_name like '%_CHAR'
  41. then 'create or replace view CCB1REP.MV_MDM_'||table_name||' as select a.*,SYSDATE-1 as JRN_EFF_START_DTTM,SYSDATE+1 as JRN_EFF_END_DTTM,''I'' as JRN_FLAG,SYSDATE-1 as JRN_SLICING_TS,'''' as JRN_SCN,''Y'' as JRN_CLEANSED_FLAG,''1'' as JRN_CURRENT_FLAG, SYSDATE+1 as EFF_END_DTTM,SYSDATE-1 as JRN_UPDATE_DTTM from '||owner||'.'||table_name||' a ;'
  42. when owner='MDMADM' and table_name like 'CI_%' and table_name not like '%0'
  43. then 'create or replace view CCB1REP.MV_MDM_'||table_name||' as select a.*,SYSDATE-1 as JRN_EFF_START_DTTM,SYSDATE+1 as JRN_EFF_END_DTTM,''I'' as JRN_FLAG,SYSDATE-1 as JRN_SLICING_TS,'''' as JRN_SCN,''Y'' as JRN_CLEANSED_FLAG,''1'' as JRN_CURRENT_FLAG, SYSDATE+1 as EFF_END_DTTM,SYSDATE-1 as JRN_UPDATE_DTTM from '||owner||'.'||table_name||' a ;'
  44. when owner='CCBADM' and table_name not like '%_CHAR'
  45. then 'create or replace view CCB1REP.'||table_name||' as select a.*,SYSDATE-1 as JRN_EFF_START_DTTM,SYSDATE+1 as JRN_EFF_END_DTTM,''I'' as JRN_FLAG,SYSDATE-1 as JRN_SLICING_TS,'''' as JRN_SCN,''Y'' as JRN_CLEANSED_FLAG,''1'' as JRN_CURRENT_FLAG, SYSDATE+1 as EFF_END_DTTM,SYSDATE-1 as JRN_UPDATE_DTTM from '||owner||'.'||table_name||' a ;'
  46. else
  47. 'create or replace view CCB1REP.'||table_name||' as select a.*,SYSDATE-1 as JRN_EFF_START_DTTM,SYSDATE+1 as JRN_EFF_END_DTTM,''I'' as JRN_FLAG,SYSDATE-1 as JRN_SLICING_TS,'''' as JRN_SCN,''Y'' as JRN_CLEANSED_FLAG,''1'' as JRN_CURRENT_FLAG, SYSDATE+1 as EFF_END_DTTM,SYSDATE-1 as JRN_UPDATE_DTTM from '||owner||'.'||table_name||' a ;'
  48. end as x
  49. from all_tables
  50. where owner in ('MDMADM','CCBADM');
  51. /
  52. select 'grant select on '||owner||'.'||view_name||' to MIRO with grant option;' from all_views where owner in ('CCB1REP');
  53. /
  54. select 'grant select on '||owner||'.'||view_name||' to REPORTER with grant option;' from all_views where owner in ('CCB1REP');
  55. /
  56. select 'create or replace synonym REPORTER.MV_'||view_name||' for '||owner||'.'||view_name||';' from all_views where owner = 'CCB1REP' and view_name like 'MV_MDM_%';
  57. /
  58. select 'create or replace synonym REPORTER.MV_'||view_name||' for '||owner||'.'||view_name||';' from all_views where owner = 'CCB1REP' and view_name like 'F1%' or view_name like 'CM%';
  59. /
  60. select case
  61. when owner='MDMADM' and table_name like 'CI_%'
  62. then 'create or replace view MIRO.MV_MDM_'||table_name||' as select a.*,SYSDATE-1 as JRN_EFF_START_DTTM,SYSDATE+1 as JRN_EFF_END_DTTM,''I'' as JRN_FLAG,SYSDATE-1 as JRN_SLICING_TS,'''' as JRN_SCN,''Y'' as JRN_CLEANSED_FLAG,''1'' as JRN_CURRENT_FLAG from '||owner||'.'||table_name||' a ;'
  63. else
  64. 'create or replace view MIRO.MV_'||table_name||' as select a.*,SYSDATE-1 as JRN_EFF_START_DTTM,SYSDATE+1 as JRN_EFF_END_DTTM,''I'' as JRN_FLAG,SYSDATE-1 as JRN_SLICING_TS,'''' as JRN_SCN,''Y'' as JRN_CLEANSED_FLAG,''1'' as JRN_CURRENT_FLAG from '||owner||'.'||table_name||' a ;'
  65. end as x
  66. from all_tables
  67. where owner in ('MDMADM','CCBADM');
  68. /
  69. select 'grant select on '||owner||'.'||view_name||' to REPORTER with grant option;' from all_views where owner in ('MIRO');
  70. /
  71. select case
  72. when owner='MDMADM' and table_name like 'CI_%'
  73. then 'create or replace view REPORTER.MV_MDM_'||table_name||' as select a.*,SYSDATE-1 as JRN_EFF_START_DTTM,SYSDATE+1 as JRN_EFF_END_DTTM,''I'' as JRN_FLAG,SYSDATE-1 as JRN_SLICING_TS,'''' as JRN_SCN,''Y'' as JRN_CLEANSED_FLAG,''1'' as JRN_CURRENT_FLAG from '||owner||'.'||table_name||' a ;'
  74. else
  75. 'create or replace view REPORTER.MV_'||table_name||' as select a.*,SYSDATE-1 as JRN_EFF_START_DTTM,SYSDATE+1 as JRN_EFF_END_DTTM,''I'' as JRN_FLAG,SYSDATE-1 as JRN_SLICING_TS,'''' as JRN_SCN,''Y'' as JRN_CLEANSED_FLAG,''1'' as JRN_CURRENT_FLAG from '||owner||'.'||table_name||' a ;'
  76. end as x
  77. from all_tables
  78. where owner in ('MDMADM','CCBADM');
  79. select 'spool off' from dual
  80. /
  81. spool off
  82. set feed on
  83. set pages 15
  84. set lines 80
  85. set trimspool off