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.

Thursday 17 October 2013

Follow my latest Doc

Please follow my latest doc "The Patch Impact Analysis using the Patch Wizard in Oracle Application Manager.". Feedback and suggestions are always welcome.

Exoprt and Import Schema

Hi Friends hope my previous post helped at-least some of you.
Taking export and import of schemas is a day to day activity for DBAs and other Oracle practitioners. The Data pump technique is one of the most convenient one.

Three steps to export a schema:-
Step 1 --> Create a directory for the dump files location--
Say location name is /TESTDB/SchemaDump/ ----- (for Linux, HP-UX, IBM-AIX, etc)
eg:-
$cd /TESTDB
$mkdir  SchemaDump
$cd  SchemaDump

 Step 2 --> Create virtual directory and grant permissions (schema say TestSchema) --
eg :-
Connect to sql and use the following commands--

create directory dump_dir as '/TESTDB/SchemaDump/';

grant read,write on directory dump_dir to TestSchema;
Grant succeeded.


 Step 3 --> Take the export --
eg:-
$expdp system@<database name with domain> schemas=TestSchema LOGFILE=TestSchema.log DUMPFILE=TestSchema.dmp flashback_time=systimestamp DIRECTORY=dump_dir

This command will create the dump and log file in the location "/TESTDB/SchemaDump"
flashback_time=systimestamp ---> This is optional
Please give the system password to process.

Command to import a schema:-
You should have the dump file located in the dump directory, once it is done use the following command:-
eg:-
$impdp system@<database name with domain> schemas=TestSchema directory=dump_dir dumpfile=TestSchema.dmp logfile=TestSchemaImp.log
Please give the system password to process.

This technique can also be used to export and import Tables as-well, the export backup of an entire database is also possible. The syntax for Table export is almost the same, please feel free to question if any one face any issues in using the commands.

Please comment if something needs to be added. Good Luck.!

Tuesday 15 October 2013

Patch Analysis(adpatch)

As a DBA we often need to apply Patches. This is a brief process to analysis the patch impact in our environments, before applying the patch.

Patch analysis:-
------------------------------------------------------------------------------------------------------------
Login to Unix/linux/solaris server that contain the Database.

$sqlplus "/ as sysdba"

SQL*Plus: Release 11.2.0.2.0 Production on Fri Jan 18 12:17:48 2013

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name from v$database;

NAME
---------
SAMPLEDB

SQL> select release_name from apps.fnd_product_groups;

RELEASE_NAME
--------------------------------------------------
11.5.10.2

SQL> select patch_level from apps.fnd_product_installations where patch_level like '%AD%';

PATCH_LEVEL
------------------------------
11i.AD.I.7

(Similarly check for other modules as well.)

SQL> select LANGUAGE_CODE, NLS_LANGUAGE, INSTALLED_FLAG from apps.fnd_languages_vl where INSTALLED_FLAG = 'I';

LANG NLS_LANGUAGE                   I
---- ------------------------------ -
ZHS  SIMPLIFIED CHINESE             I
ZHT  TRADITIONAL CHINESE            I

(This is for my sample environment, there may be other languages also)

SQL> select count(1) from dba_objects where status='INVALID';

  COUNT(1)
----------
        53

SQL> select object_type, count(1) from dba_objects where status='INVALID' group by object_type;

OBJECT_TYPE           COUNT(1)
------------------- ----------
PROCEDURE                    9
VIEW                        10
SYNONYM                      4
PACKAGE BODY                26
PACKAGE                      4

SQL> select owner, count(1) from dba_objects where status='INVALID' group by owner;

OWNER                            COUNT(1)
------------------------------ ----------
SYSTEM                                  2
EAR                                     1
EAPTIB                                  4
SUPPORT                                 2
CHUK                                    2
APPS                                   33
EDMSRUN                                 2
MFM                                     1
PERFSTAT                                2
TIBCO                                   4

SQL> select host||'.'||domain from apps.fnd_nodes where support_admin='Y';

HOST||'.'||DOMAIN
--------------------------------------------------------------------------------
eaad380.ams.sample.com

------------------------------------------------------------------------------------------------------------
Oracle also provides us the Patch Wizard in the Oracle Application Manager(OAM) for performing the patch analysis. Please wait for my next post on using the OAM.
I believe the above information shall help new DBAs in their activities. Please feel free to comment for any further information.