ORACLE資料校驗文件

yingyifeng306發表於2021-05-06

資料校驗描述

本次跨平臺XTTS 模擬遷移資料校驗主要包含兩大塊。物理資料校驗,即源端和目標端資料檔案校驗;邏輯物件後設資料校驗,即基於schema (使用者)下各物件型別 TABLE,INDEX, FUNCTION,VIEW,DB_LINK,SYNONYM,PACKAGE BODY,SEQUENCE,PACKAGE,JOB,TRIGGER PROCEDURE ,以及源端和目標端錶行數統計校驗。

 

源庫確認需遷移資料

需要遷移的資料檔案

源端表空間

源端資料檔案

TABSPC_YB

+GRP_DATA/wlpri/datafile/tabspc_yb.dbf

PERFSTAT

+GRP_DATA/wlpri/datafile/perfstat.dbf

ODC_TPS

+GRP_DATA/wlpri/datafile/odc_tps.dbf

TABSPC_AC10

+GRP_DATA/wlpri/datafile/tabspc_ac10.dbf

INDX

+GRP_DATA/wlpri/datafile/indx.dbf

ZJJB2_DATA

+GRP_DATA/wlpri/datafile/zjjb2_data.dbf

ZJJB_REP

+GRP_DATA/wlpri/datafile/zjjb_rep.dbf

ZJJB2_REP

+GRP_DATA/wlpri/datafile/zjjb2_rep.dbf

EPREP

+GRP_DATA/wlpri/datafile/eprep.dbf

ZJJB_DATA

+GRP_DATA/wlpri/datafile/zjjb_data.dbf

WLWX_DATA

+GRP_DATA/wlpri/datafile/wlwx_data.dbf

WLSB_ACA6_DATA01

+GRP_DATA/wlpri/datafile/wlsb_aca6_data01.dbf

USERS

+GRP_DATA/wlpri/datafile/users.dbf

WLSB_ACA6_DATA02

+GRP_DATA/wlpri/datafile/wlsb_aca6_data02.dbf

WLSB_ACA6_DATA03

+GRP_DATA/wlpri/datafile/wlsb_aca6_data03.dbf

WLSB_ACA6_DATA04

+GRP_DATA/wlpri/datafile/wlsb_aca6_data04.dbf

WLSB_ACB6_DATA01

+GRP_DATA/wlpri/datafile/wlsb_acb6_data01.dbf

WLSB_ACB6_DATA02

+GRP_DATA/wlpri/datafile/wlsb_acb6_data02.dbf

WLSB_ACA6_IDX01

+GRP_DATA/wlpri/datafile/wlsb_aca6_idx01.dbf

WLSB_ACB6_DATA03

+GRP_DATA/wlpri/datafile/wlsb_acb6_data03.dbf

WLSB_ACA6_IDX02

+GRP_DATA/wlpri/datafile/wlsb_aca6_idx02.dbf

WLSB_ACB6_DATA04

+GRP_DATA/wlpri/datafile/wlsb_acb6_data04.dbf

WLSB_ACA6_IDX03

+GRP_DATA/wlpri/datafile/wlsb_aca6_idx03.dbf

 

具體SQL 語句如下:

set   linesize 1000

col   file_name for a50

SELECT   d.FILE_ID,

       d.TABLESPACE_NAME,

       (SELECT (SUM(nb.BYTES/1024/1024))

          FROM dba_data_files nb

         WHERE nb.TABLESPACE_NAME =   d.TABLESPACE_NAME) ts_size_m,

       d.FILE_NAME,

       (d.BYTES/1024/1024) file_size_m,

       (d.USER_BYTES/1024/1024)   file_use_size_m

  FROM dba_data_files d

WHERE   d.TABLESPACE_NAME  not in   ('SYSTEM','SYSAUX','UNDOTBS1','UNDOTBS2')

 ORDER BY    file_id;

 

需要遷移的使用者

使用者

建立時間

WEB

2016-12-07 13:40:26

