Skip to content

Commit d425e13

Browse files
authored
[b/352468287] Add non-CDB versions of db-info and data-types (GoogleCloudPlatform#485)
- add non-CDB versions of data-types and db-info - fill in the app-schemas-pdbs implementation
1 parent 18c9cb0 commit d425e13

4 files changed

Lines changed: 100 additions & 14 deletions

File tree

dumper/app/src/main/java/com/google/edwmigration/dumper/application/dumper/connector/oracle/StatsTaskListGenerator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ class StatsTaskListGenerator {
5353

5454
private static final ImmutableList<String> NATIVE_NAMES_REQUIRED =
5555
ImmutableList.of(
56+
"data-types",
57+
"db-info",
5658
"db-objects",
5759
// The version of db-objects that gets SYNONYM objects, for which owner is PUBLIC.
5860
// A JOIN is performed to exclude objects which appear in the cdb_synonyms table.
5961
"db-objects-synonym-public");
6062

6163
private static final ImmutableList<String> NATIVE_NAMES_REQUIRED_CDB_ONLY =
62-
ImmutableList.of("data-types", "db-info", "table-types-dtl", "used-space-details");
64+
ImmutableList.of("table-types-dtl", "used-space-details");
6365

6466
private static final ImmutableList<String> STATSPACK_NAMES =
6567
ImmutableList.of("hist-cmd-types-statspack", "sql-stats-statspack");

dumper/app/src/main/resources/oracle-stats/dba/native/app-schemas-pdbs.sql

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,44 @@
1313
-- See the License for the specific language governing permissions and
1414
-- limitations under the License.
1515
SELECT
16-
NULL "Source",
17-
NULL "DbId",
18-
NULL "PdbId",
19-
NULL "PdbName",
20-
NULL "Status",
21-
NULL "Logging",
22-
NULL "ConId",
23-
NULL "ConUid",
16+
D.source "Source",
17+
D.dbid "DbId",
18+
D.pdb_id "PdbId",
19+
D.pdb_name "PdbName",
20+
D.st "Status",
21+
D.logging "Logging",
22+
D.con_id "ConId",
23+
D.con_uid "ConUid",
2424
NULL "EbsOwner",
2525
NULL "SiebelOwner",
2626
NULL "PsftOwner",
27-
NULL "RdaMatchCount",
28-
NULL "OciAutoViewMatches",
29-
NULL "DbmsCloudMatches",
30-
NULL "ApexMatches",
27+
0 "RdaMatchCount",
28+
0 "OciAutoViewMatches",
29+
0 "DbmsCloudMatches",
30+
0 "ApexMatches",
3131
NULL "SapOwner"
32-
FROM dba_pdbs A
32+
FROM (
33+
SELECT
34+
'pdbs' source,
35+
A.dbid,
36+
A.pdb_id,
37+
A.pdb_name,
38+
A.status st,
39+
A.logging,
40+
A.con_id,
41+
A.con_uid
42+
FROM dba_pdbs A
43+
UNION
44+
SELECT
45+
'sys' source,
46+
B.dbid,
47+
B.con_id# pdb_id,
48+
C.name pdb_name,
49+
to_char(B.status) st,
50+
to_char(B.flags) logging,
51+
B.con_id# con_id,
52+
B.con_uid
53+
FROM sys.container$ B
54+
INNER JOIN sys.obj$ C
55+
ON B.obj# = C.obj# AND B.con_id# = 1
56+
) D
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
-- Copyright 2022-2024 Google LLC
2+
-- Copyright 2013-2021 CompilerWorks
3+
--
4+
-- Licensed under the Apache License, Version 2.0 (the "License");
5+
-- you may not use this file except in compliance with the License.
6+
-- You may obtain a copy of the License at
7+
--
8+
-- http://www.apache.org/licenses/LICENSE-2.0
9+
--
10+
-- Unless required by applicable law or agreed to in writing, software
11+
-- distributed under the License is distributed on an "AS IS" BASIS,
12+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
-- See the License for the specific language governing permissions and
14+
-- limitations under the License.
15+
SELECT
16+
NULL "ConId",
17+
A.owner "Owner",
18+
A.data_type "DataType",
19+
A.data_length "DataLength",
20+
A.data_precision "DataPrecision",
21+
A.data_scale "DataScale",
22+
A.avg_col_len "AvgColLen",
23+
count(1) "Count",
24+
count(DISTINCT table_name) "DistinctTableCount"
25+
FROM dba_tab_columns A
26+
INNER JOIN dba_objects B
27+
ON A.owner = B.owner
28+
AND A.owner NOT LIKE '%SYS'
29+
AND A.table_name = B.object_name
30+
AND B.object_type = 'TABLE'
31+
GROUP BY
32+
A.owner,
33+
A.data_type,
34+
A.data_length,
35+
A.data_precision,
36+
A.data_scale,
37+
A.avg_col_len
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-- Copyright 2022-2024 Google LLC
2+
-- Copyright 2013-2021 CompilerWorks
3+
--
4+
-- Licensed under the Apache License, Version 2.0 (the "License");
5+
-- you may not use this file except in compliance with the License.
6+
-- You may obtain a copy of the License at
7+
--
8+
-- http://www.apache.org/licenses/LICENSE-2.0
9+
--
10+
-- Unless required by applicable law or agreed to in writing, software
11+
-- distributed under the License is distributed on an "AS IS" BASIS,
12+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
-- See the License for the specific language governing permissions and
14+
-- limitations under the License.
15+
SELECT
16+
A.dbid "DbId",
17+
A.name "Name",
18+
A.db_unique_name "DbUniqueName",
19+
NULL "ConId",
20+
NULL "ConDbId",
21+
NULL "Cdb",
22+
A.database_role "DatabaseRole"
23+
FROM v$database A

0 commit comments

Comments
 (0)