Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Sunday, January 22, 2017

Interview Question Answer

How to create custome top?
Query to know which user to which instance?
select i.host_name, s.username from
gv$session s join
gv$instance i on (i.inst_id=s.inst_id)
where username is not null;

Own Session:
SELECT sid,serial#, inst_id,username,event,ownerid FROM GV$SESSION
WHERE sid=(select sid from v$mystat where rownum=1);

benefit of shared appl_top?
what you do to clone from mutiple node to single node?
how to relink?
How to create a custom manager?

1. Define Custom Workshifts (Optional)
system Administrator->Concurrent->Manager->Workshifts
Click + icon on the menu bar (Top left) to insert new record.
Enter details and save.

2. Define Concurrent Manager
System Administrator->Concurrent->Manager->Define
Enter details for following:
Manager - New Concurrent Manager Name
Short Name - Short Name
Application Name - Usually Custom Application Name or Existing Application (Ex : Application Object Library)
Type - Concurrent Manager
Cache Size - 1
Node - If you use multi node configuration, you can differentiate primary node for this manager from standard manager such as follows otherwise just keep them blank so that EBS automatically find  the right node (Primary - XX2,Secondary - XX1)
Program Library Name - FNDLIBR
Save the Record

3.Define Workshifts for manager
Click 'Workshifts' button on Manager form
Enter following
Select Work shifts from drop down define in step 1 or select standard workshifts
Processes - 10
Sleep Seconds - 30
Save Details

4.Define Specializtion Rule for manager
Click 'Specialization Rules' button on Manager form
Enter what need to be run on new manager
Include/Exclude
Type - Program (Can include Program)
          -Oracle ID (Can include Module)
           -User (Can include Program execute by particular User )
Application - Application Name for Program
Name - Name of Program/User
Save the Record

5.Exclude from Standard Manager
System Administrator->Concurrent->Manager->Define
Query 'Standard Manager' and Click 'Specialization Rules' button
Exclude the Program/User defined in Step 4
Save the Details

Note : In Specialization Rules of  'Standard Manager', never use "Include" definition. Standard Manager is supposed to deal with all requests. If you define any Include record here, Standard Manager only deal with that "Include" object as if it is a special manager for  that object and all other concurrent requests will be kept in "No" Manager" status

6.Activate Newly Created Concurrent Manager
System Administrator->Concurrent->Manager->Administer
Scroll down the record until find the newly created concurrent  manager
Click the row and click 'Activate' Button
By Clicking 'Refresh' Button at regular interval, Monitor Actual and Target Processes are displayed as 10 which defined in step 3

7.Bounce the Standard Manager to reflect the latest definition
System Administrator->Concurrent->Manager->Administer
Scroll down the record until find the 'Standard Manager' concurrent   manager
Click the row and click 'Deactivate' Button
By Clicking 'Refresh' Button at regular interval, Monitor Status Column, Once Status column become Deactivated then Click 'Activate' button  to start the Standerd Manager.
8. Check If the concurrent request are running with newly created concurrent manager
select b.USER_CONCURRENT_QUEUE_NAME,
e.USER_CONCURRENT_PROGRAM_NAME
from fnd_concurrent_processes a,
fnd_concurrent_queues_vl b, fnd_concurrent_requests c,
FND_CONC_REQ_SUMMARY_V d,FND_CONCURRENT_PROGRAMS_TL e
where a.CONCURRENT_QUEUE_ID = b.CONCURRENT_QUEUE_ID
and a.CONCURRENT_PROCESS_ID = c.controlling_manager
and c.request_id=d.request_id
and d.concurrent_program_id=e.concurrent_program_id
and c.request_id =<Request_id>;

Application user is complaining the database is slow?

What is statistic?
1.statistics are a collection of data that describe the database, and the objects in the database.
2.statistic are basically a mathematical representation of data.They show the distribution of data.
3.statistic are main tained automatically.
4. statistics are used by the Optimizer to choose the best execution plan for each SQL statement.
5.Statistics are stored in the data dictionary, and can be accessed using data dictionary views such as
USER_TAB_STATISTICS.
6.When statistics are updated for a database object, Oracle invalidates any currently parsed SQL statements,the statement is re-parsed and  the optimizer automatically chooses a new execution plan based on the new statistics.

