Friday, June 26, 2009

ORACLE- Import and Export

Lets say u have a huge database created in Machine A. Now you want a replica of the database in machine B at a different location.. What r u gonna do? Copy the SQL CREATE-INSERT statements, then execute these. What if u miss out on an insert statement???
Well, to perform these tasks, ORACLE provides import and export commands.

If you want to create a replica of ur database, create a dump(.dmp) using exp command
exp file=(location where dump is to be created) Log=(location where log is to be created) owner=(user whose dump is being exported)

Now to import this dump into a new user:

imp file=(location where dump is kept) fromuser=(user whose dump is being exported) touser=(user where dump is being imported)

There u go... The database gets created successfully.

Saturday, June 20, 2009

Checking 32-bit/64-bit ORACLE

Have u ever installed 32-bit ORACLE on a 64-bit system by mistake nd u never realized it. Well, use this command to know whether 32 bit or 64 bit ORACLE is installed on ur system.

SELECT DISTINCT ADDRESS FROM v$sql where rownum<2;

If the address is 16 characters long like 00000000345BA23E, uve got 64 bit oracle on ur system.

But if the address is 8 characters long like 098765EA, then its 32 bit ORACLE.

Tuesday, June 16, 2009

ORACLE Installation

Have you ever tried to install ORACLE on Linux. Well, its a bit of struggle if you don't know the correct settings.Believe me, I had a hard time installing ORACLE for the first time on Linux. But I think, you guys shouldn't waste time. So, here we go:

First of all you need to have the required packages and RPMs. You can find these easily from manual.
After installing all the packages, begin with the following steps:

Step 1: Add/Modify the following lines to /etc/sysctl.conf

kernel.shmmni =4096
kernel.sem=250 32000 100 128
fs.file_max=65536
net.ip_local_port_range= 1024 65000
net.core.rmem_default=1048576
net.core.rmem_max=1048576
net.core.wmem_default=262144
net.core.wmem_max=262144
net.ipv4.tcp_wmem=262144 262144 262144
net.ipv4.tcp_rmem=4194304 4194304 4194304

Step 2: #sysctl -p
So that changes take place effectively.

Step 3: Create oracle user and groups
#groupadd oinstall
#groupadd dba
#useradd -g oinstall -a dba oracle -- This server as username.
#passwd

Step 4: Create required directories
#mkdir -p /home/oracle
#
chown -R oracle:oinstall /home/oracle
#chmod -R 755 /home/oracle

Step 5: Add the following lines to /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16348
oracle soft nofile 1024
oracle hard nofile 65536

Step 6: Add the following lines to /etc/passwd/login
session required pam_limits.so

Step 7: Add following to /etc/profile
if[$USER="oracle"]; then
ulimit -u 16384
ulimit -n 65536

Step 8: Add/modify /home/oracle/.bash_profile
umask 022
export ORACLE_BASE=/home/oracle
export ORACLE_SID=orcl
export ORACLE_HOME= $ORACLE_HOME/oracle/product/10.2.0/db_1
LD_LIBRARY_PATH=$ORACLE_HOME/bin:$PATH
export PATH

Step 9:
xhost +
xclock

Step 10: Run the GUI Installer
./runInstaller

There you go, now just do a couple of nexts and ull have oracle installed... CHEERS :)

Wednesday, May 27, 2009

ORACLE - Use of tnsnames.ora and listener.ora files

LISTENER.ORA
This file contains configuration for the server side.It contains details like on which port, which protocol etc the server should listen for connection requests from clients. This file is found in ORACLE_HOME/network/admin directory.

TNSNAMES.ORA
The file contains configuration for client side. It can be found in the ORACLE_HOME/network/admin . This file will also be present on the server if client is also on the same machine as server. This file needs to be configured for all clients with the IP address and port of the server so that clients can communicate with the server.

I will come up with the configuration of these files shortly for using a gateway.

Tuesday, May 26, 2009

OTG - Oracle Transparent Gateway

OTG or Oracle Transparent Gateway is a tool used to communicate with non-Oracle products (may be other databases like DB2) and technologies. Using OTG, we can access data in remote DB2 using Oracle's PL/SQL syntax. OTG has DRDA gateway which connects with DB2. If you want to connect to other databases like Sybase n all, you can use other gateways.

To use a gateway, we need to first install it( quite obvious). After installation, we need to configure it which is a tedious task even if we try to do it by reading manuals.( I've been working on it for 3 days, still no progress).

Well, thats all i know about it but I will surely write about the configuration in my next post. So wish me luck :).

Friday, May 22, 2009

PL/SQL Wrapper

Have you ever tried to see the contents of the object file in C ?
If not, then let me tell you that it contains all unreadable characters ie, given the object code, nobody can generate the C code from it.
If you want a similar kind of protection in PL/SQL code, you need to use wrap command. In this way, you can protect your source code. You can now distribute your wrapped code without the fear of it being copied. The PL/SQL compiler recognizes and loads wrapped code automatically.


Using PL/SQL Wrapper

wrap iname=plsqlsource.sql oname=plsqlwrapcode.plb

where the extension plb means PL/SQL binary.

Saturday, May 16, 2009

ORACLE 8i, 11g - What is "i" and "g"

Meaning of "i" and "g"

Well "g" in Oracle 10g and onwards indicates grid computing. Grid computing means clubbing of several computers, by means of a network, where they work on a single problem at the same time. It enables resource sharing for multiple applications thus giving advantages like flexibility,low cost, efficiency, performance, scalability etc.

The "i" in Oracle 8i,9i indicates support for the Internet with built-in Java Virtual Machine (JVM). With a JVM (Java interpreter) built into the DBMS, triggers and stored procedures can be written and executed in Java . It thus enables Internet developers to write applications as well as procedures in Java.