Sunday, August 23, 2009

Oracle 10g Database Cloning

Database cloning onto a different server using hot backups


Server-1 - Source
Server-2 - Destination

Step - 1 - Put the source database in backup mode.

Step - 2 - Copy all the datafiles,redologfiles,parameter files and
archived log files from server 1 to server 2.

Step - 3 - At the source datbase sql prompt execute the following
command sqlplus>backup controlfile to trace.
(Output will be generated at udump,this will be henceforth
called create_db.sql)

Step - 4 - Copy this file to server-2

Step - 5 - Edit the create_db.sql :
5.1 So as to represent new locations.
5.2 Replace "Reuse" with "set" (CREATE CONTROLFILE set DATABASE)
5.3 Update the SID of Database.

Step - 6 - Restore the initialisation parameter file to
$ORACLE_HOME/dbs
Step - 7 - Edit the file with new db name and file locations.

Step - 8 - Set ORACLE_SID with new database name



Step - 9 - Connect as "sysdba"
[oracle]/ > sqlplus
SQL*Plus: Release 10.2.0.3.0 - Production on Mon Jul 27 20:47:17 2009
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Enter user-name: / as sysdba
Connected to an idle instance.


Step - 10

SQL> @create_db.sql
ORACLE instance started.

Total System Global Area 813694976 bytes
Fixed Size 2033504 bytes
Variable Size 528488608 bytes
Database Buffers 268435456 bytes
Redo Buffers 14737408 bytes

Control file created.



It is important to specify CANCEL when you are asked for the last log.

SQL> recover database until cancel using backup controlfile;
ORA-00279: change 794271 generated at 12/22/2006 12:09:07 needed for thread 1
ORA-00289: suggestion :
/opt/oracle/flash_recovery_area/DDB/archivelog/1_4_609804799.dbf
ORA-00280: change 794271 for thread 1 is in sequence #4

Specify log: {=suggested filename AUTO CANCEL}

{Specify the location of the log file here...if the log required is present in archivelog files,else press type cancel)

CANCEL
Media recovery cancelled.
SQL> ALTER DATABASE OPEN RESETLOGS;

Database altered.

SQL> Shu immediate
SQL>Startup

Add temp file and Database is ready to use.


Useful Links:
http://www.blogger.com/www.dba-oracle.com/oracle_tips_db_copy.htm
http://www.blogger.com/www.dba-oracle.com/topica/super_fast_database_cloning.htm
=================================================================================================


[oracle] > vi create_db.sql

STARTUP NOMOUNT
CREATE CONTROLFILE set DATABASE "TEST" RESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 1000
MAXINSTANCES 1
MAXLOGHISTORY 292
LOGFILE
GROUP 1 (
'/pre/RESTORE_ACTIVITY/redo1a.log',
'/pre/RESTORE_ACTIVITY/redo1b.log'
) SIZE 1000M,
GROUP 2 (
'/pre/RESTORE_ACTIVITY/redo2a.log',
'/pre/RESTORE_ACTIVITY/redo2b.log'
) SIZE 1000M,
GROUP 3 (
'/pre/RESTORE_ACTIVITY/redo3a.log',
'/pre/RESTORE_ACTIVITY/redo3b.log'
) SIZE 1000M
-- STANDBY LOGFILE
DATAFILE
'/pre/RESTORE_ACTIVITY/system01.dbf',
'/pre/RESTORE_ACTIVITY/undo_ts01.dbf',
'/pre/RESTORE_ACTIVITY/sysaux01.dbf',
'/pre/RESTORE_ACTIVITY/index01.dbf',
'/pre/RESTORE_ACTIVITY/data01.dbf',
CHARACTER SET UTF8;

Tuesday, March 11, 2008

Oracle 9i SQL Query Tuning Tips

The following are not de-facto rules.But quite helpful when tuning SQL query

Rule - 1
Avoid data type mismatch for index columns.


Rule - 2
Avoid functions on indexed columns


Rule - 3
Move conditions from having clause to where clause wherever possible.


Rule - 4
Use joins instead of nested selects. (Very Very Imp)


Rule - 5
When joining multiple tables the smallest table should be specified last.

Rule - 6
Replace NOT IN with NOT EXISTS.

Rule - 7
Replace != by UNION of “<“and “>” .


Rule - 9
Use UNION ALL instead of UNION wherever possible.

Rule - 10
Do not use columns on both sides of operator
When an indexed column appears on both sides of an operator, the index for that column is disabled.

Rule-11

Use Count(1) instead of count(*)

The COUNT function does not need to retrieve all fields from the employees table as it had to when you used the COUNT(*) syntax. It will merely retrieve the numeric value of 1 for each record that meets your criteria.

Useful Links

============
http://people.aapt.net.au/roxsco/tuning/
http://download.oracle.com/docs/html/A86647_01/vmqtune.htm
http://www.dba-oracle.com/art_sql_tune.htm





Saturday, March 08, 2008

Oracle 9i Modifying settings in favour of Index scans

In a normal setting CBO in Oracle 9i gives equal preference to index scans and full table scans.But it is possible for the administrator to tweak the settings so as to make the optimiser favour index scan to full table scan.