**Oracle statistics tell us the size of the tables, the distribution of values within columns, and other important information so that SQL statements will always generate the best execution plans.

Oracle provides more than one way of generating statistics.

DBMS_UTILITY
ANALYZE command
DBMS_DDL
DBMS_STATS

GATHER_INDEX_STATS        >       Index statistics

GATHER_TABLE_STATS        >       Table, column, and index statistics

GATHER_SCHEMA_STATS       >       Statistics for all objects in a schema

GATHER_DATABASE_STATS     >       Statistics for all objects in a database

GATHER_SYSTEM_STATS      >        CPU and I/O statistics for the system

NOTE= Oracle strongly recommends that you use the DBMS_STATS package rather than ANALYZE to collect optimizer statistics. That package lets you collect statistics in parallel, collect global statistics for partitioned objects, and fine tune your statistics collection in other ways. Further, the cost-based optimizer will eventually use only statistics that have been collected by DBMS_STATS.

However, you must use the ANALYZE statement rather than DBMS_STATS for statistics collection not related to the cost-based optimizer, such as:
    * To use the VALIDATE or LIST CHAINED ROWS clauses
    * To collect information on freelist blocks
Oracle recommends setting the ESTIMATE_PERCENT parameter of the DBMS_STATS gathering procedures to DBMS_STATS.AUTO_SAMPLE_SIZE to maximize performance gains while achieving necessary statistical accuracy. AUTO_SAMPLE_SIZE lets Oracle determine the best sample size for good statistics. For example, to collect table and column statistics for all tables in the OE schema with auto-sampling:

If you intend to ESTIMATE statistics because of time constraints, try to arrive at an optimal sample size that will yield excellent results for your database. In general, a sample size of 5% to 10% generates adequate statistics! 

Gathering statistics on tables requires sorting to be done and this takes up resources. Gathering statistics on indexes does not require sorting. Considering this benefit, you may COMPUTE statistics on indexes for accurate data.

By default DBMS_STATS will generate statistics for the table and not it's indexes (By default CASCADE => FALSE). Gather statistics on the indexes for this table. 

https://satya-dba.blogspot.com/2010/06/oracle-database-statistics-rbo-cbo.html
http://www.mbjconsulting.com/oracle_links/Gather_Statistics.html

Oracle Tables and Statistics:
The optimizer's job is to take SQL statements and decide how to get the data that is being asked for in the SQL statement and how to get it in the quickest way possible.When a SQL statement is executed, the database must convert the query into an execution plan and choose the best way to retrieve the data.For Oracle, each SQL query has many choices for execution plans, including which index to use to retrieve table row,what order in which to join multiple tables together, and which internal join methods to use (Oracle has nested loop joins,hash joins, star joins, and sort merge join methods).
The choice of executions plans made by the Oracle SQL optimizer is only as good as the Oracle statistics.To always choose the best execution plan for a SQL query, Oracle relies on information about the tables and indexes in the query.Once the optimizer has done its job, it provides an execution plan to Oracle.

The optimizer is influenced by the following factors:
OPTIMIZER_MODE in the initialization file
Statistics in the data dictionary
Hints

What is execution plan?

An execution plan is like a set of instructions that tells Oracle how to go and get the data.

What is difference between Explain Plan and Execution plan ?
Whenever we issue a sql statment oracle by default builds an EXECUTION PLAN to execute that statment. It takes some important decisions like whether to use indexes or not ,if more than one indexes are used which one is to be followed etc.
And if we want to explore that execution plan then it provides a sql syntax EXPLAIN PLAN to determine this.
EXPLAIN PLAN FOR
SELECT * FROM   emp e, dept d WHERE  e.deptno = d.deptno AND    e.ename  = 'SMITH';

SET LINESIZE 130
SET PAGESIZE 0
SELECT * FROM   TABLE(DBMS_XPLAN.DISPLAY);

select * from table(dbms_xplan.display_awr('d6xu9cxq57ant'));

select plan_table_output from table(DBMS_XPLAN.display_cursor('7s78wpgr5wadp'));

Cost Based Optimization (CBO) vs. Rule Based Optimization (RBO):
Rule Based Optimization: 
This is an old technique.
Basically, the RBO used a set of rules to determine how to execute a query. If an index was available on a table, the RBO rules said to always use the index.
There are some cases where the use of an index slowed down a query.

