All sql

[./solutions/atonx.sql]
REM
REM script ATONX.SQL
REM =====================================
SET AUTOTRACE ON EXPLAIN
[./solutions/saved_settings.sql]
set appinfo OFF
set appinfo "SQL*Plus"
set arraysize 15
set autocommit OFF
set autoprint OFF
set autorecovery OFF
set autotrace OFF
set blockterminator "."
set cmdsep OFF
set colsep " "
set compatibility NATIVE
set concat "."
set copycommit 0
set copytypecheck ON
set define "&"
set describe DEPTH 1 LINENUM OFF INDENT ON
set echo OFF
set editfile "afiedt.buf"
set embedded OFF
set escape OFF
set feedback ON
set flagger OFF
set flush ON
set heading ON
set headsep "|"
set linesize 80
set logsource ""
set long 80
set longchunksize 80
set markup HTML OFF HEAD "<style type='text/css'> body {font:10pt Arial,Helvetica,sans-serif; color:black; background:White;} p {font:10pt Arial,Helvetica,sans-serif; color:black; background:White;} table,tr,td {font:10pt Arial,Helvetica,sans-serif; color:Black; background:#f7f7e7; padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;} th {font:bold 10pt Arial,Helvetica,sans-serif; color:#336699; background:#cccc99; padding:0px 0px 0px 0px;} h1 {font:16pt Arial,Helvetica,Geneva,sans-serif; color:#336699; background-color:White; border-bottom:1px solid #cccc99; margin-top:0pt; margin-bottom:0pt; padding:0px 0px 0px 0px;} h2 {font:bold 10pt Arial,Helvetica,Geneva,sans-serif; color:#336699; background-color:White; margin-top:4pt; margin-bottom:0pt;} a {font:9pt Arial,Helvetica,sans-serif; color:#663300; background:#ffffff; margin-top:0pt; margin-bottom:0pt; vertical-align:top;}</style><title>SQL*Plus Report</title>" BODY "" TABLE "border='1' width='90%' align='center' summary='Script output'" SPOOL OFF ENTMAP ON PRE ON
set newpage 1
set null ""
set numformat ""
set numwidth 10
set pagesize 14
set pause OFF
set recsep WRAP
set recsepchar " "
set serveroutput OFF
set shiftinout invisible
set showmode OFF
set sqlblanklines OFF
set sqlcase MIXED
set sqlcontinue "> "
set sqlnumber ON
set sqlpluscompatibility 8.1.7
set sqlprefix "#"
set sqlprompt "SQL> "
set sqlterminator ";"
set suffix "sql"
set tab ON
set termout OFF
set time OFF
set timing OFF
set trimout ON
set trimspool OFF
set underline "-"
set verify ON
set wrap ON
[./solutions/sol_06_04d.sql]
-- this script requires the sql id from the previous script to be substituted
SELECT PLAN_TABLE_OUTPUT      
FROM TABLE (DBMS_XPLAN.DISPLAY_AWR(' your sql id here'));
[./solutions/rpsqlarea.sql]
set feedback off
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR('your sql_id here'));
set feedback on
[./solutions/sqlid2.sql]
SELECT SQL_ID, SQL_TEXT FROM V$SQL
WHERE SQL_TEXT LIKE '%REPORT%' ;
[./solutions/schemastats.sql]
SELECT last_analyzed analyzed, sample_size, monitoring,
table_name
FROM user_tables;
[./solutions/allrows.sql]
REM
REM script ALLROWS.SQL
REM =====================================
alter session set optimizer_mode = all_rows
[./solutions/aton.sql]
REM
REM script ATON.SQL
REM =====================================
SET AUTOTRACE ON
[./solutions/li.sql]
REM script LI.SQL (list indexes)
REM wildcards in table_name allowed,
REM and a '%' is appended by default
REM ======================================
set termout off
store set sqlplus_settings replace
save buffer.sql replace
set verify off autotrace off
set feedback off termout on
break on table_name skip 1 on index_type
col table_name format a25
col index_name format a30
col index_type format a20
accept table_name -
prompt 'List indexes on table : '
SELECT ui.table_name
, decode(ui.index_type
,'NORMAL', ui.uniqueness
,ui.index_type) AS index_type
, ui.index_name
FROM user_indexes ui
WHERE ui.table_name LIKE upper('&table_name.%')
ORDER BY ui.table_name
, ui.uniqueness desc;
get buffer.sql nolist
@sqlplus_settings
set termout on
[./solutions/utlxplp.sql]
Rem
Rem $Header: utlxplp.sql 23-jan-2002.08:55:23 bdagevil Exp $
Rem
Rem utlxplp.sql
Rem
Rem Copyright (c) 1998, 2002, Oracle Corporation. All rights reserved.
Rem
Rem NAME
Rem utlxplp.sql - UTiLity eXPLain Parallel plans
Rem
Rem DESCRIPTION
Rem script utility to display the explain plan of the last explain plan
Rem     command. Display also Parallel Query information if the plan happens to
Rem run parallel
Rem
Rem NOTES
Rem Assume that the table PLAN_TABLE has been created. The script
Rem utlxplan.sql should be used to create that table
Rem
Rem With SQL*plus, it is recomended to set linesize and pagesize before
Rem running this script. For example:
Rem     set linesize 130
Rem     set pagesize 0
Rem
Rem MODIFIED (MM/DD/YY)
Rem bdagevil 01/23/02 - rewrite with new dbms_xplan package
Rem bdagevil 04/05/01 - include CPU cost
Rem bdagevil 02/27/01 - increase Name column
Rem jihuang 06/14/00 - change order by to order siblings by.
Rem jihuang 05/10/00 - include plan info for recursive SQL in LE row source
Rem bdagevil 01/05/00 - make deterministic with order-by
Rem bdagevil 05/07/98 - Explain plan script for parallel plans
Rem bdagevil 05/07/98 - Created
Rem
set markup html preformat on
Rem
Rem Use the display table function from the dbms_xplan package to display the last
Rem explain plan. Use default mode which will display only relevant information
Rem
select * from table(dbms_xplan.display());
[./solutions/cbinp.sql]
REM Oracle10g SQL Tuning Workshop
REM script CBI.SQL (create bitmap index)
REM prompts for input; index name generated
REM =======================================
accept TABLE_NAME prompt " on which table : "
accept COLUMN_NAME prompt " on which column: "
set termout off
store set saved_settings replace
set heading off feedback off verify off
set autotrace off termout on
column dummy new_value index_name
SELECT 'creating index'
, SUBSTR( SUBSTR('&table_name',1,4)||'_' ||
TRANSLATE(REPLACE('&column_name', ' ', '')
, 1, 25
)||'_idx' dummy
FROM dual;
CREATE BITMAP INDEX &index_name ON &TABLE_NAME(&COLUMN_NAME)
NOLOGGING COMPUTE STATISTICS
@saved_settings
set termout on
undef INDEX_NAME
undef TABLE_NAME
undef COLUMN_NAME
[./solutions/dump.sql]
SElECT *
FROM v$parameter
WHERE name LIKE '%dump%';
[./solutions/utlxplan.sql]
rem
rem $Header: utlxplan.sql 29-oct-2001.20:28:58 mzait Exp $ xplainpl.sql
rem
Rem Copyright (c) 1988, 2001, Oracle Corporation. All rights reserved.
Rem NAME
REM UTLXPLAN.SQL
Rem FUNCTION
Rem NOTES
Rem MODIFIED
Rem mzait 10/26/01 - add keys and filter predicates to the plan table
Rem ddas 05/05/00 - increase length of options column
Rem ddas 04/17/00 - add CPU, I/O cost, temp_space columns
Rem mzait 02/19/98 - add distribution method column
Rem ddas 05/17/96 - change search_columns to number
Rem achaudhr 07/23/95 - PTI: Add columns partition_{start, stop, id}
Rem glumpkin 08/25/94 - new optimizer fields
Rem jcohen 11/05/93 - merge changes from branch 1.1.710.1 - 9/24
Rem jcohen 09/24/93 - #163783 add optimizer column
Rem glumpkin 10/25/92 - Renamed from XPLAINPL.SQL
Rem jcohen 05/22/92 - #79645 - set node width to 128 (M_XDBI in gendef)
Rem rlim 04/29/91 - change char to varchar2
Rem Peeler 10/19/88 - Creation
Rem
Rem This is the format for the table that is used by the EXPLAIN PLAN
Rem statement. The explain statement requires the presence of this
Rem table in order to store the descriptions of the row sources.
create table PLAN_TABLE (
     statement_id      varchar2(30),
     timestamp      date,
     remarks      varchar2(80),
     operation      varchar2(30),
     options      varchar2(255),
     object_node      varchar2(128),
     object_owner      varchar2(30),
     object_name      varchar2(30),
     object_instance numeric,
     object_type varchar2(30),
     optimizer varchar2(255),
     search_columns number,
     id          numeric,
     parent_id     numeric,
     position     numeric,
     cost          numeric,
     cardinality     numeric,
     bytes          numeric,
     other_tag varchar2(255),
     partition_start varchar2(255),
partition_stop varchar2(255),
partition_id numeric,
     other          long,
     distribution varchar2(30),
     cpu_cost     numeric,
     io_cost          numeric,
     temp_space     numeric,
access_predicates varchar2(4000),
filter_predicates varchar2(4000));
[./solutions/indstats.sql]
accept table_name -
prompt 'on which table : '
SELECT index_name name, num_rows n_r,
last_analyzed l_a, distinct_keys d_k,
leaf_blocks l_b, avg_leaf_blocks_per_key a_l,join_index j_I
FROM user_indexes
WHERE table_name = upper('&table_name');
undef table_name
[./solutions/test.sql]
declare
x number;
begin
for i in 1..10000 loop
select count(*) into x from customers;
end loop;
end;
[./solutions/rp.sql]
set feedback off
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
set feedback on
[./solutions/sol_08_02b.sql]
ALTER SESSION SET SQL_TRACE = TRUE;
[./solutions/trace.sql]
ALTER SESSION SET SQL_TRACE = TRUE;
[./solutions/doit.sql]
DROP INDEX SALES_CH_BIX;
DROP INDEX SALES_CUST_BIX;
DROP INDEX SALES_PROD_BIX;
[./solutions/ci.sql]
REM SQL Tuning Workshop
REM script CI.SQL (create index)
REM prompts for input; index name generated
REM =======================================
accept TABLE_NAME prompt " on which table : "
accept COLUMN_NAME prompt " on which column(s): "
set termout off
store set saved_settings replace
set heading off feedback off autotrace off
set verify off termout on
column dummy new_value index_name
SELECT 'creating index'
, SUBSTR( SUBSTR('&table_name',1,4)||'_' ||
TRANSLATE(REPLACE('&column_name', ' ', '')
, 1, 25
)||'_idx' dummy
FROM dual;
CREATE INDEX &index_name
ON &table_name(&column_name)
NOLOGGING COMPUTE STATISTICS;
@saved_settings
set termout on
undef INDEX_NAME
undef TABLE_NAME
undef COLUMN_NAME
[./solutions/sol_06_04c.sql]
exec dbms_workload_repository.create_snapshot('ALL');
[./solutions/sol_06_04a.sql]
column sql_text format a25
SELECT SQL_ID, SQL_TEXT FROM V$SQL
WHERE SQL_TEXT LIKE '%REPORT%' ;
[./solutions/login.sql]
REM ======================================
REM COL[UMN] commands
REM ======================================
col dummy new_value index_name
col name format a32
col segment_name format a20
col table_name format a20
col column_name format a20
col index_name format a30
col index_type format a10
col constraint_name format a20
col num_distinct format 999999
col update_comment format a20 word
-- for the SHOW SGA/PARAMETER commands:
col name_col_plus_show_sga format a24
col name_col_plus_show_param format a40 -
heading name
col value_col_plus_show_param format a35 -
heading value
-- for the AUTOTRACE setting:
col id_plus_exp format 90 head i
col parent_id_plus_exp format 90 head p
col plan_plus_exp format a80
col other_plus_exp format a44
col other_tag_plus_exp format a29
col object_node_plus_exp format a8
REM ======================================
REM SET commands
REM ======================================
set describe depth 2
set echo off
set editfile D:\Tmp\buffer.sql
set feedback 40
set linesize 120
set long 999
set numwidth 8
set pagesize 36
set pause "[Enter]..." pause off
set tab off
set trimout on
set trimspool on
set verify off
set wrap on
REM ======================================
REM DEFINE commands
REM ======================================
def 1=employees
def table_name=employees
def column_name=first_name
def buckets=1
def sc=';'
REM ======================================
REM miscellaneous
REM ======================================
[./solutions/sqlid.sql]
SELECT SQL_ID, SQL_TEXT FROM V$SQL
WHERE SQL_TEXT LIKE '%/* my%' ;
[./solutions/hist1.sql]
SELECT * FROM products WHERE prod_status LIKE 'available, on stock'
[./solutions/sol_08_02.sql]
ALTER SESSION SET TRACEFILE_IDENTIFIER = 'User12';
[./solutions/utlxrw.sql]
Rem
Rem $Header: utlxrw.sql 29-apr-2005.08:22:09 mthiyaga Exp $
Rem
Rem utlxrw.sql
Rem
Rem Copyright (c) 2000, 2005, Oracle. All rights reserved.
Rem
Rem NAME
Rem utlxrw.sql - Create the output table for EXPLAIN_REWRITE
Rem
Rem DESCRIPTION
Rem Outputs of the EXPLAIN_REWRITE goes into the table created
Rem by utlxrw.sql (called REWRITE_TABLE). So utlxrw must be
Rem     invoked before any EXPLAIN_REWRITE tests.
Rem
Rem NOTES
Rem If user specifies a different name in EXPLAIN_REWRITE, then
Rem it should have been already created before calling EXPLAIN_REWRITE.
Rem
Rem MODIFIED (MM/DD/YY)
Rem mthiyaga 04/29/05 - Remove unncessary comment
Rem mthiyaga 06/08/04 - Add rewritten_txt field
Rem mthiyaga 10/10/02 - Add extra columns
Rem mthiyaga 09/27/00 - Create EXPLAIN_REWRITE output table
Rem mthiyaga 09/27/00 - Created
Rem
Rem
CREATE TABLE REWRITE_TABLE(
statement_id VARCHAR2(30), -- id for the query
mv_owner VARCHAR2(30), -- owner of the MV
mv_name VARCHAR2(30), -- name of the MV
sequence INTEGER, -- sequence no of the error msg
query VARCHAR2(2000),-- user query
query_block_no INTEGER, -- block no of the current subquery
rewritten_txt VARCHAR2(2000),-- rewritten query
message VARCHAR2(512), -- EXPLAIN_REWRITE error msg
pass VARCHAR2(3), -- rewrite pass no
mv_in_msg VARCHAR2(30), -- MV in current message
measure_in_msg VARCHAR2(30), -- Measure in current message
join_back_tbl VARCHAR2(30), -- Join back table in current msg
join_back_col VARCHAR2(30), -- Join back column in current msg
original_cost INTEGER, -- Cost of original query
rewritten_cost INTEGER, -- Cost of rewritten query
flags INTEGER, -- associated flags
reserved1 INTEGER, -- currently not used
reserved2 VARCHAR2(10)) -- currently not used
[./solutions/nm.sql]
ALTER INDEX &indexname NOMONITORING USAGE;
[./solutions/attox.sql]
REM
REM script ATTOX.SQL
REM =====================================
set autotrace traceonly explain
[./solutions/create_tab.sql]
DROP TABLE test_sales;
DROP TABLE test_promotions;
DROP TABLE test_customers;
DROP TABLE test_countries;
CREATE table test_sales as select * from sales;
CREATE TABLE test_promotions AS SELECT * FROM promotions;
CREATE INDEX t_promo_id_idx ON TEST_PROMOTIONS(promo_id);
ALTER TABLE test_promotions MODIFY promo_id PRIMARY KEY USING INDEX t_promo_id_idx;
CREATE TABLE test_customers AS SELECT * FROM customers;
CREATE INDEX t_cust_id_idx ON TEST_CUSTOMERS(cust_id);
ALTER TABLE test_customers MODIFY cust_id PRIMARY KEY USING INDEX t_cust_id_idx;
CREATE TABLE test_countries AS SELECT * FROM countries;
CREATE INDEX t_country_id_idx ON TEST_COUNTRIES(country_id);
ALTER TABLE test_countries MODIFY country_id PRIMARY KEY USING INDEX t_country_id_idx;
UPDATE test_customers SET cust_credit_limit = 1000 WHERE ROWNUM <= 15000;
[./solutions/cui.sql]
REM SQL Tuning Workshop
REM script CUI.SQL (create unique index)
REM prompts for input; index name generated
REM =======================================
accept TABLE_NAME prompt " on which table : "
accept COLUMN_NAME prompt " on which column(s): "\
set termout off
store set saved_settings replace
set heading off feedback off verify off
set autotrace off termout on
SELECT 'creating unique index'
, SUBSTR('ui_&TABLE_NAME._' ||
TRANSLATE(REPLACE('&COLUMN_NAME', ' ', '')
, 1, 30) dummy
from dual
CREATE UNIQUE INDEX &INDEX_NAME ON &TABLE_NAME(&COLUMN_NAME)
@saved_settings
set termout on
undef INDEX_NAME
undef TABLE_NAME
undef COLUMN_NAME
[./solutions/advisor_cache_setup.sql]
set echo on
alter system flush shared_pool;
grant advisor to sh;
connect sh/sh;
SELECT c.cust_last_name, sum(s.amount_sold) AS dollars,
sum(s.quantity_sold) as quantity
FROM sales s , customers c, products p
WHERE c.cust_id = s.cust_id
AND s.prod_id = p.prod_id
AND c.cust_state_province IN ('Dublin','Galway')
GROUP BY c.cust_last_name;
SELECT c.cust_id, SUM(amount_sold) AS dollar_sales
FROM sales s, customers c WHERE s.cust_id= c.cust_id GROUP BY c.cust_id;
select sum(unit_cost) from costs group by prod_id;
[./solutions/utlxmv.sql]
Rem
Rem $Header: utlxmv.sql 16-feb-2001.13:03:32 nshodhan Exp $
Rem
Rem utlxmv.sql
Rem
Rem Copyright (c) Oracle Corporation 2000. All Rights Reserved.
Rem
Rem NAME
Rem utlxmv.sql - UTiLity for eXplain MV
Rem
Rem DESCRIPTION
Rem The utility script creates the MV_CAPABILITIES_TABLE that is
Rem used by the DBMS_MVIEW.EXPLAIN_MVIEW() API.
Rem
Rem NOTES
Rem
Rem MODIFIED (MM/DD/YY)
Rem nshodhan 02/16/01 - Bug#1647071: replace mv with mview
Rem raavudai 11/28/00 - Fix comment.
Rem twtong 12/01/00 - fix for sql*plus
Rem twtong 09/13/00 - modify mv_capabilities_tabe
Rem twtong 08/18/00 - change create table to upper case
Rem jraitto 06/12/00 - add RELATED_NUM and MSGNO columns
Rem jraitto 05/09/00 - Explain_MV table
Rem jraitto 05/09/00 - Created
Rem
CREATE TABLE MV_CAPABILITIES_TABLE
(STATEMENT_ID VARCHAR(30), -- Client-supplied unique statement identifier
MVOWNER VARCHAR(30), -- NULL for SELECT based EXPLAIN_MVIEW
MVNAME VARCHAR(30), -- NULL for SELECT based EXPLAIN_MVIEW
CAPABILITY_NAME VARCHAR(30), -- A descriptive name of the particular
-- capability:
-- REWRITE
-- Can do at least full text match
-- rewrite
-- REWRITE_PARTIAL_TEXT_MATCH
-- Can do at leat full and partial
-- text match rewrite
-- REWRITE_GENERAL
-- Can do all forms of rewrite
-- REFRESH
-- Can do at least complete refresh
-- REFRESH_FROM_LOG_AFTER_INSERT
-- Can do fast refresh from an mv log
-- or change capture table at least
-- when update operations are
-- restricted to INSERT
-- REFRESH_FROM_LOG_AFTER_ANY
-- can do fast refresh from an mv log
-- or change capture table after any
-- combination of updates
-- PCT
-- Can do Enhanced Update Tracking on
-- the table named in the RELATED_NAME
-- column. EUT is needed for fast
-- refresh after partitioned
-- maintenance operations on the table
-- named in the RELATED_NAME column
-- and to do non-stale tolerated
-- rewrite when the mv is partially
-- stale with respect to the table
-- named in the RELATED_NAME column.
-- EUT can also sometimes enable fast
-- refresh of updates to the table
-- named in the RELATED_NAME column
-- when fast refresh from an mv log
-- or change capture table is not
-- possilbe.
POSSIBLE CHARACTER(1), -- T = capability is possible
-- F = capability is not possible
RELATED_TEXT VARCHAR(2000),-- Owner.table.column, alias name, etc.
-- related to this message. The
-- specific meaning of this column
-- depends on the MSGNO column. See
-- the documentation for
-- DBMS_MVIEW.EXPLAIN_MVIEW() for details
RELATED_NUM NUMBER, -- When there is a numeric value
-- associated with a row, it goes here.
-- The specific meaning of this column
-- depends on the MSGNO column. See
-- the documentation for
-- DBMS_MVIEW.EXPLAIN_MVIEW() for details
MSGNO INTEGER, -- When available, QSM message #
-- explaining why not possible or more
-- details when enabled.
MSGTXT VARCHAR(2000),-- Text associated with MSGNO.
SEQ NUMBER);
                    -- Useful in ORDER BY clause when
-- selecting from this table.
[./solutions/di.sql]
DROP INDEX &index_name;
[./solutions/hist2.sql]
SELECT * FROM products WHERE prod_status = 'obsolete'
[./solutions/sol_06_04b.sql]
-- this script requires the sql_id that you got from the previous step
SELECT SQL_ID, SQL_TEXT FROM dba_hist_sqltext where sql_id ='yourr sql id here';
[./solutions/tabstats.sql]
accept table_name -
prompt 'on which table : '
SELECT last_analyzed analyzed, sample_size, monitoring,
table_name
FROM user_tables
WHERE table_name = upper('&table_name');
undef TABLE_NAME
[./solutions/rewrite.sql]
ALTER SESSION SET QUERY_REWRITE_ENABLED = true
[./solutions/atto.sql]
REM
REM script ATTO.SQL
REM =====================================
set autotrace traceonly
[./solutions/flush.sql]
--this script flushes the shared pool
alter system flush shared_pool
[./solutions/atoff.sql]
REM
REM script ATOFF.SQLREM =====================================
SET AUTOTRACE OFF
[./solutions/cbi.sql]
REM Oracle10g SQL Tuning Workshop
REM script CBI.SQL (create bitmap index)
REM prompts for input; index name generated
REM =======================================
accept TABLE_NAME prompt " on which table : "
accept COLUMN_NAME prompt " on which column: "
set termout off
store set saved_settings replace
set heading off feedback off verify off
set autotrace off termout on
column dummy new_value index_name
SELECT 'creating index'
, SUBSTR( SUBSTR('&table_name',1,4)||'_' ||
TRANSLATE(REPLACE('&column_name', ' ', '')
, 1, 25
)||'_idx' dummy
FROM dual;
CREATE bitmap index &INDEX_NAME on &TABLE_NAME(&COLUMN_NAME)
LOCAL NOLOGGING COMPUTE STATISTICS
@saved_settings
set termout on
undef INDEX_NAME
undef TABLE_NAME
undef COLUMN_NAME
[./solutions/buffer.sql]
SELECT c.cust_last_name, c.cust_year_of_birth
, co.country_name
FROM customers c
JOIN countries co
USING (country_id)
[./solutions/sol_08_04.sql]
ALTER SESSION SET SQL_TRACE = false;
[./solutions/sqlplus_settings.sql]
set appinfo OFF
set appinfo "SQL*Plus"
set arraysize 15
set autocommit OFF
set autoprint OFF
set autorecovery OFF
set autotrace TRACEONLY EXPLAIN STATISTICS
set blockterminator "."
set cmdsep OFF
set colsep " "
set compatibility NATIVE
set concat "."
set copycommit 0
set copytypecheck ON
set define "&"
set describe DEPTH 1 LINENUM OFF INDENT ON
set echo OFF
set editfile "afiedt.buf"
set embedded OFF
set escape OFF
set feedback 6
set flagger OFF
set flush ON
set heading ON
set headsep "|"
set linesize 80
set logsource ""
set long 80
set longchunksize 80
set markup HTML OFF HEAD "<style type='text/css'> body {font:10pt Arial,Helvetica,sans-serif; color:black; background:White;} p {font:10pt Arial,Helvetica,sans-serif; color:black; background:White;} table,tr,td {font:10pt Arial,Helvetica,sans-serif; color:Black; background:#f7f7e7; padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;} th {font:bold 10pt Arial,Helvetica,sans-serif; color:#336699; background:#cccc99; padding:0px 0px 0px 0px;} h1 {font:16pt Arial,Helvetica,Geneva,sans-serif; color:#336699; background-color:White; border-bottom:1px solid #cccc99; margin-top:0pt; margin-bottom:0pt; padding:0px 0px 0px 0px;} h2 {font:bold 10pt Arial,Helvetica,Geneva,sans-serif; color:#336699; background-color:White; margin-top:4pt; margin-bottom:0pt;} a {font:9pt Arial,Helvetica,sans-serif; color:#663300; background:#ffffff; margin-top:0pt; margin-bottom:0pt; vertical-align:top;}</style><title>SQL*Plus Report</title>" BODY "" TABLE "border='1' width='90%' align='center' summary='Script output'" SPOOL OFF ENTMAP ON PRE OFF
set newpage 1
set null ""
set numformat ""
set numwidth 10
set pagesize 14
set pause OFF
set recsep WRAP
set recsepchar " "
set serveroutput OFF
set shiftinout invisible
set showmode OFF
set sqlblanklines OFF
set sqlcase MIXED
set sqlcontinue "> "
set sqlnumber ON
set sqlpluscompatibility 8.1.7
set sqlprefix "#"
set sqlprompt "SQL> "
set sqlterminator ";"
set suffix "sql"
set tab ON
set termout OFF
set time OFF
set timing OFF
set trimout ON
set trimspool OFF
set underline "-"
set verify ON
set wrap ON
[./solutions/sol_07_01.sql]
SELECT owner, job_name,enabled
FROM DBA_SCHEDULER_JOBS
WHERE JOB_NAME = 'GATHER_STATS_JOB';
[./solutions/colhist.sql]
SELECT column_name, num_distinct, num_buckets, histogram
FROM USER_TAB_COL_STATISTICS
WHERE histogram <> 'NONE';
[./solutions/rpawr.sql]
set feedback off
SELECT PLAN_TABLE_OUTPUT      
FROM TABLE (DBMS_XPLAN.DISPLAY_AWR('&sqlid'));
set feedback on
[./solutions/im.sql]
ALTER INDEX &indexname MONITORING USAGE;
[./solutions/utlxpls.sql]
Rem
Rem $Header: utlxpls.sql 26-feb-2002.19:49:37 bdagevil Exp $
Rem
Rem utlxpls.sql
Rem
Rem Copyright (c) 1998, 2002, Oracle Corporation. All rights reserved.
Rem
Rem NAME
Rem utlxpls.sql - UTiLity eXPLain Serial plans
Rem
Rem DESCRIPTION
Rem script utility to display the explain plan of the last explain plan
Rem     command. Do not display information related to Parallel Query
Rem
Rem NOTES
Rem Assume that the PLAN_TABLE table has been created. The script
Rem     utlxplan.sql should be used to create that table
Rem
Rem With SQL*plus, it is recomended to set linesize and pagesize before
Rem running this script. For example:
Rem     set linesize 100
Rem     set pagesize 0
Rem
Rem MODIFIED (MM/DD/YY)
Rem bdagevil 02/26/02 - cast arguments
Rem bdagevil 01/23/02 - rewrite with new dbms_xplan package
Rem bdagevil 04/05/01 - include CPU cost
Rem bdagevil 02/27/01 - increase Name column
Rem jihuang 06/14/00 - change order by to order siblings by.
Rem jihuang 05/10/00 - include plan info for recursive SQL in LE row source
Rem bdagevil 01/05/00 - add order-by to make it deterministic
Rem kquinn 06/28/99 - 901272: Add missing semicolon
Rem bdagevil 05/07/98 - Explain plan script for serial plans
Rem bdagevil 05/07/98 - Created
Rem
set markup html preformat on
Rem
Rem Use the display table function from the dbms_xplan package to display the last
Rem explain plan. Force serial option for backward compatibility
Rem
select plan_table_output from table(dbms_xplan.display('plan_table',null,'serial'));
[./solutions/dai.sql]
REM script DAI.SQL (drop all indexes)
REM prompts for a table name; % is appended
REM does not touch indexes associated with constraints
REM ==================================================
accept table_name -
prompt 'on which table : '
set termout off
store set sqlplus_settings replace
save buffer.sql replace
set heading off verify off autotrace off feedback off
spool doit.sql
SELECT 'drop index '||i.index_name||';'
FROM user_indexes i
WHERE i.table_name LIKE UPPER('&table_name.%')
AND NOT EXISTS
(SELECT 'x'
FROM user_constraints c
WHERE c.index_name = i.index_name
AND c.table_name = i.table_name
AND c.status = 'ENABLED');
spool off
@doit
get buffer.sql nolist
@sqlplus_settings
set termout on
[./solutions/setupenv.sql]
connect system/oracle
GRANT DBA TO sh;
GRANT CREATE ANY OUTLINE TO sh;
GRANT ADVISOR TO sh;
GRANT CREATE ANY VIEW TO sh;
EXECUTE DBMS_

What an insane topic. Where's your question?
I recommend you to start over with a smart question and only the relevant code lines.
Check this link: [How To Ask Questions The Smart Way|http://www.catb.org/~esr/faqs/smart-questions.html].

Similar Messages

  • Calling all SQL Server users! May TechNet Gurus announced!

    The results for May's
    TechNet Guru competition have been posted!
    http://blogs.technet.com/b/wikininjas/archive/2014/01/16/technet-guru-awards-december-2013.aspx
    Congratulations to all our new Gurus for May!
    We will be interviewing some of the winners and highlighting their achievements, as the month unfolds.
    Post your JUNE contributions here:
    http://social.technet.microsoft.com/wiki/contents/articles/24692.technet-guru-contributions-for-june-2014.aspx
    Read all about June's competition, hopefully in a stickied post, at the top of this forum.
    Below is a summary of the medal winners for May. The last column being a few of the comments from the judges.
    Unfortunately, runners up and their judge feedback comments had to be trimmed from THIS post, to fit into the forum's 60,000 character limit, however
    the full version is available on TechNet Wiki.
    Some articles only just missed out, so we may be returning to discuss those too, in future blogs.
     BizTalk Technical Guru - May 2014  
    Peter Lindgren
    BizTalk 2010: Call SSO from Orchestration
    TGN: "I bet a few people will love you for this, I often see this question at the forums, and you answered it well. Good work!"
    Mandi Ohlinger: "Great topic and great explanation. It also makes SSO seem less scary :)"
    Sandro Pereira: "Very useful sample, well explained with all the necessary code "
    boatseller
    BizTalk: Using an Orchestration Sync or Async
    Sandro Pereira: "Good sample provide by boatseller and well explained."
    TGN: "Hey, great work man! This is a well done article and I love it!"
    Steef-Jan Wiggers
    Exposing data through BizTalk Service Hybrid Connections
    Sandro Pereira: "Nice article with a good overview about BizTalk Service Hybrid Connections and how you can configure them."
    TGN: "Good article, well explained and good pictures. Again Steef-Jan, you know what you're doing!"
    Mandi Ohlinger: "Nice set-up overview. "
     Forefront Identity Manager Technical Guru - May 2014  
    Sheldon.Jaquay
    Forefront Identity Manager - RCDC - Regular Expression
    AM: "Great contribution! Option C is clever, and the other examples are also a useful reference. Thanks for sharing your work with the community."
    Ed Price: "Nice short article. Great topic, and great blend of code, color, and images!"
    Søren Granfeldt: "Nice with a little focus on RegEx with FIM and good help for people wanting to have the portal be just a little more company specific"
    GO: "Thanks for the article, but the images weren't clear enough."
    Scott Eastin
    Installing Oracle MA for FIM R2 on Windows 2012
    GO: "EX-CE-LL-EN-T article!"
    AM: "Very nice article with clear step-by-step instructions - thanks for putting this together. "
    Ed Price: "I love the sections with numbered bullets at the end. They're very clear and easy to read!"
     Microsoft Azure Technical Guru - May 2014  
    João Sousa
    Microsoft Azure - Remote Debbuging How To?
    GO: "Clever. Well Explained and written. Thanks! You absolutely deserve the GOLD medal."
    Ed Price: "Fantastic topic and great use of images!"
    Alex Mang
    The Move to the New Azure SQL Database Tiers
    Ed Price: "Great depth and descriptions! Very timely topic! Lots of collaboration on this article from community members!"
    GO: "great article but images are missing"
    Alex Mang
    Separating Insights Data In Visual Studio Online
    Application Insights For Production And Staging Cloud Services
    Ed Price: "Good descriptions and clarity!"
    GO: "great article but images are missing"
     Microsoft Visio Technical Guru - May 2014  
    Mr X
    How to export your Orchestrator Runbooks to Visio and Word
    Ed Price: "A basic tip, but very helpful. Good job!"
    GO: "Thanks for that!"
    SR: "Nice "How To" article explaining the basic steps."
    AH: "This article is to the point takes a simple tasks and describes it accurately.
     SharePoint 2010 / 2013 Technical Guru - May 2014  
    Dan Christian
    Build a loop workflow using SharePoint 2010
    Jinchun Chen: "Excellent article. Personally speaking, the biggest challenge is SharePoint Designer workflow is “while-loop”. Many customers had the same scene as this article set. I am sure they are like this article.
    Benoît Jester: "An AWESOME, huge, detailed article by Dan. Did I mention the videos? Thanks Dan!"
    GO: "Great article Dan! Thanks!"
    Margriet Bruggeman: "Detailed explanation which I admire, but wouldn't be using a vs workflow be more logical in this case?"
    Geetanjali Arora
    Export User Profile Properties using CSOM
    Benoît Jester: "Great article on this new SharePoint 2013 development capability. I appreciate the code explanations."
    GO: "This is a great article. Love the way how you explain it."
    Margriet Bruggeman: "I will use this piece of code in the future!"
    Jinchun Chen: "Nice. How about customized properties? It would be nice more, if a CSOM script version can be attached. "
    Inderjeet Singh
    Unable
    to restore site collection issue
    GO: "Simple. Good Written. Clear and Clever. Great article."
    Margriet Bruggeman: "Quite handy reference for this particular problem"
    Benoît Jester: "Good explanation on the site collection deletion process."
     Small Basic Technical Guru - May 2014  
    Philip Conrod
    Programming Home Projects with Microsoft Small Basic: Chapter
    1: Writing Programs Using Small Basic
    RZ: "Very systematic introduction."
    Ed Price: "Good overview article that covers all the basics!"
    Michiel Van Hoorn: "Nice introduction into the history of Basic. Needs to be updated to reflect current support for Windows version (Windows NT? LOL )"
    Philip Conrod
    Programming Home Projects with Microsoft Small Basic: Chapter 6: Flash
    Card Math Quiz Project
    Michiel Van Hoorn: "This article (or book chapter) is excellent material to learn how to envision, design and build your program. The actual example program is also very usable."
    Ed Price: "I love how this tutorial keeps building on itself as it goes!"
    Nonki Takahashi
    Small Basic: Variable
    RZ: "Very nice explanation of the concept of variables!"
    Michiel Van Hoorn: "Clear explanation and not frills"
    Ed Price: "Great article with fantastic formatting!"
     SQL BI and Power BI Technical Guru - May 2014  
    Durval Ramos
    SSIS - Event Handling with "OnError" ou "OnTaskFailed"
    Ed Price: "The images are very helpful! Could use a grammar pass. Great descriptions!"
    GO: "This article has everything. A conclusion, reference, see also, other languages section. everybody should write actually like this."
    NN: "An interesting topic and article but unfortunately a bit hard to understand due to grammar problems"
    PT: "This is a good article on a useful topic. Please have your article reviewed and edited for proper language."
    S Kamath
    Expansion of Time dimension in Analysis Service
    PT: "Your article is concise and to the point, and contains useful information. It would be good to conclude with a short summary and perhaps compare this technique to others, discussing best practices."
    Ed Price: "Good details on Time Dimension. The images help us understand as we go."
    GO: "I like this one, but something is missing. Do not know what, but I had a blast reading the other two's. Does not mean that this one is bad, but there is something missing, maybe my knowledge..."
    NN: "Good article, but seems to be missing conclusion. It will also benefit from adding See Also section"
    Sherry Li
    SSAS – Ignore unrelated dimension or not
    NN: "Good and interesting article based on the blog"
    GO: "Wonderful article!"
    PT: "This is an important topic and contains helpful information but this is a simple topic that can be explained in fewer words. I found this article to be overly detailed and hard to read. I suggest having it reviewed and edited for
    proper language."
    Ed Price: "Good descriptions. Could be shorter. Good use of images!"
     SQL Server General and Database Engine Technical Guru - May 2014  
    Shanky
    Curious Case Of Logging In Online and Offline Index Rebuild In Full Recovery
    Model
    Jinchun Chen: "Good article. Thank you!"
    GO: "One of the best Wiki Articles ever! Thanks buddy!"
    DRC: "-- This is a great article which provides in-depth information on internals of Online & Offline rebuild index and Transaction logging. -- The following statement need to be re-written for more clarity. “The less logging can be
    attributed to the fact that no information about page allocation is logged information about de-allocation is logged please see below figure 13. Also if you compare amount of record returned in this case we had output containing just 64 rows while offline
    index rebuild had ____ rows.” -- Overall, a great article, thoroughly enjoyed reading it."
    NN: "Very interesting article, another great contribution by Shanky"
    Ed Price: "Thorough descriptions and great solution! Good article!"
    Uwe Ricken
    SQL Server: Be aware of the correct data type for predicates in queries
    Ed Price: "Incredibly well formatted! Great breakdown of sections!"
    GO: "Whoo, this is a wonderful article!"
    DRC: "-- This article explains the Query execution behaviour when the Query is not optimally written which could cause increased execution time. Great article. -- This topic is clearly explained and documented using a simple example and
    sample output which is easy is understand. -- Simple, very well written and great article to read. "
    NN: "Very good, easy to understand article and important information to know to all SQL Server developers"
     System Center Technical Guru - May 2014  
    Mr X
    Central Management of DSRM password on Domain Controllers using Orchestrator
    Ed Price: "The images really carry you through this article. Great execution!"
    GO: "Great article. I like your article Mr X! Thanks for your passion!"
    Kevin Holman: "Nice to see real world examples of Orchestrator in action solving problems that all customers have. This was very simple, but provides an excellent solution."
    W P Chomak
    System Center Operations Manager 2012 R2 - Customizing E-Mail Notifications
    AB: "Easy reading info that can help many"
    Ed Price: "Short and sweet. An incredibly valuable topic and needed addition to the Wiki!"
    GO: "Clever and well written. Thanks"
    Christoffer S
    System Center Configuration Manager 2012 R2 - Install applications in a task sequence based on AD-Groups
    Ed Price: "Good mix of code, images, and information. Could use more in-depth descriptions. Great article!"
    GO: "Clear and simple! Thank you!"
     Transact-SQL Technical Guru - May 2014  
    Naomi N
    T-SQL: Random Equal Distribution
    Jinchun Chen: "Nice."
    JS: "The crucial thing about such a procedure is to check the data before the randomization and afterwards. You might encounter situations where "John Smith" and "John Meyers" might have exchanged their First names
    which is technically correct, but logically and obviously wrong. So make sure that there is one additional check afterwards that makes sure that eventual privicy concerns will not survive the random process. Normally this would not happen, but I have already
    checked this is one of my older blog entries, where we exactly had that problem obfuscating data to make that operational and live data will not be recognized afterwards. http://blogs.msdn.com/b/jenss/archive/2009/04/08/when-is-random-random-enough.aspx In
    addition to this some attributes are sticky to each other like gender and First Name. You also have to make sure that your distribution might change statistically in relation to other attributes."
    Richard Mueller: "Very instructive. Perhaps the See Also section should have more links."
    Ed Price: "Great formatting and topic! Could benefit from more descriptions. Great article!"
    GO: "Naomi, your article is nice. Simple to understand the 'problem' and execute the 'solution""
    Manoj Pandey: "Nice article with a different way to resolve a given problem. I think this can also be done by using NTILE() function. I've added the code in comments section."
    Rogge H
    Extending SYS.Geometry to Utilize Temporal Data
    GO: "Great article, I enjoyed reading it. Thank you"
    Manoj Pandey: "I like the idea, but it took me some more time to understand the overall logic as I'm new to Geo datatypes, Thanks."
    JS: "For me not using this sort of things regularly, I don't see the problem and the benefit. I have no doubt that this is a brilliant explanations how to cope with a problem, but for me this is missing yet the red line. More pictures
    would be helpful describing the problem and outlining the results produced."
    Richard Mueller: "Needs more explanation, and perhaps an example. There should be links to relevant references."
    Ed Price: "Good job on the opening descriptions! Could benefit from breaking up and explaining the code more. Images and references would be helpful. Good article!"
    Hasham Niaz
    DataCleanUp() Function Implementation in MS SQL Server
    Jinchun Chen: "Good."
    JS: "-Does actually not work for Case senstive areas where I want to remoce certain Upper/lower case characters. This might be not interesting for some people, but is extremely important and relevant to other people. The limitation is
    that I can´t pass multiple values to be removed from the string, right ? Could this be implemented as well as many people wash out their data from unused / unimportant control characters. "I have tested it on a table which has got more than 11 Million
    rows and it executed fine returning the correct results. Since this is a scalar function you will notice decrease in performance." Once you want to maintain the old data and keep the new cleaned up one seperately, you could suggest something like persisting
    the data in a computed column which could be indexed and then help improving the performance. This would not be the case for any adhoc queries though."
    Richard Mueller: "Very clever and also very useful. There should be links to references, for example to explain the PATINDEX function."
    Ed Price: "Great job on this article! Very clear and well executed! See JS's comments for some thoughts about what's possible. Great article!"
    Manoj Pandey: "A good utility Function that I can use and tweak for my future needs, Thanks."
    Jaliya Udagedara
    Calling WCF Service from a Stored Procedure in Microsoft SQL Server 2012
    GO: "Gold Winner. For sure!"
    Ed Price: "Amazing article! The depth, images, and code formatting make this fantastic!"
    NN: "Great article, thorough explanations, great interaction in the comments - very useful tutorial"
    Søren Granfeldt: "Nice work."
    João Sousa
    ASP.NET MVC 5 - Bootstrap 3.0 in 3 Steps
    GO: "Thanks for that great article"
    Ed Price: "Great formatting! Good use of images!"
    NN: "Nice introduction to Bootstrap in ASP.MVC project"
    Søren Granfeldt: "Just a little more technical explanation would be nice"
    Critical_stop
    Using 64-bit shortcuts from a 32-bit application
    NN: "Good and short article, right to the point"
    Søren Granfeldt: "Mixing and matching 32/64 bit always seems to give people a hassle. This will help those having issues."
    GO: "good one!"
    Ed Price: "Good article. Short and sweet."
     Wiki and Portals Technical Guru - May 2014  
    XAML guy
    TechNet Guru Competition: Judge System Explanation
    GO: "No one could do it beter than you Pete! Thanks!"
    Richard Mueller: "Excellent explanation of the judging system. Perhaps could use a See Also section."
    Ed Price: "Good quote from Shanky in the comments, "Awesome....Kudos to your for your beautiful work" -- Great job!"
    NN: "Very good article. It may also benefit from See Also section"
    Payman Biukaghazadeh
    TechNet Wiki Persian Council
    GO: "Go Persion GOOO!"
    Richard Mueller: "The Persian Council is an excellent idea. The link to "How to Write an Article" should be in a See Also section, along with other articles."
    NN: "Great article, missing a link to other portals and councils pages"
    Ed Price: "Thank you to Payman and the Persian community for jumping in! The Wiki is warm!"
    Durval Ramos
    Wiki: Best Practices for building TechNet Wiki Portals
    Ed Price: "Fantastic job from Durval on helping us standardize the portals!"
    NN: "Good article, but unfortunately a bit hard to read and understand due to bad grammar. "
    Richard Mueller: "Excellent and important topic. Grammar still needs work. I like the links and See Also."
     Windows Phone and Windows Store Apps Technical Guru - May 2014  
    Sara Silva
    Authentication using Facebook, Google and Microsoft account in WP8.0 App (MVVM)
    Ed Price: "Great article! Great code formatting and good use of code comments for descriptions of what your code's doing! Could be improved by breaking out the code with more descriptions in the article (in addition to
    the code comments). Very in-depth article! "
    Peter Laker: "An excellent article, pulling together all the bits you need to make this happen"
    SubramanyamRaju.B
    WindowsPhone Facebook Integration:How to post message/image to FaceBook Fan
    Page(C#-XAML)
    Ed Price: "Good topic! Code blocks would help with the formatting. Good job on this article!"
    Peter Laker: "Love this, very useful to many I'm sure, thanks!"
    Saad Mahmood
    Creating a custom control in Expression Blend with Custom Properties (WindowsPhone
    & Store)
    Ed Price: "This has a good mix of descriptions and clarity! The images help a lot!"
    Peter Laker: "A nice introduction to our beloved Blend. Great work!"
     Windows Presentation Foundation (WPF) Technical Guru - May 2014  
    Magnus (MM8)
    WPF/MVVM: Merging Cells In a ListView
    KJ: "Ah the collectionViewSource -- never used it myself but this looks like a good reference article if I ever needed to..."
    GO: "Thank you!"
    Ed Price: "Great formatting and good descriptions. Short and sweet! Another fantastic entry from Magnus!"
    Peter Laker: "Thank you again Magnus"
     Windows Server Technical Guru - May 2014  
    Mr X
    How to implement User
    Activity Recording for AD-Integrated Critical Servers by combining the use of Group Policy, Powershell and Orchestrator
    Philippe Levesque: "Really good information and detailed step."
    JH: "brilliant, love how it combines different technologies to achieve a solution, clearly written and well illustrated."
    JM: "Another excellent article, thanks again for your many great contributions"
    Richard Mueller: "Very creative solution. Great to have such detailed steps and images."
    GO: "I like the conclusion. Thanks"
    Mr X
    How Domain Controllers are located in Windows
    GO: "Super article Mr X! Merci!"
    JM: "Yet again, excellent article."
    Richard Mueller: "Good documentation. An explanation of how the priorities and weights are determined would help. A See Also section would also help."
    Philippe Levesque: "Good "In deep" information. Good to know to help diagnose computer problem in AD's site."
    JH: "another good article, great diagrams. Some repetition but it does help clarify a complex issue. "
    Mahdi Tehrani
    Detailed Concepts:Secure Channel Explained
    JH: "great article. This fills an important gap in this content space. Editing is a little rough, but diagrams and explanations are clear."
    JM: "This is a very good article, however you need to provide more detail in the section on how to fix a broken Channel."
    Richard Mueller: "Excellent topic. Grammar needs work. Good images. Could use a See Also section."
    Philippe Levesque: "Really good explanation of the secure's channel, I like the debugging step included ! "
    GO: "Thanks for this, not everybody know about secure channel."
    As mentioned above, runners up and their judge feedback were removed from this forum post, to fit into the forum's 60,000 character limit.
    A great big thank you to EVERYONE who contributed an article to last month's competition.
    Hopefully we will see you ALL again in this month's listings?
    As mentioned above, runners up and comments were removed from this post, to fit into the forum's 60,000 character limit.
    You will find the complete post, comments and feedback on the
    main post.
    Please join the discussion, add a comment, or suggest future categories.
    If you have not yet contributed an article for this month, and you think you can write a more useful, clever, or better produced wiki article than the winners above,
    here's your chance! :D
    More about the TechNet Guru Awards:
    TechNet Guru Competitions
    #PEJL
    Got any nice code? If you invest time in coding an elegant, novel or impressive answer on MSDN forums, why not copy it over to the one and only
    TechNet Wiki, for future generations to benefit from! You'll never get archived again!
    If you are a member of any user groups, please make sure you list them in the
    Microsoft User Groups Portal. Microsoft are trying to help promote your groups, and collating them here is the first step.

    Congrats to Shanky and Uwe!
     SQL Server General and Database Engine Technical Guru - May 2014  
    Shanky
    Curious Case Of Logging In Online and Offline Index Rebuild In Full Recovery
    Model
    Jinchun Chen: "Good article. Thank you!"
    GO: "One of the best Wiki Articles ever! Thanks buddy!"
    DRC: "-- This is a great article which provides in-depth information on internals of Online & Offline rebuild index and Transaction logging. -- The following statement need to be re-written for more clarity. “The less logging can be attributed
    to the fact that no information about page allocation is logged information about de-allocation is logged please see below figure 13. Also if you compare amount of record returned in this case we had output containing just 64 rows while offline index rebuild
    had ____ rows.” -- Overall, a great article, thoroughly enjoyed reading it."
    NN: "Very interesting article, another great contribution by Shanky"
    Ed Price: "Thorough descriptions and great solution! Good article!"
    Uwe Ricken
    SQL Server: Be aware of the correct data type for predicates in queries
    Ed Price: "Incredibly well formatted! Great breakdown of sections!"
    GO: "Whoo, this is a wonderful article!"
    DRC: "-- This article explains the Query execution behaviour when the Query is not optimally written which could cause increased execution time. Great article. -- This topic is clearly explained and documented using a simple example and sample
    output which is easy is understand. -- Simple, very well written and great article to read. "
    NN: "Very good, easy to understand article and important information to know to all SQL Server developers"
    Also worth a mention were the other entries this month:
    SQL Server installation error Could Not  Find Database Engine Startup Handle by
    Shanky
    Ed Price: "Wow, what an amazing article! Fantastic code formatting, great descriptions, and the images help you when you need it!"
    NN: "I read this article with great interest. The funny thing is that at the same time I was reading someone was having this exact problem in UniversalThread.com forum, so I was able to refer him to this article. UPDATE. Looks like he is still
    having problems"
    GO: "Thank you so much!"
    DRC: " -- This article -- Explains on modifying/deleting the registry keys after backup -- But it doesn't provide the level/how to back up the registry. -- We also need to warn the users that if we modify/delete the wrong registry key it might
    lead to crash of SQL or even WINDOWS -- In case there are multiple instances on the same machine following this article would cause all the SQL instance to crash. -- So it would be better to contact the support team or before trying out the action steps. "
    5 Top Features Your Company Can Use in SQL Server 2014 Standard Edition by Richard
    Douglas
    NN: "Very well written and quite interesting. Since it's originated from the blog, it has a personal touch which is more appropriate for a blog " 
    DRC: " -- Expand the word GA (General Availability) in the below sentence and correct the spelling mistake "it was written before the GA of SQL Server 2014" "SSD technology and a chunk of this session was on BPE" "who doesn't’t like playing
    with new cool stuff!" "which doesn't’t sound as impressive" "business from the likes of Oracle et al." -- This is a good article and provides all the required information and links to Microsoft website for more details. " 
    Ed Price: "Fantastic topic, but it should be made more "Wiki like" and less personalized. Anybody in the community can help us do that! " 
    Ed Price, Power BI & SQL Server Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • Capture all SQL statements and archive to file in real time

    Want to Capture all SQL statements and archive to file in real time?
    Oracle Session Manager is the tool just you need.
    Get it at http://www.wangz.net
    This tools monitor how connected sessions use database instance resources in real time. You can obtain an overview of session activity sorted by a statistic of your choosing. For any given session, you can then drill down for more detail. You can further customize the information you display by specifying manual or automatic data refresh, the rate of automatic refresh.
    In addition to these useful monitoring capabilities, OSM allows you to send LAN pop-up message to users of Oracle sessions.
    Features:
    --Capture all SQL statement text and archive to files in real time
    --Pinpoints problematic database sessions and displays detailed performance and resource consumption data.
    --Dynamically list sessions holding locks and other sessions who are waiting for.
    --Support to kill several selected sessions
    --Send LAN pop-up message to users of Oracle sessions
    --Gives hit/miss ratio for library cache,dictionary cache and buffer cache periodically,helps to tune memory
    --Export necessary data into file
    --Modify the dynamic system parameters on the fly
    --Syntax highlight for SQL statements
    --An overview of your current connected instance informaiton,such as Version, SGA,License,etc
    --Find out object according to File Id and Block Id
    Gudu Software
    http://www.wangz.net

    AnkitV wrote:
    Hi All
    I have 3 statements and I am writing some thing to a file using UTL_FILE.PUT_LINE after each statement is over. Each statement takes mentioned time to complete.
    I am opening file in append mode.
    statement1 (takes 2 mins)
    UTL_FILE.PUT_LINE
    statement2 (takes 5 mins)
    UTL_FILE.PUT_LINE
    statement3 (takes 10 mins)
    UTL_FILE.PUT_LINE
    I noticed that I am able to see contents written by UTL_FILE.PUT_LINE only after statement3 is over, not IMMEDIATELY after statement1 and statement2 are done ?
    Can anybody tell me if this is correct behavior or am I missing something here ?Calling procedure must terminate before data is actually written to the file.
    It is expected & correct behavior.

  • Retreiving all SQL source codes from forms

    Hi,
    Does anyone know how to retrieve source codes ( trigers,
    procedures, etc.) from forms to put into a txt file ? I know I
    can use the export option from the PL/SQL editor for individual
    triger or procedure, but is there a way to retrieve all SQLs
    from the form just at one time ?
    Your help is very appreciated.
    Thanks
    Jessica

    U can get a document of the Form in a text file. This will
    contain all Objects properties, Triggers etc.To do this:
    1. Open the Form Builder and the Form u want to document.
    2. File - Administration - Object List Report.
    Hope this helps.

  • How to find out all SQLs executed by a procedure

    I need to find out all SQLs executed by a procedure. I can trace and check but in my case the issue happened 4 hours back and i know what procedure was causing it. There are multiple dynamic queries fired from this procedure. I need to track down all SQLs fired by this procedure constructed dynamically during the time issue was happening.
    I have the sql_id of the statement which was executing the procedure. How do I track down all "child" SQLs using this sql_id?
    Will appreciate any pointers.
    -ravi

    Thanks for your suggestion and looking into this.
    We already have that functionality built in. Version is 10.2.0.3...But the issue is the proc is called thousands of time in a day and we can not keep the tracking of sqls and parameters passed on all the time. When the issue happened we were not tracking. The bind variables are not captured as the SQL is constructed within the proc by looking up the values dynamically from secondary tables dynamically based on the parameters passed to the procedure. Now the SQLs which are generated from the proc will have the bind variables captured as they will come as predicates and will have no clob types (condition for the binds to be captured).
    I need a query to track down all "child" SQLs by using the sql_id of the parent process which is the procedure's sql_id.

  • Bat file execute all *.sql files in a folder

    Hi all,
    How to write a *.bat file to execute all *.sql files in a folder?
    Because have about 20 *.sql file in a folder. There are used to fix data in my database. The number of *.sql file increases day by day. So I want to write a *.bat file to execute all *.sql file in the folder. Since I just run this *.bat file.
    Mai Thanh Hải.

    user545846 wrote:
    Hi
    I have done this many times. can guide you. :)And did it fail to work all the times you tried it?
    c:\>type test1.sql
    select 1 from dual;
    exit
    c:\>type test2.sql
    select 2 from dual;
    exit
    c:\>sqlplus scott/tiger@testdb @c:\test*.sql
    SQL*Plus: Release 10.2.0.3.0 - Production on Thu Aug 6 12:37:04 2009
    Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SP2-0556: Invalid file name.
    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining optionsWildcards in SQL*Plus filenames don't work. So why do you suggest that?
    Better is to use the DOS command FOR...
    c:\>for %i in (test*.sql) do sqlplus scott/tiger@testdb @%i
    c:\>sqlplus scott/tiger@testdb @test1.sql
    SQL*Plus: Release 10.2.0.3.0 - Production on Thu Aug 6 12:38:06 2009
    Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
             1
             1
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    c:\>sqlplus scott/tiger@testdb @test2.sql
    SQL*Plus: Release 10.2.0.3.0 - Production on Thu Aug 6 12:38:06 2009
    Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
             2
             2
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    c:\>... although even better would be to proceduralise the SQL into packages/procedures on the database and have just a single procedure call do all the work.

  • How to fill combo box with list of all SQL server

    Ok, I know how to find all SQL servers that I need, I have code for that task, and I have Array of all servers.
    My problem is ...
    I made setup project and do a huge work, and in the end this task appear!
    I used ORCA tool to change TextBox (A) template in visual studio (2008 by the way), and I transform first TextBox to ComboBox.
    Now, the little part that I'am missing is how to fill this combo box with a result of my function for listin SQL servers?
    Can I somehow send combobox object to myMethod:
    private void FillCombo(ComboBox cmb)
          // do the job
    or
    instanceOfThisCombo.Items.Add(listOfSQLServers);
    please help me to solve this... thanksc#

    Hi Valerij,
    The ComboBox control in an MSI dialog uses the ComboBox table to populate the items in it. To get what you want, you need to update the ComboBox table in the MSI package with your application and run the MSI package. The following KB article describes how to dynamically populate a ListBox control in Windows Installer:
    http://support.microsoft.com/kb/291329
    This method introduced in the above KB article also applies to populating a ComboBox control in Windows Installer.
    I don't think it's possible to run the application as a Custom Action from within the MSI package because the application will modify the content of the MSI package which is currently running. So you need to launch the MSI package from within your application after updating the ComboBox table. In short, when installing, just run your application which updates the ComboBox table and install the MSI package.
    Hope this helps.
    If you have any question, please feel free to let me know.
    Sincerely,
    Linda Liu

  • MAP Toolkit - How to use this MAP tool kit for all SQL Server inventory in new work enviornment

    Hi Every one
     Just joined to new job and planning to do Inventory for whole environment so I can get list of all SQL Server installed . I downloaded MAP tool kit just now. So looking for step by step information to use this for SQL Inventory. If anyone have documentation
    or screen shot and can share would be great.
    Also like to run It will be good to run this tool anytime or should run in night time when is less activity? 
    Hoe long generally takes for medium size environment where server count is about 30 ( Dev/Staging/Prod)
    Also any scripts that will give detailed information would be great too..
    Thank you 
    Please Mark As Answer if it is helpful. \\Aim To Inspire Rather to Teach A.Shah

    Hi Logicinisde,
    According to your description, since the issue regards Microsoft Assessment and Planning Solution Accelerator. I suggestion you post the question in the Solution Accelerators forums at
    http://social.technet.microsoft.com/Forums/en-US/map/threads/ . It is appropriate and more experts will assist you.
    The Microsoft Assessment and Planning (MAP) Toolkit is an agentless inventory, assessment, and reporting tool that can securely assess IT environments for various platform migrations. You can use MAP as part of a comprehensive process for planning and migrating
    legacy database to SQL Server instances.
    There is more information about how to use MAP Tool–Microsoft Assessment and Planning toolkit, you can review the following articles.
    http://blogs.technet.com/b/meamcs/archive/2012/09/24/how-to-use-map-tool-microsoft-assessment-and-planning-toolkit.aspx
    Microsoft Assessment and Planning Toolkit - Technical FAQ:
    http://ochoco.blogspot.in/2009/02/microsoft-assessment-and-planning.html
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • All SQL statements in a session

    Hi OTN,
    It's possible to get all SQL statements executed in a session?
    In V$SESSION and V$ACTIVE_SESSION_HISTORY are only the current and pre current statements.
    -JSG

    Hi, you can enable the sql trace to a especific session with dbms_trace and get all sql statements, if you need more information review the Note:104239.1 into Metalink site.
    Luck.
    Have a good day.
    Regards.

  • How to find all sql ran in the database for particular time

    Hi All,
    i need to find all sql ran in the database between 7am to 9am on may 22 2012 , i can generate AWR but i think it shows only top sql but i need all sql during this time
    is any views in oracle to get this information
    Thanks

    i need to find all sql ran in the database between 7am to 9am on may 22 2012 , i can generate AWR but i think it shows only top sql but i need all sql during this time use below view to get detail.
    V$active_session_history
    dba_hist_active_sess_history

  • How to see all sql statements on sql commands under history link

    Hi All,
    How to see the all the sql history on sql commands tab.
    I want see all sql statements.
    Where to set if we need to store more sql statments in history.
    We are using Apex3.2 and 10g database(EE).
    Thanks,
    Nr

    I just checked the source code of the SQL commands history region and that report fetches a maximum of 1000 records. I don't know if you change the setting somewhere in the builder, but seeing the code it looks as though 1000 is hard-coded in the report definition(apex 4.0).
    If you need to see all the command history,you can query the original table: APEX_040000.WWV_FLOW_SW_SQL_CMDS
    Note that is an internal table used by apex and hence you might not find any documentation about it(google got me one valid hit: Identifying Inactive Workspaces which seem to confirm the table's use).
    Anyway, here's what you need to do, ask your dba to grant your workspace user select access on this table
    Connect as dba user and run
    GRANT SELECT ON APEX_040000.wwv_flow_sw_sql_cmds to '<WORKSPACE SCHEMA>'Now you can run the following command from your workspace to see the entire command history using
    select * from APEX_040000.WWV_FLOW_SW_SQL_CMDS where parsed_schema = '<WORKSPACE SCHEMA>';You might want to revoke the grant once you have seen the data/taken out an export due to security issues.

  • Running all *.sql files in one go

    Hi All,
    Can anyone help me in running all *.sql files in specific folder in one go??

    Go to Form Edit mode, enter the Fields list, press Ctrl+A, then Delete.

  • Close all SQL trace

    Hi,how I can close all SQL trace .
    that is I run a SQL with a client application such as SQL developer
    and I want no one can see this SQL script use views such as v$sqltext,v$sql,v$sqlarea etc.

    user11203282 wrote:
    and I want no one can see this SQL script use views such as v$sqltext,v$sql,v$sqlarea etc.Every SQL is going to use these views. Can you elaborate a bit what exactly you are looking for ?
    Amardeep Sidhu

  • See all SQL statements that have been executed in an active transaction?

    When I query v$transaction, v$session and v$sql, all I can see is the SQL statement that is currently running in an active transaction.
    How can I view all SQL statements that have been executed in a currently running transaction since that transaction began?

    Dana N wrote:
    When I query v$transaction, v$session and v$sql, all I can see is the SQL statement that is currently running in an active transaction.
    How can I view all SQL statements that have been executed in a currently running transaction since that transaction began?In the general case: impossible.
    In some special cases you can use v$sql, v$open_cursor, or "Availabilty>View and Manage Transactions" or something else.
    But be aware, transaction could be started long time ago, all cursor could be flushed from shared pool and closed, and redo (the page from Grid Control bring Log Miner) may not always be available.

  • Capture all sql statements within an hour period

    Hi there,
    Is it possible to capture all the all sql statement? When I query the v$sql view I still missed few statements. Basically I want to statements from our in house applications.
    Thanks

    Thanks for the reply.
    It really doesn't help. I have a datatbase with three schemas and the number on connections in the v$session are 55. The SID and SERIAL# constantly changed.
    I've tried the sql_trace_in_session but the sid the changed every time I query. Also I tried set sql_trace to "true" but I have open the trace files to determine the schema.
    Is there a way capture a specific schema only?
    Thanks

  • Detemine ALL sql queries being executed by a session

    Hi All,
    I want to find out ALL SQL queries being executed by a session on the DB. I have thought of enabling the SQL Trace for that session, then create my trace file for the session in the udump area and then check that trace file to view all the SQL's being executed in that session till the time i set my trace to FALSE.
    Would enabling the trace for that session suffice for capturing each and every SQL fired in that session? Or do i need to check anything else?
    Thanks in advance.

    hi,
    select sql_text
      from   v$session, v$sqltext
      where v$session.sql_address = v$sqltext.address
      and   V$session.sql_hash_value = v$sqltext.hash_value
      and  sid = &sid
    order by piece
    /thanks,
    baskar.l

Maybe you are looking for