Removing Table Lock


Login to database as SYS or SYSTEM user. Find out the SESSION_ID by running the following SELECT statement
 
SELECT SESSION_ID
FROM DBA_DML_LOCKS
WHERE NAME = Table Name;

Use this session id to find SERIAL# by using following SELECT statment
SELECT SID,SERIAL#
FROM V$SESSION
WHERE SID IN (SELECT SESSION_ID
FROM DBA_DML_LOCKS
WHERE NAME = Table Name)

Use ALTER SYSTEM command to KILL SESSION and this will release the lock.
ALTER SYSTEM KILL SESSION 'SID,SERIALl#';

Concurrent Program Monitoring Scripts

Most frequently in support projects we need to monitor and track the concurrent programs. Here are some the important queries to track the status of concurrent program. These are also very useful for the oracle apps system administrator

 
--------- Terminating requests----------
SELECT Request_Id Reqst,
 user_concurrent_program_name concurrent_program,
       User_Name Requestor,
 Oracle_Username Orcl,
       Fcr.Logfile_Name LN,
       Concurrent_Queue_Name Manager,
       TO_CHAR(Actual_Start_Date, 'Mm-Dd-Yy Hh24:Mi') Started,
       Single_Thread_Flag
FROM Fnd_Concurrent_Requests Fcr,   Fnd_Concurrent_Programs_tl Fcp,
     Fnd_Oracle_Userid O,
     Fnd_Concurrent_Processes P,
     Fnd_Concurrent_Queues Q,
     Fnd_User
WHERE
     Controlling_Manager = Concurrent_Process_ID
  AND ( P.Concurrent_Queue_ID  = Q.Concurrent_Queue_ID
  AND P.Queue_Application_ID = Q.Application_ID )
  AND O.Oracle_Id = Fcr.Oracle_Id
  AND ( Fcr.Program_Application_Id = Fcp.Application_Id
  AND Fcr.Concurrent_Program_Id  = Fcp.Concurrent_Program_Id )
  AND Requested_By = User_Id
  AND Phase_Code = 'R' AND Status_Code = 'T'
ORDER BY  Actual_Start_Date, Request_Id
------ Currently running requests ------------
SELECT Request_Id Reqst,
User_Name Requestor,
Oracle_Username Orcl,
      Concurrent_Queue_Name Manager,
Concurrent_Program_Name Program, 
user_concurrent_program_name conc_program,
      TO_CHAR(Actual_Start_Date, 'Mm-Dd-Yy Hh24:Mi') Started,
Fcr.Logfile_Name LN,
      Run_Alone_Flag, Single_Thread_Flag
FROM Fnd_Concurrent_Requests Fcr,
      fnd_concurrent_programs_tl fcpt,
      Fnd_Concurrent_Programs Fcp,
      Fnd_Oracle_Userid O,
Fnd_Concurrent_Processes P,
      Fnd_Concurrent_Queues Q, Fnd_User
WHERE
      Controlling_Manager = Concurrent_Process_ID
  AND ( P.Concurrent_Queue_ID  = Q.Concurrent_Queue_ID
  AND P.Queue_Application_ID = Q.Application_ID )
  AND O.Oracle_Id = Fcr.Oracle_Id
  AND ( Fcr.Program_Application_Id = Fcp.Application_Id
  AND Fcr.Concurrent_Program_Id  = Fcp.Concurrent_Program_Id )
  AND (Fcpt.concurrent_program_id = Fcp.Concurrent_program_id)
  AND Requested_By = User_Id
  AND Phase_Code = 'R' AND Status_Code   = 'R'
ORDER BY  Actual_Start_Date, Request_Id
--- Summary of concurrent request execution since Date ---
SELECT L1.Meaning Request_Type,
       L2.Meaning Status,
       COUNT(Status_Code) NR
FROM   Fnd_Concurrent_Requests R,
       Fnd_Concurrent_Programs P,
       Fnd_Lookups L1,
       Fnd_Lookups L2
WHERE
       L1.Lookup_Code = P.Execution_Method_Code
  AND  L1.Lookup_Type = 'CP_EXECUTION_METHOD_CODE'
  AND (R.Program_Application_ID = P.Application_ID 
  AND R.Concurrent_Program_ID  = P.Concurrent_Program_ID )
  AND (R.Status_Code  = L2.Lookup_Code
  AND L2.Lookup_Type = 'CP_STATUS_CODE' )
  AND R.Phase_Code = 'C'
  AND R.Actual_Completion_Date > SYSDATE - 5
GROUP BY
  L1.Meaning, L2.Meaning
Errored programs on a day
SELECT fcp.user_concurrent_program_name
FROM fnd_concurrent_requests fcr,
     fnd_concurrent_programs_tl fcp
