Thursday, October 23, 2008

Export Oracle Dump file from command prompt or from Window Run Mode

The oracle Export Utility is used to export entire database or users or list of tables to the path given by the FILE parameter. The DIRECT path method is much faster than conventional method. The direct path method reads data directly from the disk and places in the buffer and then sent to the export client , writes it to the disk. Whereas conventional path follow SQL SELECT statement to fetch the data thus have to evaluate expression in the memory before transporting the file to the client to write to the disk. The COMPRESS parameter specifies the extent management during import of the table data. If it is set to Y then the table data is consolidated into single extent during import otherwise it uses current storage parameter of the tables during import. It is good practise to verify the log file after the export of the file have been completed to verify the successful export.

EXP username/password FILE=file_path\filename.dmp DIRECT=Y COMPRESS=Y ROWS= Y OWNER=user_to_export LOG=log_path_name\logfilename.txt

You can export the selected tables from the file with the TABLES option

EXP username/password FILE=file_path\filename.dmp DIRECT=Y COMPRESS=Y ROWS= Y OWNER=user_to_export TABLES=TABLE_NAME LOG=log_path_name\logfilename.txt

Import Oracle Dump file from command prompt or execute from window Run mode

The oracle Import Utility is oracle database tool used to import users, database, tablesapces from database dump file. The utility can be invoked from the command prompt and also could be executed from windows Run mode. You could simply change the parameters and paste the command given below from windows Run mode. The log parameter maintains the log of the import.

IMP username/password FILE=file_path\filename.dmp FROMUSER=user_previously_dumped TOUSER=current_user ROWS=Y INDEXES=Y CONSTRAINTS=Y LOG=log_path_name\logfilename.txt

You can import the selected tables from the file with TABLES option

IMP username/password FILE=file_path\filename.dmp FROMUSER=user_previously_dumped TOUSER=current_user TABLES=BPT_SIGNATURES ROWS=Y INDEXES=Y CONSTRAINTS=Y LOG=log_path_name\logfilename.txt

Tuesday, October 21, 2008

Managing Oracle tablespace and datafiles

It is the best practise to separate user data from system data in an oracle database. Doing so enhances the performance of the database.
Oracle manages its datafiles in logical space known as Tablespace. A tablespace can have multiple datafiles but a single datafile can belong to one and only one tablespace. Datafiles are the physical files that stores data which are divided again into logical segment and extents. It should be noted that autoextend clause extend
the datafile automatically as and when needed but the auto extension of the size of datafile depend on the maximum file size limit of the operating system and it also degrade performance of the database. Locally managed extents maintain its data state information in its own header(bitmapped). This avoids the throughput in the data dictionary, which increases performance as well.

It is the best approach to separate user datafile and user data index file in separate tablespace. Temporary tablesapce are used for sorting operation required during query executions.

--user data holder tablespace and datafiles
CREATE TABLESPACE TABLESPACE_NAME
DATAFILE '%ORACLE_BASE%\ORADATA\SID\DATAFILE01.DBF' SIZE 100M AUTOEXTEND ON
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M
SEGMENT SPACE MANAGEMENT AUTO;

--add more datafile to a tablespace

ALTER TABLESPACE TABLESPACE_NAME ADD DATAFILE '%ORACLE_BASE%\ORADATA\SID\DATAFILE02.DBF' SIZE 100M AUTOEXTEND ON;

--user index tablespace and datafiles
CREATE TABLESPACE TABLESPACE_NAME_INDX
DATAFILE '%ORACLE_BASE%\ORADATA\SID\DATA_INDX01.DBF'
SIZE 100M AUTOEXTEND ON
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M
SEGMENT SPACE MANAGEMENT AUTO;

--user temporary tablespace and datafiles
CREATE TEMPORARY TABLESPACE TABLESPACE_TEMP
TEMPFILE '%ORACLE_BASE%\ORADATA\SID\TEMP01.DBF'
SIZE 20M AUTOEXTEND ON
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;

Simple AJAX

Make your web page optimized by implementing AJAX technology. AJAX stands for Asynchronous JavaScript and XML made popular by Google.

XMLHttpRequest object is the key behind the communication between clients and server. Different browsers use different methods to create the XMLHttpRequest object. Internet Explorer uses an ActiveXObject, while other browsers uses the built-in JavaScript object called XMLHttpRequest.

The onreadystatechange event of the XMLHttpRequest will process the response from a server. By invoking the function on this event we retrieve the information sent by the server.

The readyState property holds the status of the server's response. Each time the readyState changes, the onreadystatechange function will be executed.

Here are the possible values for the readyState property:
State Description
0 Request is not initialized
1 Request has been set up
2 Request has been sent
3 Request is in process
4 Request is complete

Here is the sample code.


start of html tag
start of body tag

start of javascript function

function simpleAjax(){
var xmlHttp;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e) {
// Internet Explorer
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
alert("Your browser is very old, does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange=function() {
if(xmlHttp.readyState==4) {
//get data from the server
document.simpleAjax.fromServer.value=xmlHttp.responseText;
}
}
xmlHttp.open("GET","simpleAjax.php",true);
xmlHttp.send(null);
}

end of javascript function

start of form tag name="simpleAjax"

Name: between angle bracket(input type="text" onkeyup="simpleAjax()" name="user")
Data: between angle bracket(input type="text" name="fromServer")

end of form tag
end of body tag
end of html tag

php file

///output the data to the client
////echo "Data from Server";
//?>

save the form as "simpleAjax.php" in the same directory as html file.

Monday, October 20, 2008

How to run Oracle 9i database in Archive Mode

Steps:
1) Create pfile if the database is started from spfile.
create pfile from spfile;
This will create pfile in the %ORACLE_HOME%/database/pfileSID.ora
or
create pfile='pathname' from spfile;

2) Shutdown the database
shutdown immediate

3) add parameters
log_archive_start=true
log_archive_format='SID%D%T%S.ARC'
log_archive_dest='%ORACLE_BASE%\oradata\archive'

4) Start up the database in mount stage
startup mount;

5) Activate the database to archiving mode
alter database archivelog;

6) Verify the activation
archive log list;

7) Open the database for use
alter database open;

8) Generate the archive log manually
alter system archive log current;

This turns the database in archive log mode.