For example, assume someone put an index on the GENDER column, which holds one of two values, MALE and FEMALE. Then someone issues the following query:
SELECT * FROM emp WHERE gender='FEMALE';
If the above query returned approximately 50% of the rows, then using an index would actually slow things down.
It would be faster to read the entire table and throw away all rows that have MALE values.
Experts in Oracle query optimization have come to a rule of thumb that says if the number of rows returned is more than 5-10% of the total table volume, using an index would slow things down. The RBO would always use an index if present because its rules said to

RBO was supported in earlier versions of Oracle.
The Rule Based Optimizer (RBO) is now obsolete in Oracle 10g.
The biggest problem with the RBO was that it did not take the data distribution into account.

Cost Based Optimization: 
The CBO uses statistics about the table, its indexes and the data distribution to make better informed decisions.
Motivation behind CBO is to come up with the cheapest execution plan available for each SQL statement. The cheapest plan is the one that will use the least amount of resources (CPU, Memory, I/O, etc.) to get the desired output (in relation to our travel analogy this can be Petrol, time, etc.).

Difference between ANALYZE TABLE and DBMS_STATS.GATHER_TABLE_STATS?

The ANALYZE command counts the leaf blocks, that are currently within the index structure.
The DBMS_STATS package counts the leaf blocks, that have currently data in them.

dbms_stats is a superset of analyze command.
DBMS_STATS can be done in parallel.
Monitoring can be done and stale statistics can be collected for changed rows using DBMS_STATS.

it is easier to automate with dbms_stats (it is procedural, analyze is just a command).

dbms_stats can analyze external tables, analyze cannot.

“DBMS_STATS gathers statistics only for cost-based optimization; it does not gather other
statistics. For example, the table statistics gathered by DBMS_STATS include the number
of rows, number of blocks currently containing data, and average row length but not the
number of chained rows, average free space, or number of unused data blocks.”

Analyze table hangs for hours using DBMS_STATS.GATHER_TABLE_STATS?

Did you look at v$session_wait to see what the session was waiting on?

Also have a look at v$session_longops.

How to check previoues plan?
Select SAMPLE_TIME,SESSION_ID,SQL_PLAN_HASH_VALUE from DBA_HIST_ACTIVE_SESS_HISTORY where SQL_ID='9hha8mvkmmjfd' order by 1;

Why table will be marked as stale?
Statistics on a table are considered stale when more than STALE_PERCENT (default 10%) of the rows are changed (total number of inserts, deletes, updates) in the table.
updating > stale_percent rows in a table will mark the stats as stale:

How do I get the total number of inserts/updates that have occurred in an Oracle database over a period of time?

https://stackoverflow.com/questions/6700010/how-do-i-get-the-number-of-inserts-updates-occuring-in-an-oracle-database

Whats a Wait Event ?
An event for which a process is waiting for.
Oracle process is BUSY when it utilises the cpu time and is NOT BUSY only when it’s waiting for some thing to happen.It waits for something…. WAITS FOR WHAT ? This could be various reasons and every reason has been given a specific name and is termed to be a ORACLE WAIT EVENT.

Difference between DB file sequential read and DB File Scattered Read?
Both "db file sequential read" and "db file scattered read" events signify time waited for I/O read requests to complete.A db file scattered read is the same type of event as "db file sequential read", except that Oracle will read multiple data blocks. Multi-block reads are typically used on full table scans.
These are two types of data block access in oracle:
db file sequential read is a single block IO, most typically these comes from index range scans and table access by index rowid.
db file sequential read (A single-block read (i.e., (for index scan)index fetch by ROWID)): It is the wait even for SINGLE BLOCK IO. A block at a time, block by block, from index to table. It reads block into contiguous memory.
If the query plan was "index range scan, table access by index rowid",it will use db file sequential reads, read index, read table block, read index, read table block - all single block IO.
There are many blocks being read - sequentially from index to table, index to table.

A single-block read with p3=1
db file sequential read => index scan, table access by index rowid

db file scattered read:A multiblock read (a full-table scan, OPQ, sorting): It is full-table scan read.
db file scattered read => full table scan, index fast full scan
read a bunch of blocks and SCATTER them in the buffer cache.
one block (p3 is always >= 2).
what is enqueue (enq:) waits:
This event indicates that the session is waiting for a lock that is held by another session.