QLYG

2016-08-11 15:02:33

WLSJ

2016-07-20 10:02:47

WLWX_YD

2016-06-25 13:13:44

WLJX

2016-06-25 13:12:49

WLSBZD

2016-06-25 13:12:22

WEBUSER

2016-06-25 13:03:47

JBGC

2016-06-25 06:59:21

WLWX_LOG

2016-06-25 06:59:21

LBHIS

2016-06-25 06:59:21

WLSHK

2016-06-25 06:59:21

WEBCXYB

2016-06-25 06:59:21

WLWX

2016-06-25 06:59:21

WLJYJK

2016-06-25 06:59:21

MOVE

2016-06-25 06:59:21

QMCB_NEW

2016-06-25 06:59:21

WLWXSY

2016-06-25 06:59:21

LB01

2016-06-25 06:59:21

WL12333

2016-06-25 06:59:21

COMMVAULT

2016-06-25 06:59:21

QMCB

2016-06-25 06:59:21

LB01_TP

2016-06-25 06:59:21

WLSMKJK

2016-06-25 06:59:21

WL_JB

2016-06-25 06:59:21

QSSBCX

2016-06-25 06:59:21

XZPT_TP

2016-06-25 06:59:21

JHLIB

2016-06-25 06:59:21

XZPT

2016-06-25 06:59:21

LBSIJG

2016-06-25 06:59:21

LBSIINT

2016-06-25 06:59:21

ODC

2016-06-25 06:59:21

ZJJBUNI2

2016-06-25 06:59:21

ZJJBREP

2016-06-25 06:59:21

ZJJBUNI2REP

2016-06-25 06:59:21

ZJJBUNI

2016-06-25 06:59:21

WLREP

2016-06-25 06:59:21

JBSJ

2016-06-25 06:59:21

 

具體SQL 語句如下:

alter session set nls_date_format='yyyy-mm-dd   hh24:mi:ss';

set line 200

SELECT d.username,

         d.default_tablespace,

         d.temporary_tablespace,

         d.account_status,

       d.created

  from dba_users   d

 where   d.account_status = 'OPEN' and d.username not like '%SYS%'

    order by d.CREATED desc;

 

 

物理資料校驗

源庫與目標庫資料檔案校驗

表空間

源端資料檔案

目標端資料檔案

EPREP

+GRP_DATA/wlpri/datafile/eprep.dbf

+DATA/wlsi/eprep.dbf

INDX

+GRP_DATA/wlpri/datafile/indx.dbf

+DATA/wlsi/indx.dbf

ODC_TPS

+GRP_DATA/wlpri/datafile/odc_tps.dbf

+DATA/wlsi/odc_tps.dbf

PERFSTAT

+GRP_DATA/wlpri/datafile/perfstat.dbf

+DATA/wlsi/perfstat.dbf

TABSPC_AC10

+GRP_DATA/wlpri/datafile/tabspc_ac10.dbf

+DATA/wlsi/tabspc_ac10.dbf

TABSPC_YB

+GRP_DATA/wlpri/datafile/tabspc_yb.dbf

+DATA/wlsi/tabspc_yb.dbf

USERS

+GRP_DATA/wlpri/datafile/users.dbf

+DATA/wlsi/users.dbf

WLSB_ACA6_DATA01

+GRP_DATA/wlpri/datafile/wlsb_aca6_data01.dbf

+DATA/wlsi/wlsb_aca6_data01.dbf

WLSB_ACA6_DATA02

+GRP_DATA/wlpri/datafile/wlsb_aca6_data02.dbf

+DATA/wlsi/wlsb_aca6_data02.dbf

WLSB_ACA6_DATA03

+GRP_DATA/wlpri/datafile/wlsb_aca6_data03.dbf

+DATA/wlsi/wlsb_aca6_data03.dbf

WLSB_ACA6_DATA04

+GRP_DATA/wlpri/datafile/wlsb_aca6_data04.dbf

