bin bash TABLES COUNTRIES REGIONS LOCATIONS DEPARTMENTS JOBS EMPLOYEES

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
TABLES=(
COUNTRIES
REGIONS
LOCATIONS
DEPARTMENTS
JOBS
EMPLOYEES
JOB_HISTORY
)
ENCRYPTION_MODES=(
ALL
DATA_ONLY
ENCRYPTED_COLUMNS_ONLY
METADATA_ONLY
NONE
)
COMPRESSION_MODES=(
ALL
DATA_ONLY
METADATA_ONLY
NONE
)
ENCRYPTION_PASSWORDS=(
testpass
testerpass2
)
function lc(){
echo "${1,,}"
}
function build_command() {
table="$1"
encryption="$2"
compression="$3"
pass="$4"
name="${table}comp_${compression}"
command="$ORACLE_HOME/bin/expdp system/qwerty DIRECTORY=EXPIMP TABLES=HR.${table} COMPRESSION=${compression}"
if [ "$encryption" != "NONE" ]; then
command="${command} ENCRYPTION=${encryption} ENCRYPTION_MODE=PASSWORD ENCRYPTION_PASSWORD=${pass}"
name="${name}_encmode_${encryption}_${pass}.dmp"
else
command="${command} ENCRYPTION=${encryption}"
name="${name}_encmode_${encryption}.dmp"
fi
name=$(lc "${name}")
command="$command DUMPFILE=${name}"
echo "$command"
}
for table in "${TABLES[@]}"; do
for encryption in "${ENCRYPTION_MODES[@]}"; do
for compression in "${COMPRESSION_MODES[@]}"; do
if [ "$encryption" != "NONE" ]; then
for pass in "${ENCRYPTION_PASSWORDS[@]}"; do
bash -c "$(build_command "$table" "$encryption" "$compression" "$pass")"
done
else
bash -c "$(build_command "$table" "$encryption" "$compression" "$pass")"
fi
done
done
done