1
+ /* for requirements, see "migrate.sql" */
1
2
/* connect as migration user */
2
3
\connect - migrator
3
4
SET client_min_messages = WARNING;
@@ -14,7 +15,7 @@ SELECT db_migrate_prepare(
14
15
0
15
16
(1 row)
16
17
17
- /* perform the data migration */
18
+ /* create foreign tables */
18
19
SELECT db_migrate_mkforeign(
19
20
plugin => 'ora_migrator',
20
21
server => 'oracle',
@@ -25,7 +26,7 @@ SELECT db_migrate_mkforeign(
25
26
0
26
27
(1 row)
27
28
28
- /* migrate the rest of the database */
29
+ /* migrate the data */
29
30
SELECT db_migrate_tables(
30
31
plugin => 'ora_migrator'
31
32
);
@@ -34,14 +35,16 @@ SELECT db_migrate_tables(
34
35
0
35
36
(1 row)
36
37
37
- /* we have to check the log table before we drop the schema */
38
- SELECT operation, schema_name, object_name, failed_sql, error_message
39
- FROM pgsql_stage.migrate_log
40
- ORDER BY log_time;
41
- operation | schema_name | object_name | failed_sql | error_message
42
- -----------+-------------+-------------+------------+---------------
43
- (0 rows)
38
+ /* migrate the constraints */
39
+ SELECT db_migrate_constraints(
40
+ plugin => 'ora_migrator'
41
+ );
42
+ db_migrate_constraints
43
+ ------------------------
44
+ 0
45
+ (1 row)
44
46
47
+ /* clean up */
45
48
SELECT db_migrate_finish();
46
49
db_migrate_finish
47
50
-------------------
@@ -53,98 +56,75 @@ SELECT db_migrate_finish();
53
56
Partitioned table "testschema3.part1"
54
57
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
55
58
--------+------------------------+-----------+----------+---------+----------+--------------+-------------
56
- c1 | numeric | | | | main | |
57
- c2 | character varying(100) | | | | extended | |
59
+ c1 | integer | | not null | | plain | |
60
+ c2 | character varying(100) | | not null | | extended | |
58
61
Partition key: LIST (c1)
59
- Partitions: testschema3.part1_a FOR VALUES IN ('1', '2', '3' ),
60
- testschema3.part1_b FOR VALUES IN ('4', '5' ),
62
+ Partitions: testschema3.part1_a FOR VALUES IN (1, 2, 3 ),
63
+ testschema3.part1_b FOR VALUES IN (4, 5 ),
61
64
testschema3.part1_default DEFAULT
62
65
63
66
\d+ testschema3.part2
64
- Partitioned table "testschema3.part2"
65
- Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
66
- --------+------------------------+-----------+----------+---------+----------+--------------+-------------
67
- c1 | numeric | | | | main | |
68
- c2 | character varying(100) | | | | extended | |
69
- Partition key: RANGE (c1)
70
- Partitions: testschema3.part2_a FOR VALUES FROM (MINVALUE) TO ('0'),
71
- testschema3.part2_b FOR VALUES FROM ('0') TO ('100'),
72
- testschema3.part2_c FOR VALUES FROM ('100') TO (MAXVALUE)
73
-
74
- \d testschema3.part3
75
- Partitioned table "testschema3.part3"
76
- Column | Type | Collation | Nullable | Default
77
- --------+------------------------+-----------+----------+---------
78
- c1 | numeric | | |
79
- c2 | character varying(100) | | |
80
- Partition key: HASH (c1)
81
- Number of partitions: 3 (Use \d+ to list them.)
82
-
83
- \d+ testschema3.part4
84
- Partitioned table "testschema3.part4"
85
- Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
86
- --------+--------------------------------+-----------+----------+---------+----------+--------------+-------------
87
- c1 | character(1) | | | | extended | |
88
- c2 | timestamp(0) without time zone | | | | plain | |
89
- Partition key: LIST (c1)
90
- Partitions: testschema3.part4_a FOR VALUES IN ('A'), PARTITIONED,
91
- testschema3.part4_b FOR VALUES IN ('B'), PARTITIONED
92
-
93
- \d+ testschema3.part4_a
94
- Partitioned table "testschema3.part4_a"
67
+ Partitioned table "testschema3.part2"
95
68
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
96
69
--------+--------------------------------+-----------+----------+---------+----------+--------------+-------------
97
- c1 | character(1) | | | | extended | |
98
- c2 | timestamp(0) without time zone | | | | plain | |
99
- Partition of: testschema3.part4 FOR VALUES IN ('A')
100
- Partition constraint: ((c1 IS NOT NULL) AND (c1 = 'A'::character(1)))
101
- Partition key: RANGE (c2)
102
- Partitions: testschema3.part4_a_2020 FOR VALUES FROM (MINVALUE) TO ('2021-01-01 00:00:00'),
103
- testschema3.part4_a_2021 FOR VALUES FROM ('2021-01-01 00:00:00') TO ('2022-01-01 00:00:00'),
104
- testschema3.part4_a_2022 FOR VALUES FROM ('2022-01-01 00:00:00') TO ('2023-01-01 00:00:00')
70
+ r1 | integer | | not null | | plain | |
71
+ h1 | character varying(100) | | not null | | extended | |
72
+ h2 | timestamp(6) without time zone | | not null | | plain | |
73
+ Partition key: RANGE (r1)
74
+ Partitions: testschema3.part2_a FOR VALUES FROM (MINVALUE) TO (10), PARTITIONED,
75
+ testschema3.part2_b FOR VALUES FROM (10) TO (100), PARTITIONED,
76
+ testschema3.part2_c FOR VALUES FROM (100) TO (MAXVALUE), PARTITIONED
105
77
106
- \d+ testschema3.part4_b
107
- Partitioned table "testschema3.part4_b"
108
- Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
109
- --------+--------------------------------+-----------+----------+---------+----------+--------------+-------------
110
- c1 | character(1) | | | | extended | |
111
- c2 | timestamp(0) without time zone | | | | plain | |
112
- Partition of: testschema3.part4 FOR VALUES IN ('B')
113
- Partition constraint: ((c1 IS NOT NULL) AND (c1 = 'B'::character(1)))
114
- Partition key: RANGE (c2)
115
- Partitions: testschema3.part4_b_2020 FOR VALUES FROM (MINVALUE) TO ('2021-01-01 00:00:00'),
116
- testschema3.part4_b_2021 FOR VALUES FROM ('2021-01-01 00:00:00') TO ('2022-01-01 00:00:00'),
117
- testschema3.part4_b_2022 FOR VALUES FROM ('2022-01-01 00:00:00') TO ('2023-01-01 00:00:00')
78
+ \d+ testschema3.part3
79
+ Partitioned table "testschema3.part3"
80
+ Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
81
+ --------+------------------------+-----------+----------+---------+----------+--------------+-------------
82
+ c1 | integer | | | | plain | |
83
+ c2 | character varying(100) | | | | extended | |
84
+ Partition key: HASH (c2)
85
+ Partitions: testschema3.part3_a FOR VALUES WITH (modulus 3, remainder 0), PARTITIONED,
86
+ testschema3.part3_b FOR VALUES WITH (modulus 3, remainder 1), PARTITIONED,
87
+ testschema3.part3_c FOR VALUES WITH (modulus 3, remainder 2), PARTITIONED
118
88
119
89
SELECT tableoid::regclass partname, * FROM testschema3.part1;
120
- partname | c1 | c2
121
- ---------------------------+----+----
122
- testschema3.part1_a | 1 |
123
- testschema3.part1_b | 5 |
124
- testschema3.part1_default | 10 |
90
+ partname | c1 | c2
91
+ ---------------------------+----+------
92
+ testschema3.part1_a | 1 | one
93
+ testschema3.part1_b | 5 | five
94
+ testschema3.part1_default | 10 | ten
125
95
(3 rows)
126
96
127
97
SELECT tableoid::regclass partname, * FROM testschema3.part2;
128
- partname | c1 | c2
129
- ---------------------+-----+----
130
- testschema3.part2_a | -1 |
131
- testschema3.part2_b | 99 |
132
- testschema3.part2_c | 100 |
133
- (3 rows)
98
+ partname | r1 | h1 | h2
99
+ -----------------------+-----+-----------+---------------------
100
+ testschema3.part2_a_2 | 1 | other | 2023-01-01 23:00:00
101
+ testschema3.part2_a_2 | 1 | something | 2023-01-01 13:00:00
102
+ testschema3.part2_b_2 | 50 | other | 2023-01-01 23:00:00
103
+ testschema3.part2_b_2 | 50 | something | 2023-01-01 13:00:00
104
+ testschema3.part2_c_2 | 500 | other | 2023-01-01 23:00:00
105
+ testschema3.part2_c_2 | 500 | something | 2023-01-01 13:00:00
106
+ (6 rows)
134
107
135
108
SELECT tableoid::regclass partname, * FROM testschema3.part3;
136
- partname | c1 | c2
137
- ----------+----+----
138
- (0 rows)
139
-
140
- SELECT tableoid::regclass partname, * FROM testschema3.part4;
141
- partname | c1 | c2
142
- --------------------------+----+---------------------
143
- testschema3.part4_a_2020 | A | 2020-12-31 00:00:00
144
- testschema3.part4_a_2021 | A | 2021-12-31 00:00:00
145
- testschema3.part4_a_2022 | A | 2022-12-31 00:00:00
146
- testschema3.part4_b_2020 | B | 2020-12-31 00:00:00
147
- testschema3.part4_b_2021 | B | 2021-12-31 00:00:00
148
- testschema3.part4_b_2022 | B | 2022-12-31 00:00:00
149
- (6 rows)
109
+ partname | c1 | c2
110
+ -----------------------+----+----
111
+ testschema3.part3_a_1 | 1 | b
112
+ testschema3.part3_a_1 | 1 | d
113
+ testschema3.part3_a_1 | 1 | e
114
+ testschema3.part3_a_1 | 1 | f
115
+ testschema3.part3_a_2 | 5 | b
116
+ testschema3.part3_a_2 | 5 | d
117
+ testschema3.part3_a_2 | 5 | e
118
+ testschema3.part3_a_2 | 5 | f
119
+ testschema3.part3_a_3 | 9 | b
120
+ testschema3.part3_a_3 | 9 | d
121
+ testschema3.part3_a_3 | 9 | e
122
+ testschema3.part3_a_3 | 9 | f
123
+ testschema3.part3_c_1 | 1 | c
124
+ testschema3.part3_c_1 | 1 | a
125
+ testschema3.part3_c_2 | 5 | c
126
+ testschema3.part3_c_2 | 5 | a
127
+ testschema3.part3_c_3 | 9 | c
128
+ testschema3.part3_c_3 | 9 | a
129
+ (18 rows)
150
130
0 commit comments