what is Busy Buffer waits?
Busy Buffer waits means that the queries are waiting for the blocks to be read into the db cache.
there could be reason when the block may be busy in the cache and session is waiting for it.It could be undo/data block or segment header wait.
Select p1 "File #",p2 "Block #",p3 "Reason Code" from v$session_wait Where event = 'buffer busy waits';
Select owner, segment_name, segment_type from dba_extents where file_id = &P1 and &P2 between block_id and block_id + blocks -1;

Difference between Redo,Rollback and Undo?
Row Chaning and Row Migration?

How to find out background processes ?
select SID,PROGRAM from v$session where TYPE='BACKGROUND';
select name,description from V$bgprocess;
How to findout background processes from OS:
 ps -ef|grep ora_|grep SID

Why drop table is not going into Recycle bin?
If  using SYS user to drop any table then user’s object will not go to the recyclebin as there is no recyclebin for SYSTEM tablespace, even on setting already SET recycle bin parameter TRUE.
Select * from v$parameter where name = 'recyclebin';
Show parameter recyclebin;

Which factors are to be considered for creating index on Table? How to select column for index?
Creation of index on table depends on size of table, volume of data.If table size  is large and only need few data for selecting or in report then need to create index.
There are some basic reason of selecting column for indexing like cardinality and frequent usage in where condition of select query. Business rule is also forcing to create index like primary key, because configuring primary key or unique key automatically create unique index. Too many indexes would affect the performance of DML on table because in single transaction should need to perform on various index segments and table simultaneously.

A hot (or on-line) backup is a backup performed while the database is open and available for use (read and write activity). Except for Oracle exports, one can only do on-line backups when the database is ARCHIVELOG mode.

A cold (or off-line) backup is a backup performed while the database is off-line and unavailable to its users. Cold backups can be taken regardless if the database is in ARCHIVELOG or NOARCHIVELOG mode.
What is the difference between online and offline backups?
It is easier to restore from off-line backups as no recovery (from archived logs) would be required to make the database consistent. Nevertheless, on-line backups are less disruptive and don't require database downtime.

Point-in-time recovery (regardless if you do on-line or off-line backups) is only available when the database is in ARCHIVELOG mode.

What is the difference between restoring and recovering?
Restoring involves copying backup files from secondary storage (backup media) to disk. This can be done to replace damaged files or to copy/move a database to a new location.


Recovery is the process of applying redo logs to the database to roll it forward. One can roll-forward until a specific point-in-time (before the disaster occurred), or roll-forward until the last transaction recorded in the log files.

How to enable/disable archivelog mode?

Enable:

SQL> CONNECT sys AS SYSDBA
SQL> shutdown immediate
SQL> STARTUP MOUNT;
SQL> ALTER DATABASE ARCHIVELOG;
SQL> ALTER DATABASE OPEN;

Disable:
SQL> shutdown immediate
SQL> startup mount
SQL> alter database noarchivelog;
SQL> alter database open;
Other parameter:
SQL> show parameter recovery_file_dest
SQL> archive log list
SQL> alter system set log_archive_dest_1='LOCATION=/u02/app/oracle/oradata/orcl/arch' scope = both;
By default, archive logs will be written to the flash recovery area. If you do not want to write archive logs to the flash recovery area you can set the parameter LOG_ARCHIVE_DEST_n to the location in which you wish to write archive logs.

What  are available way for backing-up an Oracle database?
Export/Import - Exports are "logical" database backups in that they extract logical definitions and data from the database to a file.
Cold or Off-line Backups - shut the database down and backup up ALL data, log, and control files.
Hot or On-line Backups - If the database is available and in ARCHIVELOG mode, set the tablespaces into backup mode and backup their files. Also remember to backup the control files and archived redo log files.
RMAN Backups - while the database is off-line or on-line, use the "rman" utility to backup the database.

Difference between OBSOLETE and EXPIRED?

OBSOLETE:If a backup item is no longer needed for recovery – because it is older than the retention policy – then it is obsolete.

EXPIRED:means that the backup piece or backup set is not found in the backup destination or missing .Since backup info is hold in our controlfile and catalog.

How do you identify what are the all the target databases that are being backed-up with RMAN database?

