Sunday, November 30, 2014

Using Result Cache in Oracle 11g Database.

From Oracle 11g we can use result cache in function and query, these results is a faster response time. The cached results stored become invalid when data in the dependent database objects is changed. Result cache is instance specific. The Result Cache Memory pool consists of the SQL Query Result Cache and PL/SQL Function Result Cache, which stores the values returned by PL/SQL functions.

The RESULT_CACHE_MODE parameter determines the SQL query result cache behavior. This parameter contain MANUAL and FORCE. If you set manual you need to specify result_cache hint in your query. If set FORCE  all results use the cache, you can use no_result_cache hint to bypass the cache.

SQL> SET TIMING ON;
SQL> CREATE OR REPLACE FUNCTION RESULT_CASHE_TEST
  2  RETURN NUMBER
  3  RESULT_CACHE
  4  IS
  5  V_RETVALUE NUMBER:=0;
  6  BEGIN
  7
  8  FOR I IN 1 .. 5 LOOP
  9  DBMS_LOCK.sleep(1);
 10  V_RETVALUE:=V_RETVALUE*I;
 11  END LOOP;
 12
 13  RETURN V_RETVALUE;
 14  END ;
 15  /
Function created.
Elapsed: 00:00:00.01
SQL> SELECT RESULT_CASHE_TEST FROM DUAL;
RESULT_CASHE_TEST
-----------------
                0
Elapsed: 00:00:05.02
SQL> SELECT RESULT_CASHE_TEST FROM DUAL;
RESULT_CASHE_TEST
-----------------
                0
Elapsed: 00:00:00.00
SQL>
SQL> CREATE TABLE RESULT_CACHE( ID NUMBER, NAME VARCHAR2(300), SALARY NUMBER);
Table created.
Elapsed: 00:00:00.03
SQL> INSERT INTO RESULT_CACHE VALUES(10,'RAJIB.PRADHAN',5000);
1 row created.
Elapsed: 00:00:00.00
SQL> SELECT /*+ result_cache */  SALARY
  2  FROM RESULT_CACHE
  3  WHERE ID=10;
    SALARY
----------
      5000
Elapsed: 00:00:00.00
SQL>

Saturday, November 1, 2014

Delete Windows Service

1. First we need to identify which service we are going to delete.

2. Now delete service using sc delete "Service Name" command .

Now copy service name from properties 


Now delete service from cmd.



Set listener password in oracle database.

This is my listener 

SID_LIST_MYLISTENER=
  (SID_LIST=
(SID_DESC =
      (GLOBAL_DBNAME = ORCL)
      (ORACLE_HOME = D:\app\product\11.2.0\dbhome_1)
      (SID_NAME = ORCL)
    )
  )

MYLISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = N1020)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = D:\app

================================================


C:\Users\rajib.pradhan>lsnrctl

LSNRCTL for 32-bit Windows: Version 11.2.0.1.0 - Production on 02-NOV-2014 10:45:29

Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Welcome to LSNRCTL, type "help" for information.
LSNRCTL> change_password MYLISTENER
Old password:
New password:
Reenter new password:
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
Password changed for LISTENER
The command completed successfully
LSNRCTL> save_config MYLISTENER
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
Saved MYLISTENER configuration parameters.
Listener Parameter File   D:\app\product\11.2.0\dbhome_1\network\admin\listener.ora
Old Parameter File   D:\app\product\11.2.0\dbhome_1\network\admin\listener.bak
The command completed successfully
LSNRCTL> status MYLISTENER
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     MYLISTENER
Version                   TNSLSNR for 32-bit Windows: Version 11.2.0.1.0 - Production
Start Date                02-NOV-2014 10:51:24
Uptime                    0 days 0 hr. 2 min. 59 sec
Trace Level               off
Security                  ON: Password or Local OS Authentication
SNMP                      OFF
Listener Parameter File   D:\app\product\11.2.0\dbhome_1\network\admin\listener.ora
Listener Log File         d:\app\diag\tnslsnr\N1020\mylistener\alert\log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=N1020)(PORT=1521)))
Services Summary...
Service "ORCL" has 1 instance(s).
  Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL> stop MYLISTENER
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
LSNRCTL> start MYLISTENER
Starting tnslsnr: please wait...

TNSLSNR for 32-bit Windows: Version 11.2.0.1.0 - Production
System parameter file is D:\app\product\11.2.0\dbhome_1\network\admin\listener.ora
Log messages written to d:\app\diag\tnslsnr\N1020\mylistener\alert\log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=N1020)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     MYLISTENER
Version                   TNSLSNR for 32-bit Windows: Version 11.2.0.1.0 - Production
Start Date                02-NOV-2014 10:54:40
Uptime                    0 days 0 hr. 0 min. 5 sec
Trace Level               off
Security                  ON: Password or Local OS Authentication
SNMP                      OFF
Listener Parameter File   D:\app\product\11.2.0\dbhome_1\network\admin\listener.ora
Listener Log File         d:\app\diag\tnslsnr\N1020\mylistener\alert\log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=N1020)(PORT=1521)))
Services Summary...
Service "ORCL" has 1 instance(s).
  Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

LSNRCTL>

-- After set listener password listener.ora file will be change with new parameter PASSWORDS_MYLISTENER Like this --------

#----ADDED BY TNSLSNR 02-NOV-2014 10:53:38---
PASSWORDS_MYLISTENER = 95286B9DA1A6B8FE

#--------------------------------------------