Mar 4, 2010

Start up & Shut Down Oracle

After Install Oracle, go to $ORACLE_HOME/bin

run :

$ export ORACLE_SID={ORACLE_SID}
$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Mar 4 16:21:17 2010

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

SQL> connect system/manager as sysdba

**Note: if you prompted this error, means you didn't set the ORACLE_SID :
ORA-12162: TNS:net service name is incorrectly specified

To shutdown database :

SQL> shutdown immediate


To startup database :

SQL> startup

Java Hello Word

1) Download JDK
Just download SUN JDK from http://java.sun.com/javase/downloads/index.jsp
Choose the latest version of JDK, download and install to your PC.

2) Test JDK
You may now test the JDK to make sure you have installed it correctly.
Open your Command Prompt, and type : java -version
This command will show you the java version installed in your PC.

3) Hello World
Yes, hello world again... Open your note pad or other writing software, type in the following :

public class HelloWorld {
public static void main (String[] args) {
System.out.println("Hello, world!\n");
}
}

Save it as HelloWorld.java in a particular folder, let say in C:\Java

4) Compile & Run
Open Command Prompt again, and change directory to C:\Java.
Type : javac HelloWorld.java (To Compile the source)
A HelloWorld.class file will be generated in
C:\Java
Type : java HelloWorld (To Run the class file)

You will see this on the Command Prompt :

Hello, world!






Mar 3, 2010

Oracle to run SQL as script without consider define

To run Oracle sql as script without consider the parameter that starts with "&", just add this before the script :

set def off;

Mar 2, 2010

Oracle 10g SPFILE corrupted

the SPfile is in binary format, if you edit it and save accidentally, your database will not able to startup with the normal startup command.

if you are on unix,

$ cd $ORACLE_HOME/dbs
$ strings spfilename temp_pfile.ora

edit the temp_pfile.ora, clean it up if there is anything "wrong" with it.

then

SQL> startup pfile={FULL-PATH}temp_pfile.ora
SQL> create spfile from pfile;
SQL> shutdown
SQL> startup


Remember to backup your spfile.

Parameter values can only be modified with ALTER SYSTEM that will work after the STARTUP
command
. For example :

SQL> alter system set max_enabled_roles=20 scope=spfile;

Mar 1, 2010

Direct and Asynchronous I/O - Oracle 10g

I/O operations in UNIX and Linux systems typically go through the file system cache. Although this doesn't represent a problem in itself, this extra processing does require resources. Bypassing the file system cache reduces CPU requirements, and frees up the file system cache for other non-database file operations. Operations against raw devices automatically bypass the file system cache.

When a synchronous I/O request is submitted to the operating system, the writing process blocks until the write is complete before continuing processing. With asynchronous I/O, processing continues while the I/O request is submitted and processed. This allows asynchronous I/O to bypass some of the performance bottlenecks associated with I/O operations.

Oracle can take advantage of direct I/O and asynchronous I/O on supported platforms using the FILESYSTEMIO_OPTIONS parameter, whose possible values are listed below.
  • ASYNCH - Enabled asynchronous I/O where possible.
  • DIRECTIO- Enabled direct I/O where possible.
  • SETALL- Enabled both direct I/O and asynchronous I/O where possible.
  • NONE - Disabled both direct I/O and asynchronous I/O.
The following example shows how the parameter is set.

SQL> SHOW PARAMETER FILESYSTEMIO_OPTIONS

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
filesystemio_options string none
SQL> ALTER SYSTEM SET FILESYSTEMIO_OPTIONS=SETALL SCOPE=SPFILE;

System altered.

SQL> SHUTDOWN IMMEDIATE
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP
ORACLE instance started.

Total System Global Area 926941184 bytes
Fixed Size 1222672 bytes
Variable Size 239077360 bytes
Database Buffers 683671552 bytes
Redo Buffers 2969600 bytes
Database mounted.
Database opened.
SQL> SHOW PARAMETER FILESYSTEMIO_OPTIONS

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
filesystemio_options string SETALL
SQL>

also need to alter :

SQL> alter SYSTEM set disk_asynch_io=FALSE SCOPE=SPFILE;

SQL> alter system set dbwr_io_slaves=1 scope=spfile;