Connect to the catalog database and issue following query.
SQL> select name,dbid from rc_database;

When do you recommend hot backup? What are the pre-reqs?
When there is no down time for database (24/7) ,we should go for hot backup.
pre-req:database must be in archive log mode

How do you identify the expired, active, obsolete backups? Which RMAN command you use?
1) RMAN>crosscheck backup;This command will give you the output for the Active and Expired Backups.
2) RMAN>report obsolete;This command will shows you the obsolete backups.

Difference between recovery and restoring of the database.
A scenario to understand Restore & Recovery process:
Sunday 10pm : Database is backed up. and is running fine.
Monday 11am : Went down / crashed due to any reason.
To bring up the database, we have 2 options:
1. Simple Restore : copying files from backup taken Sunday night and open the database. Here, we loose all the changes that are done since Sunday night.
2. Restore and Recovery: Copying files from backup taken Sunday night and applying all the archive log and redo log files to bring up the database to the point of failure. Here you dont loose the changes done until Monday 11 am.
Restore : copying files from the backup overwriting the existing database files
Recovery: applying the changes to the database till point of failure. these changes are recorded in online redolog and archivelog ( which are the backups of redolog) files.

What happens when you run ALTER DATABASE OPEN RESETLOGS ?
The current online redo logs are archived, the log sequence number is reset to 1, new database incarnation is created, and the online redo logs are given a new time stamp and SCN.

The reason to do the open the database with the resetlogs is that after doing an incomplete recovery , the data files and control files still don't come to the same point of the redo log files. And as long as the database is not consistent within all the three file-data, redo and control, you can't open the database. The resetlogs clause would reset the log sequence numbers within the log files and would start them from 0 thus enabling you to open the database but on the cost of losing all what was there in the redo log files.

In what scenarios open resetlogs required ?

An ALTER DATABASE OPEN RESETLOGS statement is required,
1.after incomplete recovery (Point in Time Recovery) or
2.recovery with a backup control file.
3. recovery with a control file recreated with the reset logs option.


Difference between RESETLOGS and NORESETLOGS ?

The NORESETLOGS option does not clear the redo log files during startup and the online redo logs to be used for recovery. Only used in scenario where MANUAL RECOVERY is started, CANCEL is used, and then RECOVER DATABASE is started.


What is SCN (System Change Number) ?
The system change number (SCN) is an ever-increasing value that uniquely identifies a committed version of the database at a point in time. Every time a user commits a transaction Oracle records a new SCN in redo logs.
Oracle uses SCNs in control files datafile headers and redo records. Every redo log file has both a log sequence number and low and high SCN. The low SCN records the lowest SCN recorded in the log file while the high SCN records the highest SCN in the log file.

What is Database Incarnation ?
Database incarnation is effectively a new “version” of the database that happens when you reset the online redo logs using “alter database open resetlogs;”.
Database incarnation falls into following category Current, Parent, Ancestor and Sibling
i) Current Incarnation : The database incarnation in which the database is currently generating redo.
ii) Parent Incarnation : The database incarnation from which the current incarnation branched following an OPEN RESETLOGS operation.
iii) Ancestor Incarnation : The parent of the parent incarnation is an ancestor incarnation. Any parent of an ancestor incarnation is also an ancestor incarnation.
iv) Sibling Incarnation : Two incarnations that share a common ancestor are sibling incarnations if neither one is an ancestor of the other.

How to view Database Incarnation history of Database ?
Using SQL> select * from v$database_incarnation;
Using RMAN>LIST INCARNATION;
However, you can use the RESET DATABASE TO INCARNATION command to specify that SCNs are to be interpreted in the frame of reference of another incarnation.
•For example my current database INCARNATION is 3 and now I have used
FLASHBACK DATABASE TO SCN 3000;then SCN 3000 will be search in current incarnation which is 3. However if I want to get back to SCN 3000 of INCARNATION 2 then I have to use,
RMAN> RESET DATABASE TO INCARNATION 2;

The Checkpoint Process
The checkpoint process is responsible for updating file headers in the database datafiles. A checkpoint occurs when Oracle moves new or updated blocks (called dirty blocks) from the RAM buffer cache to the database datafiles. A checkpoint keeps the database buffer cache and the database datafiles synchronized. This synchronization is part of the mechanism that Oracle uses to ensure that your database can always be recovered.


