Oracle DBMS_SQLTUNE_UTIL2
Version 19.2.0.1

General Information
Library Note Morgan's Library Page Header
For how many years have you been working with physical servers that are starving your database of the memory necessary to deploy important new performance features such as the Result Cache, Memoptimize Pool, In-Memory Aggregation, In-Memory Column Store, and Full Database Caching? Too long? Contact me to learn how to improve all queries ... not just some queries.
Purpose This package is for shared utility functions that need to be part of an INVOKER rights package. Like the other dbms_sqltune_util# packages, it should NOT be documented. If a function only needs to be accessible from the dbms_sqltune/sqldiag/etc feature layer, do not put it here, but rather in the infrastructure layer (prvssqlf). This layer is for code that should be globally accessible, even from the internal package.
AUTHID CURRENT_USER
Constants
Name Data Type Value
General
DB_TYPE_ROOT VARCHAR2(4) 'ROOT'
DB_TYPE_PDB VARCHAR2(3) 'PDB'
DB_TYPE_IMP VARCHAR2(8) 'IMPORTED'
STR_NO VARCHAR2(3) 'no'
STR_YES VARCHAR2(3) 'yes'
Dependencies
DBA_HIST_SNAPSHOT DBMS_SMB PRVTEMX_ADMIN
DBMS_ADVISOR DBMS_SPM PRVTEMX_CELL
DBMS_AUTO_REPORT DBMS_SPM_INTERNAL PRVT_AWRV_METADATA
DBMS_AUTO_REPORT_INTERNAL DBMS_SQLDIAG PRVT_AWR_VIEWER
DBMS_PERF DBMS_SQLPA PRVT_SQLADV_INFRA
DBMS_REPORT DBMS_SQLTUNE PRVT_SQLSET_INFRA
Documented No
Exceptions
Error Code Reason
ORA-13768 Snapshot ID must be between <beginning snap_id> and <max_possible_valid_snap_id>;
First Available 10gR1
Security Model Owned by SYS with EXECUTE granted to PUBLIC
Source {ORACLE_HOME}/rdbms/admin/dbmssqlu.sql
Subprograms
 
CHECK_PRIV
Does a callout into the kernel to check for the given system privilege. It returns TRUE or FALSE if the current user has the privilege enabled. dbms_sqltune_util2.check_priv(priv IN VARCHAR2) RETURN BOOLEAN;
conn / as sysdba
BEGIN
  IF dbms_sqltune_util2.check_priv('SYSDBA') THEN
    dbms_output.put_line('T');
  ELSE
    dbms_output.put_line('F');
  END IF;
END;
/
 