+DATA/wlsi/wlsb_aca6_data04.dbf

WLSB_ACA6_IDX01

+GRP_DATA/wlpri/datafile/wlsb_aca6_idx01.dbf

+DATA/wlsi/wlsb_aca6_idx01.dbf

WLSB_ACA6_IDX02

+GRP_DATA/wlpri/datafile/wlsb_aca6_idx02.dbf

+DATA/wlsi/wlsb_aca6_idx02.dbf

WLSB_ACA6_IDX03

+GRP_DATA/wlpri/datafile/wlsb_aca6_idx03.dbf

+DATA/wlsi/wlsb_aca6_idx03.dbf

WLSB_ACB6_DATA01

+GRP_DATA/wlpri/datafile/wlsb_acb6_data01.dbf

+DATA/wlsi/wlsb_acb6_data01.dbf

WLSB_ACB6_DATA02

+GRP_DATA/wlpri/datafile/wlsb_acb6_data02.dbf

+DATA/wlsi/wlsb_acb6_data02.dbf

WLSB_ACB6_DATA03

+GRP_DATA/wlpri/datafile/wlsb_acb6_data03.dbf

+DATA/wlsi/wlsb_acb6_data03.dbf

WLSB_ACB6_DATA04

+GRP_DATA/wlpri/datafile/wlsb_acb6_data04.dbf

+DATA/wlsi/wlsb_acb6_data04.dbf

WLWX_DATA

+GRP_DATA/wlpri/datafile/wlwx_data.dbf

+DATA/wlsi/wlwx_data.dbf

ZJJB2_DATA

+GRP_DATA/wlpri/datafile/zjjb2_data.dbf

+DATA/wlsi/zjjb2_data.dbf

ZJJB2_REP

+GRP_DATA/wlpri/datafile/zjjb2_rep.dbf

+DATA/wlsi/zjjb2_rep.dbf

ZJJB_DATA

+GRP_DATA/wlpri/datafile/zjjb_data.dbf

+DATA/wlsi/zjjb_data.dbf

ZJJB_REP

+GRP_DATA/wlpri/datafile/zjjb_rep.dbf

+DATA/wlsi/zjjb_rep.dbf

 

具體SQL 語句如下:

set linesize 1000

col file_name for   a50

SELECT d.FILE_ID,

       d.TABLESPACE_NAME,

       (SELECT (SUM(nb.BYTES/1024/1024))

          FROM dba_data_files nb

         WHERE nb.TABLESPACE_NAME =   d.TABLESPACE_NAME) ts_size_m,

       d.FILE_NAME,

       (d.BYTES/1024/1024) file_size_m,

       (d.USER_BYTES/1024/1024)   file_use_size_m

  FROM dba_data_files d

WHERE   d.TABLESPACE_NAME  not in   ('SYSTEM','SYSAUX','UNDOTBS1','UNDOTBS2')

 ORDER BY  file_id;

 

 

邏輯物件校驗

基於使用者的資料校驗

使用者

源端

目標端

使用者物件統計

使用者物件統計

JBGC

77

77

JBSJ

10

10

JHLIB

9

9

LB01

309

309

LB01_TP

114

114

LBHIS

297

297

LBSIINT

301

301

LBSIJG

100

100

MOVE

303

303

ODC

1

1

QLYG

12

12

QMCB

265

265

QMCB_NEW

28

28

QSSBCX

4

4

WEB

145

145

WEBUSER

7

7

WL12333

30

30

WLJYJK

17

17

WLREP

161

161

WLSHK

11

11

WLSJ

29

29

WLSMKJK

4

4

WLWX

4868

4868

WLWXSY

15

15

WLWX_LOG

2346

2346

WL_JB

282

282

XZPT

307

307

XZPT_TP

118

118

ZJJBREP

150

150

ZJJBUNI

616

616

ZJJBUNI2

1137

1137

ZJJBUNI2REP

155

155

 

具體SQL 語句如下:

SELECT D.OWNER,COUNT(*)

FROM dba_objects d

WHERE d.OWNER   in   ('WEB','QLYG','WLSJ','WLWX_YD','WLJX','WLSBZD','WEBUSER','JBGC','WLWX_LOG','LBHIS','WLSHK','WEBCXYB','WLWX','WLJYJK','MOVE','QMCB_NEW','WLWXSY','LB01','WL12333','COMMVAULT','QMCB','LB01_TP','WLSMKJK','WL_JB','QSSBCX','XZPT_TP','JHLIB','XZPT','LBSIJG','LBSIINT','ODC','ZJJBUNI2','ZJJBREP','ZJJBUNI2REP','ZJJBUNI','WLREP','JBSJ')

and d.OWNER not in ('PUBLIC')

AND NOT EXISTS (SELECT * FROM   DBA_RECYCLEBIN B WHERE B.object_name=D.OBJECT_NAME AND D.OWNER=B.owner)

GROUP BY D.OWNER

ORDER BY D.OWNER;

 

基於物件型別的資料校驗

使用者

物件型別

源端

目標端

物件型別統計

物件型別統計

JBGC

INDEX

24

24

JBGC

TABLE

53

53

JBSJ

INDEX

1

1

JBSJ

PACKAGE

1

1

JBSJ

PACKAGE BODY

1

1

JBSJ

TABLE

7

7

JHLIB

FUNCTION

1

1

JHLIB

PACKAGE

3

3

JHLIB

PACKAGE BODY

3

3

JHLIB

PROCEDURE

1

1

JHLIB

TABLE

1

1

LB01

DATABASE LINK

4

4

LB01

FUNCTION

9

9

LB01

INDEX

93

93

LB01

LOB

3

3

LB01

PACKAGE

15

15

LB01

PACKAGE BODY

14

14

LB01

PROCEDURE

3

3

LB01

SEQUENCE

11

11

LB01

SYNONYM

83

83

LB01

TABLE

72

72

LB01

VIEW

2

2

LB01_TP

INDEX

1

1

LB01_TP

PACKAGE

70

70

LB01_TP

PACKAGE BODY

42

42

LB01_TP

TABLE

1

1

LBHIS

FUNCTION

20

20

LBHIS

INDEX

104

104

LBHIS

LOB

3

3

LBHIS

PACKAGE

23

23

LBHIS

PACKAGE BODY

18

18

LBHIS

PROCEDURE

1

1

LBHIS

SEQUENCE

31

31

LBHIS

SYNONYM

2

2

LBHIS

TABLE

82

82

LBHIS

VIEW

13

13

LBSIINT

FUNCTION

2

2

LBSIINT

INDEX

29

29

LBSIINT

LOB

11

11

LBSIINT

PACKAGE

21

21

LBSIINT

PACKAGE BODY

15

15

LBSIINT

PROCEDURE

6

6

LBSIINT

SEQUENCE

1

1

LBSIINT

SYNONYM

190

190

LBSIINT

TABLE

22

22

LBSIINT

VIEW

4

4

LBSIJG

INDEX

49

49

LBSIJG

SEQUENCE

3

3

LBSIJG

TABLE

41

41

LBSIJG

VIEW

7

7

MOVE

DATABASE LINK

2

2

MOVE

INDEX

63

63

MOVE

LOB

1

1

MOVE

PACKAGE

22

22

MOVE

PACKAGE BODY

21

21

MOVE

PROCEDURE

20

20

MOVE

SEQUENCE

3

3

MOVE

TABLE

171

171

ODC

TABLE

1

1

PERFSTAT

INDEX

72

72

PERFSTAT

PACKAGE

1

1

PERFSTAT

PACKAGE BODY

1

1

PERFSTAT

SEQUENCE

1

1

PERFSTAT

TABLE

72

72

PERFSTAT

VIEW

1

1

QLYG

PACKAGE

1

1

QLYG

PACKAGE BODY

2

2