https://blog.tuningsql.com/how-to-tell-if-statistics-are-stale-in-oracle/




Sunday, January 8, 2017

ORA-19815: WARNING: db_recovery_file_dest_size of 751619276800 bytes is 100.00% used, and has 0 remaining bytes available.

Unable to login to application(Front end).Unable to connect to database from application host with apps user.SQL views getting hung,query to any view is displaying nothing

Alert log file having below error:

ARC3: Error 19809 Creating archive log file to '+ASM_TEST1'
Errors in file /u01/app/oracle/diag/rdbms/test/TEST/trace/TEST1_arc0_5915.trc:
ORA-19815: WARNING: db_recovery_file_dest_size of 751619276800 bytes is 100.00% used, and has 0 remaining bytes available.

You have following choices to free up space from recovery area:
1. Consider changing RMAN RETENTION POLICY. If you are using Data Guard,
   then consider changing RMAN ARCHIVELOG DELETION POLICY.
2. Back up files to tertiary device such as tape using RMAN
   BACKUP RECOVERY AREA command.
3. Add disk space and increase db_recovery_file_dest_size parameter to
   reflect the new space.
4. Delete unnecessary files using RMAN DELETE command. If an operating
   system command was used to delete files, then use RMAN CROSSCHECK and
   DELETE EXPIRED commands.
************************************************************************
ARC0: Error 19809 Creating archive log file to '+ASM_TEST1'

Verification:

SQL> select banner from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE    11.2.0.4.0      Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

SQL>
SQL> show parameter db_recovery_file_dest_size;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest_size           big integer 700G
SQL> show parameter db_recovery_file_dest ;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string      +ASM_TEST1
db_recovery_file_dest_size           big integer 700G
SQL>

Solution:
connect to RMAN
Rman>  crosscheck archivelog all;
Output will display expired .arc logs

Rman>   delete expired archivelog all;
This will delete the Expired archivelogs
or
If there are NO expired archive logs then backup the archive logs from the 'db_recovery_file_dest ' location to some other location (like TAPE) then delete archivelogs

RMAN> delete archivelog until time 'SYSDATE-7';       (deleting older than 7 days)

If db_recovery_file_dest_size is less, then increased it to high value to avoid the problem:

SQL>  ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 500G scope=both;

Max value for db_recovery_file_dest_size is 17179869182G   (in oracle version 10.2, 11.1, 11.2)

Query to check space used and max limit using:

select space_limit/1024/1024/1024 GB,space_used/1024/1024/1024 GB from v$recovery_file_dest;

Saturday, January 7, 2017

Query failing with error ORA-01157: and ORA-01110: After clone

after clone while doing sanity received below error on running query as :

SQL> select FILE_NAME,TABLESPACE_NAME from dba_temp_files;
select FILE_NAME,TABLESPACE_NAME from dba_temp_files
                                      *
ERROR at line 1:
ORA-01157: cannot identify/lock data file 1025 - see DBWR trace file
ORA-01110: data file 1025: '+TEST_DATA'

Alert log were having below error:
Cannot re-create tempfile +TEST_DATA, the same name file exists

On verifying the temp file at database level :

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
+TEST_DATA
+TEST_DATA/testdb1/tempfile/temp.468.932365707

Decided to drop existing and recreate TEMP Tablespace:

1. Create Temporary Tablespace Temp

CREATE TEMPORARY TABLESPACE TEMP2 TEMPFILE '+TEST_DATA' SIZE 200m; 

2. Move Default Database temp tablespace to temp2:

ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp2;

3. Be sure that no sessions using your Old tablespace "Temp".

i.Session details from V$SORT_USAGE: 
SELECT USERNAME, SESSION_NUM, SESSION_ADDR FROM V$SORT_USAGE; 
ii.Session ID from V$SESSION:
SELECT SID, SERIAL#, STATUS FROM V$SESSION WHERE SERIAL#=SESSION_NUM;
       OR
SELECT SID, SERIAL#, STATUS FROM V$SESSION WHERE SADDR=SESSION_ADDR; 

iii. Kill Session.
ALTER SYSTEM KILL 'SID,SERIAL#' IMMEDIATE; 

4. Drop old temp tablespace:
DROP TABLESPACE temp INCLUDING CONTENTS AND DATAFILES;

