Tuesday, 14 January 2014

Creating A DB Link :-
-----------------------------------------------
create database link <DB Link Name> connect to <Username> identified by <Password> using 'Database Identifier';




Dropping a DB link :-
-----------------------------------------------
drop database link <DB Link Name>;

Simple query to Change the site name from back-end :-
-------------------------------------------------------------------------------
UPDATE FND_PROFILE_OPTION_VALUES set profile_option_value='<New Site Name>' where profile_option_id=125 and level_id=10001
/
commit
/
exit









#Note - The values may slightly change depending on environment.

Monday, 6 January 2014

Query to find all the concurrent programs running in any instance, execute this query in toad or sql/pl-sql developer to get the report in XL.

    SELECT fcr.request_id,
    fr.responsibility_name,
           DECODE(fcpt.user_concurrent_program_name,
                  'Report Set',
                  'Report Set:' || fcr.description,
                  fcpt.user_concurrent_program_name) CONC_PROG_NAME,
           argument_text PARAMETERS,
           NVL2(fcr.resubmit_interval,
                'PERIODICALLY',
                NVL2(fcr.release_class_id, 'ON SPECIFIC DAYS', 'ONCE')) PROG_SCHEDULE_TYPE,
           DECODE(NVL2(fcr.resubmit_interval,
                       'PERIODICALLY',
                       NVL2(fcr.release_class_id, 'ON SPECIFIC DAYS', 'ONCE')),
                  'PERIODICALLY',
                  'EVERY ' || fcr.resubmit_interval || ' ' ||
                  fcr.resubmit_interval_unit_code || ' FROM ' ||
                  fcr.resubmit_interval_type_code || ' OF PREV RUN',
                  'ONCE',
                  'AT :' ||
                  TO_CHAR(fcr.requested_start_date, 'DD-MON-RR HH24:MI'),
                  'EVERY: ' || fcrc.class_info) PROG_SCHEDULE,
           fu.user_name USER_NAME,
           requested_start_date START_DATE
      FROM apps.fnd_concurrent_programs_tl fcpt,
           apps.fnd_concurrent_requests    fcr,
           apps.fnd_user                   fu,
           fnd_responsibility_tl              fr,
           apps.fnd_conc_release_classes   fcrc
     WHERE fcpt.application_id = fcr.program_application_id
       AND fcpt.concurrent_program_id = fcr.concurrent_program_id
       AND fcr.requested_by = fu.user_id
       and fcr.responsibility_id=fr.responsibility_id
       AND fcr.phase_code = 'P'
       AND fcr.requested_start_date > SYSDATE
       AND fcpt.LANGUAGE = 'US'
       AND fcrc.release_class_id(+) = fcr.release_class_id
       AND fcrc.application_id(+) = fcr.release_class_app_id;


Mail me at - akash007.pramanik@gmail.com if you like this. Also feel free to comment for any issues.

Friday, 3 January 2014

Simple query to check Database locks:-
-----------------------------------------------------------
break on sid_serial;

SELECT l.session_id||','||v.serial# sid_serial,
       l.ORACLE_USERNAME ora_user,
       o.object_name,
       o.object_type,
       DECODE(l.locked_mode,
          0, 'None',
          1, 'Null',
          2, 'Row-S (SS)',
          3, 'Row-X (SX)',
          4, 'Share',
          5, 'S/Row-X (SSX)',
          6, 'Exclusive',
          TO_CHAR(l.locked_mode)
       ) lock_mode,
       o.status,
       to_char(o.last_ddl_time,'dd.mm.yy') last_ddl
FROM dba_objects o, gv$locked_object l, v$session v
WHERE o.object_id = l.object_id
      and l.SESSION_ID=v.sid
order by 2,3;
Simple query to check Database growth in GB with respect to time---
-------------------------------------------------------------------------------------
select to_char(Trunc(creation_time,'MM'), 'MON RRRR') "Month",
sum(bytes)/1024/1024/1024 "Growth in GB"
from sys.v_$datafile
where creation_time > SYSDATE-9999
group by Trunc(creation_time,'MM')
order by Trunc(creation_time,'MM');

