@@ -9,7 +9,7 @@ module StructureDump # :nodoc:
9
9
10
10
def structure_dump # :nodoc:
11
11
sequences = select ( <<~SQL . squish , "SCHEMA" )
12
- SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */
12
+ SELECT
13
13
sequence_name, min_value, max_value, increment_by, order_flag, cycle_flag
14
14
FROM all_sequences
15
15
where sequence_owner = SYS_CONTEXT('userenv', 'current_schema') ORDER BY 1
@@ -19,7 +19,7 @@ def structure_dump # :nodoc:
19
19
"CREATE SEQUENCE #{ quote_table_name ( result [ "sequence_name" ] ) } MINVALUE #{ result [ "min_value" ] } MAXVALUE #{ result [ "max_value" ] } INCREMENT BY #{ result [ "increment_by" ] } #{ result [ "order_flag" ] == 'Y' ? "ORDER" : "NOORDER" } #{ result [ "cycle_flag" ] == 'Y' ? "CYCLE" : "NOCYCLE" } "
20
20
end
21
21
tables = select_values ( <<~SQL . squish , "SCHEMA" )
22
- SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ table_name FROM all_tables t
22
+ SELECT table_name FROM all_tables t
23
23
WHERE owner = SYS_CONTEXT('userenv', 'current_schema') AND secondary = 'N'
24
24
AND NOT EXISTS (SELECT mv.mview_name FROM all_mviews mv
25
25
WHERE mv.owner = t.owner AND mv.mview_name = t.table_name)
@@ -31,7 +31,7 @@ def structure_dump # :nodoc:
31
31
virtual_columns = virtual_columns_for ( table_name ) if supports_virtual_columns?
32
32
ddl = +"CREATE#{ ' GLOBAL TEMPORARY' if temporary_table? ( table_name ) } TABLE \" #{ table_name } \" (\n "
33
33
columns = select_all ( <<~SQL . squish , "SCHEMA" , [ bind_string ( "table_name" , table_name ) ] )
34
- SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ column_name, data_type, data_length, char_used, char_length,
34
+ SELECT column_name, data_type, data_length, char_used, char_length,
35
35
data_precision, data_scale, data_default, nullable
36
36
FROM all_tab_columns
37
37
WHERE table_name = :table_name
@@ -92,7 +92,7 @@ def structure_dump_virtual_column(column, data_default) # :nodoc:
92
92
def structure_dump_primary_key ( table ) # :nodoc:
93
93
opts = { name : "" , cols : [ ] }
94
94
pks = select_all ( <<~SQL . squish , "SCHEMA" )
95
- SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ a.constraint_name, a.column_name, a.position
95
+ SELECT a.constraint_name, a.column_name, a.position
96
96
FROM all_cons_columns a
97
97
JOIN all_constraints c
98
98
ON a.constraint_name = c.constraint_name
@@ -111,7 +111,7 @@ def structure_dump_primary_key(table) # :nodoc:
111
111
def structure_dump_unique_keys ( table ) # :nodoc:
112
112
keys = { }
113
113
uks = select_all ( <<~SQL . squish , "SCHEMA" )
114
- SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ a.constraint_name, a.column_name, a.position
114
+ SELECT a.constraint_name, a.column_name, a.position
115
115
FROM all_cons_columns a
116
116
JOIN all_constraints c
117
117
ON a.constraint_name = c.constraint_name
@@ -147,7 +147,7 @@ def structure_dump_indexes(table_name) # :nodoc:
147
147
148
148
def structure_dump_fk_constraints # :nodoc:
149
149
foreign_keys = select_all ( <<~SQL . squish , "SCHEMA" )
150
- SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ table_name FROM all_tables
150
+ SELECT table_name FROM all_tables
151
151
WHERE owner = SYS_CONTEXT('userenv', 'current_schema') ORDER BY 1
152
152
SQL
153
153
fks = foreign_keys . map do |table |
@@ -175,7 +175,7 @@ def structure_dump_table_comments(table_name)
175
175
def structure_dump_column_comments ( table_name )
176
176
comments = [ ]
177
177
columns = select_values ( <<~SQL . squish , "SCHEMA" , [ bind_string ( "table_name" , table_name ) ] )
178
- SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ column_name FROM all_tab_columns
178
+ SELECT column_name FROM all_tab_columns
179
179
WHERE owner = SYS_CONTEXT('userenv', 'current_schema')
180
180
AND table_name = :table_name ORDER BY column_id
181
181
SQL
@@ -210,7 +210,7 @@ def foreign_key_definition(to_table, options = {}) # :nodoc:
210
210
def structure_dump_db_stored_code # :nodoc:
211
211
structure = [ ]
212
212
all_source = select_all ( <<~SQL . squish , "SCHEMA" )
213
- SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ DISTINCT name, type
213
+ SELECT DISTINCT name, type
214
214
FROM all_source
215
215
WHERE type IN ('PROCEDURE', 'PACKAGE', 'PACKAGE BODY', 'FUNCTION', 'TRIGGER', 'TYPE')
216
216
AND name NOT LIKE 'BIN$%'
@@ -219,7 +219,7 @@ def structure_dump_db_stored_code # :nodoc:
219
219
all_source . each do |source |
220
220
ddl = +"CREATE OR REPLACE \n "
221
221
texts = select_all ( <<~SQL . squish , "all source at structure dump" , [ bind_string ( "source_name" , source [ "name" ] ) , bind_string ( "source_type" , source [ "type" ] ) ] )
222
- SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ text
222
+ SELECT text
223
223
FROM all_source
224
224
WHERE name = :source_name
225
225
AND type = :source_type
@@ -242,7 +242,7 @@ def structure_dump_db_stored_code # :nodoc:
242
242
def structure_dump_views # :nodoc:
243
243
structure = [ ]
244
244
views = select_all ( <<~SQL . squish , "SCHEMA" )
245
- SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ view_name, text FROM all_views
245
+ SELECT view_name, text FROM all_views
246
246
WHERE owner = SYS_CONTEXT('userenv', 'current_schema') ORDER BY view_name ASC
247
247
SQL
248
248
views . each do |view |
@@ -254,7 +254,7 @@ def structure_dump_views # :nodoc:
254
254
def structure_dump_synonyms # :nodoc:
255
255
structure = [ ]
256
256
synonyms = select_all ( <<~SQL . squish , "SCHEMA" )
257
- SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ owner, synonym_name, table_name, table_owner
257
+ SELECT owner, synonym_name, table_name, table_owner
258
258
FROM all_synonyms
259
259
WHERE owner = SYS_CONTEXT('userenv', 'current_schema')
260
260
SQL
@@ -267,14 +267,14 @@ def structure_dump_synonyms # :nodoc:
267
267
268
268
def structure_drop # :nodoc:
269
269
sequences = select_values ( <<~SQL . squish , "SCHEMA" )
270
- SELECT/*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */
270
+ SELECT
271
271
sequence_name FROM all_sequences where sequence_owner = SYS_CONTEXT('userenv', 'current_schema') ORDER BY 1
272
272
SQL
273
273
statements = sequences . map do |seq |
274
274
"DROP SEQUENCE \" #{ seq } \" "
275
275
end
276
276
tables = select_values ( <<~SQL . squish , "SCHEMA" )
277
- SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ table_name from all_tables t
277
+ SELECT table_name from all_tables t
278
278
WHERE owner = SYS_CONTEXT('userenv', 'current_schema') AND secondary = 'N'
279
279
AND NOT EXISTS (SELECT mv.mview_name FROM all_mviews mv
280
280
WHERE mv.owner = t.owner AND mv.mview_name = t.table_name)
@@ -290,7 +290,7 @@ def structure_drop # :nodoc:
290
290
291
291
def temp_table_drop # :nodoc:
292
292
temporary_tables = select_values ( <<~SQL . squish , "SCHEMA" )
293
- SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ table_name FROM all_tables
293
+ SELECT table_name FROM all_tables
294
294
WHERE owner = SYS_CONTEXT('userenv', 'current_schema')
295
295
AND secondary = 'N' AND temporary = 'Y' ORDER BY 1
296
296
SQL
@@ -324,7 +324,7 @@ def execute_structure_dump(string)
324
324
# return [{'column_name' => 'FOOS', 'data_default' => '...'}, ...]
325
325
def virtual_columns_for ( table )
326
326
select_all ( <<~SQL . squish , "SCHEMA" , [ bind_string ( "table_name" , table . upcase ) ] )
327
- SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ column_name, data_default
327
+ SELECT column_name, data_default
328
328
FROM all_tab_cols
329
329
WHERE virtual_column = 'YES'
330
330
AND owner = SYS_CONTEXT('userenv', 'current_schema')
@@ -335,7 +335,7 @@ def virtual_columns_for(table)
335
335
def drop_sql_for_feature ( type )
336
336
short_type = type == "materialized view" ? "mview" : type
337
337
features = select_values ( <<~SQL . squish , "SCHEMA" )
338
- SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ #{ short_type } _name FROM all_#{ short_type . tableize }
338
+ SELECT #{ short_type } _name FROM all_#{ short_type . tableize }
339
339
where owner = SYS_CONTEXT('userenv', 'current_schema')
340
340
SQL
341
341
statements = features . map do |name |
@@ -346,7 +346,7 @@ def drop_sql_for_feature(type)
346
346
347
347
def drop_sql_for_object ( type )
348
348
objects = select_values ( <<~SQL . squish , "SCHEMA" )
349
- SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ object_name FROM all_objects
349
+ SELECT object_name FROM all_objects
350
350
WHERE object_type = '#{ type . upcase } ' and owner = SYS_CONTEXT('userenv', 'current_schema')
351
351
SQL
352
352
statements = objects . map do |name |
0 commit comments