5. Recreate Tablespace Temp
CREATE TEMPORARY TABLESPACE TEMP TEMPFILE '+TEST_DATA' SIZE 4g;

6. Move Default Database temp tablespace to temp:
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp;

7.Drop new created temp2 tablespace:
DROP TABLESPACE temp2 INCLUDING CONTENTS AND DATAFILES;

Restart the database and issue rsolved....!!!

script to check object lock

SET ECHO        OFF
SET FEEDBACK    6
SET HEADING     ON
SET LINESIZE    256
SET PAGESIZE    50000
SET TERMOUT     ON
SET TIMING      OFF
SET TRIMOUT     ON
SET TRIMSPOOL   ON
SET VERIFY      OFF

CLEAR COLUMNS
CLEAR BREAKS
CLEAR COMPUTES

COLUMN instance_name                FORMAT a9           HEADING 'Instance'
COLUMN sid                          FORMAT 999999       HEADING 'SID'
COLUMN sid_serial                   FORMAT a15          HEADING 'SID / Serial#'
COLUMN session_status               FORMAT a9           HEADING 'Status'
COLUMN locking_oracle_user          FORMAT a20          HEADING 'Locking Oracle User'
COLUMN object_owner                 FORMAT a15          HEADING 'Object Owner'
COLUMN object_name                  FORMAT a25          HEADING 'Object Name'
COLUMN object_type                  FORMAT a15          HEADING 'Object Type'
COLUMN locked_mode                                      HEADING 'Locked Mode'

CLEAR BREAKS

PROMPT
PROMPT
PROMPT +------------------------------------------------------------------------+
PROMPT | LOCKED OBJECTS                                                         |
PROMPT +------------------------------------------------------------------------+

SELECT
    i.instance_name                       instance_name
  , l.session_id || ' / ' || s.serial#    sid_serial
  , s.status                              session_status
  , l.oracle_username                     locking_oracle_user
  , o.owner                               object_owner
  , o.object_name                         object_name
  , o.object_type                         object_type
  , DECODE (   l.locked_mode
             , 0, 'None'                        /* Mon Lock equivalent */
             , 1, 'NoLock'                      /* N */
             , 2, 'Row-Share (SS)'              /* L */
             , 3, 'Row-Exclusive (SX)'          /* R */
             , 4, 'Share-Table'                 /* S */
             , 5, 'Share-Row-Exclusive (SSX)'   /* C */
             , 6, 'Exclusive'                   /* X */
             ,    '[Nothing]'
           )                  locked_mode
FROM
    dba_objects       o
  , gv$session        s
  , gv$locked_object  l
  , gv$instance       i
WHERE
      i.inst_id     = l.inst_id
  AND s.inst_id     = l.inst_id
  AND s.sid         = l.session_id
  AND o.object_id   = l.object_id
ORDER BY
    i.instance_name
  , l.session_id;

Sunday, January 1, 2017

Maintenance Mode -

Why to enable maintenance mode?

This is enabled to ensure optimal performance and reduce downtime during a patching session. It shuts down the workflow business event system and set up function security so that oracle applications functions are unavailable to users. This provides a clear separation between normal runtime operation and system downtime for patching.

Note:  Maintenance Mode is only needed for AutoPatch and other AD utilities not require

How Maintenance Mode enabled:
There are two way:

1. Using adadmin:
i)Source application environment.
ii)adadmin: Options 5, 1

When we enable maintenance mode using utility adadmin, internally it calls adsetmmd.sql script located at FND_TOP/sql location. 
When adsetmmd.sql executes, it sets a Profile Option 'Applications Maintenance Mode'(APPS_MAINTENANCE_MODE) to 'MAINT' to Enable 'Maintenance Mode' and to 'NORMAL' to Disable.

2.Using script directly(adsetmmd.sql):
i)Run script :sqlplus <APPS_Schema name>/<APPS Password>@adsetmmd.sql ENABLE | DISABLE

Query to know the status of maintenance mode:
sqlplus apps/apps
SQL> select fnd_profile.value('APPS_MAINTENANCE_MODE') from dual;

If returns 'MAINT', then Maintenance Mode is Enabled and unable to Login. 
If returns 'NORMAL' then Maintenance Mode is removed and able to login.