Pages

Tuesday, May 22, 2012


alter database link .. 
Instead of DB link recreation after password change of remote schema from 11gr2 we can use “alter database link”

alter database link SCOTT_DBLINK connect to scott identified by abc;

Check the below link for detailed info.

Wednesday, May 9, 2012

To know last utlrp run,

we can find an entry from alert log as below

Tue May  8 19:27:43 2012
SERVER COMPONENT id=UTLRP_BGN: timestamp=2012-05-08 19:27:43
Tue May  8 19:27:55 2012
SERVER COMPONENT id=UTLRP_END: timestamp=2012-05-08 19:27:55
Top 15 sqls from cursor and Workload repository

from Oracle 10g release there is a script named SQLTRPT.SQL at ORACLE_HOME/rdbms/admin
which lists top 15 sqls from cache cursor and workload repository and its Tuning recommendations.

SQL>  col SQL_TEXT_FRAGMENT for a67
SQL> set pages 999
SQL> @sqltrpt

--DUE TO CLUMSY FORMAT here removed from display--
 
Specify the Sql id
~~~~~~~~~~~~~~~~~~
Enter value for sqlid: b6usrg82hwsa3

Sql Id specified: b6usrg82hwsa3

Tune the sql
~~~~~~~~~~~~

GENERAL INFORMATION SECTION
-------------------------------------------------------------------------------
Tuning Task Name                  : TASK_331359
Tuning Task Owner                 : SYS
Scope                             : COMPREHENSIVE
Time Limit(seconds)               : 1800
Completion Status                 : COMPLETED
Started at                        : 05/08/2012 17:54:55
Completed at                      : 05/08/2012 17:54:55

-------------------------------------------------------------------------------
Schema Name: SYS
SQL ID     : b6usrg82hwsa3
SQL Text   : call dbms_stats.gather_database_stats_job_proc (  )

-------------------------------------------------------------------------------
ADDITIONAL INFORMATION SECTION
-------------------------------------------------------------------------------
- Type of SQL statement not supported.

-------------------------------------------------------------------------------



Tuesday, April 24, 2012

Know active timezone version

SQL> select * from v$timezone_file;

FILENAME        VERSION
------------ ----------
timezlrg.dat          4

Monday, April 23, 2012

SQL plus environment settings


To know all sql environment values


00:21:35 SQL> show all
appinfo is OFF and set to "SQL*Plus"
arraysize 15
autocommit OFF
autoprint OFF
autorecovery OFF

trimmed.....


To know specific variables value
00:31:42 SQL> sho define
define "&" (hex 26)
00:31:50 SQL>

 


DEFINE: to suppress the definition

SQL> select *  from v$tablespace where name='&tbs_name';
Enter value for tbs_name: USERS
old   1: select *  from v$tablespace where name='&tbs_name'
new   1: select *  from v$tablespace where name='USERS'

       TS# NAME                           INC BIG FLA ENC
---------- ------------------------------ --- --- --- ---
         4 USERS                          YES NO  YES

SQL> set define off
SQL> /

no rows selected

SQL> 1
  1* select *  from v$tablespace where name='&tbs_name'
SQL> /

no rows selected

SQL> set define on
SQL> /
Enter value for tbs_name: USERS
old   1: select *  from v$tablespace where name='&tbs_name'
new   1: select *  from v$tablespace where name='USERS'

       TS# NAME                           INC BIG FLA ENC
---------- ------------------------------ --- --- --- ---
         4 USERS                          YES NO  YES

SQL>



SQLBL: we can enable/disable  blank lines in query


Eg:

SQL> select
  2  name
  3  from
  4  v$database;

NAME
---------
ORCL

SQL> select
  2
SQL> name
SP2-0042: unknown command "name" - rest of line ignored.
SQL>
SQL> from
SP2-0042: unknown command "from" - rest of line ignored.
SQL> v$database;
SP2-0042: unknown command "v$database" - rest of line ignored.
SQL> set sqlbl on
SQL> select
  2
  3  name
  4
  5  from
  6  v$database;

NAME
---------
ORCL

SQL>

  • 1st query without blank lines run fines
  • 2nd query with blank lines error ed
  • 3rd with setting SQLBL on we did even with blank lines 

TERMOUT : to suppress output to screen.

when during a big select ,deployment just spool , set termout off and execute the output will not be shown in screen.

00:31:50 SQL> sho termout
termout ON
00:32:27 SQL>

 
00:20:51 SQL> @a

  COUNT(*)
----------
     72620

Elapsed: 00:00:00.08
00:21:03 SQL> set termout off
00:21:18 SQL> @a
00:21:21 SQL> set termout on
00:21:33 SQL> @a

  COUNT(*)
----------
     72620

Elapsed: 00:00:00.08