QLYG

TABLE

9

9

QMCB

DATABASE LINK

2

2

QMCB

INDEX

102

102

QMCB

LOB

1

1

QMCB

PACKAGE

8

8

QMCB

PACKAGE BODY

8

8

QMCB

SEQUENCE

1

1

QMCB

SYNONYM

7

7

QMCB

TABLE

133

133

QMCB

VIEW

3

3

QMCB_NEW

INDEX

14

14

QMCB_NEW

PACKAGE

1

1

QMCB_NEW

PACKAGE BODY

1

1

QMCB_NEW

SEQUENCE

2

2

QMCB_NEW

TABLE

10

10

QSSBCX

INDEX

1

1

QSSBCX

SEQUENCE

1

1

QSSBCX

SYNONYM

1

1

QSSBCX

TABLE

1

1

WEB

FUNCTION

7

7

WEB

INDEX

43

43

WEB

LOB

15

15

WEB

PACKAGE

7

7

WEB

PACKAGE BODY

6

6

WEB

PROCEDURE

2

2

WEB

SEQUENCE

7

7

WEB

SYNONYM

20

20

WEB

TABLE

35

35

WEB

VIEW

3

3

WEBUSER

SYNONYM

7

7

WL12333

SYNONYM

30

30

WLJYJK

DATABASE LINK

1

1

WLJYJK

SYNONYM

15

15

WLJYJK

VIEW

1

1

WLREP

FUNCTION

3

3

WLREP

INDEX

72

72

WLREP

PACKAGE

1

1

WLREP

PACKAGE BODY

1

1

WLREP

TABLE

78

78

WLREP

TRIGGER

4

4

WLREP

VIEW

2

2

WLSHK

SYNONYM

11

11

WLSJ

INDEX

6

6

WLSJ

PACKAGE

3

3

WLSJ

PACKAGE BODY

4

4

WLSJ

TABLE

16

16

WLSMKJK

SYNONYM

4

4

WLWX

DATABASE LINK

10

10

WLWX

FUNCTION

171

171

WLWX

INDEX

1048

1048

WLWX

INDEX PARTITION

81

81

WLWX

INDEX SUBPARTITION

114

114

WLWX

LOB

17

17

WLWX

PACKAGE

145

145

WLWX

PACKAGE BODY

124

124

WLWX

PROCEDURE

66

66

WLWX

SEQUENCE

128

128

WLWX

SYNONYM

56

56

WLWX

TABLE

1320

1320

WLWX

TABLE PARTITION

122

122

WLWX

TABLE SUBPARTITION

452

452

WLWX

TRIGGER

605

605

WLWX

VIEW

409

409

WLWXSY

SYNONYM

15

15

WLWX_LOG

INDEX

1690

1690

WLWX_LOG

PROCEDURE

1

1

WLWX_LOG

TABLE

655

655

WL_JB

INDEX

88

88

WL_JB

PACKAGE

3

3

WL_JB

PACKAGE BODY

3

3

WL_JB

SEQUENCE

2

2

WL_JB

TABLE

186

186

XZPT

FUNCTION

9

9

XZPT

INDEX

88

88

XZPT

LOB

3

3

XZPT

PACKAGE

17

17

XZPT

PACKAGE BODY

16

16

XZPT

PROCEDURE

3

3

XZPT

SEQUENCE

13

13

XZPT

SYNONYM

90

90

XZPT

TABLE

66

66

XZPT

VIEW

2

2

XZPT_TP

INDEX

1

1

XZPT_TP

PACKAGE

73

73

XZPT_TP

PACKAGE BODY

43

43

XZPT_TP

TABLE

1

1

ZJJBREP

FUNCTION

3

3

ZJJBREP

INDEX

73

73

ZJJBREP

TABLE

74

74

ZJJBUNI

FUNCTION

5

5

ZJJBUNI

INDEX

234

234

ZJJBUNI

LOB

3

3

ZJJBUNI

PACKAGE

6

