Wednesday, July 23, 2008

How to DROP a Datafile from a Tablespace

Starting with version 10.2 and higher You can now alter tablespace drop datafile (except first datafile of a tablespace).

Eg:
Alter tablespace TBS01 drop datafile '/dev01/oradata/dev01/data_04.dbf';

Wednesday, July 16, 2008

Enabling System Managed Undo (SMU)

As of 9iR2, Oracle Applications Release 11i supports only the use of system managed undo (SMU). SMU is more efficient than traditional rollback segments and reduces the possibilities of “snapshot too old errors.” The following steps should be used to enable system managed undo.

Step 1:
Capture the tablespace names being used for the existing rollback segments from dba_rollback_segs. Capture the datafiles and sizes being used for the rollback tablespaces from dba_data_files.

SQL> select segment_name, tablespace_name from dba_rollback_segs;

SQL> select file_name, tablespace_name, bytes from dba_data_files where tablespace_name = '';
where is the tablespace name used by a rollback segment.

Step 2:
Drop all the private and public rollback segments except for the SYSTEM rollback segment.

SQL> alter rollback segment offline;
SQL> drop rollback segment ;

Step 3:
Drop the corresponding tablespace(s) where the rollback segments reside.

SQL> alter tablespace offline;
SQL> drop tablespace ;

Step 4:
Create a new System Managed Undo tablespace per instance as follows:

create undo tablespace APPS_UNDOTS1 datafile '' size reuse extent management local ;

For the path and the size values, you should reuse the same files and sizes which were used in the tablespaces which were dropped in step 2. The sizes and file names were captured in step 1.

Step 5:
Set the following database initialization parameters:

undo_management = AUTO
undo_tablespace = APPS_UNDOTS1

Refer to the sizing table (Database Initialization Parameters Sizing section) for the appropriate setting of undo_retention.

Step 6:
Remove the database initialization parameter rollback_segments.

Step 7:
Restart the database so that the system managed undo takes effect.

Tuesday, July 15, 2008

How to trace a specific session?

Tracing a specific session instead of the entire system allows you to get smaller and very readable tracefiles.

a. Open two sessions - one where you will control the trace and one where you can run the processes to be traced.

b. Connect to the database with dba privileges

SQL> connect / as sysdba
select v$process.SPID, v$process.USERNAME from v$process, v$session where v$session.PADDR=v$process.ADDR order by v$session.logon_time;

SPID USERNAME
--------- ---------------
863 oracle
865 oracle
867 oracle
..
5104 oracle
5159 oracle

If you run this query just before and after your logon to your other session, you should be able to find the SPID of your connection. Make sure you don't trace the wrong process.

c. Suppose our SPID is 5159.

SQL>oradebug SETOSPID 5159
Statement processed.
SQL>oradebug event 10046 trace name context forever, level 12

The second command will include the bind variables in the trace file.

d. Perform the actions you want to trace in your other session, then exit server manager. Your tracefile now only contains those statements which are relevant.

DBControl Configuration in 10g

Reconfigure DBControl Configuration Files Without Losing The Repository Data :
$ORACLE_HOME/bin/emca -deconfig dbcontrol db
$ORACLE_HOME/bin/emca -config dbcontrol db

Recreating DB Control with Losing the Repository Data:
$ORACLE_HOME/bin/emca -deconfig dbcontrol db -repos drop
$ORACLE_HOME/bin/emca -config dbcontrol db -repos create

To stop & start the Database Control service run:
$ORACLE_HOME/bin/emctl stop dbconsole
$ORACLE_HOME/bin/emctl start dbconsole

A complete list of available emctl commands can be obtained by just typing:
ORACLE_HOME/bin/emctl

Monday, July 14, 2008

Merging multiple patches into one integrated patch in oracle apps?

1. Review the readme files carefully.
The patch may also require manual steps.

2. Create directories.
In the patch top area, create a source directory and a destination directory. Choose any name for these directories.

3. Unzip patches.
Copy all the patches to be merged into the source directory and unzip them.

4. Run AD Merge Patch. (admrgpch)
Run AD Merge Patch and supply the arguments for the destination directory name and the source directory name. You also need to specify the merged patch name, or accept the default.

eg: admrgpch [source_directory] [destination_directory]
admrgpch -s [source_directory] -d [destination_directory] [-merge_name [pattern]]

5. Check AD Merge Patch log files.
After AD Merge Patch runs, check the admrgpch.log file for errors. The file is located in the current working directory (where AD Merge Patch was run).

6. Run the merged patch.
Once a merged patch is created, apply it just like a single patch.

