Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions autonomous_cloud_import/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

This repository contains prerequisite SQL objects (views) to support **optimal parallel processing** and **reliable restart capability** when migrating from **non-Oracle (heterogeneous) source databases**.

You can place the SQL statements provided below into separate files (recommended structure included).

---

## Overview
Expand All @@ -30,19 +28,14 @@ If the required views are **not** created on the source database, the migration
### Purpose
To enable parallel processing and reliable restart capability on a PostgreSQL source database, create the required views.

### Files (recommended)
Place the SQL into files such as:

- `postgres/ALL_TAB_PARTITIONS.sql`
- `postgres/ALL_PART_KEY_COLUMNS.sql`
- `postgres/ALL_PART_TABLES.sql`
### Files
- `postgres/views.sql`

### Required Views
- `ALL_TAB_PARTITIONS`
- `ALL_PART_KEY_COLUMNS`
- `ALL_PART_TABLES`

> Add the PostgreSQL SQL definitions to the files above.

---

Expand All @@ -56,12 +49,8 @@ Place the SQL into files such as:
### Purpose
To enable parallel processing and reliable restart capability on a MySQL source database, create the required views.

### Files (recommended)
Place the SQL into files such as:

- `mysql/ALL_PART_TABLES.sql`
- `mysql/ALL_PART_KEY_COLUMNS.sql`
- `mysql/ALL_TAB_PARTITIONS.sql`
### Files
- `mysql/views.sql`

### Required Views
- `ALL_PART_TABLES`
Expand Down
50 changes: 0 additions & 50 deletions autonomous_cloud_import/mysql/ALL_PART_KEY_COLUMNS.sql

This file was deleted.

14 changes: 0 additions & 14 deletions autonomous_cloud_import/mysql/ALL_PART_TABLES.sql

This file was deleted.

32 changes: 0 additions & 32 deletions autonomous_cloud_import/mysql/ALL_TAB_PARTITIONS.sql

This file was deleted.

90 changes: 90 additions & 0 deletions autonomous_cloud_import/mysql/views.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
-- MySQL view creation script.
-- Execute with: mysql < views.sql

CREATE OR REPLACE VIEW ALL_PART_KEY_COLUMNS AS
WITH part_tables AS (
SELECT DISTINCT
TABLE_SCHEMA,
TABLE_NAME,
PARTITION_EXPRESSION
FROM information_schema.PARTITIONS
WHERE PARTITION_NAME IS NOT NULL
AND PARTITION_EXPRESSION IS NOT NULL
),
key_list AS (
SELECT
TABLE_SCHEMA AS OWNER,
TABLE_NAME AS NAME,
TRIM(
BOTH ')'
FROM TRIM(
BOTH '('
FROM SUBSTRING_INDEX(PARTITION_EXPRESSION, '(', -1)
)
) AS key_list
FROM part_tables
)
SELECT
k.OWNER,
k.NAME,
'TABLE' AS OBJECT_TYPE,
TRIM(BOTH '`' FROM
SUBSTRING_INDEX(
SUBSTRING_INDEX(k.key_list, ',', n.n),
',', -1
)
) AS COLUMN_NAME,
n.n AS COLUMN_POSITION
FROM key_list k
JOIN (
SELECT 1 n UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL
SELECT 7 UNION ALL SELECT 8
) n
ON n.n <= 1 + LENGTH(k.key_list) - LENGTH(REPLACE(k.key_list, ',', ''))
WHERE k.key_list NOT REGEXP '[()]'
ORDER BY
k.OWNER,
k.NAME,
COLUMN_POSITION;

CREATE OR REPLACE VIEW ALL_PART_TABLES AS
SELECT
TABLE_SCHEMA AS OWNER,
TABLE_NAME,
PARTITION_METHOD AS PARTITIONING_TYPE,
COUNT(DISTINCT PARTITION_NAME) AS PARTITION_COUNT,
LENGTH(PARTITION_EXPRESSION) - LENGTH(REPLACE(PARTITION_EXPRESSION, ',', '')) + 1 AS PARTITIONING_KEY_COUNT
FROM information_schema.partitions
GROUP BY
TABLE_SCHEMA,
TABLE_NAME,
PARTITION_METHOD,
PARTITION_EXPRESSION;

CREATE OR REPLACE VIEW ALL_TAB_PARTITIONS AS
SELECT
TABLE_SCHEMA AS TABLE_OWNER,
TABLE_NAME,
PARTITION_NAME,
MIN(PARTITION_ORDINAL_POSITION) AS PARTITION_POSITION,
CASE
WHEN MAX(PARTITION_DESCRIPTION) = 'MAXVALUE'
THEN 'MAXVALUE'
ELSE TRIM(BOTH '''' FROM MAX(PARTITION_DESCRIPTION))
END AS HIGH_VALUE,
LENGTH(
CASE
WHEN MAX(PARTITION_DESCRIPTION) = 'MAXVALUE'
THEN 'MAXVALUE'
ELSE TRIM(BOTH '''' FROM MAX(PARTITION_DESCRIPTION))
END
) AS HIGH_VALUE_LENGTH,
MAX(PARTITION_METHOD) AS PARTITIONING_TYPE,
1 AS PARTITION_KEY_COUNT
FROM information_schema.PARTITIONS
WHERE PARTITION_NAME IS NOT NULL
GROUP BY
TABLE_SCHEMA,
TABLE_NAME,
PARTITION_NAME;
27 changes: 0 additions & 27 deletions autonomous_cloud_import/postgres/ALL_PART_KEY_COLUMNS.sql

This file was deleted.

47 changes: 0 additions & 47 deletions autonomous_cloud_import/postgres/ALL_PART_TABLES.sql

This file was deleted.

62 changes: 0 additions & 62 deletions autonomous_cloud_import/postgres/ALL_TAB_PARTITIONS.sql

This file was deleted.

Loading