6

ZJJBUNI

PACKAGE BODY

6

6

ZJJBUNI

PROCEDURE

1

1

ZJJBUNI

SEQUENCE

39

39

ZJJBUNI

SYNONYM

1

1

ZJJBUNI

TABLE

106

106

ZJJBUNI

TRIGGER

210

210

ZJJBUNI

VIEW

5

5

ZJJBUNI2

DATABASE LINK

3

3

ZJJBUNI2

FUNCTION

8

8

ZJJBUNI2

INDEX

389

389

ZJJBUNI2

LOB

4

4

ZJJBUNI2

PACKAGE

15

15

ZJJBUNI2

PACKAGE BODY

15

15

ZJJBUNI2

PROCEDURE

19

19

ZJJBUNI2

SEQUENCE

30

30

ZJJBUNI2

SYNONYM

1

1

ZJJBUNI2

TABLE

224

224

ZJJBUNI2

TRIGGER

424

424

ZJJBUNI2

VIEW

5

5

ZJJBUNI2REP

FUNCTION

3

3

ZJJBUNI2REP

INDEX

76

76

ZJJBUNI2REP

TABLE

76

76

 

具體SQL 語句如下:

SELECT D.OWNER, D.OBJECT_TYPE,   COUNT(1)

FROM dba_objects d

WHERE d.OWNER in   ('WEB','QLYG','WLSJ','WLWX_YD','WLJX','WLSBZD','WEBUSER','JBGC','WLWX_LOG','LBHIS','WLSHK','WEBCXYB','WLWX','WLJYJK','MOVE','QMCB_NEW','WLWXSY','LB01','WL12333','COMMVAULT','QMCB','LB01_TP','WLSMKJK','WL_JB','QSSBCX','XZPT_TP','JHLIB','XZPT','LBSIJG','LBSIINT','ODC','ZJJBUNI2','ZJJBREP','ZJJBUNI2REP','ZJJBUNI','WLREP','JBSJ')

and d.OWNER not in ('PUBLIC')

AND NOT EXISTS (SELECT 1

FROM DBA_RECYCLEBIN B

WHERE B.object_name =   D.OBJECT_NAME

AND D.OWNER = B.owner)

GROUP BY D.OWNER, D.OBJECT_TYPE

ORDER BY D.OWNER;

 

基於表的資料校驗

建立 TAB_CHECK 儲存過程來統計各錶行數

create table check_tab(schema   varchar2(30),tab_name varchar2(30),tab_count int);

 

CREATE OR REPLACE PROCEDURE   TAB_CHECK

AS

    cursor tab_cur is

    SELECT OWNER,TABLE_NAME FROM DBA_TABLES   WHERE OWNER IN ('WEB','QLYG','WLSJ','WLWX_YD','WLJX','WLSBZD','WEBUSER','JBGC','WLWX_LOG','LBHIS','WLSHK','WEBCXYB','WLWX','WLJYJK','MOVE','QMCB_NEW','WLWXSY','LB01','WL12333','COMMVAULT','QMCB','LB01_TP','WLSMKJK','WL_JB','QSSBCX','XZPT_TP','JHLIB','XZPT','LBSIJG','LBSIINT','ODC','ZJJBUNI2','ZJJBREP','ZJJBUNI2REP','ZJJBUNI','WLREP','JBSJ');

    sqlddl varchar2(1000);

begin

    for tab_recoder in tab_cur loop

    sqlddl:='insert into check_tab select   '||''''||tab_recoder.owner||''''||','||''''||tab_recoder.table_name||''''||',count(1)   from '||tab_recoder.owner||'.'||tab_recoder.table_name;

    dbms_output.put_line(sqlddl);

    EXECUTE IMMEDIATE sqlddl;

    end loop;

end;

/

 

exec sys.TAB_CHECK;

 

臨時表資料校驗

臨時表描述