GET_SQLSET_USERBINDS
Used by dbms_sqltune.unpack_sqlsets_bulk: Gets the list of binds of a given SQL statement from a table and converts the list of binds into a varray as required by sqlset_row. dbms_sqltune_util2.get_sqlset_userbinds(
get_sqlset_userbinds(
sql_id          IN VARCHAR2,
plan_hash_value IN NUMBER,
sqlset_name     IN VARCHAR2,
sqlset_owner    IN VARCHAR2,
table_name      IN VARCHAR2)
RETURN sys.sql_binds;
TBD
 
GET_TIMING_INFO
Returns elapsed and CPU timing information for a section of PL/SQL code dbms_sqltune_util2.get_timing_info(
phase   IN     BINARY_INTEGER,
elapsed IN OUT NUMBER,
cpu     IN OUT NUMBER);
TBD
 
IS_IMPORTED_CDB
Checks whether the dbid is imported CDB or not dbms_sqltune_util2.is_imported_cdb(p_dbid IN NUMBER)
RETURN VARCHAR22;
SQL> SELECT dbid
  2  FROM v$database;

      DBID
----------
 549318987

SQL> SELECT dbms_sqltune_util2.is_imported_cdb(549318987)
  2  FROM dual;

DBMS_SQLTUNE_UTIL2.IS_IMPORTED_CDB(549318987)
---------------------------------------------
no
 
IS_IMPORTED_PDB
hecks whether the dbid is imported PDB or not dbms_sqltune_util2.is_imported_pdb(p_dbid IN NUMBER)
RETURN VARCHAR22;
SQL> SELECT dbid, name
  2  FROM v$containers
  3  ORDER BY 2;

DBID       NAME
---------- ----------
549318987  CDB$ROOT
700560205  PDB$SEED
542716466  PDBDEV
2341452460 PDBTEST

SQL> SELECT dbms_sqltune_util2.is_imported_pdb(700560205)
  2  FROM dual;

DBMS_SQLTUNE_UTIL2.IS_IMPORTED_CDB(700560205)
---------------------------------------------
no
 
IS_RAS_USER
Returns TRUE or FALSE based if the current user is a Real Application Security User (RAS) user. This function is used by create_tuning_task, schedule_tuning_task and create_analysis_task. dbms_sqltune_util2.is_ras_user RETURN BOOLEAN;
BEGIN
  IF dbms_sqltune_util2.is_ras_user THEN
    dbms_output.put_line('Using Real Application Security');
  ELSE
    dbms_output.put_line('Not Using Real Application Security');
  END IF;
END;
/
 
RESOLVE_DATABASE_TYPE
Resolves the type of database that corresponds to the dbid given as parameter. It is used by get_awr_view_location function to determine the location of AWR views. dbms_sqltune_util2.resolve_database_type(dbid IN NUMBER)
RETURN VARCHAR2;
SQL> SELECT dbid
  2  FROM v$database;

DBID
----------
549318987

SQL> SELECT dbms_sqltune_util2.resolve_database_type(549318987)
  2  FROM dual;

DBMS_SQLTUNE_UTIL2.RESOLVE_DATABASE_TYPE(549318987)
----------------------------------------------------
ROOT
 
RESOLVE_USERNAME
When passed a NULL name, this function returns the current schema owner. Otherwise, it returns the name passed in, after validating it. dbms_sqltune_util2.resolve_username(
user_name IN VARCHAR2,
validate  IN BOOLEAN := TRUE,
con_id    IN NUMBER  := NULL)
RETURN VARCHAR2;
conn uwclass/uwclass@pdbdev

DECLARE
 retVal VARCHAR2(30);
BEGIN
  retVal := dbms_sqltune_util2.resolve_username(USER);
  dbms_output.put_line(retVal);
END;
/
 
SQL_BINDS_NTAB_TO_VARRAY
Converts the sql binds data from the nested table stored in the staging table on an unpack/pack to the varray type used in the SQLSET_ROW dbms_sqltune_util2.sql_binds_ntab_to_varray(
binds_ntab IN sys.sql_bind_set)
RETURN sys.sql_binds;
TBD
 
SQL_BINDS_VARRAY_TO_NTAB
Converts the sql binds data from a VARRAY as it exists in SQLSET_ROW into a nested table that can be stored in the staging table dbms_sqltune_util2.sql_binds_varray_to_ntab(binds_varray IN sys.sql_binds)
RETURN sys.sql_bind_set;
TBD
 
VALIDATE_SNAPSHOT
Checks whether a snapshot id interval is valid. It raises an error if passed an invalid interval. dbms_sqltune_util2.validate_snapshot(
begin_snap IN NUMBER,
end_snap   IN NUMBER,
incl_bid   IN BOOLEAN := FALSE);
SELECT TO_CHAR(s.startup_time,' DD MON "at" HH24:MI:SS') INSTART_FMT,
di.instance_name INST_NAME, di.db_name DB_NAME, s.snap_id SNAP_ID,
TO_CHAR(s.end_interval_time,'DD MON YYYY HH24:MI') SNAPDAT, s.snap_level LVL
FROM dba_hist_snapshot s, dba_hist_database_instance di
WHERE di.dbid = s.dbid
AND di.instance_number = s.instance_number
AND di.startup_time = s.startup_time
ORDER BY snap_id;

exec dbms_sqltune_util2.validate_snapshot(2376, 2391);

SELECT max(snap_id)+100
FROM dba_hist_snapshot;

exec dbms_sqltune_util2.validate_snapshot(2376, 9999);
 
VARR_TO_HINTS
Converts sqlprof_attr object type to XML format dbms_sqltune_util2.varr_to_hints_xml(varr IN sqlprof_attr)
RETURN CLOB;
TBD

Related Topics
Built-in Functions
Built-in Packages
DBMS_AUTO_SQLTUNE
DBMS_SQLDIAG
DBMS_SQLPA
DBMS_SQLSET
DBMS_SQLTUNE
DBMS_SQLTUNE_UTIL0
DBMS_SQLTUNE_UTIL1
PRVTEMX_PERF
What's New In 18cR3
What's New In 19cR2

Morgan's Library Page Footer
This site is maintained by Dan Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2019 Daniel A. Morgan All Rights Reserved