vorax 0.1.0pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. data/.gitignore +7 -0
  2. data/.rspec +1 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +45 -0
  5. data/Rakefile +30 -0
  6. data/lib/vorax/base_funnel.rb +30 -0
  7. data/lib/vorax/output/html_convertor.rb +120 -0
  8. data/lib/vorax/output/html_funnel.rb +79 -0
  9. data/lib/vorax/output/pagezip_convertor.rb +20 -0
  10. data/lib/vorax/output/tablezip_convertor.rb +22 -0
  11. data/lib/vorax/output/vertical_convertor.rb +53 -0
  12. data/lib/vorax/output/zip_convertor.rb +117 -0
  13. data/lib/vorax/parser/argument.rb~ +125 -0
  14. data/lib/vorax/parser/body_split.rb +168 -0
  15. data/lib/vorax/parser/conn_string.rb +104 -0
  16. data/lib/vorax/parser/grammars/alias.rb +912 -0
  17. data/lib/vorax/parser/grammars/alias.rl +146 -0
  18. data/lib/vorax/parser/grammars/column.rb +454 -0
  19. data/lib/vorax/parser/grammars/column.rl +64 -0
  20. data/lib/vorax/parser/grammars/common.rl +98 -0
  21. data/lib/vorax/parser/grammars/package_spec.rb +1186 -0
  22. data/lib/vorax/parser/grammars/package_spec.rl +78 -0
  23. data/lib/vorax/parser/grammars/plsql_def.rb +469 -0
  24. data/lib/vorax/parser/grammars/plsql_def.rl +59 -0
  25. data/lib/vorax/parser/grammars/statement.rb +925 -0
  26. data/lib/vorax/parser/grammars/statement.rl +83 -0
  27. data/lib/vorax/parser/parser.rb +320 -0
  28. data/lib/vorax/parser/plsql_structure.rb +158 -0
  29. data/lib/vorax/parser/plsql_walker.rb +143 -0
  30. data/lib/vorax/parser/statement_inspector.rb~ +52 -0
  31. data/lib/vorax/parser/stmt_inspector.rb +78 -0
  32. data/lib/vorax/parser/target_ref.rb +110 -0
  33. data/lib/vorax/sqlplus.rb +281 -0
  34. data/lib/vorax/version.rb +7 -0
  35. data/lib/vorax/vorax_io.rb +70 -0
  36. data/lib/vorax.rb +60 -0
  37. data/spec/column_spec.rb +40 -0
  38. data/spec/conn_string_spec.rb +53 -0
  39. data/spec/package_spec_spec.rb +48 -0
  40. data/spec/pagezip_spec.rb +153 -0
  41. data/spec/parser_spec.rb +299 -0
  42. data/spec/plsql_structure_spec.rb +44 -0
  43. data/spec/spec_helper.rb +13 -0
  44. data/spec/sql/create_objects.sql +69 -0
  45. data/spec/sql/dbms_crypto.spc +339 -0
  46. data/spec/sql/dbms_crypto.~spc +339 -0
  47. data/spec/sql/dbms_stats.spc +4097 -0
  48. data/spec/sql/drop_user.sql +10 -0
  49. data/spec/sql/muci.spc +24 -0
  50. data/spec/sql/setup_user.sql +22 -0
  51. data/spec/sql/test.pkg +67 -0
  52. data/spec/sqlplus_spec.rb +52 -0
  53. data/spec/stmt_inspector_spec.rb +84 -0
  54. data/spec/tablezip_spec.rb +111 -0
  55. data/spec/vertical_spec.rb +150 -0
  56. data/vorax.gemspec +21 -0
  57. metadata +139 -0