How to find if a Sun Solaris OS is 32-Bit or 64-Bit ?

Type "isainfo -v" at the OS prompt.

If the output shows 2 entries, then its 64bit.

$ isainfo -v
64-bit sparcv9 applications
32-bit sparc applications

Else if it shows only one entry then its 32 bit.

$ isainfo -v
32-bit sparc applications

Tuesday, July 8, 2008

How to gather statistics in Oracle apps from backend

Use the following command to gather schema statistics:
exec fnd_stats.gather_schema_statistics('ONT') < For a specific schema >
exec fnd_stats.gather_schema_statistics('ALL') < For all schemas >

How can one improve Import/ Export performance?

EXPORT:
Set the BUFFER parameter to a high value (e.g. 2M)
Set the RECORDLENGTH parameter to a high value (e.g. 64K)
Stop unnecessary applications to free-up resources for your job.
If you run multiple export sessions, ensure they write to different physical disks.
DO NOT export to an NFS mounted filesystem. It will take forever.
IMPORT:
Create an indexfile so that you can create indexes AFTER you have imported data. Do this by setting INDEXFILE to a filename and then import. No data will be imported but a file containing index definitions will be created. You must edit this file afterwards and supply the passwords for the schemas on all CONNECT statements.
Place the file to be imported on a separate physical disk from the oracle data files
Increase DB_CACHE_SIZE (DB_BLOCK_BUFFERS prior to 9i) considerably in the init$SID.ora file
Set the LOG_BUFFER to a big value and restart oracle.
Stop redo log archiving if it is running (ALTER DATABASE NOARCHIVELOG;)
Create a BIG tablespace with a BIG rollback segment inside. Set all other rollback segments offline (except the SYSTEM rollback segment of course). The rollback segment must be as big as your biggest table (I think?)
Use COMMIT=N in the import parameter file if you can afford it
Use ANALYZE=N in the import parameter file to avoid time consuming ANALYZE statements
Remember to run the indexfile previously created

Tips for changing delimiter in excel

To change the File delimiter on your PC to a pipe(or anything) rather than a comma bring up your default options window by clicking Start => Settings => Control Panel => Regional Settings (aka Regional Options).

Click the "Number" tab.
In the "List Separator" field, replace the current default separator with the one you want to use (e.g. a pipe symbol I ).

Click "Apply" (if it is there) and "OK" to save the change and close the window. You can now save Excel files as pipe delimited files by simply doing the following in Excel:

Open or Create a new file in Excel.
Click File => Save As on the menu bar.
In the "File Type" drop down, select "CSV (Comma Delimited) *.csv".

Duplicate data files

In order to find duplicate data files in your environemnt use the following sql:
select tablespace_name,file_name from dba_data_files a where 1< (select count(*) from
dba_data_files b where substr(a.file_name,24,60)=substr (b.file_name,24,60)) ;

To fix the duplicate datafiles follow the below procedure:

1. If the database is up, shut it down.
> SHUTDOWN IMMEDIATE
2. Copy the datafile to the new name/location at operating system level.
> cp
3. Mount the database.
> STARTUP MOUNT
This command will read the control file but will not mount the datafiles.
4. Rename the file inside Oracle.
> ALTER DATABASE RENAME FILE
'/FULL_PATH_OF_OLD_LOCATION/AND_DATAFILE_NAME.DBF'
TO
'/FULL_PATH_OF_NEW_LOCATION/AND_DATAFILE_NAME.DBF';
Do this for all the datafiles that were renamed or moved at the operating system level.
5. Open the database.
> ALTER DATABASE OPEN;
6. Query v$dbfile to confirm that the changes made were correct.
> SELECT * FROM V$DBFILE;
7. Remove the datafile(s) from the old location at the operating system level.

Compiling library files(.pll) in Oracle Apps

1. Logon as applmgr to the application server where the forms are installed.

2. Change directory to $AU_TOP/resource where all the .pll reside.

cd $AU_TOP/resource

3. Syntax for the f60gen command is as follows:

f60gen module=.pll userid=password> output_file=/resource/.plx
module_type=library batch=no compile_all=special

4. Examples:

cd $AU_TOP/forms/US

Example 1:
f60gen module=FNDCONC.pll userid=APPS/APPS output_file=$AU_TOP/resource/FNDCONC.
plx module_type=library batch=no compile_all=special

Example 2:
f60gen module=FAXMAD.pll userid=FA/FA output_file=$AU_TOP/resource/FAXMAD.plx
module_type=library batch=no compile_all=special

Find Server CPU Information

To Find Server CPU Information in Solaris:

Execute:
/usr/platform/sun4u/sbin/prtdiag