optimizer_index_cost_adj is the parameter used for the purpose.By default its value is 100.Here it gives equal weightage to index scan as well as full table scan.By bringing that value down the CBO prefers for a index scan to full table scan.The value can range between 1-10000.

Tuesday, October 02, 2007

Error - ora-01034 - 8i STANDARD EDITION

CONNECTION PROBLEMS- 8i STANDARD EDITION (ora-01034 )
----------------------------------------------------------------------

GO TO THE "svrmgrl" file (in a 'BIN' file - do a search for files if not sure where it is). Double-click on it and a dos_style prompt will open. Type "connect internal" (without the quotes!) and press enter. Then type "startup open". Then wait a short while and the database will be opened. You will then be able to connect to sql, etc without getting this error.

Monday, June 18, 2007

Thursday, June 14, 2007

Useful Links

Java
=================================================
Random Number Generation
1.http://www.cs.geneseo.edu/~baldwin/reference/random.html

Location of my Home in Google Maps
=================================================
http://maps.google.com/?ie=UTF8&ll=10.616611,76.501719&spn=0.0029,0.004259&t=h&z=18&om=1

=================================================

TRAVEL


Kailas Mansarover YATRA

http://www.kailashmansarovar-yatra.com/index.html

http://www.mansarovar-kailash.com/aboutus.htm

http://www.pilgrimage-india.com/pilgrimage-tours/pilgrimage-tour-india.html

Lake Superior Hike (Info Source - Nat Geo)

Maps and info are available at www.shta.org. The Superior Shuttle (www.superiorshuttle.com) costs $15. Arrange a trip with Boundary Country Trekking (www.boundarycountry.com).
http://adventure.nationalgeographic.com/adventure/trips/americas-best-adventures/hike-superior-trail/

World's Best Hike,Trails (Source Nat Geo)

http://adventure.nationalgeographic.com/adventure/trips/best-trails/world-hikes/?source=email_adventure

Tuesday, June 12, 2007

BREW Sequential Debugging

BREW Sequential Debugging is a feature that helps us to find the current values (for eg:Current memory utilization) of various parameters during runtime, displayed on the handset (or Simulator ) screen.

To enable it :After launching the app,
Enter : ###BREWDEBUG# OR ###273933284#

###0: Turn Debugging off.

###1: Memory Validation On every heap access, BREW walksthe heap to determine if the pointer is in valid range andwill not over-write/over-read a heap node. An exceptionwill be thrown if the heap access will cause corruption of a heap node.

###3: Largest Available Heap BlockDisplays the maximum size block that can be allocated onthe heap in the upper left corner of the screen.

###5: Debug Malloc – throws exception on MALLOC failure

###6: Debug Null – Every Nth MALLOC is failed When thisdebug sequence is turned on, every Nth MALLOC willfail, even if RAM is available. Currently, N is set to 100.

###7: Sync/Async DBGPRINTF This debug sequence togglesbetween two modes: synchronous DBGPRINTF andasynchronous DBFPRINTF. In synchronous DBGPRINTFmode, BREW waits for certain duration before returningfrom a DBGPRINTF statement in order to allow time forthe DBGPRINTF message to be sent on the serial port. Inthe default, asynchronous mode, the DBGPRINTF returns immediately.

###9: Debug Dump HeapEvery time this sequence is pressed, heap andresource usage information is dumped on the emulator debug windowor onto the Serial port.

(All these has been tried and tested only on MotoRazr)

For a detailed info. check the following link:
http://brewforums.qualcomm.com/showthread.php?t=3979&highlight=%23%23%23BREWDEBUG%23

Friday, January 27, 2006

Cluster Analysis

Cluster analysis (first used by Tryon, 1939) is an exploratory data analysis tool for solving classification problems. Clustering is the classification of similar objects into different groups, or more precisely, the partitioning of a data set into subsets (clusters), so that the data in each subset (ideally) share some common trait - often proximity according to some defined distance measure Its objective is to sort cases (people, things, events, etc) into groups, or clusters, so that the degree of association is strong between members of the same cluster and weak between members of different clusters. Each cluster thus describes, in terms of the data collected, the class to which its members belong; and this description may be abstracted through use from the particular to the general class or type.

Cluster analysis is thus a tool of discovery.It may reveal associations and structure in data which, though not previously evident, nevertheless are sensible and useful once found. The results of cluster analysis may contribute to the definition of a formal classification scheme, such as a taxonomy for related animals, insects or plants; or suggest statistical models with which to describe populations; or indicate rules for assigning new cases to classes for identification and diagnostic purposes; or provide measures of definition, size and change in what previously were only broad concepts; or find exemplars to represent classes.

Machine learning typically regards data clustering as a form of unsupervised learning.Besides the term cluster analysis (or just clustering), there are a number of terms with similar meanings, including:
  • Data clustering,
  • Automatic classification,
  • Numerical taxonomy,
  • Botryology
  • Typological analysis.

Saturday, January 14, 2006

First Blog.....

This is my first blogging in this site.And this wnt be an ad-hoc blogging centre.I will be using this more as an information Junkyard.A one stop location where I can store and retrieve relevant information.