WHERE status_code = 'E'
AND fcr.concurrent_program_id = fcp.concurrent_program_id
AND TRUNC(requested_start_date) = TRUNC(SYSDATE)
STATUS_CODE
A Waiting
B Resuming
C
D Cancelled
E Error
F Scheduled
G Warning
H On Hold
I
M No Manager
Q Standby
R
S Suspended
T Terminating
U Disabled
W Paused
X Terminated
Z Waiting
Managers that are currently running a request
SELECT Concurrent_Queue_Name Manager,
       Request_Id Request,
 User_name,
       Concurrent_Program_Name Program,
 Run_Alone_Flag,
       TO_CHAR(Actual_Start_Date, 'DD-MON-YY HH24:MI') Started
  FROM Fnd_Concurrent_Queues Fcq,
 Fnd_Concurrent_Requests Fcr,
       Fnd_Concurrent_Programs Fcp,
 Fnd_User Fu,
 Fnd_Concurrent_Processes Fpro
 WHERE
       Phase_Code = 'R' AND
       Fcr.Controlling_Manager = Concurrent_Process_Id       AND               (Fcq.Concurrent_Queue_Id = Fpro.Concurrent_Queue_Id    AND 
Fcq.Application_Id      = Fpro.Queue_Application_Id ) AND (Fcr.Concurrent_Program_Id = Fcp.Concurrent_Program_Id AND Fcr.Program_Application_Id = Fcp.Application_Id )     AND 
Fcr.Requested_By = User_Id;
*******************************************************************************

Find out the URL of the Application in the database



If you want to find out the URL of the Application in the database in which table you can check ?

Option 1:
SQL> select * from icx_parameters;

Option 2:
SELECT PROFILE_OPTION_VALUE
  FROM FND_PROFILE_OPTION_VALUES
WHERE PROFILE_OPTION_ID = (SELECT PROFILE_OPTION_ID
                                                             FROM FND_PROFILE_OPTIONS
                                                           WHERE PROFILE_OPTION_NAME ='APPS_FRAMEWORK_AGENT')
                                                                AND LEVEL_VALUE=0;

Oracle Database Links (DB Link)

A database link is a path through which a remote user in another database can connect to any other database. Once created the database link exists as an object in the user schema.


Type of DB Links
There are 3 types of DB links. They are as follows:

1. PRIVATE: When the DB links is created, it is created under Private mode as default. The Private DBLINK is only available to the user who has created it. It is not possible for a user to grant access on a private DBLINK to other users.

2. PUBLIC: The Public DBLINK is available to all the users and all users can have the access without any restrictions.

3. SHARED: Shared database link uses share the server connection to support database link connection. If there are multiple concurrent database link access into a remote database, shared database link can be used to reduce the number of server connections required. Without the shared clause each database link connection requires a separate connection to the remote database.

Types of Logins:
In dblink we can use 2 types of login. They are as follows:

1. DEFAULT LOGIN: The User name and Password is same in both the databases.
Syntax
======
CREATE [PUBLIC] DATABASE LINK CONNECT TO CURRENT_USER USING
Code: (Text)
Create public database link daslink connect to current_user using ‘ORCL’

2. EXPLICIT LOGIN: The User Name and Password is different in both the databases.
Syntax
======
CREATE [PUBLIC|SHARED] DATABASE LINK CONNECT TOIDENTIFIED BY USING
Code: (text)
CREATE PUBLIC DATABASE LINK DDLNK CONNECT TO SCOTT IDENTIFIED BY TIGER USING ‘ORCL’

Note: To create the public DBLINK the user must have create public database link system privileges.


path:D:\app\prasanthb\product\11.1.0\db_1\NETWORK\ADMIN
oracle2test = 


  (DESCRIPTION =


    (ADDRESS_LIST =


      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.7.107)(PORT = 1526))


      )


    (CONNECT_DATA =


      (SERVICE_NAME =VIS)


      (SRVR = DEDICATED)


    )


  )
*************************************************************************************************************************

Add Responsibility using Sqlplus:


BEGIN
FND_USER_RESP_GROUPS_API.LOAD_ROW
(X_USER_NAME => 'ANATESH',
X_RESP_KEY => 'APPLICATION_DEVELOPER',
X_APP_SHORT_NAME => 'FND',
X_SECURITY_GROUP => 'STANDARD',
X_OWNER => 'SYSADMIN',
X_START_DATE => Trunc(sysdate),
X_END_DATE => NULL,
X_DESCRIPTION => NULL,
X_LAST_UPDATE_DATE => Trunc(sysdate));
COMMIT;
END
  Query to List all the responsibilities attached to a User
Based on a request from one of the reader here is the query which he was looking for.
He needed query that can list all the responsibilities attached to a user.

select fu.user_name, fr.responsibility_name, furg.START_DATE, furg.END_DATE

from fnd_user_resp_groups_direct furg, fnd_user fu, fnd_responsibility_tl fr
where fu.user_user_name = :user_name
and furg.user_id = fu.user_id
and furg.responsibility_id = fr.responsibility_id
and fr.language = userenv('LANG');
 
 

RAC Background Processes

Oracle RAC Background Processes

RAC Background Processes:

1. Lock Monitor Processes ( LMON)
2. Lock Monitor Services (LMS)
3. Lock Monitor Daemon Process ( LMD)
4. LCKn ( Lock Process)
5. DIAG (Diagnostic Daemon)

1. Lock Monitor Processes ( LMON)

It Maintains GCS memory structures.
Handles the abnormal termination of processes and instances.
Reconfiguration of locks & resources when an instance joins or leaves the cluster are handled by LMON ( During reconfiguration LMON generate the trace files)
It responsible for executing dynamic lock remastering every 10 mins ( Only in 10g R2 & later versions).
LMON Processes manages the global locks & resources.
It monitors all instances in cluster, primary for dictionary cache locks,library cache locks & deadlocks on deadlock sensitive on enqueue & resources.
LMON also provides cluster group services.
Also called Global enqueue service monitor.

2. Lock Monitor Services (LMS)

LMS is most very active background processes.
Consuming significant amount of CPU time. ( 10g R2 - ensure that LMS process does not encounter the CPU starvation).
Its primary job is to transport blocks across the nodes for cache-fusion requests.
If there is a consistent-read request, the LMS process rolls back the block, makes a Consistent-Read image of the block and then ship this block across the HSI (High Speed Interconnect) to the process requesting from a remote node.
LMS must also check constantly with the LMD background process (or our GES process) to get the lock requests placed by the LMD process.
Each node have 2 or more LMS processes.

GCS_SERVER_PROCESSES --> no of LMS processes specified in init. ora parameter.
Above parameter value set based on number of cpu's ( MIN(CPU_COUNT/2,2))
10gR2, single CPU instance,only one LMS processes started.
Increasing the parameter value,if global cache activity is very high.
Also called the GCS (Global Cache Services) processes.

Internal View: X$KJMSDP

3. Lock Monitor Daemon Process ( LMDn)

LMD process performs global lock deadlock detection.
Also monitors for lock conversion timeouts.
Also sometimes referred to as the GES (Global Enqueue Service) daemon since its job is to manage the global enqueue and global resource access.
LMD process also handles deadlock detection and remote enqueue requests.
Remote resource requests are the requests originating from another instance.
Internal View: X$KJMDDP

4. LCKn ( Lock Process)

Manages instance resource requests & cross instance calls for shared resources.
During instance recovery,it builds a list of invalid lock elements and validates lock elements.

5. DIAG (Diagnostic Daemon)

Oracle 10g - this one new background processes ( New enhanced diagnosability framework).
Regularly monitors the health of the instance.
Also checks instance hangs & deadlocks.
It captures the vital diagnostics data for instance & process failures.
 
 

Differences between 9i and 10g that affects RAC


1- Oracle Clusterware: In 9i was called oracm cluster manager; renamed to Oracle Cluster Ready Services     10.1. Finally in 10.2 called Oracle Clusterware.

2- Virtual IP: In 9i it was take a long time to recover clients connection after node failure.
Introduced in 10.1 VIP used instead of Public IP. When a node failure happens the client connection    
transferred from the failed node to another node using the VIP.

3- ASM ( Automatic Storage Management ): This feature introduced in 10.1 that is an alternative to the volume manager. It also provide double or triple mirroring. The only exception in ASM that it allow to store Oracle Database files  and associated files like archive redo logs and flash recover area files.

4- AWR (Automatic Workload Repository): Introduced in 10.1; Records an extended set of database usage statistics in the database for subsequent analysis and performance tuning. Its an evolution of STATSPACK.

5- ASH (Active Session History): Introduced in 10.1; Records wait events for each session. This information is initially stored in the SGA and subsequantaly summerized and flushed to the database to be kept for time-based performance tuning.


6- FAN(Fast Application Notification): Introduced in 10.1;allows databases, listeners, application servers and clients to receive rapid notifications of database events such as start/stop database, instances or services.
Well-written application can be also utilize this to reconnect to the instance without end user aware.

7- ADDM(Automatic Database Diagnostics Monitor):Introduced in 10.1; It provides the same STATSPACK reports functionality plus detecting problems and provide resolutions.

7- Database services: Introduced in 8i and enhanced in 10.1; It's logical grouping for sessions doing the same kind of work. Service later assigned to a Preferred instance(s) and Available(backup) instance(s) 

8- Database scheduler: Introduced in 10.1 and replaced DBMS_JOB package. Its more felxable by allowing jobs to be grouped in classes, job chains and windows to be created and external jobs such as shell scripts to be executed.
 
9- CVU (Cluster Verification Utility): Introduced in 10.2 to provide a method for verifying each stage of RAC installation process.

10- OEM (Oracle Enterprise Manager): This tool is converted from Java application to HTML web application and extended greatly. Two types of OEM available:
   A- Grid Control: Allow managing multiple nodes, database, instances and more.
   B- Database Control: This allow managing single database node.

ERROR 1396 (HY000): Operation ALTER USER failed for 'Mysql'@'%'

 This MySQL error — ERROR 1396 (HY000): Operation ALTER USER failed for 'Mysql'@'%' — means that MySQL cannot find the user ...