Monday, 30 December 2013

Simplest query to check the existing application and Database nodes in your database:
-----------------------------------------------------------------------------------------------------------
set lines 150
set pages 200
col NODE_NAME for a10
col NODE_NAME for a20
col SERVER_ADDRESS for a18
col HOST for a15
col DOMAIN for a18
col SUPPORT_CP for a3
col SUPPORT_FORMS for a3
col SUPPORT_WEB for a3
col SUPPORT_ADMIN for a3
col STATUS for a10
select NODE_NAME, SERVER_ADDRESS, HOST, DOMAIN,SUPPORT_DB D, SUPPORT_CP C, SUPPORT_FORMS F,SUPPORT_WEB w, SUPPORT_ADMIN A, STATUS from apps.fnd_nodes;

Friday, 27 December 2013

Check your Database health and status

Database Health Check
-----------------------------------------------------------------------

connect as sysdba
SQL> select status, name from v$controlfile;


connect as sysdba
SQL> select * from v$logfile;


connect as sysdba
SQL> archive log list



To determine if a datafile and thus, a tablespace, has AUTOEXTEND capabilities:-
----------------------------------------------------------------------------------
select file_id, tablespace_name, bytes, maxbytes, maxblocks, increment_by, file_name
from dba_data_files
where autoextensible = 'YES';


Location of Datafiles:-
-------------------------------
SQL> select * from v$dbfile;


Check System Tablespace:-
---------------------------
select owner, segment_name, segment_type
from dba_segments
where tablespace_name = 'SYSTEM'
and owner not in ('SYS','SYSTEM');


Check SYSAUX Tablespace:-
------------------------------
select space_usage_kbytes, occupant_name, occupant_desc
from v$sysaux_occupants
order by 1 desc;


Local vs Dictionalr Managed tablespaces:-
-------------------------------------------
select tablespace_name, extent_management
from dba_tablespaces;


Users that have permanent Tablespaces Specified:-
------------------------------------------------------
select u.username, t.tablespace_name
from dba_users u, dba_tablespaces t
where u.temporary_tablespace = t.tablespace_name
and t.contents <> 'TEMPORARY';


Size of Temporary Tablespace:-
-----------------------------------------------------
select tablespace_name, sum(bytes)/1024/1024 mb
from dba_temp_files
group by tablespace_name;



High watermark of Temp tablespace:-
-------------------------------------
select tablespace_name, sum(bytes_cached)/1024/1024 mb
from v$temp_extent_pool
group by tablespace_name;


Current usage of Temp table space:-
--------------------------------------
select ss.tablespace_name,
sum((ss.used_blocks*ts.blocksize))/1024/1024 mb
from gv$sort_segment ss, sys.ts$ ts
where ss.tablespace_name = ts.name
group by ss.tablespace_name;


Find number of extent:-
-------------------------
select owner, segment_type, segment_name, tablespace_name,
count(blocks), SUM(bytes/1024) "BYTES K", SUM(blocks)
from dba_extents
where owner NOT IN ('SYS','SYSTEM')
group by owner, segment_type, segment_name, tablespace_name
having count(*) > <--minext-->>
order by segment_type, segment_name;


Find next extent:-
-------------------------
select s.owner, s.segment_name, s.segment_type,
s.tablespace_name, s.next_extent
from dba_segments s
where s.next_extent > (select MAX(f.bytes)
from dba_free_space f
where f.tablespace_name = s.tablespace_name);


Rollback Segments:-
-------------------------
select d.segment_name, d.tablespace_name, s.waits, s.shrinks,
s.wraps, s.status
from v$rollstat s, dba_rollback_segs d
where s.usn = d.segment_id
order by 1;


Alert log location:-
------------------------------
show parameter background_dump_dest


Max dump file size:-
---------------------------
show parameter max_dump_file_size






Please write to me on akash007.pramanik@gmail.com for any concerns.