Monday, August 24, 2009

Basic Scripts to find Version: ORACLE/UNIX

Some common basic scripts to find version:

Version of Unix Operating System
Red Hat Linux -> cat /etc/redhat-release

To find database version:
SQL> select * from v$version;

Find the URL for the application:
Login as apps:SQL> select home_url from icx_parameters;

To find Apps Version:
SQL> select release_name from apps.fnd_product_groups;

Web Server/Apache or Application Server in Apps R12
Log in as Application user: run below query
$IAS_ORACLE_HOME/Apache/Apache/bin/httpd -version

Oracle Java Plug-in in R12/12iLog in as Application user:
Query:$ grep plugin $CONTEXT_FILE

File Version on file system strings grep Header
$strings -a grep -i '$Header'
## to find reports version ###
adident $Header

Discoverer Version for 11i Log in as Application user, set environment variable and run below query$ORACLE_HOME/bin/disc4ws grep -i Version

Tuesday, July 3, 2007

Enabling Faster Incremental Backups in Oracle 10g

In this blog entry let me introduce you to a new capability in Oracle 10g called Block Change Tracking, which can help DBA’s do faster incremental backups via RMAN (Recovery Manager).
Once this new capability in Oracle 10g is enabled it start recording the modified since last backup and stores the log of it in a block change tracking file.
Later while doing backup RMAN uses this file to determine which blocks are needed to be backed up?
Logically as we can see, this process improves the performance as RMAN does not have to scan whole datafile to detect which block in it has changed and needs backup.
This may not show any significant impact on smaller database but definitely will have big impact on bigger databases as now with this new functionality it does not have to scan full datafile but only need to query block change tracking file.
To create the Change Tracking file and enable Change Tracking, make sure the database is either open or mounted. Then issue following SQL:
SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USINGFILE ‘c:\oracle\oradata\rkt\block_track\block_track_file01.log’;
Database altered.
Once you issue above SQL, Oracle creates a new background process which is responsible for writing data to the block change tracking file, which is called the block change writer CTRW.
To verify the status of block change tracking, use following SQL:
SQL> SELECT filename, status, bytes FROM v$block_change_tracking;
FILENAME
——————————————————
STATUS BYTE
————— ————–
C:\ORACLE\ORADATA\RKT\BLOCK_TRACK\BLOCK_TRACK_FILE01.LOG
ENABLED 1024
To disable block change tracking, use following SQL:
SQL> ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;

Updating a table from another table

Updating a table from another table

Lets first create following tables to show the concept
SQL> CREATE TABLE table_1 ( c_code NUMBER PRIMARY KEY, c_name VARCHAR2(40) );Table created.
SQL> CREATE TABLE table_2 ( c_code NUMMBER PRIMARY KEY, c_name VARCHAR2(40) );Table created.
Note:We need a PRIMARY KEY or an UNIQUE KEY on source table atleast from where we will be getting the values because if this CONSTRAINT is not there then it will result in multiple rows which will create an ambigous situation.
SQL> INSERT INTO table_1 VALUES ( 1, ‘First Row’ );SQL> INSERT INTO table_1 VALUES ( 2, ‘Nothing’ );SQL> INSERT INTO table_2 VALUES ( 2, ‘Second Row’ );
SQL> UPDATE ( SELECT a.c_name a_col, b.c_name b_col2 FROM table_1 a, table_2 b3 WHERE a.c_code = b.c_code )4 SET a_col = b_col5 /
1 row updated.
SQL> select * from a2 /
c_code c_name————– ————————-1 First Row2 Second Row
Below are few more variance sql for same purpose, but SQL above gives best chance to optimizer in getting a good execution plan.
SQL> UPDATE table_1 a2 SET c_name = ( SELECT c_name3 FROM table_2 b4 WHERE b.c_code = a.c_code)5 WHERE EXISTS ( SELECT c_name6 FROM table_2 b7 WHERE b.c_code = a.c_code )8 /
1 row updated.
SQL> UPDATE table_1 a2 SET c_name = ( SELECT c_name3 FROM table_2 b4 WHERE b.c_code = a.c_code )5 WHERE a.c_code IN ( SELECT c_code6 FROM table_2 )7 /
1 row updated.