Wednesday, October 31, 2007

Remove ^M from files transferred from Windows to Linux

Inside vi [in ESC mode] type:

:%s/^M//g (to make the ^M -> CTRL+V then CTRL+M)

Friday, October 19, 2007

Oracle ODBC : Driver's SQLAllocHandle on SQL_HANDLE_ENV failed

While configuring DSN using Oracle ODBC driver, one might encounter error "Driver's SQLAllocHandle on SQL_HANDLE_ENV failed". Cause being, Permissions of the remote desktop software did not allow the user access via the remote desktop software.

Do the following to resolve the issue:

1. Select Administration Tools , Local Security Setting and Local Policy.
2. Then select "User Rights Assignment"
3. Double click on "Create Global Objects"
4. Select Add User or Group.
5. Make sure Object Types Group Box is checked.
6. Select Locations and highlight the name of the server you are working on (Not the Domain).
7. Enter "Remote Desktop Users" or "Everyone" (without the quotes) into the Object Names Box.
8. Select OK.
9. Add the same users to the group "Power User".
10. If this does not work, after step 8 a reboot may be required.

Tuesday, October 16, 2007

Oracle: Spooling Column of type Long

Set the following sqlplus options for spooling a long column. This will avoild truncation of lines to a particular width.

SQL> set trimspool on
SQL> set linesize 20000
SQL> set long 100000000
SQL> set longchunksize 2000
SQL> set pagesize 0

Thursday, October 4, 2007

Oracle : Support for Very Large Memory (VLM) Configurations

Oracle Database for Windows supports Very Large Memory (VLM) configurations in Windows to access more than the 4 gigabyte (GB) of RAM traditionally available to Windows applications.

The requirements for taking advantage of this support are:

  1. The computer on which Oracle Database is installed must have more than 4 GB of memory.

  2. The operating system must be configured to take advantage of Physical Address Extensions (PAE) by adding the /PAE switch in boot.ini. See Microsoft Knowledge Base article Q268363 for instructions on modifying boot.ini to enable PAE.

  3. It is advisable (though not necessary) to enable 4GT support by adding the /3GB parameter in boot.ini. See Microsoft Knowledge Base article Q171793 for additional requirements and instructions on modifying boot.ini to enable 4GT.

  4. The user account under which Oracle Database runs (typically the LocalSystem account), must have the "Lock memory pages" Windows 2000 and Windows XP privilege.

  5. USE_INDIRECT_DATA_BUFFERS=TRUE must be present in the initialization parameter file for the database instance that will use VLM support. If this parameter is not set, then Oracle Database 10g Release 1 (10.1) behaves in exactly the same way as previous releases.

  6. Initialization parameters DB_BLOCK_BUFFERS and DB_BLOCK_SIZE must be set to values you have chosen for Oracle Database.

  7. Registry parameter AWE_WINDOW_MEMORY must be created and set in the appropriate key for your Oracle home. This parameter is specified in bytes and has a default value of 1 GB. AWE_WINDOW_MEMORY tells Oracle Database how much of its 3 GB address space to reserve for mapping in database buffers.
  8. Once this parameter is set, Oracle Database can be started and will function exactly the same as before except that more database buffers are available to the instance. In addition, disk I/O may be reduced because more Oracle Database data blocks can be cached in the System Global Area (SGA).

  9. If DB_BLOCK_SIZE is large, however, the default AWE_WINDOW_MEMORY value of 1 GB may not be sufficient to start the database.
Reference Note:
http://download-west.oracle.com/docs/cd/B14117_01/win.101/b10113/architec.htm#sthref58

Tuesday, September 25, 2007

Reset OC4J Admin Password