@@ -0,0 +1,4097 @@
1
+ create or replace package sys.dbms_stats authid current_user is
2
+
3
+ --
4
+ -- This package provides a mechanism for users to view and modify
5
+ -- optimizer statistics gathered for database objects.
6
+ -- The statistics can reside in two different locations:
7
+ -- 1) in the dictionary
8
+ -- 2) in a table created in the user's schema for this purpose
9
+ -- Only statistics stored in the dictionary itself will have an
10
+ -- impact on the cost-based optimizer.
11
+ --
12
+ -- This package also facilitates the gathering of some statistics
13
+ -- in parallel.
14
+ --
15
+ -- The package is divided into three main sections:
16
+ -- 1) procedures which set/get individual stats.
17
+ -- 2) procedures which transfer stats between the dictionary and
18
+ -- user stat tables.
19
+ -- 3) procedures which gather certain classes of optimizer statistics
20
+ -- and have improved (or equivalent) performance characteristics as
21
+ -- compared to the analyze command.
22
+ --
23
+ -- Most of the procedures include the three parameters: statown,
24
+ -- stattab, and statid.
25
+ -- These parameters are provided to allow users to store statistics in
26
+ -- their own tables (outside of the dictionary) which will not affect
27
+ -- the optimizer. Users can thereby maintain and experiment with "sets"
28
+ -- of statistics without fear of permanently changing good dictionary
29
+ -- statistics. The stattab parameter is used to specify the name of a
30
+ -- table in which to hold statistics and is assumed to reside in the same
31
+ -- schema as the object for which statistics are collected (unless the
32
+ -- statown parameter is specified). Users may create
33
+ -- multiple such tables with different stattab identifiers to hold separate
34
+ -- sets of statistics. Additionally, users can maintain different sets of
35
+ -- statistics within a single stattab by making use of the statid
36
+ -- parameter (which can help avoid cluttering the user's schema).
37
+ --
38
+ -- For all of the set/get procedures, if stattab is not provided (i.e., null),
39
+ -- the operation will work directly on the dictionary statistics; therefore,
40
+ -- users need not create these statistics tables if they only plan to
41
+ -- modify the dictionary directly. However, if stattab is not null,
42
+ -- then the set/get operation will work on the specified user statistics
43
+ -- table, not the dictionary.
44
+ --
45
+ -- lock_*_stats/unlock_*_stats procedures: When statistics on a table is
46
+ -- locked, all the statistics depending on the table, including table
47
+ -- statistics, column statistics, histograms and statistics on all
48
+ -- dependent indexes, are considered to be locked.
49
+ -- set_*, delete_*, import_*, gather_* procedures that modify statistics
50
+ -- in dictionary of an individual table/index/column will raise an error
51
+ -- if statistics of the object is locked. Procedures that operates on
52
+ -- multiple objects (eg: gather_schema_stats) will skip modifying the
53
+ -- statistics of an object if it is locked. Most of the procedures have
54
+ -- force argument to override the lock.
55
+ --
56
+ -- Whenever statistics in dictionary are modified, old versions of statistics
57
+ -- are saved automatically for future restoring. Statistics can be restored
58
+ -- using RESTORE procedures. These procedures use a time stamp as an argument
59
+ -- and restore statistics as of that time stamp.
60
+ -- There are dictionary views that display the time of statistics
61
+ -- modifications. These views are useful in determining the time stamp to
62
+ -- be used for statistics restoration.
63
+ --
64
+ -- Catalog view DBA_OPTSTAT_OPERATIONS contain history of
65
+ -- statistics operations performed at schema and database level
66
+ -- using DBMS_STATS.
67
+ --
68
+ -- The views *_TAB_STATS_HISTORY views (ALL, DBA, or USER) contain
69
+ -- history of table statistics modifications.
70
+ --
71
+ -- The old statistics are purged automatically at regular intervals based on
72
+ -- the statistics history retention setting and the time of the recent
73
+ -- analyze of the system. Retention is configurable using the
74
+ -- ALTER_STATS_HISTORY_RETENTION procedure. The default value is 31 days,
75
+ -- which means that you would be able to restore the optimizer statistics to
76
+ -- any time in last 31 days.
77
+ -- Automatic purging is enabled when STATISTICS_LEVEL parameter is set
78
+ -- to TYPICAL or ALL. If automatic purging is disabled, the old versions
79
+ -- of statistics need to be purged manually using the PURGE_STATS procedure.
80
+ --
81
+ -- Other related functions:
82
+ -- GET_STATS_HISTORY_RETENTION: This function can be used to get the
83
+ -- current statistics history retention value.
84
+ -- GET_STATS_HISTORY_AVAILABILITY: This function gets the oldest time stamp
85
+ -- where statistics history is available. Users cannot restore statistics
86
+ -- to a time stamp older than the oldest time stamp.
87
+ --
88
+ --
89
+ -- When a dbms_stats subprogram modifies or deletes the statistics
90
+ -- for an object, all the dependent cursors are invalidated by
91
+ -- default and corresponding statements are subject to recompilation
92
+ -- next time so that new statistics have immediate effects. This
93
+ -- behavior can be altered with the no_invalidate argument when
94
+ -- applicable.
95
+ --
96
+ -- Extended Statistics: This package allows you to collect statistics for
97
+ -- column groups and expressions (known as "statistics extensions"). The
98
+ -- statistics collected for column groups and expressions are called
99
+ -- "extended statistics". Statistics on Column groups are used by optimizer for
100
+ -- accounting correlation between columns. For example, if query has predicates
101
+ -- c1=1 and c2=1 and if there are statistics on (c1, c2), optimizer will use
102
+ -- this statistics for estimating the combined selectivity of the predicates.
103
+ -- The expression statistics are used by optimizer for estimating selectivity
104
+ -- of predicates on those expressions. The extended statistics are similar to
105
+ -- column statistics and the procedures that take columns names will accept
106
+ -- extension names in place of column names.
107
+ --
108
+ -- The following procedures can be used for managing extensions.
109
+ -- create_extended_stats - create extensions manually or based on
110
+ -- groups of columns seen in workload.
111
+ -- drop_extended_stats - drop an extension
112
+ -- show_extended_stats_name - show name of an extension
113
+ --
114
+ -- seed_col_usage - record usage of column (group)s in a
115
+ -- workload
116
+ -- reset_col_usage - delete recorded column (group)s usage
117
+ -- information
118
+ -- report_col_usage - generate a report of column group(s)
119
+ -- usage.
120
+ --
121
+ -- Comparing statistics:
122
+ --
123
+ -- diff_table_stats_* functions can be used to compare statistics for a table
124
+ -- from two different sources. The statistics can be from
125
+ --
126
+ -- - two different user statistics tables
127
+ -- - a single user statistics table containing two sets of
128
+ -- statistics that can be identified using statid's
129
+ -- - a user statistics table and dictionary
130
+ -- - history
131
+ -- - pending statistics
132
+
133
+ -- The functions also compares the statistics of the dependent objects
134
+ -- (indexes, columns, partitions).
135
+ -- They displays statistics of the object(s) from both sources if the
136
+ -- difference between those statistics exceeds a certain threshold (%).
137
+ -- The threshold can be specified as an argument to the function, with
138
+ -- a default of 10%.
139
+ -- The statistics corresponding to the first source (stattab1 or time1)
140
+ -- will be used as basis for computing the diff percentage.
141
+ --
142
+ -- Pending Statistics:
143
+ --
144
+ -- Optimizer statistics are gathered and saved in a pending state for tables
145
+ -- that have FALSE value for the PUBLISH preference (see set_*_prefs()).
146
+ -- The default value of the PUBLISH preference is TRUE.
147
+ -- Pending statistics can be published, exported, or deleted.
148
+ -- See the section corresponding to each of these procedures for details.
149
+ --
150
+ -- Pending statistics are not used by the Query Optimizer unless parameter
151
+ -- optimizer_use_pending_statistics is set to TRUE (system or session level).
152
+ -- The default value of this parameter is FALSE.
153
+ -- Pending statistics provide a mechanism to verify the impact of the new
154
+ -- statistics on query plans before making them available for general use.
155
+ --
156
+ -- There are two scenarios to verify the query plans:
157
+ -- 1. export the pending statistics (use export_pending_stats) to a test
158
+ -- system, then run the query workload and check the performance or plans.
159
+ -- 2. set optimizer_use_pending_statistics to TRUE in a session on the system
160
+ -- where pending statistics have been gathered, run the workload, and
161
+ -- check the performance or plans.
162
+ --
163
+ -- Once the performance or query plans have been verified, the pending
164
+ -- statistics can be published (run publish_pending_stats) if the performance
165
+ -- are acceptable or delete (run delete_pending_stats) if not.
166
+ --
167
+ -- Related procedures:
168
+ -- publish_pending_stats
169
+ -- export_pending_stats
170
+ -- delete_pending_stats
171
+ --
172
+ --
173
+ -- Nearly all the procedures in this package (more specifically, the
174
+ -- set_*, delete_*, export_*, import_*, gather_*, and *_stat_table
175
+ -- procedures) commit the current transaction, perform the operation,
176
+ -- and then commit again.
177
+ --
178
+
179
+ -- types for minimum/maximum values and histogram endpoints
180
+ type numarray is varray(256) of number;
181
+ type datearray is varray(256) of date;
182
+ type chararray is varray(256) of varchar2(4000);
183
+ type rawarray is varray(256) of raw(2000);
184
+ type fltarray is varray(256) of binary_float;
185
+ type dblarray is varray(256) of binary_double;
186
+
187
+ type StatRec is record (
188
+ epc number,
189
+ minval raw(2000),
190
+ maxval raw(2000),
191
+ bkvals numarray,
192
+ novals numarray,
193
+ chvals chararray,
194
+ eavs number);
195
+
196
+ -- type for objects whose statistics may be gathered
197
+ -- make sure to maintain satisfy_obj_filter when ObjectElem type
198
+ -- is changed
199
+ type ObjectElem is record (
200
+ ownname varchar2(32), -- owner
201
+ objtype varchar2(6), -- 'TABLE' or 'INDEX'
202
+ objname varchar2(32), -- table/index
203
+ partname varchar2(32), -- partition
204
+ subpartname varchar2(32) -- subpartition
205
+ );
206
+ type ObjectTab is table of ObjectElem;
207
+
208
+
209
+ -- type for displaying stats difference report
210
+ type DiffRepElem is record (
211
+ report clob, -- stats difference report
212
+ maxdiffpct number); -- max stats difference (percentage)
213
+ type DiffRepTab is table of DiffRepElem;
214
+
215
+ -- type for gather_table_stats context -- internal only
216
+ type CContext is varray(10) of varchar2(100);
217
+
218
+ -- oracle decides whether to collect stats for indexes or not
219
+ AUTO_CASCADE CONSTANT BOOLEAN := null;
220
+
221
+ -- oracle decides when to invalidate dependend cursors
222
+ AUTO_INVALIDATE CONSTANT BOOLEAN := null;
223
+
224
+ -- constant used to indicate auto sample size algorithms should
225
+ -- be used.
226
+ AUTO_SAMPLE_SIZE CONSTANT NUMBER := 0;
227
+
228
+ -- constant to indicate use of the system default degree of
229
+ -- parallelism determined based on the initialization parameters.
230
+ DEFAULT_DEGREE CONSTANT NUMBER := 32767;
231
+ -- force serial execution if the object is relatively small.
232
+ -- use the system default degree of parallelism otherwise.
233
+ AUTO_DEGREE CONSTANT NUMBER := 32768;
234
+
235
+ --
236
+ -- Default values for key parameters passed to dbms_stats procedures
237
+ -- These values are specified in the DEFAULT clause when declaring the
238
+ -- corresponding parameter in any of the dbms_stats procedures.
239
+ --
240
+ DEFAULT_CASCADE CONSTANT BOOLEAN := null;
241
+ DEFAULT_DEGREE_VALUE CONSTANT NUMBER := 32766;
242
+ DEFAULT_ESTIMATE_PERCENT CONSTANT NUMBER := 101;
243
+ DEFAULT_METHOD_OPT CONSTANT VARCHAR2(1) := 'Z';
244
+ DEFAULT_NO_INVALIDATE CONSTANT BOOLEAN := null;
245
+ DEFAULT_GRANULARITY CONSTANT VARCHAR2(1) := 'Z';
246
+ DEFAULT_PUBLISH CONSTANT BOOLEAN := true;
247
+ DEFAULT_INCREMENTAL CONSTANT BOOLEAN := false;
248
+ DEFAULT_STALE_PERCENT CONSTANT NUMBER := 10;
249
+ DEFAULT_AUTOSTATS_TARGET CONSTANT VARCHAR2(1) := 'Z';
250
+ DEFAULT_STAT_CATEGORY CONSTANT VARCHAR2(20) := 'OBJECT_STATS';
251
+
252
+ -- Constant which is used as an indicator that purge_stats should
253
+ -- purge everything (i.e., truncate) in stats history tables.
254
+ PURGE_ALL CONSTANT TIMESTAMP WITH TIME ZONE :=
255
+ TO_TIMESTAMP_TZ('1001-01-0101:00:00-00:00','YYYY-MM-DDHH:MI:SSTZH:TZM');
256
+
257
+ --
258
+ -- This set of procedures enable the storage and retrieval of
259
+ -- individual column-, index-, table- and system- related statistics
260
+ --
261
+ -- The procedures are:
262
+ --
263
+ -- prepare_column_values*
264
+ --
265
+ -- set_column_stats
266
+ -- set_index_stats
267
+ -- set_table_stats
268
+ -- set_system_stats
269
+ --
270
+ -- convert_raw_value*
271
+ --
272
+ -- get_column_stats
273
+ -- get_index_stats
274
+ -- get_table_stats
275
+ -- get_system_stats
276
+ --
277
+ -- delete_column_stats
278
+ -- delete_index_stats
279
+ -- delete_table_stats
280
+ -- delete_schema_stats
281
+ -- delete_database_stats
282
+ -- delete_system_stats
283
+ -- delete_fixed_objects_stats
284
+ -- delete_dictionary_stats
285
+ --
286
+
287
+
288
+ procedure prepare_column_values(
289
+ srec in out StatRec, charvals chararray);
290
+ pragma restrict_references(prepare_column_values, WNDS, RNDS, WNPS, RNPS);
291
+ procedure prepare_column_values(
292
+ srec in out StatRec, datevals datearray);
293
+ pragma restrict_references(prepare_column_values, WNDS, RNDS, WNPS, RNPS);
294
+ procedure prepare_column_values(
295
+ srec in out StatRec, numvals numarray);
296
+ pragma restrict_references(prepare_column_values, WNDS, RNDS, WNPS, RNPS);
297
+ procedure prepare_column_values(
298
+ srec in out StatRec, fltvals fltarray);
299
+ pragma restrict_references(prepare_column_values, WNDS, RNDS, WNPS, RNPS);
300
+ procedure prepare_column_values(
301
+ srec in out StatRec, dblvals dblarray);
302
+ pragma restrict_references(prepare_column_values, WNDS, RNDS, WNPS, RNPS);
303
+ procedure prepare_column_values(
304
+ srec in out StatRec, rawvals rawarray);
305
+ pragma restrict_references(prepare_column_values, WNDS, RNDS, WNPS, RNPS);
306
+ procedure prepare_column_values_nvarchar(
307
+ srec in out StatRec, nvmin nvarchar2, nvmax nvarchar2);
308
+ pragma restrict_references(prepare_column_values, WNDS, RNDS, WNPS, RNPS);
309
+ procedure prepare_column_values_rowid(
310
+ srec in out StatRec, rwmin rowid, rwmax rowid);
311
+ pragma restrict_references(prepare_column_values, WNDS, RNDS, WNPS, RNPS);
312
+ --
313
+ -- Convert user-specified minimum, maximum, and histogram endpoint
314
+ -- datatype-specific values into Oracle's internal representation
315
+ -- for future storage via set_column_stats.
316
+ --
317
+ -- Generic input arguments:
318
+ -- srec.epc - The number of values specified in charvals, datevals,
319
+ -- numvals, or rawvals. This value must be between 2 and 256 inclusive.
320
+ -- Should be set to 2 for procedures which don't allow histogram
321
+ -- information (nvarchar and rowid).
322
+ -- The first corresponding array entry should hold the minimum
323
+ -- value for the column and the last entry should hold the maximum.
324
+ -- If there are more than two entries, then all the others hold the
325
+ -- remaining height-balanced or frequency histogram endpoint values
326
+ -- (with in-between values ordered from next-smallest to next-largest).
327
+ -- This value may be adjusted to account for compression, so the
328
+ -- returned value should be left as is for a call to set_column_stats.
329
+ -- srec.bkvals - If a frequency distribution is desired, this array contains
330
+ -- the number of occurrences of each distinct value specified in
331
+ -- charvals, datevals, numvals, or rawvals. Otherwise, it is merely an
332
+ -- output argument and must be set to null when this procedure is
333
+ -- called.
334
+ --
335
+ -- Datatype specific input arguments (one of these):
336
+ -- charvals - The array of values when the column type is character-based.
337
+ -- Up to the first 32 bytes of each string should be provided.
338
+ -- Arrays must have between 2 and 256 entries, inclusive.
339
+ -- If the datatype is fixed char, the strings must be space padded
340
+ -- to 15 characters for correct normalization.
341
+ -- datevals - The array of values when the column type is date-based.
342
+ -- numvals - The array of values when the column type is numeric-based.
343
+ -- rawvals - The array of values when the column type is raw.
344
+ -- Up to the first 32 bytes of each strings should be provided.
345
+ -- nvmin,nvmax - The minimum and maximum values when the column type
346
+ -- is national character set based (NLS). No histogram information
347
+ -- can be provided for a column of this type.
348
+ -- If the datatype is fixed char, the strings must be space padded
349
+ -- to 15 characters for correct normalization.
350
+ -- rwmin,rwmax - The minimum and maximum values when the column type
351
+ -- is rowid. No histogram information can be provided for a column
352
+ -- of this type.
353
+ --
354
+ -- Output arguments:
355
+ -- srec.minval - Internal representation of the minimum which is
356
+ -- suitable for use in a call to set_column_stats.
357
+ -- srec.maxval - Internal representation of the maximum which is
358
+ -- suitable for use in a call to set_column_stats.
359
+ -- srec.bkvals - array suitable for use in a call to set_column_stats.
360
+ -- srec.novals - array suitable for use in a call to set_column_stats.
361
+ --
362
+ -- Exceptions:
363
+ -- ORA-20001: Invalid or inconsistent input values
364
+ --
365
+
366
+ procedure set_param(
367
+ pname in varchar2,
368
+ pval in varchar2);
369
+ --
370
+ -- WARNING ** WARNING ---> obsoleted <--- WARNING ** WARNING
371
+ -- Please use SET_GLOBAL_PREFS() instead.
372
+ -- WARNING ** WARNING ---> obsoleted <--- WARNING ** WARNING
373
+ --
374
+ -- This procedure can be used to set default value for parameters
375
+ -- of dbms_stats procedures.
376
+ --
377
+ -- The function get_param can be used to get the current
378
+ -- default value of a parameter.
379
+ --
380
+ -- To run this procedure, you must have the SYSDBA OR
381
+ -- both ANALYZE ANY DICTIONARY and ANALYZE ANY system privilege.
382
+ --
383
+ -- Input arguments:
384
+ -- pname - parameter name
385
+ -- The default value for following parameters can be set.
386
+ -- CASCADE - The default value for CASCADE set by set_param
387
+ -- is not used by export/import procedures.
388
+ -- It is used only by gather procedures.
389
+ -- DEGREE
390
+ -- ESTIMATE_PERCENT
391
+ -- METHOD_OPT
392
+ -- NO_INVALIDATE
393
+ -- GRANULARITY
394
+ -- AUTOSTATS_TARGET
395
+ -- This parameter is applicable only for auto stats
396
+ -- collection. The value of this parameter controls
397
+ -- the objects considered for stats collection
398
+ -- It takes the following values
399
+ -- 'ALL' -- statistics collected
400
+ -- for all objects in system
401
+ -- 'ORACLE' -- statistics collected
402
+ -- for all oracle owned objects
403
+ -- 'AUTO' -- oracle decide which objects
404
+ -- to collect stats
405
+ -- pval - parameter value.
406
+ -- if null is specified, it will set the oracle default value
407
+ --
408
+ -- Notes:
409
+ -- Both arguments are of type varchar2 and values are enclosed in quotes,
410
+ -- even when they represent numbers
411
+ --
412
+ -- Examples:
413
+ -- dbms_stats.set_param('CASCADE','DBMS_STATS.AUTO_CASCADE');
414
+ -- dbms_stats.set_param('ESTIMATE_PERCENT','5');
415
+ -- dbms_stats.set_param('DEGREE','NULL');
416
+ --
417
+ -- Exceptions:
418
+ -- ORA-20000: Insufficient privileges
419
+ -- ORA-20001: Invalid or Illegal input values
420
+ --
421
+
422
+ function get_param(
423
+ pname in varchar2)
424
+ return varchar2;
425
+ --
426
+ -- WARNING ** WARNING ---> obsoleted <--- WARNING ** WARNING
427
+ -- Please use GET_PREFS() instead.
428
+ -- WARNING ** WARNING ---> obsoleted <--- WARNING ** WARNING
429
+ --
430
+ -- Get default value of parameters of dbms_stats procedures
431
+ --
432
+ -- Input arguments:
433
+ -- pname - parameter name
434
+ --
435
+ -- Exceptions:
436
+ -- ORA-20001: Invalid input values
437
+ --
438
+
439
+ procedure reset_param_defaults;
440
+ --
441
+ -- WARNING ** WARNING ---> obsoleted <--- WARNING ** WARNING
442
+ -- Please use RESET_GLOBAL_PREF_DEFAULTS() instead.
443
+ -- WARNING ** WARNING ---> obsoleted <--- WARNING ** WARNING
444
+ --
445
+ -- This procedure resets the default of parameters to ORACLE
446
+ -- recommended values.
447
+ --
448
+
449
+ procedure reset_global_pref_defaults;
450
+ --
451
+ -- This procedure resets the global preference to the default values
452
+ --
453
+
454
+ procedure set_global_prefs(
455
+ pname varchar2,
456
+ pvalue varchar2);
457
+ --
458
+ -- This procedure is used to set the global statistics preferences.
459
+ -- This setting is honored only of there is no preference specified
460
+ -- for the table to be analyzed.
461
+ --
462
+ -- To run this procedure, you need to have the SYSDBA OR
463
+ -- both ANALYZE ANY DICTIONARY and ANALYZE ANY system privilege.
464
+ --
465
+ -- Input arguments:
466
+ -- pname - preference name
467
+ -- The default value for following preferences can be set.
468
+ -- CASCADE
469
+ -- DEGREE
470
+ -- ESTIMATE_PERCENT
471
+ -- METHOD_OPT
472
+ -- NO_INVALIDATE
473
+ -- GRANULARITY
474
+ -- PUBLISH
475
+ -- INCREMENTAL
476
+ -- STALE_PERCENT
477
+ -- AUTOSTATS_TARGET
478
+ -- CONCURRENT
479
+ --
480
+ -- pvalue - preference value.
481
+ -- if null is specified, it will set the oracle default value.
482
+ --
483
+ --
484
+ -- CASCADE: Please see CASCADE in gather_table_stats
485
+ --
486
+ -- DEGREE: Please see DEGREE in gather_table_stats
487
+ --
488
+ -- ESTIMATE_PERCENT: Please see ESTIMATE_PERCENT in gather_table_stats
489
+ --
490
+ -- METHOD_OPT: Please see METHOD_OPT in gather_table_stats
491
+ --
492
+ -- NO_INVALIDATE: Please see NO_INVALIDATE in gather_table_stats
493
+ --
494
+ -- GRANULARITY: Please see GRANULARITY in gather_table_stats
495
+ --
496
+ -- PUBLISH: The "PUBLISH" value determines whether or not newly gathered
497
+ -- statistics will be published once the gather job has completed.
498
+ -- Prior to 11g, once a statistic gathering job completed, the new
499
+ -- statistics were automatically published into the dictionary tables.
500
+ -- The user now has the ability to gather statistics but not publish
501
+ -- them immediately. This allows the DBA to test the new statistics
502
+ -- before publishing them.
503
+ --
504
+ -- INCREMENTAL: The "INCREMENTAL" value determines whether or not the global
505
+ -- statistics of a partitioned table will be maintained without doing a
506
+ -- full table scan. With partitioned tables it is very common to load new
507
+ -- data into a new partition. As new partitions are added and data loaded,
508
+ -- the global table statistics need to be kept up to date. Oracle will
509
+ -- update the global table statistics by scanning only the partitions that
510
+ -- have been changed instead of the entire table if the following conditions
511
+ -- hold: (1) the INCREMENTAL value for the partitioned table is set to TRUE;
512
+ -- (2) the PUBLISH value for the partitioned table is set to TRUE; and
513
+ -- (3) the user specifies AUTO_SAMPLE_SIZE for estimate_percent and AUTO for
514
+ -- granularity when gathering statistics on the table.
515
+ -- If the INCREMENTAL value for the partitioned table was set to FALSE
516
+ -- (default value), then a full table scan would be used to maintain the
517
+ -- global statistics.
518
+ --
519
+ -- STALE_PERCENT: The "STALE_PERCENT" value determines the percentage of rows
520
+ -- in a table that have to change before the statistics on that table are
521
+ -- deemed stale and should be regathered. The default value is 10%.
522
+ --
523
+ -- AUTOSTATS_TARGET
524
+ -- This preference is applicable only for auto stats collection. The value
525
+ -- of this parameter controls the objects considered for stats collection.
526
+ -- It takes the following values
527
+ -- 'ALL' -- statistics collected for all objects in system
528
+ -- 'ORACLE' -- statistics collected for all oracle owned objects
529
+ -- 'AUTO' -- oracle decide which objects to collect stats
530
+ --
531
+ -- CONCURRENT
532
+ -- This preference determines whether the statistics of tables or
533
+ -- (sub)partitions of tables to be gathered concurrently when user issues
534
+ -- gather_*_stats procedures. DBMS_STATS has the ability to collect
535
+ -- statistics for a single object (table, (sub)partition) in parallel
536
+ -- based on the value of degree parameter. However the parallelism is
537
+ -- limited to one object. CONCURRENT preference extends the scope of
538
+ -- "parallelization" to multiple database objects by enabling users to
539
+ -- concurrently gather statistics for multiple tables in a schema/database
540
+ -- and multiple (sub)partitions within a table. Note that this is primarily
541
+ -- intented for multi cpu systems and it may not be suitable for small
542
+ -- databases on single cpu machines.
543
+
544
+ -- To gather statistics concurrently, the user must have DBA role or have
545
+ -- the following privileges in addition to privileges that are required for
546
+ -- gathering statistics.
547
+ -- CREATE JOB, MANAGE SCHEDULER, MANAGE ANY QUEUE
548
+ --
549
+ -- The preference takes the following values.
550
+ -- 'TRUE' - Gather statistics concurrently
551
+ -- 'FALSE' - Gather statistics in non concurrent fasion. This is the
552
+ -- default.
553
+ --
554
+ -- Notes:
555
+ -- Both arguments are of type varchar2 and values are enclosed in quotes,
556
+ -- even when they represent numbers
557
+ --
558
+ -- Examples:
559
+ -- dbms_stats.set_global_prefs('ESTIMATE_PERCENT','9');
560
+ -- dbms_stats.set_global_prefs('DEGREE','99');
561
+ --
562
+ -- Exceptions:
563
+ -- ORA-20000: Insufficient privileges
564
+ -- ORA-20001: Invalid or Illegal input values
565
+ --
566
+
567
+ function get_prefs(
568
+ pname in varchar2,
569
+ ownname in varchar2 default null,
570
+ tabname in varchar2 default null)
571
+ return varchar2;
572
+ --
573
+ --
574
+ -- Get default value of the specified preference.
575
+ -- If the ownname and tabname are provided and a preference has been entered
576
+ -- for the table then it returns the preference as specified for the table.
577
+ -- In all other cases it returns the global preference, in case it has been
578
+ -- specified, otherwise the default value is returned.
579
+ --
580
+ -- Input arguments:
581
+ -- pname - preference name
582
+ -- The default value for following preferences can be retrieved.
583
+ -- CASCADE
584
+ -- DEGREE
585
+ -- ESTIMATE_PERCENT
586
+ -- METHOD_OPT
587
+ -- NO_INVALIDATE
588
+ -- GRANULARITY
589
+ -- PUBLISH
590
+ -- INCREMENTAL
591
+ -- STALE_PERCENT
592
+ -- AUTOSTATS_TARGET
593
+ -- ownname - owner name
594
+ -- tabname - table name
595
+ --
596
+ --
597
+ -- Exceptions:
598
+ -- ORA-20001: Invalid input values
599
+ --
600
+
601
+ procedure set_table_prefs(
602
+ ownname varchar2,
603
+ tabname varchar2,
604
+ pname varchar2,
605
+ pvalue varchar2);
606
+ --
607
+ -- This procedure is used to set the statistics preferences of the
608
+ -- specified table in the specified schema.
609
+ --
610
+ -- To run this procedure, you need to connect as owner of the table
611
+ -- or be granted ANALYZE ANY system privilege.
612
+ --
613
+ -- Input arguments:
614
+ -- ownname - owner name
615
+ -- tabname - table name
616
+ -- pname - preference name
617
+ -- The default value for following preferences can be set.
618
+ -- CASCADE
619
+ -- DEGREE
620
+ -- ESTIMATE_PERCENT
621
+ -- METHOD_OPT
622
+ -- NO_INVALIDATE
623
+ -- GRANULARITY
624
+ -- PUBLISH
625
+ -- INCREMENTAL
626
+ -- STALE_PERCENT
627
+ -- pvalue - preference value.
628
+ -- if null is specified, it will set the oracle default value.
629
+ --
630
+ -- Notes:
631
+ -- All arguments are of type varchar2 and values are enclosed in quotes,
632
+ -- even when they represent numbers
633
+ --
634
+ -- Examples:
635
+ -- dbms_stats.set_table_prefs('SH', 'SALES', 'CASCADE',
636
+ -- 'DBMS_STATS.AUTO_CASCADE');
637
+ -- dbms_stats.set_table_prefs('SH', 'SALES', 'ESTIMATE_PERCENT','9');
638
+ -- dbms_stats.set_table_prefs('SH', 'SALES', 'DEGREE','99');
639
+ --
640
+ -- Exceptions:
641
+ -- ORA-20000: Insufficient privileges
642
+ -- ORA-20001: Invalid or Illegal input values
643
+ --
644
+
645
+ procedure delete_table_prefs(
646
+ ownname varchar2,
647
+ tabname varchar2,
648
+ pname varchar2);
649
+ --
650
+ -- This procedure is used to delete the statistics preferences of the
651
+ -- specified table in the specified schema.
652
+ --
653
+ -- To run this procedure, you need to connect as owner of the table
654
+ -- or be granted ANALYZE ANY system privilege.
655
+ --
656
+ -- Input arguments:
657
+ -- ownname - owner name
658
+ -- tabname - table name
659
+ -- pname - preference name
660
+ -- The default value for following preferences can be deleted.
661
+ -- CASCADE
662
+ -- DEGREE
663
+ -- ESTIMATE_PERCENT
664
+ -- METHOD_OPT
665
+ -- NO_INVALIDATE
666
+ -- GRANULARITY
667
+ -- PUBLISH
668
+ -- INCREMENTAL
669
+ -- STALE_PERCENT
670
+ --
671
+ -- Notes:
672
+ -- All arguments are of type varchar2 and values are enclosed in quotes.
673
+ --
674
+ -- Examples:
675
+ -- dbms_stats.delete_table_prefs('SH', 'SALES', 'CASCADE');
676
+ -- dbms_stats.delete_table_prefs('SH', 'SALES', 'DEGREE');
677
+ --
678
+ -- Exceptions:
679
+ -- ORA-20000: Insufficient privileges
680
+ -- ORA-20001: Invalid or Illegal input values
681
+ --
682
+
683
+
684
+ procedure export_table_prefs(
685
+ ownname varchar2,
686
+ tabname varchar2,
687
+ stattab varchar2,
688
+ statid varchar2 default null,
689
+ statown varchar2 default null);
690
+ --
691
+ -- This procedure is used to export the statistics preferences of the
692
+ -- specified table in the specified schema into the specified statistics
693
+ -- table.
694
+ --
695
+ -- To run this procedure, you need to connect as owner of the table
696
+ -- or be granted ANALYZE ANY system privilege.
697
+ --
698
+ -- Input arguments:
699
+ -- ownname - owner name
700
+ -- tabname - table name
701
+ -- stattab - statistics table name where to export the statistics
702
+ -- statid - (optional) identifier to associate with these statistics
703
+ -- within stattab.
704
+ -- statown - The schema containing stattab (if different then ownname)
705
+ --
706
+ -- Notes:
707
+ -- All arguments are of type varchar2 and values are enclosed in quotes.
708
+ --
709
+ -- Examples:
710
+ -- dbms_stats.export_table_prefs('SH', 'SALES', 'MY_STAT_TAB');
711
+ --
712
+ -- Exceptions:
713
+ -- ORA-20000: Object does not exist or insufficient privileges
714
+ --
715
+
716
+
717
+ procedure import_table_prefs(
718
+ ownname varchar2,
719
+ tabname varchar2,
720
+ stattab varchar2,
721
+ statid varchar2 default null,
722
+ statown varchar2 default null);
723
+ --
724
+ -- This procedure is used to set the statistics preferences of the
725
+ -- specified table in the specified schema.
726
+ --
727
+ -- To run this procedure, you need to connect as owner of the table
728
+ -- or be granted ANALYZE ANY system privilege.
729
+ --
730
+ -- Input arguments:
731
+ -- ownname - owner name
732
+ -- tabname - table name
733
+ -- stattab - The user stat table identifier describing from where
734
+ -- to retrieve the statistics.
735
+ -- statid - (optional) identifier to associate with these statistics
736
+ -- within stattab.
737
+ -- statown - The schema containing stattab (if different then ownname)
738
+ --
739
+ -- Notes:
740
+ -- All arguments are of type varchar2 and values are enclosed in quotes.
741
+ --
742
+ -- Examples:
743
+ -- dbms_stats.import_table_prefs('SH', 'SALES', 'MY_STAT_TAB');
744
+ --
745
+ -- Exceptions:
746
+ -- ORA-20000: Insufficient privileges
747
+ -- ORA-20000: Schema "<schema>" does not exist
748
+ --
749
+
750
+
751
+ procedure set_schema_prefs(
752
+ ownname varchar2,
753
+ pname varchar2,
754
+ pvalue varchar2);
755
+ --
756
+ -- This procedure is used to set the statistics preferences of all
757
+ -- the tables owned by the specified owner name.
758
+ --
759
+ -- To run this procedure, you need to connect as owner, have the SYSDBA
760
+ -- privilege, OR have the ANALYZE ANY system privilege
761
+ --
762
+ -- Input arguments:
763
+ -- ownname - owner name
764
+ -- pname - preference name
765
+ -- The default value for following preferences can be set.
766
+ -- CASCADE
767
+ -- DEGREE
768
+ -- ESTIMATE_PERCENT
769
+ -- METHOD_OPT
770
+ -- NO_INVALIDATE
771
+ -- GRANULARITY
772
+ -- PUBLISH
773
+ -- INCREMENTAL
774
+ -- STALE_PERCENT
775
+ -- pvalue - preference value.
776
+ -- if null is specified, it will set the oracle default value.
777
+ -- Notes:
778
+ -- All arguments are of type varchar2 and values are enclosed in quotes,
779
+ -- even when they represent numbers
780
+ --
781
+ -- Examples:
782
+ -- dbms_stats.set_schema_prefs('SH', 'CASCADE',
783
+ -- 'DBMS_STATS.AUTO_CASCADE');
784
+ -- dbms_stats.set_schema_prefs('SH' 'ESTIMATE_PERCENT','9');
785
+ -- dbms_stats.set_schema_prefs('SH', 'DEGREE','99');
786
+ --
787
+ -- Exceptions:
788
+ -- ORA-20000: Insufficient privileges
789
+ -- ORA-20000: Schema "<schema>" does not exist
790
+ -- ORA-20001: Invalid or Illegal input values
791
+ --
792
+
793
+
794
+ procedure delete_schema_prefs(
795
+ ownname varchar2,
796
+ pname varchar2);
797
+ --
798
+ -- This procedure is used to delete the statistics preferences of all
799
+ -- the tables owned by the specified owner name.
800
+ --
801
+ -- To run this procedure, you need to connect as owner, have the SYSDBA
802
+ -- privilege, OR have the ANALYZE ANY system privilege
803
+ --
804
+ -- Input arguments:
805
+ -- ownname - owner name
806
+ -- pname - preference name
807
+ -- The default value for following preferences can be deleted.
808
+ -- CASCADE
809
+ -- DEGREE
810
+ -- ESTIMATE_PERCENT
811
+ -- METHOD_OPT
812
+ -- NO_INVALIDATE
813
+ -- GRANULARITY
814
+ -- PUBLISH
815
+ -- INCREMENTAL
816
+ -- STALE_PERCENT
817
+ --
818
+ -- Notes:
819
+ -- All arguments are of type varchar2 and values are enclosed in quotes.
820
+ --
821
+ -- Examples:
822
+ -- dbms_stats.delete_schema_prefs('SH', 'CASCADE');
823
+ -- dbms_stats.delete_schema_prefs('SH', 'ESTIMATE_PERCENT');
824
+ -- dbms_stats.delete_schema_prefs('SH', 'DEGREE');
825
+ --
826
+ -- Exceptions:
827
+ -- ORA-20000: Insufficient privileges
828
+ -- ORA-20000: Schema "<schema>" does not exist
829
+ -- ORA-20001: Invalid or Illegal input values
830
+ --
831
+
832
+
833
+ procedure export_schema_prefs(
834
+ ownname varchar2,
835
+ stattab varchar2,
836
+ statid varchar2 default null,
837
+ statown varchar2 default null);
838
+ --
839
+ -- This procedure is used to export the statistics preferences of all
840
+ -- the tables owner by the specified owner name.
841
+ --
842
+ -- To run this procedure, you need to connect as owner, have the SYSDBA
843
+ -- privilege, OR have the ANALYZE ANY system privilege
844
+ --
845
+ -- Input arguments:
846
+ -- ownname - owner name
847
+ -- stattab - statistics table name where to export the statistics
848
+ -- statid - (optional) identifier to associate with these statistics
849
+ -- within stattab.
850
+ -- statown - The schema containing stattab (if different then ownname)
851
+ --
852
+ -- Notes:
853
+ -- All arguments are of type varchar2 and values are enclosed in quotes.
854
+ --
855
+ -- Examples:
856
+ -- dbms_stats.export_schema_prefs('SH', 'MY_STAT_TAB');
857
+ --
858
+ -- Exceptions:
859
+ -- ORA-20000: Insufficient privileges
860
+ -- ORA-20000: Schema "<schema>" does not exist
861
+ --
862
+
863
+
864
+ procedure import_schema_prefs(
865
+ ownname varchar2,
866
+ stattab varchar2,
867
+ statid varchar2 default null,
868
+ statown varchar2 default null);
869
+ --
870
+ -- This procedure is used to import the statistics preferences of all
871
+ -- the tables owner by the specified owner name.
872
+ --
873
+ -- To run this procedure, you need to connect as owner, have the SYSDBA
874
+ -- privilege, OR have the ANALYZE ANY system privilege
875
+ --
876
+ -- Input arguments:
877
+ -- ownname - owner name
878
+ -- stattab - The user stat table identifier describing from where
879
+ -- to retrieve the statistics.
880
+ -- statid - (optional) identifier to associate with these statistics
881
+ -- within stattab.
882
+ -- statown - The schema containing stattab (if different from ownname)
883
+ --
884
+ -- Notes:
885
+ -- All arguments are of type varchar2 and values are enclosed in quotes.
886
+ --
887
+ -- Examples:
888
+ -- dbms_stats.import_schema_prefs('SH', 'MY_STAT_TAB');
889
+ --
890
+ -- Exceptions:
891
+ -- ORA-20000: Insufficient privileges
892
+ -- ORA-20000: Schema "<schema>" does not exist
893
+ --
894
+
895
+
896
+ procedure set_database_prefs(
897
+ pname varchar2,
898
+ pvalue varchar2,
899
+ add_sys boolean default false);
900
+ --
901
+ -- This procedure is used to set the statistics preferences of all
902
+ -- the tables, excluding the tables owned by Oracle. These tables
903
+ -- can by included by passing TRUE for the add_sys parameter.
904
+ --
905
+ -- To run this procedure, you need to have the SYSDBA role OR both
906
+ -- ANALYZE ANY DICTIONARY and ANALYZE ANY system privileges.
907
+ --
908
+ -- Input arguments:
909
+ -- pname - preference name
910
+ -- The default value for following preferences can be set.
911
+ -- CASCADE
912
+ -- DEGREE
913
+ -- ESTIMATE_PERCENT
914
+ -- METHOD_OPT
915
+ -- NO_INVALIDATE
916
+ -- GRANULARITY
917
+ -- PUBLISH
918
+ -- INCREMENTAL
919
+ -- STALE_PERCENT
920
+ -- pvalue - preference value.
921
+ -- if null is specified, it will set the oracle default value.
922
+ -- add_sys - value TRUE will include the Oracle-owned tables
923
+ --
924
+ -- Notes:
925
+ -- All arguments are of type varchar2 and values are enclosed in quotes,
926
+ -- even when they represent numbers.
927
+ --
928
+ -- Examples:
929
+ -- dbms_stats.set_database_prefs('CASCADE', 'DBMS_STATS.AUTO_CASCADE');
930
+ -- dbms_stats.set_database_prefs('ESTIMATE_PERCENT','9');
931
+ -- dbms_stats.set_database_prefs('DEGREE','99');
932
+ --
933
+ -- Exceptions:
934
+ -- ORA-20000: Insufficient privileges
935
+ -- ORA-20001: Invalid or Illegal input values
936
+ --
937
+
938
+
939
+ procedure delete_database_prefs(
940
+ pname varchar2,
941
+ add_sys boolean default false);
942
+ --
943
+ -- This procedure is used to delete the statistics preferences of
944
+ -- all the tables, excluding the tables owned by Oracle. These
945
+ -- tables can by included by passing TRUE for the add_sys parameter.
946
+ --
947
+ -- To run this procedure, you need to have the SYSDBA role OR both
948
+ -- ANALYZE ANY DICTIONARY and ANALYZE ANY system privileges.
949
+ --
950
+ -- Input arguments:
951
+ -- pname - preference name
952
+ -- The default value for following preferences can be deleted.
953
+ -- CASCADE
954
+ -- DEGREE
955
+ -- ESTIMATE_PERCENT
956
+ -- METHOD_OPT
957
+ -- NO_INVALIDATE
958
+ -- GRANULARITY
959
+ -- PUBLISH
960
+ -- INCREMENTAL
961
+ -- STALE_PERCENT
962
+ -- add_sys - value TRUE will include the Oracle-owned tables
963
+ --
964
+ -- Notes:
965
+ -- All arguments are of type varchar2 and values are enclosed in quotes.
966
+ --
967
+ -- Examples:
968
+ -- dbms_stats.delete_database_prefs('CASCADE', false);
969
+ -- dbms_stats.delete_database_prefs('ESTIMATE_PERCENT',true);
970
+ --
971
+ -- Exceptions:
972
+ -- ORA-20000: Insufficient privileges
973
+ -- ORA-20001: Invalid or Illegal input values
974
+ --
975
+
976
+
977
+ procedure export_database_prefs(
978
+ stattab varchar2,
979
+ statid varchar2 default null,
980
+ statown varchar2 default null,
981
+ add_sys boolean default false);
982
+ --
983
+ -- This procedure is used to export the statistics preferences of
984
+ -- all the tables, excluding the tables owned by Oracle. These
985
+ -- tables can by included by passing TRUE for the add_sys parameter.
986
+ --
987
+ -- To run this procedure, you need to have the SYSDBA role OR both
988
+ -- ANALYZE ANY DICTIONARY and ANALYZE ANY system privileges.
989
+ --
990
+ -- Input arguments:
991
+ -- stattab - statistics table name where to export the statistics
992
+ -- statid - (optional) identifier to associate with these statistics
993
+ -- within stattab.
994
+ -- statown - The schema containing stattab (if different then ownname)
995
+ -- add_sys - value TRUE will include the Oracle-owned tables
996
+ --
997
+ -- Examples:
998
+ -- dbms_stats.export_database_prefs('MY_STAT_TAB', statown=>'SH');
999
+ --
1000
+ -- Exceptions:
1001
+ -- ORA-20000: Insufficient privileges
1002
+ --
1003
+
1004
+
1005
+ procedure import_database_prefs(
1006
+ stattab varchar2,
1007
+ statid varchar2 default null,
1008
+ statown varchar2 default null,
1009
+ add_sys boolean default false);
1010
+ --
1011
+ -- This procedure is used to import the statistics preferences of
1012
+ -- all the tables, excluding the tables owned by Oracle. These
1013
+ -- tables can by included by passing TRUE for the add_sys parameter.
1014
+ --
1015
+ -- To run this procedure, you need to have the SYSDBA role OR both
1016
+ -- ANALYZE ANY DICTIONARY and ANALYZE ANY system privileges.
1017
+ --
1018
+ -- Input arguments:
1019
+ -- stattab - The user stat table identifier describing from where
1020
+ -- to retrieve the statistics.
1021
+ -- statid - (optional) identifier to associate with these statistics
1022
+ -- within stattab.
1023
+ -- statown - The schema containing stattab
1024
+ -- add_sys - value TRUE will include the Oracle-owned tables
1025
+ -- Examples:
1026
+ -- dbms_stats.import_database_prefs('MY_STAT_TAB', statown=>'SH');
1027
+ --
1028
+ -- Exceptions:
1029
+ -- ORA-20000: Insufficient privileges
1030
+ --
1031
+
1032
+
1033
+ -- THE FOLLOWING PROCEDURES ARE FOR INTERNAL USE ONLY.
1034
+ function to_cascade_type(cascade varchar2) return boolean;
1035
+ function to_estimate_percent_type(estimate_percent varchar2) return number;
1036
+ function to_degree_type(degree varchar2) return number;
1037
+ function to_no_invalidate_type(no_invalidate varchar2) return boolean;
1038
+ function to_publish_type(publish varchar2) return boolean;
1039
+ procedure init_package;
1040
+ -- THE ABOVE PROCEDURES ARE FOR INTERNAL USE ONLY.
1041
+
1042
+
1043
+ procedure publish_pending_stats(
1044
+ ownname varchar2 default USER,
1045
+ tabname varchar2,
1046
+ no_invalidate boolean default
1047
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
1048
+ force boolean default FALSE);
1049
+ --
1050
+ -- This procedure is used to publish the statistics gathered and stored
1051
+ -- as pending.
1052
+ -- If the parameter TABNAME is null then publish applies to all tables
1053
+ -- of the specified schema.
1054
+ -- The default owner/schema is the user who runs the procedure.
1055
+ --
1056
+ -- To run this procedure, you need to have the privilge to collect stats
1057
+ -- for the tables that will be touched by this procedure.
1058
+ --
1059
+ -- Input arguments:
1060
+ -- ownname - owner name
1061
+ -- tabname - table name
1062
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
1063
+ -- The procedure invalidates the dependent cursors immediately
1064
+ -- if set to FALSE.
1065
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
1066
+ -- invalidate dependend cursors. This is the default. The default
1067
+ -- can be changed using set_param procedure.
1068
+ -- force - to override the lock (TRUE will override the lock).
1069
+ --
1070
+ -- Notes:
1071
+ -- All arguments are of type varchar2 and values are enclosed in quotes.
1072
+ --
1073
+ -- Examples:
1074
+ -- dbms_stats.publish_pending_stats('SH', null);
1075
+ --
1076
+ -- Exceptions:
1077
+ -- ORA-20000: Insufficient privileges
1078
+ --
1079
+
1080
+ procedure export_pending_stats(
1081
+ ownname varchar2 default USER,
1082
+ tabname varchar2,
1083
+ stattab varchar2,
1084
+ statid varchar2 default null,
1085
+ statown varchar2 default USER);
1086
+ --
1087
+ -- This procedure is used to export the statistics gathered and stored
1088
+ -- as pending.
1089
+ --
1090
+ -- If the parameter TABNAME is null then export applies to all tables
1091
+ -- of the specified schema.
1092
+ -- The default owner/schema is the user who runs the procedure.
1093
+ --
1094
+ -- To run this procedure, you need to have the SYSDBA role OR both
1095
+ -- ANALYZE ANY DICTIONARY and ANALYZE ANY system privileges.
1096
+ --
1097
+ -- Input arguments:
1098
+ -- ownname - owner name
1099
+ -- tabname - table name
1100
+ -- stattab - statistics table name where to export the statistics
1101
+ -- statid - (optional) identifier to associate with these statistics
1102
+ -- within stattab.
1103
+ -- statown - The schema containing stattab (if different from ownname)
1104
+ --
1105
+ -- Notes:
1106
+ -- All arguments are of type varchar2 and values are enclosed in quotes.
1107
+ --
1108
+ -- Examples:
1109
+ -- dbms_stats.export_pending_stats(null, null, 'MY_STAT_TAB');
1110
+ --
1111
+ -- Exceptions:
1112
+ -- ORA-20000: Insufficient privileges
1113
+ --
1114
+
1115
+ procedure delete_pending_stats(
1116
+ ownname varchar2 default USER,
1117
+ tabname varchar2 default null);
1118
+ --
1119
+ -- This procedure is used to delete the pending statistics that have
1120
+ -- been gathered but not published yet, i.e, stored as pending.
1121
+ --
1122
+ -- If the parameter TABNAME is null then delete applies to all tables
1123
+ -- of the specified schema.
1124
+ -- The default owner/schema is the user who runs the procedure.
1125
+ --
1126
+ -- To run this procedure, you need to have the SYSDBA role OR both
1127
+ -- ANALYZE ANY DICTIONARY and ANALYZE ANY system privileges.
1128
+ --
1129
+ -- Input arguments:
1130
+ -- ownname - owner name
1131
+ -- tabname - table name
1132
+ --
1133
+ -- Notes:
1134
+ -- All arguments are of type varchar2 and values are enclosed in quotes.
1135
+ --
1136
+ -- Examples:
1137
+ -- dbms_stats.delete_pending_stats('SH', 'SALES');
1138
+ --
1139
+ -- Exceptions:
1140
+ -- ORA-20000: Insufficient privileges
1141
+ --
1142
+
1143
+ procedure resume_gather_stats;
1144
+ --
1145
+ -- This procedure is used to resume statistics gathering at the point
1146
+ -- where it was interrupted. Statistics gathering can be interrupted
1147
+ -- as a result of a user action or a system event.
1148
+ --
1149
+ -- To run this procedure, you need to have the SYSDBA role OR both
1150
+ -- ANALYZE ANY DICTIONARY and ANALYZE ANY system privileges.
1151
+ --
1152
+ -- Input arguments:
1153
+ -- None.
1154
+ --
1155
+ -- Examples:
1156
+ -- dbms_stats.resume_gather_stats();
1157
+ --
1158
+ -- Exceptions:
1159
+ -- ORA-20000: Insufficient privileges
1160
+ --
1161
+
1162
+ procedure set_column_stats(
1163
+ ownname varchar2, tabname varchar2, colname varchar2,
1164
+ partname varchar2 default null,
1165
+ stattab varchar2 default null, statid varchar2 default null,
1166
+ distcnt number default null, density number default null,
1167
+ nullcnt number default null, srec StatRec default null,
1168
+ avgclen number default null, flags number default null,
1169
+ statown varchar2 default null,
1170
+ no_invalidate boolean default
1171
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
1172
+ force boolean default FALSE);
1173
+
1174
+ procedure set_column_stats(
1175
+ ownname varchar2, tabname varchar2, colname varchar2,
1176
+ partname varchar2 default null,
1177
+ stattab varchar2 default null, statid varchar2 default null,
1178
+ ext_stats raw,
1179
+ stattypown varchar2 default null,
1180
+ stattypname varchar2 default null,
1181
+ statown varchar2 default null,
1182
+ no_invalidate boolean default
1183
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
1184
+ force boolean default FALSE);
1185
+ --
1186
+ -- Set column-related information
1187
+ --
1188
+ -- Input arguments:
1189
+ -- ownname - The name of the schema
1190
+ -- tabname - The name of the table to which this column belongs
1191
+ -- colname - The name of the column or extension
1192
+ -- partname - The name of the table partition in which to store
1193
+ -- the statistics. If the table is partitioned and partname
1194
+ -- is null, the statistics will be stored at the global table
1195
+ -- level.
1196
+ -- stattab - The user stat table identifier describing where
1197
+ -- to store the statistics. If stattab is null, the statistics
1198
+ -- will be stored directly in the dictionary.
1199
+ -- statid - The (optional) identifier to associate with these statistics
1200
+ -- within stattab (Only pertinent if stattab is not NULL).
1201
+ -- distcnt - The number of distinct values
1202
+ -- density - The column density. If this value is null and distcnt is
1203
+ -- not null, density will be derived from distcnt.
1204
+ -- nullcnt - The number of nulls
1205
+ -- srec - StatRec structure filled in by a call to prepare_column_values
1206
+ -- or get_column_stats.
1207
+ -- avgclen - The average length for the column (in bytes)
1208
+ -- flags - For internal Oracle use (should be left as null)
1209
+ -- statown - The schema containing stattab (if different then ownname)
1210
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
1211
+ -- The procedure invalidates the dependent cursors immediately
1212
+ -- if set to FALSE.
1213
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
1214
+ -- invalidate dependend cursors. This is the default. The default
1215
+ -- can be changed using set_param procedure.
1216
+ -- force - set the values even if statistics of the object is locked
1217
+ --
1218
+ -- Input arguments for user-defined statistics:
1219
+ -- ext_stats - external (user-defined) statistics
1220
+ -- stattypown - owner of statistics type associated with column
1221
+ -- stattypname - name of statistics type associated with column
1222
+ --
1223
+ -- Exceptions:
1224
+ -- ORA-20000: Object does not exist or insufficient privileges
1225
+ -- ORA-20001: Invalid or inconsistent input values
1226
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
1227
+ -- ORA-20005: object statistics are locked
1228
+ --
1229
+
1230
+
1231
+ procedure set_index_stats(
1232
+ ownname varchar2, indname varchar2,
1233
+ partname varchar2 default null,
1234
+ stattab varchar2 default null, statid varchar2 default null,
1235
+ numrows number default null, numlblks number default null,
1236
+ numdist number default null, avglblk number default null,
1237
+ avgdblk number default null, clstfct number default null,
1238
+ indlevel number default null, flags number default null,
1239
+ statown varchar2 default null,
1240
+ no_invalidate boolean default
1241
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
1242
+ guessq number default null,
1243
+ cachedblk number default null,
1244
+ cachehit number default null,
1245
+ force boolean default FALSE);
1246
+
1247
+ procedure set_index_stats(
1248
+ ownname varchar2, indname varchar2,
1249
+ partname varchar2 default null,
1250
+ stattab varchar2 default null, statid varchar2 default null,
1251
+ ext_stats raw,
1252
+ stattypown varchar2 default null,
1253
+ stattypname varchar2 default null,
1254
+ statown varchar2 default null,
1255
+ no_invalidate boolean default
1256
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
1257
+ force boolean default FALSE);
1258
+ --
1259
+ -- Set index-related information
1260
+ -- Input arguments:
1261
+ -- ownname - The name of the schema
1262
+ -- indname - The name of the index
1263
+ -- partname - The name of the index partition in which to store
1264
+ -- the statistics. If the index is partitioned and partname
1265
+ -- is null, the statistics will be stored at the global index
1266
+ -- level.
1267
+ -- stattab - The user stat table identifier describing where
1268
+ -- to store the statistics. If stattab is null, the statistics
1269
+ -- will be stored directly in the dictionary.
1270
+ -- statid - The (optional) identifier to associate with these statistics
1271
+ -- within stattab (Only pertinent if stattab is not NULL).
1272
+ -- numrows - The number of rows in the index (partition)
1273
+ -- numlblks - The number of leaf blocks in the index (partition)
1274
+ -- numdist - The number of distinct keys in the index (partition)
1275
+ -- avglblk - Average integral number of leaf blocks in which each
1276
+ -- distinct key appears for this index (partition). If not provided,
1277
+ -- this value will be derived from numlblks and numdist.
1278
+ -- avgdblk - Average integral number of data blocks in the table
1279
+ -- pointed to by a distinct key for this index (partition).
1280
+ -- If not provided, this value will be derived from clstfct
1281
+ -- and numdist.
1282
+ -- clstfct - See clustering_factor column of the all_indexes view
1283
+ -- for a description.
1284
+ -- indlevel - The height of the index (partition)
1285
+ -- flags - For internal Oracle use (should be left as null)
1286
+ -- statown - The schema containing stattab (if different then ownname)
1287
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
1288
+ -- The procedure invalidates the dependent cursors immediately
1289
+ -- if set to FALSE.
1290
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
1291
+ -- invalidate dependend cursors. This is the default. The default
1292
+ -- can be changed using set_param procedure.
1293
+ -- guessq - IOT guess quality. See pct_direct_access column of the
1294
+ -- all_indexes view for a description.
1295
+ -- force - set the values even if statistics of the object is locked
1296
+ --
1297
+ -- Input arguments for user-defined statistics:
1298
+ -- ext_stats - external (user-defined) statistics
1299
+ -- stattypown - owner of statistics type associated with index
1300
+ -- stattypname - name of statistics type associated with index
1301
+ --
1302
+ -- Exceptions:
1303
+ -- ORA-20000: Object does not exist or insufficient privileges
1304
+ -- ORA-20001: Invalid input value
1305
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
1306
+ -- ORA-20005: object statistics are locked
1307
+ --
1308
+
1309
+ procedure set_table_stats(
1310
+ ownname varchar2,
1311
+ tabname varchar2,
1312
+ partname varchar2 default null,
1313
+ stattab varchar2 default null,
1314
+ statid varchar2 default null,
1315
+ numrows number default null,
1316
+ numblks number default null,
1317
+ avgrlen number default null,
1318
+ flags number default null,
1319
+ statown varchar2 default null,
1320
+ no_invalidate boolean default
1321
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
1322
+ cachedblk number default null,
1323
+ cachehit number default null,
1324
+ force boolean default FALSE);
1325
+ --
1326
+ -- Set table-related information
1327
+ --
1328
+ -- Input arguments:
1329
+ -- ownname - The name of the schema
1330
+ -- tabname - The name of the table
1331
+ -- partname - The name of the table partition in which to store
1332
+ -- the statistics. If the table is partitioned and partname
1333
+ -- is null, the statistics will be stored at the global table
1334
+ -- level.
1335
+ -- stattab - The user stat table identifier describing where
1336
+ -- to store the statistics. If stattab is null, the statistics
1337
+ -- will be stored directly in the dictionary.
1338
+ -- statid - The (optional) identifier to associate with these statistics
1339
+ -- within stattab (Only pertinent if stattab is not NULL).
1340
+ -- numrows - Number of rows in the table (partition)
1341
+ -- numblks - Number of blocks the table (partition) occupies
1342
+ -- avgrlen - Average row length for the table (partition)
1343
+ -- flags - For internal Oracle use (should be left as null)
1344
+ -- statown - The schema containing stattab (if different then ownname)
1345
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
1346
+ -- The procedure invalidates the dependent cursors immediately
1347
+ -- if set to FALSE.
1348
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
1349
+ -- invalidate dependend cursors. This is the default. The default
1350
+ -- can be changed using set_param procedure.
1351
+ -- force - set the values even if statistics of the object is locked
1352
+ --
1353
+ -- Exceptions:
1354
+ -- ORA-20000: Object does not exist or insufficient privileges
1355
+ -- ORA-20001: Invalid input value
1356
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
1357
+ -- ORA-20005: object statistics are locked
1358
+ --
1359
+
1360
+
1361
+ procedure convert_raw_value(
1362
+ rawval raw, resval out varchar2);
1363
+ pragma restrict_references(convert_raw_value, WNDS, RNDS, WNPS, RNPS);
1364
+ procedure convert_raw_value(
1365
+ rawval raw, resval out date);
1366
+ pragma restrict_references(convert_raw_value, WNDS, RNDS, WNPS, RNPS);
1367
+ procedure convert_raw_value(
1368
+ rawval raw, resval out number);
1369
+ pragma restrict_references(convert_raw_value, WNDS, RNDS, WNPS, RNPS);
1370
+ procedure convert_raw_value(
1371
+ rawval raw, resval out binary_float);
1372
+ pragma restrict_references(convert_raw_value, WNDS, RNDS, WNPS, RNPS);
1373
+ procedure convert_raw_value(
1374
+ rawval raw, resval out binary_double);
1375
+ pragma restrict_references(convert_raw_value, WNDS, RNDS, WNPS, RNPS);
1376
+ procedure convert_raw_value_nvarchar(
1377
+ rawval raw, resval out nvarchar2);
1378
+ pragma restrict_references(convert_raw_value_nvarchar,
1379
+ WNDS, RNDS, WNPS, RNPS);
1380
+ procedure convert_raw_value_rowid(
1381
+ rawval raw, resval out rowid);
1382
+ pragma restrict_references(convert_raw_value_rowid, WNDS, RNDS, WNPS, RNPS);
1383
+ --
1384
+ -- Convert the internal representation of a minimum or maximum value
1385
+ -- into a datatype-specific value. The minval and maxval fields
1386
+ -- of the StatRec structure as filled in by get_column_stats or
1387
+ -- prepare_column_values are appropriate values for input.
1388
+ --
1389
+ -- Input argument
1390
+ -- rawval - The raw representation of a column minimum or maximum
1391
+ --
1392
+ -- Datatype specific output arguments:
1393
+ -- resval - The converted, type-specific value
1394
+ --
1395
+ -- Exceptions:
1396
+ -- None
1397
+ --
1398
+
1399
+
1400
+ procedure get_column_stats(
1401
+ ownname varchar2, tabname varchar2, colname varchar2,
1402
+ partname varchar2 default null,
1403
+ stattab varchar2 default null, statid varchar2 default null,
1404
+ distcnt out number, density out number,
1405
+ nullcnt out number, srec out StatRec,
1406
+ avgclen out number,
1407
+ statown varchar2 default null);
1408
+
1409
+ procedure get_column_stats(
1410
+ ownname varchar2, tabname varchar2, colname varchar2,
1411
+ partname varchar2 default null,
1412
+ stattab varchar2 default null, statid varchar2 default null,
1413
+ ext_stats out raw,
1414
+ stattypown out varchar2, stattypname out varchar2,
1415
+ statown varchar2 default null);
1416
+ --
1417
+ -- Gets all column-related information
1418
+ --
1419
+ -- Input arguments:
1420
+ -- ownname - The name of the schema
1421
+ -- tabname - The name of the table to which this column belongs
1422
+ -- colname - The name of the column or extension
1423
+ -- partname - The name of the table partition from which to get
1424
+ -- the statistics. If the table is partitioned and partname
1425
+ -- is null, the statistics will be retrieved from the global table
1426
+ -- level.
1427
+ -- stattab - The user stat table identifier describing from where
1428
+ -- to retrieve the statistics. If stattab is null, the statistics
1429
+ -- will be retrieved directly from the dictionary.
1430
+ -- statid - The (optional) identifier to associate with these statistics
1431
+ -- within stattab (Only pertinent if stattab is not NULL).
1432
+ -- statown - The schema containing stattab (if different then ownname)
1433
+ --
1434
+ -- Output arguments:
1435
+ -- distcnt - The number of distinct values
1436
+ -- density - The column density
1437
+ -- nullcnt - The number of nulls
1438
+ -- srec - structure holding internal representation of column minimum,
1439
+ -- maximum, and histogram values
1440
+ -- avgclen - The average length of the column (in bytes)
1441
+ --
1442
+ -- Output arguments for user-defined column statistics:
1443
+ -- ext_stats - external (user-defined) statistics
1444
+ -- stattypown - owner of statistics type associated with column
1445
+ -- stattypname - name of statistics type associated with column
1446
+ --
1447
+ -- Exceptions:
1448
+ -- ORA-20000: Object does not exist or insufficient privileges or
1449
+ -- no statistics have been stored for requested object
1450
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
1451
+ --
1452
+
1453
+
1454
+ procedure get_index_stats(
1455
+ ownname varchar2, indname varchar2,
1456
+ partname varchar2 default null,
1457
+ stattab varchar2 default null, statid varchar2 default null,
1458
+ numrows out number, numlblks out number,
1459
+ numdist out number, avglblk out number,
1460
+ avgdblk out number, clstfct out number,
1461
+ indlevel out number,
1462
+ statown varchar2 default null,
1463
+ guessq out number,
1464
+ cachedblk out number,
1465
+ cachehit out number);
1466
+
1467
+ procedure get_index_stats(
1468
+ ownname varchar2, indname varchar2,
1469
+ partname varchar2 default null,
1470
+ stattab varchar2 default null, statid varchar2 default null,
1471
+ numrows out number, numlblks out number,
1472
+ numdist out number, avglblk out number,
1473
+ avgdblk out number, clstfct out number,
1474
+ indlevel out number,
1475
+ statown varchar2 default null,
1476
+ guessq out number);
1477
+
1478
+ procedure get_index_stats(
1479
+ ownname varchar2, indname varchar2,
1480
+ partname varchar2 default null,
1481
+ stattab varchar2 default null, statid varchar2 default null,
1482
+ numrows out number, numlblks out number,
1483
+ numdist out number, avglblk out number,
1484
+ avgdblk out number, clstfct out number,
1485
+ indlevel out number,
1486
+ statown varchar2 default null);
1487
+
1488
+ procedure get_index_stats(
1489
+ ownname varchar2, indname varchar2,
1490
+ partname varchar2 default null,
1491
+ stattab varchar2 default null, statid varchar2 default null,
1492
+ ext_stats out raw,
1493
+ stattypown out varchar2, stattypname out varchar2,
1494
+ statown varchar2 default null);
1495
+ --
1496
+ -- Gets all index-related information
1497
+ --
1498
+ -- Input arguments:
1499
+ -- ownname - The name of the schema
1500
+ -- indname - The name of the index
1501
+ -- partname - The name of the index partition for which to get
1502
+ -- the statistics. If the index is partitioned and partname
1503
+ -- is null, the statistics will be retrieved for the global index
1504
+ -- level.
1505
+ -- stattab - The user stat table identifier describing from where
1506
+ -- to retrieve the statistics. If stattab is null, the statistics
1507
+ -- will be retrieved directly from the dictionary.
1508
+ -- statid - The (optional) identifier to associate with these statistics
1509
+ -- within stattab (Only pertinent if stattab is not NULL).
1510
+ -- statown - The schema containing stattab (if different then ownname)
1511
+ --
1512
+ -- Output arguments:
1513
+ -- numrows - The number of rows in the index (partition)
1514
+ -- numlblks - The number of leaf blocks in the index (partition)
1515
+ -- numdist - The number of distinct keys in the index (partition)
1516
+ -- avglblk - Average integral number of leaf blocks in which each
1517
+ -- distinct key appears for this index (partition).
1518
+ -- avgdblk - Average integral number of data blocks in the table
1519
+ -- pointed to by a distinct key for this index (partition).
1520
+ -- clstfct - The clustering factor for the index (partition).
1521
+ -- indlevel - The height of the index (partition).
1522
+ -- guessq - IOT guess quality of the index (partition).
1523
+ --
1524
+ -- Output arguments for user defined statistics:
1525
+ -- ext_stats - external (user-defined) statistics
1526
+ -- stattypown - owner of statistics type associated with index
1527
+ -- stattypname - name of statistics type associated with index
1528
+ --
1529
+ -- Exceptions:
1530
+ -- ORA-20000: Object does not exist or insufficient privileges or
1531
+ -- no statistics have been stored for requested object
1532
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
1533
+ --
1534
+
1535
+
1536
+ procedure get_table_stats(
1537
+ ownname varchar2, tabname varchar2,
1538
+ partname varchar2 default null,
1539
+ stattab varchar2 default null, statid varchar2 default null,
1540
+ numrows out number, numblks out number,
1541
+ avgrlen out number,
1542
+ statown varchar2 default null);
1543
+
1544
+ procedure get_table_stats(
1545
+ ownname varchar2,
1546
+ tabname varchar2,
1547
+ partname varchar2 default null,
1548
+ stattab varchar2 default null,
1549
+ statid varchar2 default null,
1550
+ numrows out number,
1551
+ numblks out number,
1552
+ avgrlen out number,
1553
+ statown varchar2 default null,
1554
+ cachedblk out number,
1555
+ cachehit out number);
1556
+ --
1557
+ -- Gets all table-related information
1558
+ --
1559
+ -- Input arguments:
1560
+ -- ownname - The name of the schema
1561
+ -- tabname - The name of the table to which this column belongs
1562
+ -- partname - The name of the table partition from which to get
1563
+ -- the statistics. If the table is partitioned and partname
1564
+ -- is null, the statistics will be retrieved from the global table
1565
+ -- level.
1566
+ -- stattab - The user stat table identifier describing from where
1567
+ -- to retrieve the statistics. If stattab is null, the statistics
1568
+ -- will be retrieved directly from the dictionary.
1569
+ -- statid - The (optional) identifier to associate with these statistics
1570
+ -- within stattab (Only pertinent if stattab is not NULL).
1571
+ -- statown - The schema containing stattab (if different then ownname)
1572
+ --
1573
+ -- Output arguments:
1574
+ -- numrows - Number of rows in the table (partition)
1575
+ -- numblks - Number of blocks the table (partition) occupies
1576
+ -- avgrlen - Average row length for the table (partition)
1577
+ --
1578
+ -- Exceptions:
1579
+ -- ORA-20000: Object does not exist or insufficient privileges or
1580
+ -- no statistics have been stored for requested object
1581
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
1582
+ --
1583
+
1584
+
1585
+
1586
+ procedure delete_column_stats(
1587
+ ownname varchar2, tabname varchar2, colname varchar2,
1588
+ partname varchar2 default null,
1589
+ stattab varchar2 default null, statid varchar2 default null,
1590
+ cascade_parts boolean default true,
1591
+ statown varchar2 default null,
1592
+ no_invalidate boolean default
1593
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
1594
+ force boolean default FALSE,
1595
+ col_stat_type varchar2 default 'ALL');
1596
+ --
1597
+ -- Deletes column-related statistics
1598
+ --
1599
+ -- Input arguments:
1600
+ -- ownname - The name of the schema
1601
+ -- tabname - The name of the table to which this column belongs
1602
+ -- colname - The name of the column or extension
1603
+ -- partname - The name of the table partition for which to delete
1604
+ -- the statistics. If the table is partitioned and partname
1605
+ -- is null, global column statistics will be deleted.
1606
+ -- stattab - The user stat table identifier describing from where
1607
+ -- to delete the statistics. If stattab is null, the statistics
1608
+ -- will be deleted directly from the dictionary.
1609
+ -- statid - The (optional) identifier to associate with these statistics
1610
+ -- within stattab (Only pertinent if stattab is not NULL).
1611
+ -- cascade_parts - If the table is partitioned and partname is null,
1612
+ -- setting this to true will cause the deletion of statistics for
1613
+ -- this column for all underlying partitions as well.
1614
+ -- statown - The schema containing stattab (if different then ownname)
1615
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
1616
+ -- The procedure invalidates the dependent cursors immediately
1617
+ -- if set to FALSE.
1618
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
1619
+ -- invalidate dependend cursors. This is the default. The default
1620
+ -- can be changed using set_param procedure.
1621
+ -- force - delete statistics even if it is locked
1622
+ -- col_stat_type - Type of column statitistics to be deleted.
1623
+ -- This argument takes the following values:
1624
+ -- 'HISTOGRAM' - delete column histogram only
1625
+ -- 'ALL' - delete base column stats and histogram
1626
+ --
1627
+ -- Exceptions:
1628
+ -- ORA-20000: Object does not exist or insufficient privileges
1629
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
1630
+ -- ORA-20005: object statistics are locked
1631
+ --
1632
+
1633
+
1634
+ procedure delete_index_stats(
1635
+ ownname varchar2, indname varchar2,
1636
+ partname varchar2 default null,
1637
+ stattab varchar2 default null, statid varchar2 default null,
1638
+ cascade_parts boolean default true,
1639
+ statown varchar2 default null,
1640
+ no_invalidate boolean default
1641
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
1642
+ stattype varchar2 default 'ALL',
1643
+ force boolean default FALSE);
1644
+ --
1645
+ -- Deletes index-related statistics
1646
+ --
1647
+ -- Input arguments:
1648
+ -- ownname - The name of the schema
1649
+ -- indname - The name of the index
1650
+ -- partname - The name of the index partition for which to delete
1651
+ -- the statistics. If the index is partitioned and partname
1652
+ -- is null, index statistics will be deleted at the global level.
1653
+ -- stattab - The user stat table identifier describing from where
1654
+ -- to delete the statistics. If stattab is null, the statistics
1655
+ -- will be deleted directly from the dictionary.
1656
+ -- statid - The (optional) identifier to associate with these statistics
1657
+ -- within stattab (Only pertinent if stattab is not NULL).
1658
+ -- cascade_parts - If the index is partitioned and partname is null,
1659
+ -- setting this to true will cause the deletion of statistics for
1660
+ -- this index for all underlying partitions as well.
1661
+ -- statown - The schema containing stattab (if different then ownname)
1662
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
1663
+ -- The procedure invalidates the dependent cursors immediately
1664
+ -- if set to FALSE.
1665
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
1666
+ -- invalidate dependend cursors. This is the default. The default
1667
+ -- can be changed using set_param procedure.
1668
+ -- force - delete the statistics even if it is locked
1669
+ --
1670
+ -- Exceptions:
1671
+ -- ORA-20000: Object does not exist or insufficient privileges
1672
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
1673
+ -- ORA-20005: object statistics are locked
1674
+ --
1675
+
1676
+
1677
+ procedure delete_table_stats(
1678
+ ownname varchar2, tabname varchar2,
1679
+ partname varchar2 default null,
1680
+ stattab varchar2 default null, statid varchar2 default null,
1681
+ cascade_parts boolean default true,
1682
+ cascade_columns boolean default true,
1683
+ cascade_indexes boolean default true,
1684
+ statown varchar2 default null,
1685
+ no_invalidate boolean default
1686
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
1687
+ stattype varchar2 default 'ALL',
1688
+ force boolean default FALSE);
1689
+ --
1690
+ -- Deletes table-related statistics
1691
+ --
1692
+ -- Input arguments:
1693
+ -- ownname - The name of the schema
1694
+ -- tabname - The name of the table to which this column belongs
1695
+ -- partname - The name of the table partition from which to get
1696
+ -- the statistics. If the table is partitioned and partname
1697
+ -- is null, the statistics will be retrieved from the global table
1698
+ -- level.
1699
+ -- stattab - The user stat table identifier describing from where
1700
+ -- to retrieve the statistics. If stattab is null, the statistics
1701
+ -- will be retrieved directly from the dictionary.
1702
+ -- statid - The (optional) identifier to associate with these statistics
1703
+ -- within stattab (Only pertinent if stattab is not NULL).
1704
+ -- cascade_parts - If the table is partitioned and partname is null,
1705
+ -- setting this to true will cause the deletion of statistics for
1706
+ -- this table for all underlying partitions as well.
1707
+ -- cascade_columns - Indicates that delete_column_stats should be
1708
+ -- called for all underlying columns (passing the cascade_parts
1709
+ -- parameter).
1710
+ -- cascade_indexes - Indicates that delete_index_stats should be
1711
+ -- called for all underlying indexes (passing the cascade_parts
1712
+ -- parameter).
1713
+ -- statown - The schema containing stattab (if different then ownname)
1714
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
1715
+ -- The procedure invalidates the dependent cursors immediately
1716
+ -- if set to FALSE.
1717
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
1718
+ -- invalidate dependend cursors. This is the default. The default
1719
+ -- can be changed using set_param procedure.
1720
+ -- force - delete the statistics even if it is locked
1721
+ --
1722
+ -- Exceptions:
1723
+ -- ORA-20000: Object does not exist or insufficient privileges
1724
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
1725
+ -- ORA-20005: object statistics are locked
1726
+ --
1727
+
1728
+
1729
+ procedure delete_schema_stats(
1730
+ ownname varchar2,
1731
+ stattab varchar2 default null, statid varchar2 default null,
1732
+ statown varchar2 default null,
1733
+ no_invalidate boolean default
1734
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
1735
+ stattype varchar2 default 'ALL',
1736
+ force boolean default FALSE);
1737
+ --
1738
+ -- Deletes statistics for a schema
1739
+ --
1740
+ -- Input arguments:
1741
+ -- ownname - The name of the schema
1742
+ -- stattab - The user stat table identifier describing from where
1743
+ -- to delete the statistics. If stattab is null, the statistics
1744
+ -- will be deleted directly in the dictionary.
1745
+ -- statid - The (optional) identifier to associate with these statistics
1746
+ -- within stattab (Only pertinent if stattab is not NULL).
1747
+ -- statown - The schema containing stattab (if different then ownname)
1748
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
1749
+ -- The procedure invalidates the dependent cursors immediately
1750
+ -- if set to FALSE.
1751
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
1752
+ -- invalidate dependend cursors. This is the default. The default
1753
+ -- can be changed using set_param procedure.
1754
+ -- stattype - The type of statistics to be deleted
1755
+ -- ALL - both data and cache statistics will be deleted
1756
+ -- CACHE - only cache statistics will be deleted
1757
+ -- force - Ignores the statistics lock on objects and delete
1758
+ -- the statistics if set to TRUE.
1759
+ --
1760
+ --
1761
+ --
1762
+ -- Exceptions:
1763
+ -- ORA-20000: Object does not exist or insufficient privileges
1764
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
1765
+ --
1766
+
1767
+
1768
+ procedure delete_database_stats(
1769
+ stattab varchar2 default null, statid varchar2 default null,
1770
+ statown varchar2 default null,
1771
+ no_invalidate boolean default
1772
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
1773
+ stattype varchar2 default 'ALL',
1774
+ force boolean default FALSE);
1775
+ --
1776
+ -- Deletes statistics for an entire database
1777
+ --
1778
+ -- Input arguments:
1779
+ -- stattab - The user stat table identifier describing from where
1780
+ -- to delete the statistics. If stattab is null, the statistics
1781
+ -- will be deleted directly in the dictionary.
1782
+ -- statid - The (optional) identifier to associate with these statistics
1783
+ -- within stattab (Only pertinent if stattab is not NULL).
1784
+ -- statown - The schema containing stattab.
1785
+ -- If stattab is not null and statown is null, it is assumed that
1786
+ -- every schema in the database contains a user statistics table
1787
+ -- with the name stattab.
1788
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
1789
+ -- The procedure invalidates the dependent cursors immediately
1790
+ -- if set to FALSE.
1791
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
1792
+ -- invalidate dependend cursors. This is the default. The default
1793
+ -- can be changed using set_param procedure.
1794
+ -- stattype - The type of statistics to be deleted
1795
+ -- ALL - both data and cache statistics will be deleted
1796
+ -- CACHE - only cache statistics will be deleted
1797
+ -- force - Ignores the statistics lock on objects and delete
1798
+ -- the statistics if set to TRUE.
1799
+ --
1800
+ -- Exceptions:
1801
+ -- ORA-20000: Object does not exist or insufficient privileges
1802
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
1803
+ --
1804
+
1805
+
1806
+
1807
+
1808
+
1809
+
1810
+ --
1811
+ -- This set of procedures enable the transferrance of statistics
1812
+ -- from the dictionary to a user stat table (export_*) and from a user
1813
+ -- stat table to the dictionary (import_*).
1814
+ --
1815
+ -- The procedures are:
1816
+ --
1817
+ -- create_stat_table
1818
+ -- drop_stat_table
1819
+ -- upgrade_stat_table
1820
+ --
1821
+ -- export_column_stats
1822
+ -- export_index_stats
1823
+ -- export_table_stats
1824
+ -- export_schema_stats
1825
+ -- export_database_stats
1826
+ -- export_system_stats
1827
+ -- export_fixed_objects_stats
1828
+ -- export_dictionary_stats
1829
+ --
1830
+ -- import_column_stats
1831
+ -- import_index_stats
1832
+ -- import_table_stats
1833
+ -- import_schema_stats
1834
+ -- import_database_stats
1835
+ -- import_system_stats
1836
+ -- import_fixed_objects_stats
1837
+ -- import_dictionary_stats
1838
+ --
1839
+ -- Notes:
1840
+ -- We do not support export/import of stats across databases of
1841
+ -- different character sets.
1842
+ --
1843
+
1844
+
1845
+ procedure create_stat_table(
1846
+ ownname varchar2, stattab varchar2,
1847
+ tblspace varchar2 default null,
1848
+ global_temporary boolean default false);
1849
+ --
1850
+ -- Creates a table with name 'stattab' in 'ownname's
1851
+ -- schema which is capable of holding statistics. The columns
1852
+ -- and types that compose this table are not relevant as it
1853
+ -- should be accessed solely through the procedures in this
1854
+ -- package.
1855
+ --
1856
+ -- Input arguments:
1857
+ -- ownname - The name of the schema
1858
+ -- stattab - The name of the table to create. This value should
1859
+ -- be passed as the 'stattab' argument to other procedures
1860
+ -- when the user does not wish to modify the dictionary statistics
1861
+ -- directly.
1862
+ -- tblspace - The tablespace in which to create the stat tables.
1863
+ -- If none is specified, they will be created in the user's
1864
+ -- default tablespace.
1865
+ -- table_options - Whether or not the table should be created as a global
1866
+ -- temporary table.
1867
+ --
1868
+ -- Exceptions:
1869
+ -- ORA-20000: Insufficient privileges
1870
+ -- ORA-20001: Tablespace does not exist
1871
+ -- ORA-20002: Table already exists
1872
+ --
1873
+
1874
+
1875
+ procedure drop_stat_table(
1876
+ ownname varchar2, stattab varchar2);
1877
+ --
1878
+ -- Drops a user stat table
1879
+ --
1880
+ -- Input arguments:
1881
+ -- ownname - The name of the schema
1882
+ -- stattab - The user stat table identifier
1883
+ --
1884
+ -- Exceptions:
1885
+ -- ORA-20000: Insufficient privileges
1886
+ -- ORA-20001: Table is not a statistics table
1887
+ -- ORA-20002: Table does not exist
1888
+ --
1889
+
1890
+
1891
+ procedure upgrade_stat_table(
1892
+ ownname varchar2, stattab varchar2);
1893
+ --
1894
+ -- Upgrade a user stat table from an older version
1895
+ --
1896
+ -- Input arguments:
1897
+ -- ownname - The name of the schema
1898
+ -- stattab - The user stat table identifier
1899
+ --
1900
+ -- Exceptions:
1901
+ -- ORA-20000: Unable to upgrade table
1902
+ --
1903
+
1904
+
1905
+ procedure export_column_stats(
1906
+ ownname varchar2, tabname varchar2, colname varchar2,
1907
+ partname varchar2 default null,
1908
+ stattab varchar2, statid varchar2 default null,
1909
+ statown varchar2 default null);
1910
+ --
1911
+ -- Retrieves statistics for a particular column and stores them in the user
1912
+ -- stat table identified by stattab
1913
+ --
1914
+ -- Input arguments:
1915
+ -- ownname - The name of the schema
1916
+ -- tabname - The name of the table to which this column belongs
1917
+ -- colname - The name of the column or extension
1918
+ -- partname - The name of the table partition. If the table is
1919
+ -- partitioned and partname is null, global and partition column
1920
+ -- statistics will be exported.
1921
+ -- stattab - The user stat table identifier describing where
1922
+ -- to store the statistics.
1923
+ -- statid - The (optional) identifier to associate with these statistics
1924
+ -- within stattab.
1925
+ -- statown - The schema containing stattab (if different then ownname)
1926
+ --
1927
+ -- Exceptions:
1928
+ -- ORA-20000: Object does not exist or insufficient privileges
1929
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
1930
+ --
1931
+
1932
+
1933
+ procedure export_index_stats(
1934
+ ownname varchar2, indname varchar2,
1935
+ partname varchar2 default null,
1936
+ stattab varchar2, statid varchar2 default null,
1937
+ statown varchar2 default null);
1938
+ --
1939
+ -- Retrieves statistics for a particular index and stores them
1940
+ -- in the user stat table identified by stattab
1941
+ --
1942
+ -- Input arguments:
1943
+ -- ownname - The name of the schema
1944
+ -- indname - The name of the index
1945
+ -- partname - The name of the index partition. If the index is
1946
+ -- partitioned and partname is null, global and partition index
1947
+ -- statistics will be exported.
1948
+ -- stattab - The user stat table identifier describing where
1949
+ -- to store the statistics.
1950
+ -- statid - The (optional) identifier to associate with these statistics
1951
+ -- within stattab.
1952
+ -- statown - The schema containing stattab (if different then ownname)
1953
+ --
1954
+ -- Exceptions:
1955
+ -- ORA-20000: Object does not exist or insufficient privileges
1956
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
1957
+ --
1958
+
1959
+
1960
+ procedure export_table_stats(
1961
+ ownname varchar2, tabname varchar2,
1962
+ partname varchar2 default null,
1963
+ stattab varchar2, statid varchar2 default null,
1964
+ cascade boolean default true,
1965
+ statown varchar2 default null,
1966
+ stat_category varchar2 default DEFAULT_STAT_CATEGORY
1967
+ );
1968
+ --
1969
+ -- Retrieves statistics for a particular table and stores them
1970
+ -- in the user stat table.
1971
+ -- Cascade will result in all index and column stats associated
1972
+ -- with the specified table being exported as well.
1973
+ --
1974
+ -- Input arguments:
1975
+ -- ownname - The name of the schema
1976
+ -- tabname - The name of the table
1977
+ -- partname - The name of the table partition. If the table is
1978
+ -- partitioned and partname is null, global and partition table
1979
+ -- statistics will be exported.
1980
+ -- stattab - The user stat table identifier describing where
1981
+ -- to store the statistics.
1982
+ -- statid - The (optional) identifier to associate with these statistics
1983
+ -- within stattab.
1984
+ -- cascade - If true, column and index statistics for this table
1985
+ -- will also be exported.
1986
+ -- statown - The schema containing stattab (if different then ownname)
1987
+ -- stat_category - what statistics to export. It accepts multiple values
1988
+ -- separated by comma. The values we support now are 'OBJECT_STATS'
1989
+ -- (i.e., table statistics, column statistics and index statistics) and
1990
+ -- 'SYNOPSES'
1991
+ -- Exceptions:
1992
+ -- ORA-20000: Object does not exist or insufficient privileges
1993
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
1994
+ --
1995
+
1996
+
1997
+ procedure export_schema_stats(
1998
+ ownname varchar2,
1999
+ stattab varchar2, statid varchar2 default null,
2000
+ statown varchar2 default null,
2001
+ stat_category varchar2 default DEFAULT_STAT_CATEGORY);
2002
+ --
2003
+ -- Retrieves statistics for all objects in the schema identified
2004
+ -- by ownname and stores them in the user stat table identified
2005
+ -- by stattab
2006
+ --
2007
+ -- Input arguments:
2008
+ -- ownname - The name of the schema
2009
+ -- stattab - The user stat table identifier describing where
2010
+ -- to store the statistics.
2011
+ -- statid - The (optional) identifier to associate with these statistics
2012
+ -- within stattab.
2013
+ -- statown - The schema containing stattab (if different then ownname)
2014
+ -- stat_category - what statistics to export. It accepts multiple values
2015
+ -- separated by comma. The values we support now are 'OBJECT_STATS'
2016
+ -- (i.e., table statistics, column statistics and index statistics) and
2017
+ -- 'SYNOPSES'
2018
+ --
2019
+ -- Exceptions:
2020
+ -- ORA-20000: Object does not exist or insufficient privileges
2021
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
2022
+ --
2023
+
2024
+
2025
+ procedure export_database_stats(
2026
+ stattab varchar2, statid varchar2 default null,
2027
+ statown varchar2 default null,
2028
+ stat_category varchar2 default DEFAULT_STAT_CATEGORY);
2029
+ --
2030
+ -- Retrieves statistics for all objects in the database
2031
+ -- and stores them in the user stat tables identified
2032
+ -- by statown.stattab
2033
+ --
2034
+ -- Input arguments:
2035
+ -- stattab - The user stat table identifier describing where
2036
+ -- to store the statistics.
2037
+ -- statid - The (optional) identifier to associate with these statistics
2038
+ -- within stattab.
2039
+ -- statown - The schema containing stattab.
2040
+ -- If statown is null, it is assumed that every schema in the database
2041
+ -- contains a user statistics table with the name stattab.
2042
+ -- stat_category - what statistics to export. It accepts multiple values
2043
+ -- separated by comma. The values we support now are 'OBJECT_STATS'
2044
+ -- (i.e., table statistics, column statistics and index statistics) and
2045
+ -- 'SYNOPSES'
2046
+ --
2047
+ -- Exceptions:
2048
+ -- ORA-20000: Object does not exist or insufficient privileges
2049
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
2050
+ --
2051
+
2052
+
2053
+ procedure import_column_stats(
2054
+ ownname varchar2, tabname varchar2, colname varchar2,
2055
+ partname varchar2 default null,
2056
+ stattab varchar2, statid varchar2 default null,
2057
+ statown varchar2 default null,
2058
+ no_invalidate boolean default
2059
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
2060
+ force boolean default FALSE);
2061
+ --
2062
+ -- Retrieves statistics for a particular column from the user stat table
2063
+ -- identified by stattab and stores them in the dictionary
2064
+ --
2065
+ -- Input arguments:
2066
+ -- ownname - The name of the schema
2067
+ -- tabname - The name of the table to which this column belongs
2068
+ -- colname - The name of the column or extension
2069
+ -- partname - The name of the table partition. If the table is
2070
+ -- partitioned and partname is null, global and partition column
2071
+ -- statistics will be imported.
2072
+ -- stattab - The user stat table identifier describing from where
2073
+ -- to retrieve the statistics.
2074
+ -- statid - The (optional) identifier to associate with these statistics
2075
+ -- within stattab.
2076
+ -- statown - The schema containing stattab (if different then ownname)
2077
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
2078
+ -- The procedure invalidates the dependent cursors immediately
2079
+ -- if set to FALSE.
2080
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
2081
+ -- invalidate dependend cursors. This is the default. The default
2082
+ -- can be changed using set_param procedure.
2083
+ -- force - import statistics even if it is locked
2084
+ --
2085
+ -- Exceptions:
2086
+ -- ORA-20000: Object does not exist or insufficient privileges
2087
+ -- ORA-20001: Invalid or inconsistent values in the user stat table
2088
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
2089
+ -- ORA-20005: object statistics are locked
2090
+ --
2091
+
2092
+
2093
+ procedure import_index_stats(
2094
+ ownname varchar2, indname varchar2,
2095
+ partname varchar2 default null,
2096
+ stattab varchar2, statid varchar2 default null,
2097
+ statown varchar2 default null,
2098
+ no_invalidate boolean default
2099
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
2100
+ force boolean default FALSE);
2101
+ --
2102
+ -- Retrieves statistics for a particular index from the user
2103
+ -- stat table identified by stattab and stores them in the
2104
+ -- dictionary
2105
+ --
2106
+ -- Input arguments:
2107
+ -- ownname - The name of the schema
2108
+ -- indname - The name of the index
2109
+ -- partname - The name of the index partition. If the index is
2110
+ -- partitioned and partname is null, global and partition index
2111
+ -- statistics will be imported.
2112
+ -- stattab - The user stat table identifier describing from where
2113
+ -- to retrieve the statistics.
2114
+ -- statid - The (optional) identifier to associate with these statistics
2115
+ -- within stattab.
2116
+ -- statown - The schema containing stattab (if different then ownname)
2117
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
2118
+ -- The procedure invalidates the dependent cursors immediately
2119
+ -- if set to FALSE.
2120
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
2121
+ -- invalidate dependend cursors. This is the default. The default
2122
+ -- can be changed using set_param procedure.
2123
+ -- force - import the statistics even if it is locked
2124
+ --
2125
+ -- Exceptions:
2126
+ -- ORA-20000: Object does not exist or insufficient privileges
2127
+ -- ORA-20001: Invalid or inconsistent values in the user stat table
2128
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
2129
+ -- ORA-20005: object statistics are locked
2130
+ --
2131
+
2132
+
2133
+ procedure import_table_stats(
2134
+ ownname varchar2, tabname varchar2,
2135
+ partname varchar2 default null,
2136
+ stattab varchar2, statid varchar2 default null,
2137
+ cascade boolean default true,
2138
+ statown varchar2 default null,
2139
+ no_invalidate boolean default
2140
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
2141
+ force boolean default FALSE,
2142
+ stat_category varchar2 default DEFAULT_STAT_CATEGORY);
2143
+ --
2144
+ -- Retrieves statistics for a particular table from the user
2145
+ -- stat table identified by stattab and stores them in the dictionary.
2146
+ -- Cascade will result in all index and column stats associated
2147
+ -- with the specified table being imported as well.
2148
+ -- The statistics will be imported as pending in case PUBLISH preference
2149
+ -- is set to FALSE.
2150
+ --
2151
+ -- Input arguments:
2152
+ -- ownname - The name of the schema
2153
+ -- tabname - The name of the table
2154
+ -- partname - The name of the table partition. If the table is
2155
+ -- partitioned and partname is null, global and partition table
2156
+ -- statistics will be imported.
2157
+ -- stattab - The user stat table identifier describing from where
2158
+ -- to retrieve the statistics.
2159
+ -- statid - The (optional) identifier to associate with these statistics
2160
+ -- within stattab.
2161
+ -- cascade - If true, column and index statistics for this table
2162
+ -- will also be imported.
2163
+ -- statown - The schema containing stattab (if different then ownname)
2164
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
2165
+ -- The procedure invalidates the dependent cursors immediately
2166
+ -- if set to FALSE.
2167
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
2168
+ -- invalidate dependend cursors. This is the default. The default
2169
+ -- can be changed using set_param procedure.
2170
+ -- force - import even if statistics of the object is locked
2171
+ -- stat_category - what statistics to import. It accepts multiple values
2172
+ -- separated by comma. The values we support now are 'OBJECT_STATS'
2173
+ -- (i.e., table statistics, column statistics and index statistics) and
2174
+ -- 'SYNOPSES'
2175
+ -- Exceptions:
2176
+ -- ORA-20000: Object does not exist or insufficient privileges
2177
+ -- ORA-20001: Invalid or inconsistent values in the user stat table
2178
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
2179
+ -- ORA-20005: object statistics are locked
2180
+ --
2181
+
2182
+
2183
+ procedure import_schema_stats(
2184
+ ownname varchar2,
2185
+ stattab varchar2, statid varchar2 default null,
2186
+ statown varchar2 default null,
2187
+ no_invalidate boolean default
2188
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
2189
+ force boolean default FALSE,
2190
+ stat_category varchar2 default DEFAULT_STAT_CATEGORY);
2191
+ --
2192
+ -- Retrieves statistics for all objects in the schema identified
2193
+ -- by ownname from the user stat table and stores them in the
2194
+ -- dictionary
2195
+ -- The statistics will be imported as pending in case PUBLISH preference
2196
+ -- is set to FALSE.
2197
+ --
2198
+ -- Input arguments:
2199
+ -- ownname - The name of the schema
2200
+ -- stattab - The user stat table identifier describing from where
2201
+ -- to retrieve the statistics.
2202
+ -- statid - The (optional) identifier to associate with these statistics
2203
+ -- within stattab.
2204
+ -- statown - The schema containing stattab (if different then ownname)
2205
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
2206
+ -- The procedure invalidates the dependent cursors immediately
2207
+ -- if set to FALSE.
2208
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
2209
+ -- invalidate dependend cursors. This is the default. The default
2210
+ -- can be changed using set_param procedure.
2211
+ -- force - Override statistics lock.
2212
+ -- TRUE- Ignores the statistics lock on objects and import
2213
+ -- the statistics.
2214
+ -- FALSE-The statistics of an object will be imported only if it
2215
+ -- is not locked.
2216
+ -- ie if both DATA and CACHE statistics is locked, it will not
2217
+ -- import anything. If CACHE statistics of an object is locked,
2218
+ -- only DATA statistics will be imported and vice versa.
2219
+ -- stat_category - what statistics to import. It accepts multiple values
2220
+ -- separated by comma. The values we support now are 'OBJECT_STATS'
2221
+ -- (i.e., table statistics, column statistics and index statistics) and
2222
+ -- 'SYNOPSES'
2223
+ --
2224
+ -- Exceptions:
2225
+ -- ORA-20000: Object does not exist or insufficient privileges.
2226
+ -- if ORA-20000 shows "no statistics are imported", several
2227
+ -- possible reasons are: (1) no statistics exist for the specified
2228
+ -- ownname or statid in the stattab; (2) statistics are locked; (3)
2229
+ -- objects in the stattab no longer exist in the current database
2230
+ -- ORA-20001: Invalid or inconsistent values in the user stat table
2231
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
2232
+ --
2233
+
2234
+
2235
+ procedure import_database_stats(
2236
+ stattab varchar2, statid varchar2 default null,
2237
+ statown varchar2 default null,
2238
+ no_invalidate boolean default
2239
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
2240
+ force boolean default FALSE,
2241
+ stat_category varchar2 default DEFAULT_STAT_CATEGORY
2242
+ );
2243
+ --
2244
+ -- Retrieves statistics for all objects in the database
2245
+ -- from the user stat table(s) and stores them in the
2246
+ -- dictionary
2247
+ -- The statistics will be imported as pending in case PUBLISH preference
2248
+ -- is set to FALSE.
2249
+ --
2250
+ -- Input arguments:
2251
+ -- stattab - The user stat table identifier describing from where
2252
+ -- to retrieve the statistics.
2253
+ -- statid - The (optional) identifier to associate with these statistics
2254
+ -- within stattab.
2255
+ -- statown - The schema containing stattab.
2256
+ -- If statown is null, it is assumed that every schema in the database
2257
+ -- contains a user statistics table with the name stattab.
2258
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
2259
+ -- The procedure invalidates the dependent cursors immediately
2260
+ -- if set to FALSE.
2261
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
2262
+ -- invalidate dependend cursors. This is the default. The default
2263
+ -- can be changed using set_param procedure.
2264
+ -- force - Override statistics lock.
2265
+ -- TRUE- Ignores the statistics lock on objects and import
2266
+ -- the statistics.
2267
+ -- FALSE-The statistics of an object will be imported only if it
2268
+ -- is not locked.
2269
+ -- ie if both DATA and CACHE statistics is locked, it will not
2270
+ -- import anything. If CACHE statistics of an object is locked,
2271
+ -- only DATA statistics will be imported and vice versa.
2272
+ -- stat_category - what statistics to import. It accepts multiple values
2273
+ -- separated by comma. The values we support now are 'OBJECT_STATS'
2274
+ -- (i.e., table statistics, column statistics and index statistics) and
2275
+ -- 'SYNOPSES'
2276
+ --
2277
+ -- Exceptions:
2278
+ -- ORA-20000: Object does not exist or insufficient privileges
2279
+ -- if ORA-20000 shows "no statistics are imported", several
2280
+ -- possible reasons are: (1) user specified statid does not
2281
+ -- exist; (2) statistics are locked; (3) objects in the
2282
+ -- stattab no longer exist in the current database
2283
+ -- ORA-20001: Invalid or inconsistent values in the user stat table
2284
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
2285
+ --
2286
+
2287
+
2288
+
2289
+
2290
+
2291
+
2292
+
2293
+
2294
+ --
2295
+ -- This set of procedures enable the gathering of certain
2296
+ -- classes of optimizer statistics with possible performance
2297
+ -- improvements over the analyze command.
2298
+ --
2299
+ -- The procedures are:
2300
+ --
2301
+ -- gather_index_stats
2302
+ -- gather_table_stats
2303
+ -- gather_schema_stats
2304
+ -- gather_database_stats
2305
+ -- gather_system_stats
2306
+ -- gather_fixed_objects_stats
2307
+ -- gather_dictionary_stats
2308
+ --
2309
+ -- We also provide the following procedure for generating some
2310
+ -- statistics for derived objects when we have sufficient statistics
2311
+ -- on related objects
2312
+ --
2313
+ -- generate_stats
2314
+ --
2315
+
2316
+ procedure gather_index_stats
2317
+ (ownname varchar2, indname varchar2, partname varchar2 default null,
2318
+ estimate_percent number default DEFAULT_ESTIMATE_PERCENT,
2319
+ stattab varchar2 default null, statid varchar2 default null,
2320
+ statown varchar2 default null,
2321
+ degree number default to_degree_type(get_param('DEGREE')),
2322
+ granularity varchar2 default DEFAULT_GRANULARITY,
2323
+ no_invalidate boolean default
2324
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
2325
+ stattype varchar2 default 'DATA',
2326
+ force boolean default FALSE);
2327
+ --
2328
+ -- This procedure gathers index statistics.
2329
+ -- It attempts to parallelize as much of the work as possible.
2330
+ -- are some restrictions as described in the individual parameters.
2331
+ -- This operation will not parallelize with certain types of indexes,
2332
+ -- including cluster indexes, domain indexes and bitmap join indexes.
2333
+ -- The "granularity" and "no_invalidate" arguments are also not pertinent to
2334
+ -- these types of indexes.
2335
+ --
2336
+ -- ownname - schema of index to analyze
2337
+ -- indname - name of index
2338
+ -- partname - name of partition
2339
+ -- estimate_percent - Percentage of rows to estimate (NULL means compute).
2340
+ -- The valid range is [0.000001,100]. Use the constant
2341
+ -- DBMS_STATS.AUTO_SAMPLE_SIZE to have Oracle determine the
2342
+ -- appropriate sample size for good statistics. This is the default.
2343
+ -- The default value can be changed using set_param procedure.
2344
+ -- degree - degree of parallelism (NULL means use of table default value
2345
+ -- which was specified by DEGREE clause in CREATE/ALTER INDEX statement)
2346
+ -- Use the constant DBMS_STATS.DEFAULT_DEGREE for the default value
2347
+ -- based on the initialization parameters.
2348
+ -- default for degree is NULL.
2349
+ -- The default value can be changed using set_param procedure.
2350
+ -- granularity - the granularity of statistics to collect (only pertinent
2351
+ -- if the table is partitioned)
2352
+ -- 'AUTO' - the procedure determines what level of statistics to collect
2353
+ -- 'GLOBAL AND PARTITION' - gather global- and partition-level statistics
2354
+ -- 'SUBPARTITION' - gather subpartition-level statistics
2355
+ -- 'PARTITION' - gather partition-level statistics
2356
+ -- 'GLOBAL' - gather global statistics
2357
+ -- 'ALL' - gather all (subpartition, partition, and global) statistics
2358
+ -- default for granularity is AUTO.
2359
+ -- The default value can be changed using set_param procedure.
2360
+ -- stattab - The user stat table identifier describing where to save
2361
+ -- the current statistics.
2362
+ -- statid - The (optional) identifier to associate with these statistics
2363
+ -- within stattab.
2364
+ -- statown - The schema containing stattab (if different then ownname)
2365
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
2366
+ -- The procedure invalidates the dependent cursors immediately
2367
+ -- if set to FALSE.
2368
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
2369
+ -- invalidate dependend cursors. This is the default. The default
2370
+ -- can be changed using set_param procedure.
2371
+ -- force - gather statistics of index even if it is locked.
2372
+ --
2373
+ -- Exceptions:
2374
+ -- ORA-20000: Index does not exist or insufficient privileges
2375
+ -- ORA-20001: Bad input value
2376
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
2377
+ -- ORA-20005: object statistics are locked
2378
+ --
2379
+
2380
+ procedure gather_table_stats
2381
+ (ownname varchar2, tabname varchar2, partname varchar2 default null,
2382
+ estimate_percent number default DEFAULT_ESTIMATE_PERCENT,
2383
+ block_sample boolean default FALSE,
2384
+ method_opt varchar2 default DEFAULT_METHOD_OPT,
2385
+ degree number default to_degree_type(get_param('DEGREE')),
2386
+ granularity varchar2 default DEFAULT_GRANULARITY,
2387
+ cascade boolean default DEFAULT_CASCADE,
2388
+ stattab varchar2 default null, statid varchar2 default null,
2389
+ statown varchar2 default null,
2390
+ no_invalidate boolean default
2391
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
2392
+ stattype varchar2 default 'DATA',
2393
+ force boolean default FALSE,
2394
+ -- the context is intended for internal use only.
2395
+ context dbms_stats.CContext default null);
2396
+
2397
+ --
2398
+ -- This procedure gathers table and column (and index) statistics.
2399
+ -- It attempts to parallelize as much of the work as possible, but there
2400
+ -- are some restrictions as described in the individual parameters.
2401
+ -- This operation will not parallelize if the user does not have select
2402
+ -- privilege on the table being analyzed.
2403
+ --
2404
+ -- Input arguments:
2405
+ -- ownname - schema of table to analyze
2406
+ -- tabname - name of table
2407
+ -- partname - name of partition
2408
+ -- estimate_percent - Percentage of rows to estimate (NULL means compute).
2409
+ -- The valid range is [0.000001,100]. Use the constant
2410
+ -- DBMS_STATS.AUTO_SAMPLE_SIZE to have Oracle determine the
2411
+ -- appropriate sample size for good statistics. This is the default.
2412
+ -- The default value can be changed using set_param procedure.
2413
+ -- block_sample - whether or not to use random block sampling instead of
2414
+ -- random row sampling. Random block sampling is more efficient, but
2415
+ -- if the data is not randomly distributed on disk then the sample values
2416
+ -- may be somewhat correlated. Only pertinent when doing an estimate
2417
+ -- statistics.
2418
+ -- method_opt - method options of the following format
2419
+ --
2420
+ -- method_opt := FOR ALL [INDEXED | HIDDEN] COLUMNS [size_clause]
2421
+ -- FOR COLUMNS [size_clause]
2422
+ -- column|attribute [size_clause]
2423
+ -- [,column|attribute [size_clause] ... ]
2424
+ --
2425
+ -- size_clause := SIZE [integer | auto | skewonly | repeat],
2426
+ -- where integer is between 1 and 254
2427
+ --
2428
+ -- column := column name | extension name | extension
2429
+ --
2430
+ -- default is FOR ALL COLUMNS SIZE AUTO.
2431
+ -- The default value can be changed using set_param procedure.
2432
+ -- Optimizer related table statistics are always gathered.
2433
+ --
2434
+ -- If an extension is provided, the procedure create the extension if it
2435
+ -- does not exist already. Please refer to create_extended_stats for
2436
+ -- description of extension.
2437
+ --
2438
+ -- degree - degree of parallelism (NULL means use of table default value
2439
+ -- which was specified by DEGREE clause in CREATE/ALTER TABLE statement)
2440
+ -- Use the constant DBMS_STATS.DEFAULT_DEGREE for the default value
2441
+ -- based on the initialization parameters.
2442
+ -- default for degree is NULL.
2443
+ -- The default value can be changed using set_param procedure.
2444
+ -- granularity - the granularity of statistics to collect (only pertinent
2445
+ -- if the table is partitioned)
2446
+ -- 'AUTO' - the procedure determines what level of statistics to collect
2447
+ -- 'GLOBAL AND PARTITION' - gather global- and partition-level statistics
2448
+ -- 'APPROX_GLOBAL AND PARTITION' - This option is similar to
2449
+ -- 'GLOBAL AND PARTITION'. But the global statistics are aggregated
2450
+ -- from partition level statistics. It will aggregate all statistics except number of
2451
+ -- distinct values for columns and number of distinct keys of indexes.
2452
+ -- The existing histograms of the columns at the table level
2453
+ -- are also aggregated.The global statistics are gathered
2454
+ -- (i.e., going back to GLOBAL AND PARTITION behaviour)
2455
+ -- if partname argument is null. The aggregation will use only
2456
+ -- partitions with statistics, so to get accurate global statistics,
2457
+ -- user has to make sure to have statistics for all partitions.
2458
+ --
2459
+ --
2460
+ -- This option is useful when you collect statistics for a new partition added
2461
+ -- into a range partitioned table (for example, a table partitioned by month).
2462
+ -- The new data in the partition makes the global statistics stale (especially
2463
+ -- the min/max values of the partitioning column). This stale global statistics
2464
+ -- may cause suboptimal plans. In this scenario, users can collect statistics
2465
+ -- for the newly added partition with 'APPROX_GLOBAL AND PARTITION'
2466
+ -- option so that the global statistics will reflect the newly added range.
2467
+ -- This option will take less time than 'GLOBAL AND PARTITION' option since the
2468
+ -- global statistics are aggregated from underlying partition level statistics.
2469
+ -- Note that, if you are using APPROX_GLOBAL AND PARTITION,
2470
+ -- you still need to collect global statistics (with granularity = 'GLOBAL' option)
2471
+ -- when there is substantial amount of change at the table level.
2472
+ -- For example you added 10% more data to the table. This is needed to get the
2473
+ -- correct number of distinct values/keys statistic at table level.
2474
+ -- 'SUBPARTITION' - gather subpartition-level statistics
2475
+ -- 'PARTITION' - gather partition-level statistics
2476
+ -- 'GLOBAL' - gather global statistics
2477
+ -- 'ALL' - gather all (subpartition, partition, and global) statistics
2478
+ -- default for granularity is AUTO.
2479
+ -- The default value can be changed using set_param procedure.
2480
+ -- cascade - gather statistics on the indexes for this table.
2481
+ -- Use the constant DBMS_STATS.AUTO_CASCADE to have Oracle determine
2482
+ -- whether index stats to be collected or not. This is the default.
2483
+ -- The default value can be changed using set_param procedure.
2484
+ -- Using this option is equivalent to running the gather_index_stats
2485
+ -- procedure on each of the table's indexes.
2486
+ -- stattab - The user stat table identifier describing where to save
2487
+ -- the current statistics.
2488
+ -- statid - The (optional) identifier to associate with these statistics
2489
+ -- within stattab.
2490
+ -- statown - The schema containing stattab (if different then ownname)
2491
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
2492
+ -- The procedure invalidates the dependent cursors immediately
2493
+ -- if set to FALSE.
2494
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
2495
+ -- invalidate dependend cursors. This is the default. The default
2496
+ -- can be changed using set_param procedure.
2497
+ -- When the 'cascade' argument is specified, not pertinent with certain
2498
+ -- types of indexes described in the gather_index_stats section.
2499
+ -- force - gather statistics of table even if it is locked.
2500
+ -- context - internal use only.
2501
+ --
2502
+ -- Exceptions:
2503
+ -- ORA-20000: Table does not exist or insufficient privileges
2504
+ -- ORA-20001: Bad input value
2505
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
2506
+ -- ORA-20005: object statistics are locked
2507
+ --
2508
+ procedure gather_schema_stats
2509
+ (ownname varchar2,
2510
+ estimate_percent number default DEFAULT_ESTIMATE_PERCENT,
2511
+ block_sample boolean default FALSE,
2512
+ method_opt varchar2 default DEFAULT_METHOD_OPT,
2513
+ degree number default to_degree_type(get_param('DEGREE')),
2514
+ granularity varchar2 default DEFAULT_GRANULARITY,
2515
+ cascade boolean default DEFAULT_CASCADE,
2516
+ stattab varchar2 default null, statid varchar2 default null,
2517
+ options varchar2 default 'GATHER', objlist out ObjectTab,
2518
+ statown varchar2 default null,
2519
+ no_invalidate boolean default
2520
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
2521
+ gather_temp boolean default FALSE,
2522
+ gather_fixed boolean default FALSE,
2523
+ stattype varchar2 default 'DATA',
2524
+ force boolean default FALSE,
2525
+ obj_filter_list ObjectTab default null);
2526
+ procedure gather_schema_stats
2527
+ (ownname varchar2,
2528
+ estimate_percent number default DEFAULT_ESTIMATE_PERCENT,
2529
+ block_sample boolean default FALSE,
2530
+ method_opt varchar2 default DEFAULT_METHOD_OPT,
2531
+ degree number default to_degree_type(get_param('DEGREE')),
2532
+ granularity varchar2 default DEFAULT_GRANULARITY,
2533
+ cascade boolean default DEFAULT_CASCADE,
2534
+ stattab varchar2 default null, statid varchar2 default null,
2535
+ options varchar2 default 'GATHER', statown varchar2 default null,
2536
+ no_invalidate boolean default
2537
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
2538
+ gather_temp boolean default FALSE,
2539
+ gather_fixed boolean default FALSE,
2540
+ stattype varchar2 default 'DATA',
2541
+ force boolean default FALSE,
2542
+ obj_filter_list ObjectTab default null);
2543
+ --
2544
+ -- Input arguments:
2545
+ -- ownname - schema to analyze (NULL means current schema)
2546
+ -- estimate_percent - Percentage of rows to estimate (NULL means compute).
2547
+ -- The valid range is [0.000001,100]. Use the constant
2548
+ -- DBMS_STATS.AUTO_SAMPLE_SIZE to have Oracle determine the
2549
+ -- appropriate sample size for good statistics. This is the default.
2550
+ -- The default value can be changed using set_param procedure.
2551
+ -- block_sample - whether or not to use random block sampling instead of
2552
+ -- random row sampling. Random block sampling is more efficient, but
2553
+ -- if the data is not randomly distributed on disk then the sample values
2554
+ -- may be somewhat correlated. Only pertinent when doing an estimate
2555
+ -- statistics.
2556
+ -- method_opt - method options of the following format
2557
+ --
2558
+ -- method_opt := FOR ALL [INDEXED | HIDDEN] COLUMNS [size_clause]
2559
+ --
2560
+ -- size_clause := SIZE [integer | auto | skewonly | repeat],
2561
+ -- where integer is between 1 and 254
2562
+ --
2563
+ -- default is FOR ALL COLUMNS SIZE AUTO.
2564
+ -- The default value can be changed using set_param procedure.
2565
+ -- This value will be passed to all of the individual tables.
2566
+ -- degree - degree of parallelism (NULL means use table default value which
2567
+ -- is specified by DEGREE clause in CREATE/ALTER TABLE statement)
2568
+ -- Use the constant DBMS_STATS.DEFAULT_DEGREE for the default value
2569
+ -- based on the initialization parameters.
2570
+ -- default for degree is NULL.
2571
+ -- The default value can be changed using set_param procedure.
2572
+ -- granularity - the granularity of statistics to collect (only pertinent
2573
+ -- if the table is partitioned)
2574
+ -- 'AUTO' - the procedure determines what level of statistics to collect
2575
+ -- 'GLOBAL AND PARTITION' - gather global- and partition-level statistics
2576
+ -- 'SUBPARTITION' - gather subpartition-level statistics
2577
+ -- 'PARTITION' - gather partition-level statistics
2578
+ -- 'GLOBAL' - gather global statistics
2579
+ -- 'ALL' - gather all (subpartition, partition, and global) statistics
2580
+ -- default for granularity is AUTO.
2581
+ -- The default value can be changed using set_param procedure.
2582
+ -- cascade - gather statistics on the indexes as well.
2583
+ -- Use the constant DBMS_STATS.AUTO_CASCADE to have Oracle determine
2584
+ -- whether index stats to be collected or not. This is the default.
2585
+ -- The default value can be changed using set_param procedure.
2586
+ -- Using this option is equivalent to running the gather_index_stats
2587
+ -- procedure on each of the indexes in the schema in addition to
2588
+ -- gathering table and column statistics.
2589
+ -- stattab - The user stat table identifier describing where to save
2590
+ -- the current statistics.
2591
+ -- statid - The (optional) identifier to associate with these statistics
2592
+ -- within stattab.
2593
+ -- options - further specification of which objects to gather statistics for
2594
+ -- 'GATHER' - gather statistics on all objects in the schema
2595
+ -- 'GATHER AUTO' - gather all necessary statistics automatically. Oracle
2596
+ -- implicitly determines which objects need new statistics, and
2597
+ -- determines how to gather those statistics. When 'GATHER AUTO' is
2598
+ -- specified, the only additional valid parameters are ownname, stattab,
2599
+ -- statid, objlist and statown; all other parameter settings will be
2600
+ -- ignored. Also, return a list of objects processed.
2601
+ -- 'GATHER STALE' - gather statistics on stale objects as determined
2602
+ -- by looking at the *_tab_modifications views. Also, return
2603
+ -- a list of objects found to be stale.
2604
+ -- 'GATHER EMPTY' - gather statistics on objects which currently
2605
+ -- have no statistics. also, return a list of objects found
2606
+ -- to have no statistics.
2607
+ -- 'LIST AUTO' - return list of objects to be processed with 'GATHER AUTO'
2608
+ -- 'LIST STALE' - return list of stale objects as determined
2609
+ -- by looking at the *_tab_modifications views
2610
+ -- 'LIST EMPTY' - return list of objects which currently
2611
+ -- have no statistics
2612
+ -- objlist - list of objects found to be stale or empty
2613
+ -- statown - The schema containing stattab (if different then ownname)
2614
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
2615
+ -- The procedure invalidates the dependent cursors immediately
2616
+ -- if set to FALSE.
2617
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
2618
+ -- invalidate dependend cursors. This is the default. The default
2619
+ -- can be changed using set_param procedure.
2620
+ -- When 'cascade' option is specified, not pertinent with certain types
2621
+ -- of indexes described in the gather_index_stats section.
2622
+ -- gather_temp - gather stats on global temporary tables also. The
2623
+ -- temporary table must be created with "on commit preserve rows" clause,
2624
+ -- and the statistics being collected are based on the data in the session
2625
+ -- which this procedure is run but shared across all the sessions.
2626
+ -- gather_fixed - Gather statistics on fixed tables also.
2627
+ -- Statistics for fixed tables can be collected only by user SYS.
2628
+ -- Also the ownname should be SYS or NULL.
2629
+ -- Specified values for the following arguments will be ignored while
2630
+ -- gathering statistics for fixed tables.
2631
+ -- estimate_percent, block_sample, stattab, statid, statown
2632
+ -- It will not invalidate the dependent cursors on fixed table
2633
+ -- on which stats is collected.
2634
+ -- This option is meant for internal use only.
2635
+ -- force - gather statistics of objects even if they are locked.
2636
+ -- obj_filter_list - a list of object filters. When provided, gather_schema_stats
2637
+ -- will only gather statistics on the objects which satisfy at least one
2638
+ -- object filter in the list as needed. Please refer to obj_filter_list
2639
+ -- in gather_database_stats.
2640
+ -- Exceptions:
2641
+ -- ORA-20000: Schema does not exist or insufficient privileges
2642
+ -- ORA-20001: Bad input value
2643
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
2644
+ --
2645
+
2646
+ procedure gather_database_stats
2647
+ (estimate_percent number default DEFAULT_ESTIMATE_PERCENT,
2648
+ block_sample boolean default FALSE,
2649
+ method_opt varchar2 default DEFAULT_METHOD_OPT,
2650
+ degree number default to_degree_type(get_param('DEGREE')),
2651
+ granularity varchar2 default DEFAULT_GRANULARITY,
2652
+ cascade boolean default DEFAULT_CASCADE,
2653
+ stattab varchar2 default null, statid varchar2 default null,
2654
+ options varchar2 default 'GATHER', objlist out ObjectTab,
2655
+ statown varchar2 default null,
2656
+ gather_sys boolean default TRUE,
2657
+ no_invalidate boolean default
2658
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
2659
+ gather_temp boolean default FALSE,
2660
+ gather_fixed boolean default FALSE,
2661
+ stattype varchar2 default 'DATA',
2662
+ obj_filter_list ObjectTab default null);
2663
+ procedure gather_database_stats
2664
+ (estimate_percent number default DEFAULT_ESTIMATE_PERCENT,
2665
+ block_sample boolean default FALSE,
2666
+ method_opt varchar2 default DEFAULT_METHOD_OPT,
2667
+ degree number default to_degree_type(get_param('DEGREE')),
2668
+ granularity varchar2 default DEFAULT_GRANULARITY,
2669
+ cascade boolean default DEFAULT_CASCADE,
2670
+ stattab varchar2 default null, statid varchar2 default null,
2671
+ options varchar2 default 'GATHER', statown varchar2 default null,
2672
+ gather_sys boolean default TRUE,
2673
+ no_invalidate boolean default
2674
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
2675
+ gather_temp boolean default FALSE,
2676
+ gather_fixed boolean default FALSE,
2677
+ stattype varchar2 default 'DATA',
2678
+ obj_filter_list ObjectTab default null);
2679
+ --
2680
+ -- Input arguments:
2681
+ -- estimate_percent - Percentage of rows to estimate (NULL means compute).
2682
+ -- The valid range is [0.000001,100]. Use the constant
2683
+ -- DBMS_STATS.AUTO_SAMPLE_SIZE to have Oracle determine the
2684
+ -- appropriate sample size for good statistics. This is the default.
2685
+ -- The default value can be changed using set_param procedure.
2686
+ -- block_sample - whether or not to use random block sampling instead of
2687
+ -- random row sampling. Random block sampling is more efficient, but
2688
+ -- if the data is not randomly distributed on disk then the sample values
2689
+ -- may be somewhat correlated. Only pertinent when doing an estimate
2690
+ -- statistics.
2691
+ -- method_opt - method options of the following format
2692
+ --
2693
+ -- method_opt := FOR ALL [INDEXED | HIDDEN] COLUMNS [size_clause]
2694
+ --
2695
+ -- size_clause := SIZE [integer | auto | skewonly | repeat],
2696
+ -- where integer is between 1 and 254
2697
+ --
2698
+ -- default is FOR ALL COLUMNS SIZE AUTO.
2699
+ -- The default value can be changed using set_param procedure.
2700
+ -- This value will be passed to all of the individual tables.
2701
+ -- degree - degree of parallelism (NULL means use table default value which
2702
+ -- is specified by DEGREE clause in CREATE/ALTER TABLE statement)
2703
+ -- Use the constant DBMS_STATS.DEFAULT_DEGREE for the default value
2704
+ -- based on the initialization parameters.
2705
+ -- default for degree is NULL.
2706
+ -- The default value can be changed using set_param procedure.
2707
+ -- granularity - the granularity of statistics to collect (only pertinent
2708
+ -- if the table is partitioned)
2709
+ -- 'AUTO' - the procedure determines what level of statistics to collect
2710
+ -- 'GLOBAL AND PARTITION' - gather global- and partition-level statistics
2711
+ -- 'SUBPARTITION' - gather subpartition-level statistics
2712
+ -- 'PARTITION' - gather partition-level statistics
2713
+ -- 'GLOBAL' - gather global statistics
2714
+ -- 'ALL' - gather all (subpartition, partition, and global) statistics
2715
+ -- default for granularity is AUTO.
2716
+ -- The default value can be changed using set_param procedure.
2717
+ -- cascade - gather statistics on the indexes as well.
2718
+ -- Use the constant DBMS_STATS.AUTO_CASCADE to have Oracle determine
2719
+ -- whether index stats to be collected or not. This is the default.
2720
+ -- The default value can be changed using set_param procedure.
2721
+ -- Using this option is equivalent to running the gather_index_stats
2722
+ -- procedure on each of the indexes in the database in addition to
2723
+ -- gathering table and column statistics.
2724
+ -- stattab - The user stat table identifier describing where to save
2725
+ -- the current statistics.
2726
+ -- statid - The (optional) identifier to associate with these statistics
2727
+ -- within stattab.
2728
+ -- options - further specification of which objects to gather statistics for
2729
+ -- 'GATHER' - gather statistics on all objects in the schema
2730
+ -- 'GATHER AUTO' - gather all necessary statistics automatically. Oracle
2731
+ -- implicitly determines which objects need new statistics, and
2732
+ -- determines how to gather those statistics. When 'GATHER AUTO' is
2733
+ -- specified, the only additional valid parameters are stattab,
2734
+ -- statid, objlist and statown; all other parameter settings will be
2735
+ -- ignored. Also, return a list of objects processed.
2736
+ -- 'GATHER STALE' - gather statistics on stale objects as determined
2737
+ -- by looking at the *_tab_modifications views. Also, return
2738
+ -- a list of objects found to be stale.
2739
+ -- 'GATHER EMPTY' - gather statistics on objects which currently
2740
+ -- have no statistics. also, return a list of objects found
2741
+ -- to have no statistics.
2742
+ -- 'LIST AUTO' - return list of objects to be processed with 'GATHER AUTO'
2743
+ -- 'LIST STALE' - return list of stale objects as determined
2744
+ -- by looking at the *_tab_modifications views
2745
+ -- 'LIST EMPTY' - return list of objects which currently
2746
+ -- have no statistics
2747
+ -- objlist - list of objects found to be stale or empty
2748
+ -- statown - The schema containing stattab. If null, it will assume
2749
+ -- there is a table named stattab in each relevant schema in the
2750
+ -- database if stattab is specified for saving current statistics.
2751
+ -- gather_sys - Gather statistics on the objects owned by the 'SYS' user
2752
+ -- as well.
2753
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
2754
+ -- The procedure invalidates the dependent cursors immediately
2755
+ -- if set to FALSE.
2756
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
2757
+ -- invalidate dependend cursors. This is the default. The default
2758
+ -- can be changed using set_param procedure.
2759
+ -- When 'cascade' option is specified, not pertinent with certain types
2760
+ -- of indexes described in the gather_index_stats section.
2761
+ -- gather_temp - gather stats on global temporary tables also. The
2762
+ -- temporary table must be created with "on commit preserve rows" clause,
2763
+ -- and the statistics being collected are based on the data in the session
2764
+ -- which this procedure is run but shared across all the sessions.
2765
+ -- gather_fixed - Gather stats on fixed tables also.
2766
+ -- Statistics for fixed tables can be collected only by user SYS.
2767
+ -- Specified values for the following arguments will be ignored while
2768
+ -- gathering statistics for fixed tables.
2769
+ -- gathering statistics for fixed tables.
2770
+ -- estimate_percent, block_sample, stattab, statid, statown
2771
+ -- It will not invalidate the dependent cursors on fixed table
2772
+ -- on which stats is collected.
2773
+ -- This option is meant for internal use only.
2774
+ -- obj_filter_list - a list of object filters. When provided, gather_database_
2775
+ -- stats will only gather statistics on the objects which satisfy at least
2776
+ -- one of the object filters as needed.
2777
+ --
2778
+ -- In one single object filter, we can specify the constraints on the object
2779
+ -- attributes. The attribute values specified in the object filter are case-
2780
+ -- insensitive unless double-quoted. Wildcard is allowed in the attribute values.
2781
+ -- Suppose non-null values s1, s2, ... are specified for attributes a1, a2, ... in
2782
+ -- one object filter. An object o is said to satisfy this object filter if
2783
+ -- (o.a1 like s1) and (o.a2 like s2) and ... is true.
2784
+ -- The following example specifies that any table with a "SALES" prefix in the
2785
+ -- SH schema and any table in the SYS schema, if stale, will be gathered.
2786
+ -- Note that the statistics for the partitions of the tables also will be
2787
+ -- gathered if they are stale.
2788
+ -- Example:
2789
+ -- declare
2790
+ -- filter_lst dbms_stats.objecttab := dbms_stats.objecttab();
2791
+ -- begin
2792
+ -- filter_lst.extend(2);
2793
+ -- filter_lst(1).ownname := 'sh';
2794
+ -- filter_lst(1).objname := 'sales%';
2795
+ -- filter_lst(2).ownname := 'sys';
2796
+ -- dbms_stats.gather_schema_stats(null, obj_filter_list => filter_lst,
2797
+ -- options => 'gather_stale');
2798
+ -- end;
2799
+ -- Exceptions:
2800
+ -- ORA-20000: Insufficient privileges
2801
+ -- ORA-20001: Bad input value
2802
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
2803
+ --
2804
+
2805
+
2806
+ procedure generate_stats
2807
+ (ownname varchar2, objname varchar2,
2808
+ organized number default 7,
2809
+ force boolean default FALSE);
2810
+ --
2811
+ -- This procedure generates object statistics from previously collected
2812
+ -- statistics of related objects. For fully populated
2813
+ -- schemas, the gather procedures should be used instead when more
2814
+ -- accurate statistics are desired.
2815
+ -- The currently supported objects are b-tree and bitmap indexes.
2816
+ --
2817
+ -- ownname - schema of object
2818
+ -- objname - name of object
2819
+ -- organized - the amount of ordering associated between the index and
2820
+ -- its undelrying table. A heavily organized index would have consecutive
2821
+ -- index keys referring to consecutive rows on disk for the table
2822
+ -- (the same block). A heavily disorganized index would have consecutive
2823
+ -- keys referencing different table blocks on disk. This parameter is
2824
+ -- only used for b-tree indexes.
2825
+ -- The number can be in the range of 0-10, with 0 representing a completely
2826
+ -- organized index and 10 a completely disorganized one.
2827
+ -- force - generate statistics even if it is locked
2828
+ -- Exceptions:
2829
+ -- ORA-20000: Unsupported object type of object does not exist
2830
+ -- ORA-20001: Invalid option or invalid statistics
2831
+ -- ORA-20005: object statistics are locked
2832
+ --
2833
+
2834
+
2835
+
2836
+
2837
+ --
2838
+ -- This procedure enables the flushing of in-memory monitoring
2839
+ -- information to the dictionary. Corresponding entries in the
2840
+ -- *_tab_modifications views are updated immediately, without waiting
2841
+ -- for Oracle to flush it periodically. Useful for the users who need
2842
+ -- up-to-date information in those views.
2843
+ -- The gather_*_stats procedures internally flush the monitoring information
2844
+ -- accordingly, and it is NOT necessary to run this procedure before
2845
+ -- gathering the statistics.
2846
+ --
2847
+ --
2848
+ -- The procedure is:
2849
+ --
2850
+ -- flush_database_monitoring_info
2851
+ --
2852
+ -- The modification monitoring mechanism is now controlled by the
2853
+ -- STATISTICS_LEVEL initialization parameter, and the following
2854
+ -- procedures no longer have any effect:
2855
+ --
2856
+ -- alter_schema_tab_monitoring
2857
+ -- alter_database_tab_monitoring
2858
+ --
2859
+
2860
+ procedure flush_database_monitoring_info;
2861
+ --
2862
+ -- Flush in-memory monitoring information for all the tables to the dictionary.
2863
+ --
2864
+ -- Exceptions:
2865
+ -- ORA-20000: Insufficient privileges
2866
+ --
2867
+
2868
+ procedure alter_schema_tab_monitoring
2869
+ (ownname varchar2 default NULL, monitoring boolean default TRUE);
2870
+ procedure alter_database_tab_monitoring
2871
+ (monitoring boolean default TRUE, sysobjs boolean default FALSE);
2872
+
2873
+
2874
+
2875
+ procedure gather_system_stats (
2876
+ gathering_mode varchar2 default 'NOWORKLOAD',
2877
+ interval integer default 60,
2878
+ stattab varchar2 default null,
2879
+ statid varchar2 default null,
2880
+ statown varchar2 default null);
2881
+ --
2882
+ -- This procedure gathers system statistics.
2883
+ --
2884
+ -- Input arguments:
2885
+ -- mode - Allowable values: INTERVAL, START, STOP.
2886
+ -- INTERVAL:
2887
+ -- In INTERVAL mode user can provide interval parameter. After <interval>
2888
+ -- minutes elapsed system statistics in dictionary or stattab will be
2889
+ -- updated or created. This statistics captures system activity during
2890
+ -- specified interval.
2891
+ -- START | STOP:
2892
+ -- START will initiate gathering statistics. STOP will calculate
2893
+ -- statistics for elapsed period of time (since START) and refresh
2894
+ -- dictionary or stattab. Interval in these modes is ignored.
2895
+ -- interval - Specifies period of time in minutes for gathering statistics
2896
+ -- in INTERVAL mode.
2897
+ -- stattab - The user stat table identifier describing where to save
2898
+ -- the current statistics.
2899
+ -- statid - The (optional) identifier to associate with these statistics
2900
+ -- within stattab.
2901
+ -- statown - The schema containing stattab (if different then ownname)
2902
+ --
2903
+ -- Exceptions:
2904
+ -- ORA-20000: Object does not exist or insufficient privileges
2905
+ -- ORA-20001: Bad input value
2906
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
2907
+ -- ORA-20003: Unable to gather system statistics
2908
+ -- ORA-20004: Error in "INTERVAL" mode :
2909
+ -- system parameter job_queue_processes must be > 0
2910
+ --
2911
+
2912
+ procedure get_system_stats (
2913
+ status out varchar2,
2914
+ dstart out date,
2915
+ dstop out date,
2916
+ pname varchar2,
2917
+ pvalue out number,
2918
+ stattab varchar2 default null,
2919
+ statid varchar2 default null,
2920
+ statown varchar2 default null);
2921
+
2922
+ --
2923
+ -- Input arguments:
2924
+ -- stattab - The user stat table identifier describing from where to get
2925
+ -- the current statistics info. If stattab is null, the statistics info
2926
+ -- will be obtained directly from the dictionary.
2927
+ -- statid - The (optional) identifier to associate with these statistics
2928
+ -- within stattab.
2929
+ -- statown - The schema containing stattab (if different then ownname)
2930
+ -- pname - parameter name to get
2931
+ --
2932
+ -- Output arguments:
2933
+ -- status - returns one of the following: COMPLETED, AUTOGATHERING,
2934
+ -- MANUALGATHERING, BADSTATS
2935
+ -- dstart - date when system stats gathering has been started
2936
+ -- dstop - date when gathering was finished if status = COMPLETE,
2937
+ -- will be finished if status = AUTOGATHERING,
2938
+ -- had to be finished if status = BADSTATS,
2939
+ -- dstarted if status = MANUALGATHERING,
2940
+ -- the following parameters defined only if status = COMPLETE
2941
+ -- pvalue - parameter value to get
2942
+ --
2943
+ -- Exceptions:
2944
+ -- ORA-20000: Object does not exist or insufficient privileges
2945
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
2946
+ -- ORA-20003: Unable to get system statistics
2947
+ -- ORA-20004: Parameter doesn't exist
2948
+ --
2949
+
2950
+ procedure set_system_stats (
2951
+ pname varchar2,
2952
+ pvalue number,
2953
+ stattab varchar2 default null,
2954
+ statid varchar2 default null,
2955
+ statown varchar2 default null);
2956
+
2957
+ --
2958
+ -- Input arguments:
2959
+ -- pname - parameter name to set
2960
+ -- pvalue - parameter value to set
2961
+ -- stattab - The user stat table identifier describing from where to get
2962
+ -- the current statistics info. If stattab is null, the statistics info
2963
+ -- will be obtained directly from the dictionary.
2964
+ -- statid - The (optional) identifier to associate with these statistics
2965
+ -- within stattab.
2966
+ -- statown - The schema containing stattab (if different then ownname)
2967
+ --
2968
+ -- Exceptions:
2969
+ -- ORA-20000: Object does not exist or insufficient privileges
2970
+ -- ORA-20001: Invalid input value
2971
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
2972
+ -- ORA-20003: Unable to set system statistics
2973
+ -- ORA-20004: Parameter doesn't exist
2974
+ --
2975
+
2976
+
2977
+ procedure delete_system_stats (
2978
+ stattab varchar2 default nulL,
2979
+ statid varchar2 default nulL,
2980
+ statown varchar2 default null);
2981
+
2982
+ --
2983
+ -- Deletes system statistics
2984
+ --
2985
+ -- Input arguments:
2986
+ -- stattab - The user stat table identifier describing from where
2987
+ -- to delete the statistics. If stattab is null, the statistics
2988
+ -- will be deleted directly from the dictionary.
2989
+ -- statid - The (optional) identifier to associate with these statistics
2990
+ -- within stattab (Only pertinent if stattab is not NULL).
2991
+ -- statown - The schema containing stattab (if different then ownname)
2992
+ --
2993
+ -- Exceptions:
2994
+ -- ORA-20000: Object does not exist or insufficient privileges
2995
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
2996
+ --
2997
+
2998
+ procedure import_system_stats (
2999
+ stattab varchar2,
3000
+ statid varchar2 default null,
3001
+ statown varchar2 default null);
3002
+
3003
+ --
3004
+ -- Retrieves system statistics from the user
3005
+ -- stat table identified by stattab and stores it in the
3006
+ -- dictionary
3007
+ --
3008
+ -- Input arguments:
3009
+ -- stattab - The user stat table identifier describing from where
3010
+ -- to retrieve the statistics.
3011
+ -- statid - The (optional) identifier to associate with these statistics
3012
+ -- within stattab.
3013
+ -- statown - The schema containing stattab (if different then ownname)
3014
+ --
3015
+ -- Exceptions:
3016
+ -- ORA-20000: Object does not exist or insufficient privileges
3017
+ -- if ORA-20000 shows "no statistics are imported", several
3018
+ -- possible reasons are: (1) user specified statid does not
3019
+ -- exist; (2) statistics are locked; (3) objects in the
3020
+ -- stattab no longer exist in the current database
3021
+ -- ORA-20001: Invalid or inconsistent values in the user stat table
3022
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
3023
+ -- ORA-20003: Unable to import system statistics
3024
+ --
3025
+
3026
+
3027
+ procedure export_system_stats (
3028
+ stattab varchar2,
3029
+ statid varchar2 default null,
3030
+ statown varchar2 default null);
3031
+
3032
+ --
3033
+ -- Retrieves system statistics and stores it
3034
+ -- in the user stat table identified by stattab
3035
+ --
3036
+ -- Input arguments:
3037
+ -- stattab - The user stat table identifier describing where
3038
+ -- to store the statistics.
3039
+ -- statid - The (optional) identifier to associate with these statistics
3040
+ -- within stattab.
3041
+ -- statown - The schema containing stattab (if different then ownname)
3042
+ --
3043
+ -- Exceptions:
3044
+ -- ORA-20000: Object does not exist or insufficient privileges
3045
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
3046
+ -- ORA-20003: Unable to export system statistics
3047
+ --
3048
+
3049
+
3050
+ procedure gather_fixed_objects_stats
3051
+ (stattab varchar2 default null, statid varchar2 default null,
3052
+ statown varchar2 default null,
3053
+ no_invalidate boolean default
3054
+ to_no_invalidate_type(get_param('NO_INVALIDATE')));
3055
+ --
3056
+ -- Gather statistics for fixed tables.
3057
+ -- To run this procedure, you must have the SYSDBA or ANALYZE ANY DICTIONARY
3058
+ -- system privilege.
3059
+ --
3060
+ -- Input arguments:
3061
+ -- stattab - The user stat table identifier describing where to save
3062
+ -- the current statistics.
3063
+ -- statid - The (optional) identifier to associate with these statistics
3064
+ -- within stattab.
3065
+ -- statown - The schema containing stattab (if different then ownname)
3066
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
3067
+ -- The procedure invalidates the dependent cursors immediately
3068
+ -- if set to FALSE.
3069
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
3070
+ -- invalidate dependend cursors. This is the default. The default
3071
+ -- can be changed using set_param procedure.
3072
+ -- Exceptions:
3073
+ -- ORA-20000: insufficient privileges
3074
+ -- ORA-20001: Bad input value
3075
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
3076
+ --
3077
+
3078
+
3079
+ procedure delete_fixed_objects_stats(
3080
+ stattab varchar2 default null, statid varchar2 default null,
3081
+ statown varchar2 default null,
3082
+ no_invalidate boolean default
3083
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
3084
+ force boolean default FALSE);
3085
+ --
3086
+ -- Deletes statistics for fixed tables
3087
+ -- To run this procedure, you must have the SYSDBA or ANALYZE ANY DICTIONARY
3088
+ -- system privilege.
3089
+ --
3090
+ -- Input arguments:
3091
+ -- stattab - The user stat table identifier describing from where
3092
+ -- to delete the statistics. If stattab is null, the statistics
3093
+ -- will be deleted directly in the dictionary.
3094
+ -- statid - The (optional) identifier to associate with these statistics
3095
+ -- within stattab (Only pertinent if stattab is not NULL).
3096
+ -- statown - The schema containing stattab (if different then ownname)
3097
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
3098
+ -- The procedure invalidates the dependent cursors immediately
3099
+ -- if set to FALSE.
3100
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
3101
+ -- invalidate dependend cursors. This is the default. The default
3102
+ -- can be changed using set_param procedure.
3103
+ -- force - Ignores the statistics lock on objects and delete
3104
+ -- the statistics if set to TRUE.
3105
+ --
3106
+ -- Exceptions:
3107
+ -- ORA-20000: insufficient privileges
3108
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
3109
+ --
3110
+
3111
+
3112
+ procedure export_fixed_objects_stats(
3113
+ stattab varchar2, statid varchar2 default null,
3114
+ statown varchar2 default null);
3115
+ --
3116
+ -- Retrieves statistics for fixed tables and stores them in the user
3117
+ -- stat table identified by stattab
3118
+ -- To run this procedure, you must have the SYSDBA or ANALYZE ANY DICTIONARY
3119
+ -- system privilege.
3120
+ --
3121
+ -- Input arguments:
3122
+ -- stattab - The user stat table identifier describing where
3123
+ -- to store the statistics.
3124
+ -- statid - The (optional) identifier to associate with these statistics
3125
+ -- within stattab.
3126
+ -- statown - The schema containing stattab (if different then ownname)
3127
+ --
3128
+ -- Exceptions:
3129
+ -- ORA-20000: insufficient privileges
3130
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
3131
+ --
3132
+
3133
+
3134
+ procedure import_fixed_objects_stats(
3135
+ stattab varchar2, statid varchar2 default null,
3136
+ statown varchar2 default null,
3137
+ no_invalidate boolean default
3138
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
3139
+ force boolean default FALSE);
3140
+ --
3141
+ -- Retrieves statistics for fixed tables from the user stat table and
3142
+ -- stores them in the dictionary
3143
+ -- To run this procedure, you must have the SYSDBA or ANALYZE ANY DICTIONARY
3144
+ -- system privilege.
3145
+ -- The statistics will be imported as pending in case PUBLISH preference
3146
+ -- is set to FALSE.
3147
+ --
3148
+ -- Input arguments:
3149
+ -- stattab - The user stat table identifier describing from where
3150
+ -- to retrieve the statistics.
3151
+ -- statid - The (optional) identifier to associate with these statistics
3152
+ -- within stattab.
3153
+ -- statown - The schema containing stattab (if different then ownname)
3154
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
3155
+ -- The procedure invalidates the dependent cursors immediately
3156
+ -- if set to FALSE.
3157
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
3158
+ -- invalidate dependend cursors. This is the default. The default
3159
+ -- can be changed using set_param procedure.
3160
+ -- force - Override statistics lock.
3161
+ -- TRUE- Ignores the statistics lock on objects and import
3162
+ -- the statistics.
3163
+ -- FALSE-The statistics of an object will be imported only if it
3164
+ -- is not locked.
3165
+ --
3166
+ -- Exceptions:
3167
+ -- ORA-20000: insufficient privileges
3168
+ -- if ORA-20000 shows "no statistics are imported", several
3169
+ -- possible reasons are: (1) user specified statid does not
3170
+ -- exist; (2) statistics are locked; (3) objects in the
3171
+ -- stattab no longer exist in the current database
3172
+ -- ORA-20001: Invalid or inconsistent values in the user stat table
3173
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
3174
+ --
3175
+
3176
+ procedure gather_dictionary_stats
3177
+ (comp_id varchar2 default null,
3178
+ estimate_percent number default DEFAULT_ESTIMATE_PERCENT,
3179
+ block_sample boolean default FALSE,
3180
+ method_opt varchar2 default DEFAULT_METHOD_OPT,
3181
+ degree number default to_degree_type(get_param('DEGREE')),
3182
+ granularity varchar2 default DEFAULT_GRANULARITY,
3183
+ cascade boolean default DEFAULT_CASCADE,
3184
+ stattab varchar2 default null, statid varchar2 default null,
3185
+ options varchar2 default 'GATHER AUTO', objlist out ObjectTab,
3186
+ statown varchar2 default null,
3187
+ no_invalidate boolean default
3188
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
3189
+ stattype varchar2 default 'DATA',
3190
+ obj_filter_list ObjectTab default null);
3191
+ procedure gather_dictionary_stats
3192
+ (comp_id varchar2 default null,
3193
+ estimate_percent number default DEFAULT_ESTIMATE_PERCENT,
3194
+ block_sample boolean default FALSE,
3195
+ method_opt varchar2 default DEFAULT_METHOD_OPT,
3196
+ degree number default to_degree_type(get_param('DEGREE')),
3197
+ granularity varchar2 default DEFAULT_GRANULARITY,
3198
+ cascade boolean default DEFAULT_CASCADE,
3199
+ stattab varchar2 default null, statid varchar2 default null,
3200
+ options varchar2 default 'GATHER AUTO', statown varchar2 default null,
3201
+ no_invalidate boolean default
3202
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
3203
+ stattype varchar2 default 'DATA',
3204
+ obj_filter_list ObjectTab default null);
3205
+
3206
+ --
3207
+ -- Gather statistics for dictionary schemas 'SYS', 'SYSTEM' and schemas of
3208
+ -- RDBMS components.
3209
+ -- To run this procedure, you must have the SYSDBA OR
3210
+ -- both ANALYZE ANY DICTIONARY and ANALYZE ANY system privilege.
3211
+ --
3212
+ -- Input arguments:
3213
+ -- comp_id - component id of the schema to analyze (NULL means schemas
3214
+ -- of all RDBMS components).
3215
+ -- Please refer to comp_id column of dba_registry view.
3216
+ -- The procedure always gather stats on 'SYS' and 'SYSTEM' schemas
3217
+ -- regardless of this argument.
3218
+ -- estimate_percent - Percentage of rows to estimate (NULL means compute).
3219
+ -- The valid range is [0.000001,100]. Use the constant
3220
+ -- DBMS_STATS.AUTO_SAMPLE_SIZE to have Oracle determine the
3221
+ -- appropriate sample size for good statistics. This is the default.
3222
+ -- The default value can be changed using set_param procedure.
3223
+ -- block_sample - whether or not to use random block sampling instead of
3224
+ -- random row sampling. Random block sampling is more efficient, but
3225
+ -- if the data is not randomly distributed on disk then the sample values
3226
+ -- may be somewhat correlated. Only pertinent when doing an estimate
3227
+ -- statistics.
3228
+ -- method_opt - method options of the following format
3229
+ --
3230
+ -- method_opt := FOR ALL [INDEXED | HIDDEN] COLUMNS [size_clause]
3231
+ --
3232
+ -- size_clause := SIZE [integer | auto | skewonly | repeat],
3233
+ -- where integer is between 1 and 254
3234
+ --
3235
+ -- default is FOR ALL COLUMNS SIZE AUTO.
3236
+ -- The default value can be changed using set_param procedure.
3237
+ -- This value will be passed to all of the individual tables.
3238
+ -- degree - degree of parallelism (NULL means use table default value which
3239
+ -- is specified by DEGREE clause in CREATE/ALTER TABLE statement)
3240
+ -- Use the constant DBMS_STATS.DEFAULT_DEGREE for the default value
3241
+ -- based on the initialization parameters.
3242
+ -- default for degree is NULL.
3243
+ -- The default value can be changed using set_param procedure.
3244
+ -- granularity - the granularity of statistics to collect (only pertinent
3245
+ -- if the table is partitioned)
3246
+ -- 'AUTO' - the procedure determines what level of statistics to collect
3247
+ -- 'GLOBAL AND PARTITION' - gather global- and partition-level statistics
3248
+ -- 'SUBPARTITION' - gather subpartition-level statistics
3249
+ -- 'PARTITION' - gather partition-level statistics
3250
+ -- 'GLOBAL' - gather global statistics
3251
+ -- 'ALL' - gather all (subpartition, partition, and global) statistics
3252
+ -- default for granularity is AUTO.
3253
+ -- The default value can be changed using set_param procedure.
3254
+ -- cascade - gather statistics on the indexes as well.
3255
+ -- Use the constant DBMS_STATS.AUTO_CASCADE to have Oracle determine
3256
+ -- whether index stats to be collected or not. This is the default.
3257
+ -- The default value can be changed using set_param procedure.
3258
+ -- Using this option is equivalent to running the gather_index_stats
3259
+ -- procedure on each of the indexes in the schema in addition to
3260
+ -- gathering table and column statistics.
3261
+ -- stattab - The user stat table identifier describing where to save
3262
+ -- the current statistics.
3263
+ -- statid - The (optional) identifier to associate with these statistics
3264
+ -- within stattab.
3265
+ -- options - further specification of which objects to gather statistics for
3266
+ -- 'GATHER' - gather statistics on all objects in the schema
3267
+ -- 'GATHER AUTO' - gather all necessary statistics automatically. Oracle
3268
+ -- implicitly determines which objects need new statistics, and
3269
+ -- determines how to gather those statistics. When 'GATHER AUTO' is
3270
+ -- specified, the only additional valid parameters are comp_id, stattab,
3271
+ -- statid and statown; all other parameter settings will be
3272
+ -- ignored. Also, return a list of objects processed.
3273
+ -- 'GATHER STALE' - gather statistics on stale objects as determined
3274
+ -- by looking at the *_tab_modifications views. Also, return
3275
+ -- a list of objects found to be stale.
3276
+ -- 'GATHER EMPTY' - gather statistics on objects which currently
3277
+ -- have no statistics. also, return a list of objects found
3278
+ -- to have no statistics.
3279
+ -- 'LIST AUTO' - return list of objects to be processed with 'GATHER AUTO'
3280
+ -- 'LIST STALE' - return list of stale objects as determined
3281
+ -- by looking at the *_tab_modifications views
3282
+ -- 'LIST EMPTY' - return list of objects which currently
3283
+ -- have no statistics
3284
+ -- objlist - list of objects found to be stale or empty
3285
+ -- statown - The schema containing stattab (if different from current schema)
3286
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
3287
+ -- The procedure invalidates the dependent cursors immediately
3288
+ -- if set to FALSE.
3289
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
3290
+ -- invalidate dependend cursors. This is the default. The default
3291
+ -- can be changed using set_param procedure.
3292
+ -- When 'cascade' option is specified, not pertinent with certain types
3293
+ -- of indexes described in the gather_index_stats section.
3294
+ -- obj_filter_list - a list of object filters. When provided, gather_dictionary_
3295
+ -- stats will only gather statistics on the objects which satisfy at least
3296
+ -- one of the object filters as needed. Please refer to obj_filter_list in
3297
+ -- gather_database_stats
3298
+ -- Exceptions:
3299
+ -- ORA-20000: Schema does not exist or insufficient privileges
3300
+ -- ORA-20001: Bad input value
3301
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
3302
+ --
3303
+
3304
+ procedure delete_dictionary_stats(
3305
+ stattab varchar2 default null, statid varchar2 default null,
3306
+ statown varchar2 default null,
3307
+ no_invalidate boolean default
3308
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
3309
+ stattype varchar2 default 'ALL',
3310
+ force boolean default FALSE);
3311
+ --
3312
+ -- Deletes statistics for all dictionary schemas ('SYS', 'SYSTEM' and
3313
+ -- RDBMS component schemas)
3314
+ --
3315
+ -- To run this procedure, you must have the SYSDBA OR
3316
+ -- both ANALYZE ANY DICTIONARY and ANALYZE ANY system privilege.
3317
+ --
3318
+ -- Input arguments:
3319
+ -- stattab - The user stat table identifier describing from where
3320
+ -- to delete the statistics. If stattab is null, the statistics
3321
+ -- will be deleted directly in the dictionary.
3322
+ -- statid - The (optional) identifier to associate with these statistics
3323
+ -- within stattab (Only pertinent if stattab is not NULL).
3324
+ -- statown - The schema containing stattab (if different from current schema)
3325
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
3326
+ -- The procedure invalidates the dependent cursors immediately
3327
+ -- if set to FALSE.
3328
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
3329
+ -- invalidate dependend cursors. This is the default. The default
3330
+ -- can be changed using set_param procedure.
3331
+ -- stattype - The type of statistics to be deleted
3332
+ -- ALL - both data and cache statistics will be deleted
3333
+ -- CACHE - only cache statistics will be deleted
3334
+ -- force - Ignores the statistics lock on objects and delete
3335
+ -- the statistics if set to TRUE.
3336
+ --
3337
+ -- Exceptions:
3338
+ -- ORA-20000: Object does not exist or insufficient privileges
3339
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
3340
+ --
3341
+
3342
+ procedure export_dictionary_stats(
3343
+ stattab varchar2, statid varchar2 default null,
3344
+ statown varchar2 default null,
3345
+ stat_category varchar2 default DEFAULT_STAT_CATEGORY);
3346
+ --
3347
+ -- Retrieves statistics for all dictionary schemas ('SYS', 'SYSTEM' and
3348
+ -- RDBMS component schemas) and stores them in the user stat table
3349
+ -- identified by stattab
3350
+ --
3351
+ -- To run this procedure, you must have the SYSDBA OR
3352
+ -- both ANALYZE ANY DICTIONARY and ANALYZE ANY system privilege.
3353
+ --
3354
+ -- Input arguments:
3355
+ -- stattab - The user stat table identifier describing where
3356
+ -- to store the statistics.
3357
+ -- statid - The (optional) identifier to associate with these statistics
3358
+ -- within stattab.
3359
+ -- statown - The schema containing stattab (if different from current schema)
3360
+ -- stat_category - what statistics to export. It accepts multiple values
3361
+ -- separated by comma. The values we support now are 'OBJECT_STATS'
3362
+ -- (i.e., table statistics, column statistics and index statistics) and
3363
+ -- 'SYNOPSES'
3364
+ --
3365
+ -- Exceptions:
3366
+ -- ORA-20000: Object does not exist or insufficient privileges
3367
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
3368
+ --
3369
+ procedure import_dictionary_stats(
3370
+ stattab varchar2, statid varchar2 default null,
3371
+ statown varchar2 default null,
3372
+ no_invalidate boolean default
3373
+ to_no_invalidate_type(get_param('NO_INVALIDATE')),
3374
+ force boolean default FALSE,
3375
+ stat_category varchar2 default DEFAULT_STAT_CATEGORY);
3376
+ --
3377
+ -- Retrieves statistics for all dictionary schemas ('SYS', 'SYSTEM' and
3378
+ -- RDBMS component schemas) from the user stat table and stores them in
3379
+ -- the dictionary
3380
+ -- The statistics will be imported as pending in case PUBLISH preference
3381
+ -- is set to FALSE.
3382
+ ---
3383
+ -- To run this procedure, you must have the SYSDBA OR
3384
+ -- both ANALYZE ANY DICTIONARY and ANALYZE ANY system privilege.
3385
+ --
3386
+ -- Input arguments:
3387
+ -- stattab - The user stat table identifier describing from where
3388
+ -- to retrieve the statistics.
3389
+ -- statid - The (optional) identifier to associate with these statistics
3390
+ -- within stattab.
3391
+ -- statown - The schema containing stattab (if different from current schema)
3392
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
3393
+ -- The procedure invalidates the dependent cursors immediately
3394
+ -- if set to FALSE.
3395
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
3396
+ -- invalidate dependend cursors. This is the default. The default
3397
+ -- can be changed using set_param procedure.
3398
+ -- force - Override statistics lock.
3399
+ -- TRUE- Ignores the statistics lock on objects and import
3400
+ -- the statistics.
3401
+ -- FALSE-The statistics of an object will be imported only if it
3402
+ -- is not locked.
3403
+ -- ie if both DATA and CACHE statistics is locked, it will not
3404
+ -- import anything. If CACHE statistics of an object is locked,
3405
+ -- only DATA statistics will be imported and vice versa.
3406
+ -- stat_category - what statistics to import. It accepts multiple values
3407
+ -- separated by comma. The values we support now are 'OBJECT_STATS'
3408
+ -- (i.e., table statistics, column statistics and index statistics) and
3409
+ -- 'SYNOPSES'
3410
+ --
3411
+ -- Exceptions:
3412
+ -- ORA-20000: Object does not exist or insufficient privileges
3413
+ -- if ORA-20000 shows "no statistics are imported", several
3414
+ -- possible reasons are: (1) user specified statid does not
3415
+ -- exist; (2) statistics are locked; (3) objects in the
3416
+ -- stattab no longer exist in the current database
3417
+ -- ORA-20001: Invalid or inconsistent values in the user stat table
3418
+ -- ORA-20002: Bad user statistics table, may need to upgrade it
3419
+ --
3420
+
3421
+ procedure lock_table_stats(
3422
+ ownname varchar2,
3423
+ tabname varchar2,
3424
+ stattype varchar2 default 'ALL');
3425
+ --
3426
+ -- This procedure enables the user to lock the statistics on the table
3427
+ --
3428
+ -- Input arguments:
3429
+ -- ownname - schema of table to lock
3430
+ -- tabname - name of the table
3431
+ -- stattype - type of statistics to be locked
3432
+ -- 'CACHE' - lock only caching statistics
3433
+ -- 'DATA' - lock only data statistics
3434
+ -- 'ALL' - lock both data and caching statistics. This is the default
3435
+
3436
+
3437
+ procedure lock_partition_stats(
3438
+ ownname varchar2,
3439
+ tabname varchar2,
3440
+ partname varchar2);
3441
+
3442
+ --
3443
+ -- This procedure enables the user to lock statistics for a partition
3444
+ --
3445
+ -- Input arguments:
3446
+ -- ownname - schema of the table to lock
3447
+ -- tabname - name of the table
3448
+ -- partname - name of the partition
3449
+ --
3450
+
3451
+
3452
+ procedure lock_schema_stats(
3453
+ ownname varchar2,
3454
+ stattype varchar2 default 'ALL');
3455
+
3456
+ --
3457
+ -- This procedure enables the user to lock the statistics of all
3458
+ -- tables of a schema
3459
+ --
3460
+ -- Input arguments:
3461
+ -- ownname - schema of tables to lock
3462
+ -- stattype - type of statistics to be locked
3463
+ -- 'CACHE' - lock only caching statistics
3464
+ -- 'DATA' - lock only data statistics
3465
+ -- 'ALL' - lock both data and caching statistics. This is the default
3466
+
3467
+
3468
+ procedure unlock_table_stats(
3469
+ ownname varchar2,
3470
+ tabname varchar2,
3471
+ stattype varchar2 default 'ALL');
3472
+ --
3473
+ -- This procedure enables the user to unlock the statistics on the table
3474
+ --
3475
+ -- Input arguments:
3476
+ -- ownname - schema of table to unlock
3477
+ -- tabname - name of the table
3478
+ -- stattype - type of statistics to be unlocked
3479
+ -- 'CACHE' - unlock only caching statistics
3480
+ -- 'DATA' - unlock only data statistics
3481
+ -- 'ALL' - unlock both data and caching statistics. This is the default
3482
+
3483
+
3484
+ procedure unlock_partition_stats(
3485
+ ownname varchar2,
3486
+ tabname varchar2,
3487
+ partname varchar2);
3488
+
3489
+ --
3490
+ -- This procedure enables the user to unlock statistics for a partition
3491
+ --
3492
+ -- Input arguments:
3493
+ -- ownname - schema of table to unlock
3494
+ -- tabname - name of the table
3495
+ -- partname - name of the partition
3496
+ --
3497
+
3498
+
3499
+ procedure unlock_schema_stats(
3500
+ ownname varchar2,
3501
+ stattype varchar2 default 'ALL');
3502
+ --
3503
+ -- This procedure enables the user to unlock the statistics of all
3504
+ -- tables of a schema
3505
+ --
3506
+ -- Input arguments:
3507
+ -- ownname - schema of tables to unlock
3508
+ -- stattype - type of statistics to be unlocked
3509
+ -- 'CACHE' - unlock only caching statistics
3510
+ -- 'DATA' - unlock only data statistics
3511
+ -- 'ALL' - unlock both data and caching statistics. This is the default
3512
+
3513
+ procedure restore_table_stats(
3514
+ ownname varchar2,
3515
+ tabname varchar2,
3516
+ as_of_timestamp timestamp with time zone,
3517
+ restore_cluster_index boolean default FALSE,
3518
+ force boolean default FALSE,
3519
+ no_invalidate boolean default
3520
+ to_no_invalidate_type(get_param('NO_INVALIDATE')));
3521
+ --
3522
+ -- This procedure enables the user to restore statistics of a table as of
3523
+ -- a specified timestamp (as_of_timestamp). The procedure will restore
3524
+ -- statistics of associated indexes and columns as well. If the table
3525
+ -- statistics were locked at the specified timestamp the procedure will
3526
+ -- lock the statistics.
3527
+ -- Note:
3528
+ -- The procedure may not restore statistics correctly if analyze interface
3529
+ -- is used for computing/deleting statistics.
3530
+ -- Old statistics versions are not saved when SYSAUX tablespace is
3531
+ -- offline, this affects restore functionality.
3532
+ -- The procedure may not restore statistics if the table defn is
3533
+ -- changed (eg: column added/deleted, partition exchanged etc).
3534
+ -- Also it will not restore stats if the object is created after
3535
+ -- the specified timestamp.
3536
+ -- The procedure will not restore user defined statistics.
3537
+ -- Input arguments:
3538
+ -- ownname - schema of table for which statistics to be restored
3539
+ -- tabname - table name
3540
+ -- as_of_timestamp - statistics as of this timestamp will be restored.
3541
+ -- restore_cluster_index - If the table is part of a cluster,
3542
+ -- restore statistics of the cluster index if set to TRUE.
3543
+ -- force - restore statistics even if the table statistics are locked.
3544
+ -- if the table statistics were not locked at the specified
3545
+ -- timestamp, it will unlock the statistics
3546
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
3547
+ -- The procedure invalidates the dependent cursors immediately
3548
+ -- if set to FALSE.
3549
+ -- The procedure invalidates the dependent cursors immediately
3550
+ -- if set to FALSE.
3551
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
3552
+ -- invalidate dependend cursors. This is the default. The default
3553
+ -- can be changed using set_param procedure.
3554
+ --
3555
+ -- Exceptions:
3556
+ -- ORA-20000: Object does not exist or insufficient privileges
3557
+ -- ORA-20001: Invalid or inconsistent values
3558
+ -- ORA-20006: Unable to restore statistics , statistics history not available
3559
+
3560
+ procedure restore_schema_stats(
3561
+ ownname varchar2,
3562
+ as_of_timestamp timestamp with time zone,
3563
+ force boolean default FALSE,
3564
+ no_invalidate boolean default
3565
+ to_no_invalidate_type(get_param('NO_INVALIDATE')));
3566
+ --
3567
+ -- This procedure enables the user to restore statistics of all tables of
3568
+ -- a schema as of a specified timestamp (as_of_timestamp).
3569
+
3570
+ -- Input arguments:
3571
+ -- ownname - schema of tables for which statistics to be restored
3572
+ -- as_of_timestamp - statistics as of this timestamp will be restored.
3573
+ -- force - restore statistics of tables even if their statistics are locked.
3574
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
3575
+ -- The procedure invalidates the dependent cursors immediately
3576
+ -- if set to FALSE.
3577
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
3578
+ -- invalidate dependend cursors. This is the default. The default
3579
+ -- can be changed using set_param procedure.
3580
+ --
3581
+ -- Exceptions:
3582
+ -- ORA-20000: Object does not exist or insufficient privileges
3583
+ -- ORA-20001: Invalid or inconsistent values
3584
+ -- ORA-20006: Unable to restore statistics , statistics history not available
3585
+
3586
+ procedure restore_database_stats(
3587
+ as_of_timestamp timestamp with time zone,
3588
+ force boolean default FALSE,
3589
+ no_invalidate boolean default
3590
+ to_no_invalidate_type(get_param('NO_INVALIDATE')));
3591
+ --
3592
+ -- This procedure enables the user to restore statistics of all tables of
3593
+ -- the database as of a specified timestamp (as_of_timestamp).
3594
+
3595
+ -- Input arguments:
3596
+ -- as_of_timestamp - statistics as of this timestamp will be restored.
3597
+ -- force - restore statistics of tables even if their statistics are locked.
3598
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
3599
+ -- The procedure invalidates the dependent cursors immediately
3600
+ -- if set to FALSE.
3601
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
3602
+ -- invalidate dependend cursors. This is the default. The default
3603
+ -- can be changed using set_param procedure.
3604
+ --
3605
+ -- Exceptions:
3606
+ -- ORA-20000: Insufficient privileges
3607
+ -- ORA-20001: Invalid or inconsistent values
3608
+ -- ORA-20006: Unable to restore statistics , statistics history not available
3609
+
3610
+ procedure restore_fixed_objects_stats(
3611
+ as_of_timestamp timestamp with time zone,
3612
+ force boolean default FALSE,
3613
+ no_invalidate boolean default
3614
+ to_no_invalidate_type(get_param('NO_INVALIDATE')));
3615
+ --
3616
+ -- This procedure enables the user to restore statistics of all fixed tables
3617
+ -- as of a specified timestamp (as_of_timestamp).
3618
+ -- To run this procedure, you must have the SYSDBA or ANALYZE ANY DICTIONARY
3619
+ -- system privilege.
3620
+ --
3621
+ -- Input arguments:
3622
+ -- as_of_timestamp - statistics as of this timestamp will be restored.
3623
+ -- force - restore statistics of tables even if their statistics are locked.
3624
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
3625
+ -- The procedure invalidates the dependent cursors immediately
3626
+ -- if set to FALSE.
3627
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
3628
+ -- invalidate dependend cursors. This is the default. The default
3629
+ -- can be changed using set_param procedure.
3630
+ --
3631
+ -- Exceptions:
3632
+ -- ORA-20000: Insufficient privileges
3633
+ -- ORA-20001: Invalid or inconsistent values
3634
+ -- ORA-20006: Unable to restore statistics , statistics history not available
3635
+
3636
+ procedure restore_dictionary_stats(
3637
+ as_of_timestamp timestamp with time zone,
3638
+ force boolean default FALSE,
3639
+ no_invalidate boolean default
3640
+ to_no_invalidate_type(get_param('NO_INVALIDATE')));
3641
+ --
3642
+ -- This procedure enables the user to restore statistics of all dictionary
3643
+ -- tables (tables of 'SYS', 'SYSTEM' and RDBMS component schemas)
3644
+ -- as of a specified timestamp (as_of_timestamp).
3645
+ --
3646
+ -- To run this procedure, you must have the SYSDBA OR
3647
+ -- both ANALYZE ANY DICTIONARY and ANALYZE ANY system privilege.
3648
+ --
3649
+ -- Input arguments:
3650
+ -- as_of_timestamp - statistics as of this timestamp will be restored.
3651
+ -- force - restore statistics of tables even if their statistics are locked.
3652
+ -- no_invalidate - Do not invalide the dependent cursors if set to TRUE.
3653
+ -- The procedure invalidates the dependent cursors immediately
3654
+ -- if set to FALSE.
3655
+ -- Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to
3656
+ -- invalidate dependend cursors. This is the default. The default
3657
+ -- can be changed using set_param procedure.
3658
+ --
3659
+ -- Exceptions:
3660
+ -- ORA-20000: Insufficient privileges
3661
+ -- ORA-20001: Invalid or inconsistent values
3662
+ -- ORA-20006: Unable to restore statistics , statistics history not available
3663
+
3664
+ procedure restore_system_stats(
3665
+ as_of_timestamp timestamp with time zone);
3666
+ --
3667
+ -- This procedure enables the user to restore system statistics
3668
+ -- as of a specified timestamp (as_of_timestamp).
3669
+ --
3670
+ -- Input arguments:
3671
+ -- as_of_timestamp - statistics as of this timestamp will be restored.
3672
+ --
3673
+ -- Exceptions:
3674
+ -- ORA-20000: Insufficient privileges
3675
+ -- ORA-20001: Invalid or inconsistent values
3676
+ -- ORA-20006: Unable to restore statistics , statistics history not available
3677
+
3678
+ procedure purge_stats(
3679
+ before_timestamp timestamp with time zone);
3680
+ --
3681
+ -- This procedure enables the user to purge old versions of statistics
3682
+ -- saved in dictionary
3683
+ --
3684
+ -- To run this procedure, you must have the SYSDBA OR
3685
+ -- both ANALYZE ANY DICTIONARY and ANALYZE ANY system privilege.
3686
+ --
3687
+ -- Input arguments:
3688
+ -- before_timestamp - versions of statistics saved before this timestamp
3689
+ -- will be purged. if null, it uses the purging policy
3690
+ -- used by automatic purge. The automatic purge deletes all
3691
+ -- history older than
3692
+ -- min(current time - stats history retention,
3693
+ -- time of recent analyze in the system - 1).
3694
+ -- stats history retention value can be changed using
3695
+ -- alter_stats_history_retention procedure.
3696
+ -- The default is 31 days.
3697
+ --
3698
+ -- When before_timestamp is specified as DBMS_STATS.PURGE_ALL, all stats
3699
+ -- history tables are truncated. Please note that interrupting
3700
+ -- (e.g., hitting Ctrl-C) purge_stats while it is running with PURGE_ALL
3701
+ -- option may lead to inconsistencies. Hence, please avoid interrupting
3702
+ -- purge_stats manually.
3703
+ --
3704
+ --
3705
+ -- Exceptions:
3706
+ -- ORA-20000: Insufficient privileges
3707
+ -- ORA-20001: Invalid or inconsistent values
3708
+
3709
+ procedure alter_stats_history_retention(
3710
+ retention in number);
3711
+ --
3712
+ -- This procedure enables the user to change stats history retention
3713
+ -- value. Stats history retention is used by both the automatic
3714
+ -- purge and purge_stats procedure.
3715
+ --
3716
+ --
3717
+ -- To run this procedure, you must have the SYSDBA OR
3718
+ -- both ANALYZE ANY DICTIONARY and ANALYZE ANY system privilege.
3719
+ --
3720
+ -- Input arguments:
3721
+ -- retention - The retention time in days. The stats history will be
3722
+ -- ratained for at least these many number of days.
3723
+ -- The valid range is [1,365000]. Also the following
3724
+ -- values can be used for special purposes.
3725
+ -- 0 - old stats are never saved. The automatic purge will
3726
+ -- delete all stats history
3727
+ -- -1 - stats history is never purged by automatic purge.
3728
+ -- null - change stats history retention to default value
3729
+
3730
+ --
3731
+
3732
+ function get_stats_history_retention return number;
3733
+
3734
+ -- This function returns the current retention value.
3735
+
3736
+ function get_stats_history_availability
3737
+ return timestamp with time zone;
3738
+
3739
+ -- This function returns oldest timestamp where stats history
3740
+ -- is available.
3741
+ -- Users can not restore stats to timestamp older than this one.
3742
+
3743
+
3744
+ procedure copy_table_stats(
3745
+ ownname varchar2,
3746
+ tabname varchar2,
3747
+ srcpartname varchar2,
3748
+ dstpartname varchar2,
3749
+ scale_factor number DEFAULT 1,
3750
+ flags number DEFAULT null,
3751
+ force boolean DEFAULT FALSE);
3752
+
3753
+ --
3754
+ -- This procedure copies the stats of the source [sub] partition to the
3755
+ -- dst [sub] partition after scaling (the number of blks, number of rows etc.).
3756
+ -- It sets the high bound partitioning value as the max value of the first
3757
+ -- partitioning col and high bound partitioning value of the previous partition
3758
+ -- as the min value of the first partitioning col for range partitioned table.
3759
+ -- It finds the max and min from the list of values for the list partitioned table.
3760
+ -- It also sets the normalized max and min values. If the destination partition
3761
+ -- is the first partition then min values are equal to max values. It also copies
3762
+ -- statistics of all dependent object such as columns and local indexes. If the
3763
+ -- statistics for source are not available then nothing is copied.
3764
+ --
3765
+ -- ownname - schema of index to analyze
3766
+ -- tabname - table name of source and destination [sub]partitions
3767
+ -- srcpartname - source [sub]partition
3768
+ -- dstpartname - destination [sub]partition
3769
+ -- scale_factor - scale factor to scale nblks, nrows etc. in dstpart
3770
+ -- Exceptions:
3771
+ -- ORA-20000: Invalid partition name
3772
+ -- ORA-20001: Bad input value
3773
+ --
3774
+
3775
+
3776
+ function diff_table_stats_in_stattab(
3777
+ ownname varchar2,
3778
+ tabname varchar2,
3779
+ stattab1 varchar2,
3780
+ stattab2 varchar2 default null,
3781
+ pctthreshold number default 10,
3782
+ statid1 varchar2 default null,
3783
+ statid2 varchar2 default null,
3784
+ stattab1own varchar2 default null,
3785
+ stattab2own varchar2 default null)
3786
+ return DiffRepTab pipelined;
3787
+
3788
+ -- Input arguments:
3789
+ -- ownname - owner of the table. Specify null for current schema.
3790
+ -- tabname - table for which statistics are to be compared.
3791
+ -- stattab1 - user stats table 1.
3792
+ -- stattab2 - user stats table 2. If null, statistics in stattab1
3793
+ -- is compared with current statistics in dictionary.
3794
+ -- This is the default.
3795
+ -- Specify same table as stattab1 to compare two sets
3796
+ -- within the stats table (Please see statid below).
3797
+ -- pctthreshold - The function report difference in statistics
3798
+ -- only if it exceeds this limit. The default value is 10.
3799
+ -- statid1 - (optional) identifies statistics set within stattab1.
3800
+ -- statid2 - (optional) identifies statistics set within stattab2.
3801
+ -- stattab1own - The schema containing stattab1 (if different than ownname)
3802
+ -- stattab2own - The schema containing stattab2 (if different than ownname)
3803
+ --
3804
+
3805
+ function diff_table_stats_in_history(
3806
+ ownname varchar2,
3807
+ tabname varchar2,
3808
+ time1 timestamp with time zone,
3809
+ time2 timestamp with time zone default null,
3810
+ pctthreshold number default 10)
3811
+ return DiffRepTab pipelined;
3812
+
3813
+ -- Input arguments:
3814
+ -- ownname - owner of the table. Specify null for current schema.
3815
+ -- tabname - table for which statistics are to be compared.
3816
+ -- time1 - first time stamp
3817
+ -- time2 - second time stamp
3818
+ --
3819
+ -- pctthreshold - The function report difference in statistics
3820
+ -- only if it exceeds this limit. The default value is 10.
3821
+ --
3822
+ -- NOTE:
3823
+ -- If the second timestamp is null, the function compares the current
3824
+ -- statistics in dictionary with the statistics as of the other timestamp.
3825
+
3826
+ function diff_table_stats_in_pending(
3827
+ ownname varchar2,
3828
+ tabname varchar2,
3829
+ time_stamp timestamp with time zone default null,
3830
+ pctthreshold number default 10)
3831
+ return DiffRepTab pipelined;
3832
+
3833
+ -- Input arguments:
3834
+ -- ownname - owner of the table. Specify null for the current schema.
3835
+ -- tabname - table for which statistics are to be compared.
3836
+ -- time_stamp - time stamp to get statistics from the history
3837
+ --
3838
+ -- pctthreshold - The function report difference in statistics
3839
+ -- only if it exceeds this limit. The default value is 10.
3840
+ --
3841
+ -- NOTE:
3842
+ -- If the time_stamp parameter is null, the function compares the current
3843
+ -- statistics in the dictionary with the pending statistics. This is the
3844
+ -- default
3845
+
3846
+
3847
+
3848
+ function create_extended_stats(
3849
+ ownname varchar2,
3850
+ tabname varchar2,
3851
+ extension varchar2)
3852
+ return varchar2;
3853
+
3854
+ -- This function creates a column stats entry in the system for a user specified
3855
+ -- column group or an expression in a table. Statistics for this extension will
3856
+ -- be gathered when user or auto statistics gathering job gathers statistics for
3857
+ -- the table. We call statistics for such an extension, "extended statistics".
3858
+ -- This function returns the name of this newly created entry for the extension.
3859
+ -- If the extension already exists then this function throws an error.
3860
+
3861
+ --
3862
+ -- Parameters:
3863
+ -- ownname -- owner name of a table
3864
+ -- tabname -- table name
3865
+ -- extension -- can be either a column group or an expression. Suppose
3866
+ -- the specified table has two column c1, c2. An example
3867
+ -- column group can be '(c1, c2)', an example expression
3868
+ -- can be '(c1 + c2)'.
3869
+ --
3870
+ -- Notes:
3871
+ --
3872
+ -- 1. An extension cannot contain a virtual column.
3873
+ --
3874
+ -- 2. You can not create extensions on tables owned by SYS.
3875
+ --
3876
+ -- 3. You can not create extensions on cluster tables, index organized
3877
+ -- tables, temporary tables, external tables.
3878
+ --
3879
+ -- 4. Total number of extensions in a table cannot be greater than
3880
+ -- maximum of (20, 10 % of number of non-virtual columns in the table).
3881
+ --
3882
+ -- 5. Number of columns in a column group must be in the range [2, 32].
3883
+ --
3884
+ -- 6. A column can not appear more than once in a column group.
3885
+ --
3886
+ -- 7. Column group can not contain expressions.
3887
+ --
3888
+ -- 8. An expression must contain at least one column.
3889
+ --
3890
+ -- 9. An expression can not contain subquery.
3891
+ --
3892
+ -- 10. COMPATIBLE parameter needs to be 11.0.0.0.0 or greater.
3893
+ --
3894
+ -- Exceptions:
3895
+ --
3896
+ -- ORA-20000: Insufficient privileges / creating extension is not supported
3897
+ --
3898
+ -- ORA-20001: Error when processing extension
3899
+ --
3900
+ -- ORA-20007: Extension already exist
3901
+ --
3902
+ -- ORA-20008: Reached the upper limit on number of extensions
3903
+ --
3904
+
3905
+ function create_extended_stats(
3906
+ ownname varchar2,
3907
+ tabname varchar2)
3908
+ return clob;
3909
+
3910
+ -- This function is very similar to the function above but creates statistics
3911
+ -- extension based on the column group usage recorded by seed_col_usage
3912
+ -- procedure. This function returns a report of extensions created.
3913
+ --
3914
+ --
3915
+ -- Parameters:
3916
+ -- ownname -- owner name of a table. If null, all schemas in the
3917
+ -- database.
3918
+ -- tabname -- table name. If null, creates statistics extensions
3919
+ -- for all tables of ownname.
3920
+
3921
+ function show_extended_stats_name(
3922
+ ownname varchar2,
3923
+ tabname varchar2,
3924
+ extension varchar2)
3925
+ return varchar2;
3926
+
3927
+ -- This function returns the name of the statistics entry that is created for
3928
+ -- the user specified extension. It raises error if no extension is created
3929
+ -- yet
3930
+ --
3931
+ --
3932
+ -- Parameters:
3933
+ -- ownname -- owner name of a table
3934
+ -- tabname -- table name
3935
+ -- extension -- can be either a column group or an expression
3936
+ -- (see description in create_extended_stats)
3937
+ -- Exceptions:
3938
+ -- ORA-20000: Insufficient privileges or extension does not exist.
3939
+ -- ORA-20001: Error when processing extension
3940
+
3941
+ procedure drop_extended_stats(
3942
+ ownname varchar2,
3943
+ tabname varchar2,
3944
+ extension varchar2);
3945
+
3946
+ -- This function drops the statistics entry that is created for the user
3947
+ -- specified extension. This cancels the effects of created_extended_stats.
3948
+ -- If no extension is created for the extension, this function
3949
+ -- throws an error.
3950
+ --
3951
+ --
3952
+ -- Parameters:
3953
+ -- ownname -- owner name of a table
3954
+ -- tabname -- table name
3955
+ -- extension -- can be either a column group or an expression
3956
+ -- (see description in create_extended_stats)
3957
+ -- Exceptions:
3958
+ -- ORA-20000: Insufficient privileges or extension does not exist.
3959
+ -- ORA-20001: Error when processing extension
3960
+ --
3961
+ -- The following procedure is for internal use only.
3962
+ --
3963
+ -- gather_database_stats_job_proc
3964
+ -- cleanup_stats_job_proc
3965
+ --
3966
+
3967
+
3968
+ procedure merge_col_usage(
3969
+ dblink varchar2);
3970
+
3971
+ --
3972
+ -- This procedure merges column usage information from a source database,
3973
+ -- specified via a dblink, into the local database.
3974
+ -- If the column usage information already exists for a given table and
3975
+ -- column then it will combine both the local and the remote information
3976
+ -- otherwise it will insert the remote information as new.
3977
+ -- This procedure is allowed is executed as SYS only, otherwise you will
3978
+ -- an error message 'Insufficient privileges'.
3979
+ -- In addition the user specified during the creation of the dblink is
3980
+ -- expected to have privileges to select from tables in the SYS schema.
3981
+ --
3982
+ -- Parameters:
3983
+ -- dblink - dblink name
3984
+ --
3985
+ -- Exceptions:
3986
+ -- ORA-20000: Insufficient privileges
3987
+ -- ORA-20001: Parameter dblink cannot be null
3988
+ -- ORA-20002: Unable to create a temp table
3989
+ --
3990
+
3991
+
3992
+ procedure seed_col_usage(
3993
+ sqlset_name IN VARCHAR2,
3994
+ owner_name IN VARCHAR2,
3995
+ time_limit IN POSITIVE DEFAULT NULL);
3996
+
3997
+ --
3998
+ -- This procedure seeds column usage information from a statements in
3999
+ -- the specified sql tuning set.
4000
+ -- The procedure will iterate over the SQL statements in the SQL tuning
4001
+ -- set and compile them in order to seed column usage information for
4002
+ -- the columns that appear in these statements. This procedure records
4003
+ -- group of columns as well. Extensions for the recorded group of columns
4004
+ -- can be created using create_extended_stats procedure.
4005
+ --
4006
+ -- Parameters:
4007
+ -- sqlset_name - sqlset name
4008
+ -- owner_name - owner name
4009
+ -- time_limit - time limit (in seconds)
4010
+ --
4011
+ -- If sqlset_name and owner_name is null, it records the column (group) usage
4012
+ -- information for the statements executed in the system in next time_limit
4013
+ -- seconds.
4014
+ --
4015
+ -- Exceptions:
4016
+ -- ORA-20000: Insufficient privileges
4017
+ --
4018
+
4019
+ procedure reset_col_usage(
4020
+ ownname varchar2,
4021
+ tabname varchar2);
4022
+
4023
+ -- This procedure deletes the recorded column (group) usage information
4024
+ -- from dictionary. Column (group) usage information is used by gather
4025
+ -- procedures to automatically determine the columns that require histograms.
4026
+ -- Also this information is used by create_extended_stats to create extensions
4027
+ -- for the group of columns seen in the workload. So resetting column usage
4028
+ -- will affect these functionalities. This procedure should be used only in very
4029
+ -- rare cases where you need to start from scratch and need to seed
4030
+ -- column usage all over again.
4031
+ --
4032
+ -- Parameters:
4033
+ -- ownname - owner name. If null it resets column usage information
4034
+ -- for tables in all schemas in the database.
4035
+ -- tabname - table name. If null, resets column usage information
4036
+ -- for all tables of ownname.
4037
+ -- If ownname and tabname is null, it will stop seeding column usage, if
4038
+ -- currently seeding column usage using seed_col_usage.
4039
+
4040
+ function report_col_usage(
4041
+ ownname varchar2,
4042
+ tabname varchar2) return clob;
4043
+
4044
+ -- This procedure reports the recorded column (group) usage information.
4045
+ --
4046
+ -- Parameters:
4047
+ -- ownname - owner name. If null it reports column usage information
4048
+ -- for tables in all schemas in the database.
4049
+ -- tabname - table name. If null, it reports column usage information
4050
+ -- for all tables of ownname.
4051
+ -- Examples:
4052
+ -- The following example shows column usage information for customers table
4053
+ -- in SH schema.
4054
+ --
4055
+ --SQL> set long 100000
4056
+ --SQL> set lines 120
4057
+ --SQL> set pages 0
4058
+ --SQL>
4059
+ --SQL> -- Display column usage
4060
+ --SQL> select dbms_stats.report_col_usage('sh', 'customers') from dual;
4061
+ --LEGEND:
4062
+ --.......
4063
+ --
4064
+ --EQ : Used in single table EQuality predicate
4065
+ --RANGE : Used in single table RANGE predicate
4066
+ --LIKE : Used in single table LIKE predicate
4067
+ --NULL : Used in single table is (not) NULL predicate
4068
+ --EQ_JOIN : Used in EQuality JOIN predicate
4069
+ --NONEQ_JOIN : Used in NON EQuality JOIN predicate
4070
+ --FILTER : Used in single table FILTER predicate
4071
+ --JOIN : Used in JOIN predicate
4072
+ --GROUP_BY : Used in GROUP BY expression
4073
+ --...............................................................................
4074
+ --
4075
+ --###############################################################################
4076
+ --
4077
+ --COLUMN USAGE REPORT FOR SH.CUSTOMERS
4078
+ --....................................
4079
+ --
4080
+ --1. COUNTRY_ID : EQ
4081
+ --2. CUST_CITY : EQ
4082
+ --3. CUST_STATE_PROVINCE : EQ
4083
+ --4. (CUST_CITY, CUST_STATE_PROVINCE,
4084
+ -- COUNTRY_ID) : FILTER
4085
+ --5. (CUST_STATE_PROVINCE, COUNTRY_ID) : GROUP_BY
4086
+ --###############################################################################
4087
+
4088
+
4089
+
4090
+ procedure gather_database_stats_job_proc;
4091
+
4092
+ procedure cleanup_stats_job_proc(
4093
+ ctx number, job_owner varchar2, job_name varchar2,
4094
+ sesid number, sesser number);
4095
+
4096
+ end;
4097
+ /