Oracle 資料庫中,臨時表的資料都是存放在記憶體中,即都是臨時性呼叫。當資料庫關閉,記憶體釋放或者將表空間只讀開啟,臨時表中資料會被清空。 基於這一點,當時模擬遷移測試,未將臨時表遷移至測試庫。

臨時表資料校驗

使用者

源庫臨時表

目標庫臨時表

WLWX

AB08_TEMP

AB08_TEMP

WLWX

AB09_TEMP

AB09_TEMP

WLWX

AC10_TEMP

AC10_TEMP

WLWX

AC11

AC11

WLWX

AC19_TEMP

AC19_TEMP

WLWX

AC53

AC53

WLWX

AC54

AC54

WLWX

BJK_BANK_ZF_IC16

BJK_BANK_ZF_IC16

WLWX

BST_PRO_TMP

BST_PRO_TMP

WLWX

IC20_ZY

IC20_ZY

WLWX

IC22_BACK

IC22_BACK

WLWX

IC26_TMP

IC26_TMP

WLWX

KS04

KS04

WLWX

KS05

KS05

WLWX

KS05_TMP

KS05_TMP

WLWX

PD04_TMP

PD04_TMP

WLWX

QUEST_SL_TEMP_EXPLAIN1

QUEST_SL_TEMP_EXPLAIN1

WLWX

QUEST_SL_TEMP_EXPLAIN2

QUEST_SL_TEMP_EXPLAIN2

WLWX

REP_0000152

REP_0000152

WLWX

REP_0000153

REP_0000153

WLWX

REP_0000155

REP_0000155

WLWX

REP_0000173

REP_0000173

WLWX

REP_0000179

REP_0000179

WLWX

REP_0000187

REP_0000187

WLWX

REP_QFJS

REP_QFJS

WLWX

TEMP_AC02

TEMP_AC02

WLWX

TEMP_IC11

TEMP_IC11

WLWX

TEMP_IC12

TEMP_IC12

LBSIINT

KC12_HIS_TMP

KC12_HIS_TMP

LBSIINT

KC13_HIS

KC13_HIS

LB01

BST_USER_PARAM

BST_USER_PARAM

PERFSTAT

STATS$TEMP_SQLSTATS

STATS$TEMP_SQLSTATS

WLWX

TEMP_YLLNZM

TEMP_YLLNZM

XZPT

BST_USER_PARAM

BST_USER_PARAM

LBHIS

SYS_TEMP_FBT

SYS_TEMP_FBT

WLWX

TEMP_IC11_TZ

TEMP_IC11_TZ

 

具體SQL 語句如下:

 

獲取建立臨時表DDL 語句

set echo off;

Set pages 999;

set long 90000;

spool get_tmptable_ddl.sql

select   dbms_metadata.get_ddl('TABLE','BST_USER_PARAM','LB01') FROM dual ;

 

資料庫許可權校驗

收集生產庫使用者許可權,具體SQL 如下:

drop table t_tmp_user_lhr;                                                                                          

create table t_tmp_user_lhr( id number,   username varchar2(50), exec_sql varchar2(4000),create_type varchar2(20));

DROP sequence s_t_tmp_user_lhr;                                                                                  

create sequence s_t_tmp_user_lhr;                                                                                  

                                                                                                                    