Reset the oc4jadmin password using the following procedure while you are logged in as the user who installed the Oracle Application Server instance:

  1. Stop OC4J and the Application Server Control.

    Enter the following command in the Oracle home of the application server instance:

    (UNIX) ORACLE_HOME/opmn/bin/opmnctl stopproc ias-component=OC4J
    (Windows) ORACLE_HOME\opmn\bin\opmnctl stopproc ias-component=OC4J

  2. Locate and open the following file in a text editor:

    (UNIX)ORACLE_HOME/j2ee/home/config/system-jazn-data.xml
    (Windows)ORACLE_HOME\j2ee\home\config\system-jazn-data.xml

  3. Locate the line that defines the credentials property for the oc4jadmin user.

    The following example shows the section of system-jazn-data.xml with the encrypted credentials entry in boldface type:



    jazn.com

    .
    .
    oc4jadmin
    OC4J Administrator
    OC4J Administrator
    {903}4L50lHJWIFGwLgHXTub7eYK9e0AnWLUH

  4. Replace the existing encrypted password with the new password.

    Be sure to prefix the password with an exclamation point (!). For example:

    !mynewpassword123

Tuesday, September 18, 2007

ORA-27047: unable to read the header block of file

If while restoring backup, Db errors out with ORA-27047, it implied that the block header is corrupt.

Following three actions can be taken to restore DB:

1. resize the database file in the source system and again take the cold backup. Resizing reformats the block header.
2. use the existing control files to startup the database and then resize the file.
3. If control files can not be reused, because of the change in file location where db files will be restored, just take the cold backup copy of only the resized file from the source system. replace the existing corrupt header file with the newly backup copy and create the control file.
revert back to the original corrupt header file and try to open db with the newly created control file. It will fail with checkpoint mismatch asking for some file needing recovery.
Give the command "recover database using backup control file". When asked for the achive logs, supply the redo log file (try with each of the log files), it will recover the DB.

Wednesday, September 5, 2007

Oracle BITMAP Index Structure

Index block with PCTFREE 50

select extent_id, file_id,block_id from dba_extents where segment_name='IND_BMP_50' order by extent_id

EXTENT_ID FILE_ID BLOCK_ID
---------- ---------- ----------
0 1074 53953
1 1115 53841
2 1196 53745
3 1742 447857
4 1744 446833


SQL > alter system dump datafile 1742 block 447857

row#0[6126] flag: ------, lock: 0, len=1906
col 0; len 1; (1): 80 <-key value
col 1; len 6; (6): 2b 40 d2 29 00 08 <-Starting Rowid
col 2; len 6; (6): 2b 40 d2 c1 00 1f <-Ending Rowid
col 3; len 1886; (1886): <-Bitmap for the key value


row#1[4221] flag: ------, lock: 0, len=1905
col 0; len 1; (1): 80
col 1; len 6; (6): 2b 40 d2 c1 00 30
col 2; len 6; (6): 2b 40 d3 48 00 67
col 3; len 1885; (1885):

There are two rows in the block. Totallying their column size :
1+6+6+1886+1+6+6+1885 = 3797kb
So, block is occupying approx 50% of the block (8192kb)



Index block with PCTFREE 10

SQL> select extent_id, file_id,block_id from dba_extents where segment_name='IND_BMP_10' order by extent_id;

EXTENT_ID FILE_ID BLOCK_ID
---------- ---------- ----------
0 1074 63057
1 1115 62945
2 1196 62849
3 1742 457377
4 1744 456177
5 1786 429665
6 1809 411889


alter system dump datafile 1742 block 457377

row#0[4495] flag: ------, lock: 0, len=3537
col 0; len 1; (1): 80 <-key value
col 1; len 6; (6): b3 c6 f6 2b 00 28 <-Starting rowid
col 2; len 6; (6): b3 c6 f6 ce 00 37 <-Ending rowid
col 3; len 3517; (3517): <-Bitmap for the key value


row#1[957] flag: ------, lock: 0, len=3538
col 0; len 1; (1): 80
col 1; len 6; (6): b3 c6 f6 ce 00 48
col 2; len 6; (6): b3 c6 f7 74 00 37
col 3; len 3518; (3518):


There are two rows in the block. Totallying their column size:
1+6+6+3517+1+6+6+3518 = 7161 kb
So, block is occupying approx 90% of the block (8192kb)