Tuesday 25 December 2012

Difference between DROP,Truncate and Delete in Oracle?

Difference between Truncate and Delete in Oracle?

Answer:

1.TRUNCATE is a DDL command and cannot be rolled back. All of the memory space is released back to the server.

2. DELETE is a DML command and can be rolled back.

3. TRUNCATE : You can't use WHERE clause and DELETE : You can use WHERE clause

4. Both commands accomplish identical tasks (removing all data from a table), but TRUNCATE is much faster.

5.Truncate: Drop all object's statistics and marks like High Water Mark, free extents and leave the object really empty with the first extent.Delete: You can keep object's statistics and all allocated space.

6. In case of TRUNCATE ,Trigger doesn't get fired.But in DML commands like DELETE .Trigger get fired.

7. Drop command will delete the entire row also the structure.But truncate will delete the contenets only not the strucure, so no need to give specifications for another table creation.

8. Drop command remove the table from data dictionary. This is the DDL statement. We can not recover the table before Oracle 10g. But Oracle 10g provide the command to recover it by using the command (FLASHBACK)

9. DROP and TRUNCATE are DDL commands, whereas DELETE is a DML command. Therefore DELETE operations can be rolled back (undone), while DROP and TRUNCATE operations cannot be rolled back.

From Oracle 10g a table can be "undropped". Example:

SQL> FLASHBACK TABLE emp TO BEFORE DROP;
Flashback complete.

PS: DELETE will not free up used space within a table. This means that repeated DELETE commands will severely fragment the table and queries will have to navigate this "free space" in order to retrieve rows.

10. Truncate will not use the undo TBS, whereas a delete will.

Friday 14 December 2012

OHS and It's Configuration


mod_wl_ohs: is a module in Oracle HTTP Server 11g R1 which allows requests to be proxied from Oracle HTTP Server (OHS) to Oracle WebLogic Server.

mod_weblogic: This module is part of Apache HTTP Server and allows requests to be proxied from Apache HTTP Server to Oracle WebLogic Server.

For difference between mod_wl_ohs and mod_weblogic click here

Things good to know about configuring OHS infront of weblogic


1. You can use Fusion Middleware control /em (register OHS with weblogic Server to access it from control) , steps here  or directly update httpd.conf  (steps given below) to configure mod_wl_ohs
2. If weblogic server is clustered then mod_wl_ohs uses simple round-robin to forwards requests from HTTP Server to all available weblogic servers.
  mod_wl_ohs directs HTTP requests containing a cookie, URL-encoded session, or a session stored in the POST data to the server in the cluster that originally created the cookie.

3. mod_wl_ohs (as of 11gR1) only support container level failover and NOT application level failover. mod_wl_ohs continues to route requests to a down application as long as the managed server is up and running.

4. Configuration file of mod_wl_ohs is $INSTANCE_HOME/ config/ OHS/ <component_name>/ mod_wl_ohs.conf and included in $INSTANCE_HOME/ config/ OHS/ <component_name>/ httpd.conf (entry like
include “${ORACLE_INSTANCE}/ config/ ${COMPONENT_TYPE}/${COMPONENT_NAME}/ mod_wl_ohs.conf”)

5. mod_wl_ohs module file is available at $ORACLE_HOME/ ohs/ modules/ mod_wl_ohs.so
6. You can either use URL like /console using location directive (<Location /console>) or MatchExpression directive in mod_wl_ohs.conf to forward requests from HTTP Server to WebLogic Server.

7. While starting OHS on Windows, if you see error like

C:/atul/ fmw/ instances1/ config/ OHS/ ohs1/ mod_wl_ohs.conf:
Cannot load C:/ atul/ fmw/ ohs/ modules/ mod_wl_ohs.so into server: The specified module could not be found


Check mod_wl_ohs.so exists in specified location, if yes then
Copy “$ORACLE_HOME\ oui\ lib\ win32\ msvcp71.dll” to “c:\ windows\ system32″ and try again
.
Configure HTTP Serer infront of WebLogic Server
1. Install WebLogic Server and define server listening on port XXXX (7001 in this example)
2. Install Oracle HTTP Sever 11g steps here
3. Modify mod_wl_ohs.conf
$ORACLE_INSTANCE/ config/ <COMPONENT_TYPE>/ <COMPONENT_NAME>/ mod_wl_ohs.conf
a) For weblogic single instance
<Location /console>
    SetHandler weblogic-handler
    WebLogicHost server1
    WeblogicPort 7001
</Location>
* This will forward /console from HTTP server to /console on WebLogic Server server1:7001


b) For Weblogic instances in cluster
<Location /myServerURL>
    SetHandler weblogic-handler
    WebLogicCluster server1:7010,server2:7010
</Location>
* This will forward /myServerURL from HTTP server to /myServerURL on WebLogic Cluster server1:7010 and server2:7010

4. Restart HTTP Server
$INSTANCE_HOME/ bin/ opmnctl restartproc ias-component=ohs1
5. Test that you can access application deployed on Weblogic using Oracle HTTP Server like
http://servername:ohs_http_port/console

Source: http://onlineappsdba.com/index.php/2009/09/23/configure-oracle-http-server-infront-of-oracle-weblogic-server-mod_wl_ohs/
Thanks to Atul Kumar