begin                                                                                                                                                                                                                                 

  for   cur in (SELECT d.username,                                                                                     

                       d.default_tablespace,                                                                          

                     d.account_status,                                                                              

                       'create user ' ||   d.username || ' identified by ' ||                                         

                     d.username || ' default   tablespace ' ||                                                        

                     d.default_tablespace ||   '  TEMPORARY TABLESPACE  ' ||                                        

                     D.temporary_tablespace   || ';' CREATE_USER,                                                     

                       replace(to_char(DBMS_METADATA.GET_DDL('USER',                                                  

                                                             D.username)),                                          

                             chr(10),                                                                              

                             '')   create_USER1                                                                       

                FROM dba_users d                                                                                     

 WHERE d.username   in    ('WEB','QLYG','WLSJ','WLWX_YD','WLJX','WLSBZD','WEBUSER','JBGC','WLWX_LOG','LBHIS','WLSHK','WEBCXYB','WLWX','WLJYJK','MOVE','QMCB_NEW','WLWXSY','LB01','WL12333','COMMVAULT','QMCB','LB01_TP','WLSMKJK','WL_JB','QSSBCX','XZPT_TP','JHLIB','XZPT','LBSIJG','LBSIINT','ODC','ZJJBUNI2','ZJJBREP','ZJJBUNI2REP','ZJJBUNI','WLREP','JBSJ'))   loop                                                       

      INSERT INTO t_tmp_user_lhr                                                                                      

        (id, username, exec_sql, create_type)                                                                         

      values                                                                                                         

        (s_t_tmp_user_lhr.nextval, cur.username, cur.CREATE_USER,   'USER');                                          

                                                                                                                     

      INSERT INTO t_tmp_user_lhr                                                                                      

        (id, username, exec_sql, create_type)                                                                        

        SELECT s_t_tmp_user_lhr.nextval,                                                                              

               cur.username,                                                                                           

               CASE                                                                                                   

               WHEN D.ADMIN_OPTION = 'YES'   THEN                                                                     

                'GRANT ' || d.privilege || ' TO '   || d.GRANTEE ||                                                   

                ' WITH GRANT OPTION ;'                                                                              

               ELSE                                                                                                

                'GRANT ' || d.privilege || '   TO ' || d.GRANTEE || ';'                                               

               END priv,                                                                                               

               'DBA_SYS_PRIVS'                                                                                        

          FROM dba_sys_privs d                                                                                         

         WHERE D.GRANTEE = CUR.USERNAME;                                                                              

                                                                                                                     

      INSERT INTO t_tmp_user_lhr                                                                                      

        (id, username, exec_sql, create_type)                                                                         

        SELECT s_t_tmp_user_lhr.nextval,                                                                              

               cur.username,                                                                                          

               CASE                                                                                                  

               WHEN D.ADMIN_OPTION = 'YES'   THEN                                                                     

                'GRANT ' || d.GRANTED_ROLE ||   ' TO ' || d.GRANTEE ||                                                

                ' WITH GRANT OPTION;'                                                                               

               ELSE                                                                                                  

                'GRANT ' || d.GRANTED_ROLE ||   ' TO ' || d.GRANTEE || ';'                                          

               END priv,                                                                                               

               'DBA_ROLE_PRIVS'                                                                                       

          FROM DBA_ROLE_PRIVS d                                                                                       

         WHERE D.GRANTEE = CUR.USERNAME;                                                                              

                                                                                                                    

      INSERT INTO t_tmp_user_lhr                                                                                     

        (id, username, exec_sql, create_type)                                                                         

        SELECT s_t_tmp_user_lhr.nextval,                                                                             

               cur.username,                                                                                          

               CASE                                                                                                    

               WHEN d.grantable = 'YES'   THEN                                                                        

                'GRANT ' || d.privilege || '   ON ' || d.owner || '.' ||                                             

                d.table_name || ' TO ' ||   d.GRANTEE ||                                                              

                '  WITH GRANT OPTION ;'                                                                             

               ELSE                                                                                                 

                'GRANT ' || d.privilege || '   ON ' || d.owner || '.' ||                                            

                d.table_name || ' TO ' ||   d.GRANTEE || ';'                                                          

               END priv,                                                                                              

               'DBA_TAB_PRIVS'                                                                                       

          FROM DBA_TAB_PRIVS d                                                                                        

         WHERE D.GRANTEE = CUR.USERNAME;                                                                               

  end   loop;                                                                                                         

    COMMIT;                                                                                                            

end;                                                                                                                

/                                                                                                                   

SELECT * FROM t_tmp_user_lhr;

 


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23732248/viewspace-2770897/,如需轉載,請註明出處,否則將追究法律責任。

相關文章