Tuesday, December 29, 2009

BACKUP AND RECOVERY TECHNIQUES IN ORACLE 10G

Recover database from loss of control file in oracle 10g:


We may face problem with loss of control files and the following method can be emploed to restore/recreate control file:

if control files are already multiplexed and few of those are available, then copy a right/good state of control file over a damaged/missing one. ie.. copy surviving control file with copy command giving missing control filename for new control file and open database or edit the parameter file to remove the reference to the missing or damaged controld file, if db SPFILE being used then use alter system set control_files="avaliable controlfiles path" scope=spfile; and startup

Example:

alter system set control_files='/control01.ctl',
'/control02.ctl',
'/control03.ctl' scope=spfile
startup

Note: Any change to control_files requires db restart

if no control files are available then follow below method.

startup nomount;
SHOW PARAMETER CONTROL


SQL> CREATE CONTROLFILE REUSE DATABASE "MYDB" RESETLOGS NOARCHIVELOG
2 NOARCHIVELOG
3 MAXLOGFILES 16
4 MAXLOGMEMBERS 3
5 MAXDATAFILES 100
6 MAXINSTANCES 10
7 MAXLOGHISTORY 10000
8 LOGFILE
9 GROUP 1 'F:\oracle\product\10.2.0\oradata\MYDB\REDO01.LOG' SIZE
10 100M,
11 GROUP 2 'F:\oracle\product\10.2.0\oradata\MYDB\REDO02.LOG' SIZE
12 100M,
13 GROUP 3 'F:\oracle\product\10.2.0\oradata\MYDB\REDO03.LOG' SIZE
14 100M
15 DATAFILE
16 'F:\oracle\product\10.2.0\oradata\MYDB\SYSTEM01.DBF',
17 'F:\oracle\product\10.2.0\oradata\MYDB\SYSAUX01.DBF',
18 'F:\oracle\product\10.2.0\oradata\MYDB\EXAMPLE01.DBF',
19 'F:\oracle\product\10.2.0\oradata\MYDB\UNDOTBS01.DBF',
20 'F:\oracle\product\10.2.0\oradata\MYDB\USERS01.DBF'
21 CHARACTER SET UTF8
22 ;

Control file created.

Note:
check alert_sid.log file for character set incase if you dont have an idea what character set of db is..
alert_sid.log default location is background_dump_dest (show parameter background_dump_dest)
RESETLOGS synchronizes the SCN between the database files and control files and redo log files and oracle redo log files will be recreated when we open with resetlogs option.

SQL> SHOW PARAMETER CONTROL

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string F:\ORACLE\PRODUCT\10.2.0\ORADA
TA\MYDB\CONTROL01.CTL, F:\ORAC
LE\PRODUCT\10.2.0\ORADATA\MYDB
\CONTROL02.CTL, F:\ORACLE\PROD
UCT\10.2.0\ORADATA\MYDB\CONTRO
L03.CTL
SQL> ALTER DATABASE OPEN;
ALTER DATABASE OPEN
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> ALTER DATABASE OPEN RESETLOGS;

Database altered.

SQL> DESC V$CONTROLFILE;
Name Null? Type
----------------------------------------- -------- ----------------------------
STATUS VARCHAR2(7)
NAME VARCHAR2(513)
IS_RECOVERY_DEST_FILE VARCHAR2(3)
BLOCK_SIZE NUMBER
FILE_SIZE_BLKS NUMBER

SQL> SELECT NAME, STATUS FROM V$CONTROLFILE;

NAME
--------------------------------------------------------------------------------
STATUS
-------
F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL01.CTL
F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL02.CTL
F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL03.CTL
SQL>


SQL> select file#,status,enabled,name from V$tempfile;

no rows selected

SQL>

Create temporary tablespace:

It may be necessary to add files to these tablespaces. That can be done using the SQL statement:

ALTER TABLESPACE temp ADD TEMPFILE 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\TEMP01.DBF' REUSE;
SQL> select file#,status,enabled,name from V$tempfile;

no rows selected

SQL> ALTER TABLESPACE temp ADD TEMPFILE 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\TEMP01.DBF'
REUSE;

Tablespace altered.

SQL> select file#,status,enabled,name from V$tempfile;

FILE# STATUS ENABLED
---------- ------- ----------
NAME
--------------------------------------------------------------------------------
1 ONLINE READ WRITE
F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\TEMP01.DBF


SQL> ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp;

Note:

1. multiplex Control files and Redo log files.
2. Backup of the database regularly with either RMAN or in traditional method.
3. execute alter database backup controlfile to trace; after each change to the database, USE alter session set tracefile_identifier before you take control file backup to have meaning full name. check user_dump_dest (show parameter user_dump_dest as sys)


how to multiplex control files in oracle 10g:

steps:
1. shutdown immediate;
2. copy existing controld file to new control file.
cp existingcontrolfile.ctl newcontrolfile.ctl
3. startup nomount
4. show parameter control
5.
alter system set control_files='F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL01.CTL',
'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL02.CTL',
'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL03.CTL',
'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL04.CTL' scope=spfile

6. startup force;
7. select name from v$controlfile;
8. show parameter control;

How to multiplex Online redo log files

1. select * from v$log;
2. select * from v$logfile;
if there is one member in each group, then it is the time to multiplex redo log files.. the minimum is that each group at least consist two members i.e. not less than 2 members in each group.
3. alter system swith logfile; -- do this couple of times till you find all the groups are gone through it.

4. Adding A New Member To An Existing Group

alter database add logfile member 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\REDO01B.LOG' TO GROUP
alter database add logfile member 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\REDO2B.LOG' TO GROUP 2
alter database add logfile member 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\REDO3B.LOG' TO GROUP 3

5. SELECT GROUP#,MEMBER FROM V$LOGFILE -- To see the logfile members
select group#, members, status from v$log; -- To see log group level.

Optimal size of redo log files can be find using

select optimal_logfile_size from v$instance_recovery;


size of redo log files:
select sum(bytes)/1024/1024 "Meg" from sys.v_$log;

select group#,sum(bytes)/1024/1024 "Meg" from sys.v_$log group by group#;

it gives u size of each redo log file from each group... not all the redo log files size if group has more than 1 redo log files...



very nice post on redo log files addition or deletion can be seen at

http://oralog.wordpress.com/2009/12/16/how-to-add-remove-or-relocate-online-redolog-files-and-groups/

Recovering Database from lost multiplexed online redo log files

select group#,status from v$log;
select group#,status,member from v$logfile order by group#
Ensure two members at least there in each group
now to test how we do recover from redo log file is

1. shutdown immediate;
2. remove one of the mulitplexed redo log file either using del on windows or rm on unix
3. startup
database will open normally but there is an error entry in alert log file.. see the details in alert log file.

4. alter system switch logfile; run this more then number of total number of groups.
5. select group#,status,member from v$logfile order by group#
there will an entry with status = invalid.

6. select group#, status from v$log;

ensure that the about to restore group not in active or current i.e. should be inactive state.

7. alter database clear logfile group 1;

which will delete and re-create the members of given logfile group.

8.alter system switch logfile; run this more then number of total number of groups.
9. select group#,status,member from v$logfile order by group#;
run this to find all are in well state...

Backup No Archive Mode oracle 10g Database with RMAN


open command prompt
set ORACLE_SID=ORCL OR export ORACLE_SID=ORCL --- ORCL is sid here

rman target /

run
{
shutdown immediate;
startup mount;
backup as copy database;
alter database open;
}

it would start backup now...

output of this process when default configuration is being used:

it will create a directory with sid i.e. ORCL in this case in flash recovery area
show parameter db_recovery_file_dest
D:\oracle\product\10.2.0\flash_recovery_area\ORCL
Three direcotries will be created automatically
1. backupset -- spfile will be backed up in backup set format
2. controlfile -- where control file being backed up in copy format
3. DATAFILE -- All the dbf files are backed up here....

no temp files , no redo log files are backed up and it is normal...

as last step .. database will be open for ready..

How to restore and recover a Temporary Tablespace:

The first thing to know that the temporary tablespaces and temp files are never backed up and even RMAN do not do the backup of thses and backup of those never needed.

The only way to restore and recover of temparary tablespace/temp file is to recreate when one is missing.
Method :

Add another temp filee:
alter tablespace temp_ts add tempfile '' size 1000M;
take the damaged tempfile offline
alter database tempfile '' offline;
drop the damaged temp file;
alter database tempfile '' drop;

or

create new temp tablespace;
create temporary tablespace temp1 tempfile '' size 1000M;
switch database to use newly created temp tablespace;
alter database default temporary tablespace temp1;
drop damaged temp tablespace;
drop tablespace temp_old including contents and datafiles;

this is fastest method as as file being created is not formated.


.. Hope this will help you all... cheers...

BACKUP AND RECOVERY TECHNIQUES IN ORACLE 10G

Recover database from loss of control file in oracle 10g:


We may face problem with loss of control files and the following method can be emploed to restore/recreate control file:

if control files are already multiplexed and few of those are available, then copy a right/good state of control file over a damaged/missing one. ie.. copy surviving control file with copy command giving missing control filename for new control file and open database or edit the parameter file to remove the reference to the missing or damaged controld file, if db SPFILE being used then use alter system set control_files="avaliable controlfiles path" scope=spfile; and startup

Example:

alter system set control_files='/control01.ctl',
'/control02.ctl',
'/control03.ctl' scope=spfile
startup

Note: Any change to control_files requires db restart

if no control files are available then follow below method.

startup nomount;
SHOW PARAMETER CONTROL


SQL> CREATE CONTROLFILE REUSE DATABASE "MYDB" RESETLOGS NOARCHIVELOG
2 NOARCHIVELOG
3 MAXLOGFILES 16
4 MAXLOGMEMBERS 3
5 MAXDATAFILES 100
6 MAXINSTANCES 10
7 MAXLOGHISTORY 10000
8 LOGFILE
9 GROUP 1 'F:\oracle\product\10.2.0\oradata\MYDB\REDO01.LOG' SIZE
10 100M,
11 GROUP 2 'F:\oracle\product\10.2.0\oradata\MYDB\REDO02.LOG' SIZE
12 100M,
13 GROUP 3 'F:\oracle\product\10.2.0\oradata\MYDB\REDO03.LOG' SIZE
14 100M
15 DATAFILE
16 'F:\oracle\product\10.2.0\oradata\MYDB\SYSTEM01.DBF',
17 'F:\oracle\product\10.2.0\oradata\MYDB\SYSAUX01.DBF',
18 'F:\oracle\product\10.2.0\oradata\MYDB\EXAMPLE01.DBF',
19 'F:\oracle\product\10.2.0\oradata\MYDB\UNDOTBS01.DBF',
20 'F:\oracle\product\10.2.0\oradata\MYDB\USERS01.DBF'
21 CHARACTER SET UTF8
22 ;

Control file created.

Note:
check alert_sid.log file for character set incase if you dont have an idea what character set of db is..
alert_sid.log default location is background_dump_dest (show parameter background_dump_dest)
RESETLOGS synchronizes the SCN between the database files and control files and redo log files and oracle redo log files will be recreated when we open with resetlogs option.

SQL> SHOW PARAMETER CONTROL

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string F:\ORACLE\PRODUCT\10.2.0\ORADA
TA\MYDB\CONTROL01.CTL, F:\ORAC
LE\PRODUCT\10.2.0\ORADATA\MYDB
\CONTROL02.CTL, F:\ORACLE\PROD
UCT\10.2.0\ORADATA\MYDB\CONTRO
L03.CTL
SQL> ALTER DATABASE OPEN;
ALTER DATABASE OPEN
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> ALTER DATABASE OPEN RESETLOGS;

Database altered.

SQL> DESC V$CONTROLFILE;
Name Null? Type
----------------------------------------- -------- ----------------------------
STATUS VARCHAR2(7)
NAME VARCHAR2(513)
IS_RECOVERY_DEST_FILE VARCHAR2(3)
BLOCK_SIZE NUMBER
FILE_SIZE_BLKS NUMBER

SQL> SELECT NAME, STATUS FROM V$CONTROLFILE;

NAME
--------------------------------------------------------------------------------
STATUS
-------
F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL01.CTL
F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL02.CTL
F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL03.CTL
SQL>


SQL> select file#,status,enabled,name from V$tempfile;

no rows selected

SQL>

Create temporary tablespace:

It may be necessary to add files to these tablespaces. That can be done using the SQL statement:

ALTER TABLESPACE temp ADD TEMPFILE 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\TEMP01.DBF' REUSE;
SQL> select file#,status,enabled,name from V$tempfile;

no rows selected

SQL> ALTER TABLESPACE temp ADD TEMPFILE 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\TEMP01.DBF'
REUSE;

Tablespace altered.

SQL> select file#,status,enabled,name from V$tempfile;

FILE# STATUS ENABLED
---------- ------- ----------
NAME
--------------------------------------------------------------------------------
1 ONLINE READ WRITE
F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\TEMP01.DBF


SQL> ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp;

Note:

1. multiplex Control files and Redo log files.
2. Backup of the database regularly with either RMAN or in traditional method.
3. execute alter database backup controlfile to trace; after each change to the database, USE alter session set tracefile_identifier before you take control file backup to have meaning full name. check user_dump_dest (show parameter user_dump_dest as sys)


how to multiplex control files in oracle 10g:

steps:
1. shutdown immediate;
2. copy existing controld file to new control file.
cp existingcontrolfile.ctl newcontrolfile.ctl
3. startup nomount
4. show parameter control
5.
alter system set control_files='F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL01.CTL',
'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL02.CTL',
'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL03.CTL',
'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\CONTROL04.CTL' scope=spfile

6. startup force;
7. select name from v$controlfile;
8. show parameter control;

How to multiplex Online redo log files

1. select * from v$log;
2. select * from v$logfile;
if there is one member in each group, then it is the time to multiplex redo log files.. the minimum is that each group at least consist two members i.e. not less than 2 members in each group.
3. alter system swith logfile; -- do this couple of times till you find all the groups are gone through it.

4. Adding A New Member To An Existing Group

alter database add logfile member 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\REDO01B.LOG' TO GROUP
alter database add logfile member 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\REDO2B.LOG' TO GROUP 2
alter database add logfile member 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\MYDB\REDO3B.LOG' TO GROUP 3

5. SELECT GROUP#,MEMBER FROM V$LOGFILE -- To see the logfile members
select group#, members, status from v$log; -- To see log group level.

Optimal size of redo log files can be find using

select optimal_logfile_size from v$instance_recovery;


size of redo log files:
select sum(bytes)/1024/1024 "Meg" from sys.v_$log;

select group#,sum(bytes)/1024/1024 "Meg" from sys.v_$log group by group#;

it gives u size of each redo log file from each group... not all the redo log files size if group has more than 1 redo log files...



very nice post on redo log files addition or deletion can be seen at

http://oralog.wordpress.com/2009/12/16/how-to-add-remove-or-relocate-online-redolog-files-and-groups/

Recovering Database from lost multiplexed online redo log files

select group#,status from v$log;
select group#,status,member from v$logfile order by group#
Ensure two members at least there in each group
now to test how we do recover from redo log file is

1. shutdown immediate;
2. remove one of the mulitplexed redo log file either using del on windows or rm on unix
3. startup
database will open normally but there is an error entry in alert log file.. see the details in alert log file.

4. alter system switch logfile; run this more then number of total number of groups.
5. select group#,status,member from v$logfile order by group#
there will an entry with status = invalid.

6. select group#, status from v$log;

ensure that the about to restore group not in active or current i.e. should be inactive state.

7. alter database clear logfile group 1;

which will delete and re-create the members of given logfile group.

8.alter system switch logfile; run this more then number of total number of groups.
9. select group#,status,member from v$logfile order by group#;
run this to find all are in well state...

Backup No Archive Mode oracle 10g Database with RMAN


open command prompt
set ORACLE_SID=ORCL OR export ORACLE_SID=ORCL --- ORCL is sid here

rman target /

run
{
shutdown immediate;
startup mount;
backup as copy database;
alter database open;
}

it would start backup now...

output of this process when default configuration is being used:

it will create a directory with sid i.e. ORCL in this case in flash recovery area
show parameter db_recovery_file_dest
D:\oracle\product\10.2.0\flash_recovery_area\ORCL
Three direcotries will be created automatically
1. backupset -- spfile will be backed up in backup set format
2. controlfile -- where control file being backed up in copy format
3. DATAFILE -- All the dbf files are backed up here....

no temp files , no redo log files are backed up and it is normal...

as last step .. database will be open for ready..

How to restore and recover a Temporary Tablespace:

The first thing to know that the temporary tablespaces and temp files are never backed up and even RMAN do not do the backup of thses and backup of those never needed.

The only way to restore and recover of temparary tablespace/temp file is to recreate when one is missing.
Method :

Add another temp filee:
alter tablespace temp_ts add tempfile '' size 1000M;
take the damaged tempfile offline
alter database tempfile '' offline;
drop the damaged temp file;
alter database tempfile '' drop;

or

create new temp tablespace;
create temporary tablespace temp1 tempfile '' size 1000M;
switch database to use newly created temp tablespace;
alter database default temporary tablespace temp1;
drop damaged temp tablespace;
drop tablespace temp_old including contents and datafiles;

this is fastest method as as file being created is not formated.


.. Hope this will help you all... cheers...

Happy New Year 2010


** Happy New Year 2010 **
Copy this onto notepad, press cntrl + H, enter 6 in the find box and underscore (_) in replace box and click replace all button. Try this..




666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
666996666699669966999999996699666669966666669966666699669999999966996666996666666666666696666666666666666666666
666996666699669966999999996699666669966666666996666996669999999966996666996666666666666999666666666666666666666
666996666699669966996666666699666669966666666699669966669966669966996666996666666666669969966666666666666666666
666996696699669966999999996699999999966666666669999666669966669966996666996666666666699666996666666666666666666
666996999699669966999999996699999999966666666666996666669966669966996666996666666666999999999666666666666666666
666999969999669966666666996699666669966666666666996666669966669966996666996666666669999999999966666666666666666
666999666999669966999999996699666669966666666666996666669999999966996666996666666699666666666996666666666666666
666996666699669966999999996699666669966666666666996666669999999966999999996666666996666666666699666666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
669966666996666666669666666666999999996699999999669966666699666666669966666996699999999669966666996666666666666
669966666996666666699966666666999999996699999999666996666996666666669996666996699999999669966666996666666666666
669966666996666666996996666666996666996699666699666699669966666666669999666996699666666669966666996666666666666
669999999996666669966699666666999999996699999999666669999666666666669969966996699999999669966966996666666666666
669999999996666699999999966666999999996699999999666666996666666666669966996996699999999669969996996666666666666
669966666996666999999999996666999666666699666666666666996666666666669966699996699666666669999699996666666666666
669966666996669966666666699666996666666699666666666666996666666666669966669996699999999669996669996666666666666
669966666996699666666666669966996666666699666666666666996666666666669966666996699999999669966666996666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
666996666669966999999996666666669666666666999999996666666699999996699999999666999666699999999666666666666666666
666699666699666999999996666666699966666666999999996666666699999999699666699666699666699666699666666666666666666
666669966996666996666666666666996996666666996666996666666666666699699966699666699666699966699666666666666666666
666666999966666999999996666669966699666666999999996666666666666996699696699666699666699696699666666666666666666
666666699666666999999996666699999999966666999999996666666666669966699669699666699666699669699666666666666666666
666666699666666996666666666999999999996666996996666666666666996666699666999666699666699666999666666666666666666
666666699666666999999996669966666666699666996699666666666699999999699666699666699666699666699666666666666666666
666666699666666999999996699666666666669966996666996666666699999999699999999666999966699999999666666666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666

Wish you all A Happy New Year 2010 .



...Cheers...

Happy New Year 2010


** Happy New Year 2010 **
Copy this onto notepad, press cntrl + H, enter 6 in the find box and underscore (_) in replace box and click replace all button. Try this..




666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
666996666699669966999999996699666669966666669966666699669999999966996666996666666666666696666666666666666666666
666996666699669966999999996699666669966666666996666996669999999966996666996666666666666999666666666666666666666
666996666699669966996666666699666669966666666699669966669966669966996666996666666666669969966666666666666666666
666996696699669966999999996699999999966666666669999666669966669966996666996666666666699666996666666666666666666
666996999699669966999999996699999999966666666666996666669966669966996666996666666666999999999666666666666666666
666999969999669966666666996699666669966666666666996666669966669966996666996666666669999999999966666666666666666
666999666999669966999999996699666669966666666666996666669999999966996666996666666699666666666996666666666666666
666996666699669966999999996699666669966666666666996666669999999966999999996666666996666666666699666666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
669966666996666666669666666666999999996699999999669966666699666666669966666996699999999669966666996666666666666
669966666996666666699966666666999999996699999999666996666996666666669996666996699999999669966666996666666666666
669966666996666666996996666666996666996699666699666699669966666666669999666996699666666669966666996666666666666
669999999996666669966699666666999999996699999999666669999666666666669969966996699999999669966966996666666666666
669999999996666699999999966666999999996699999999666666996666666666669966996996699999999669969996996666666666666
669966666996666999999999996666999666666699666666666666996666666666669966699996699666666669999699996666666666666
669966666996669966666666699666996666666699666666666666996666666666669966669996699999999669996669996666666666666
669966666996699666666666669966996666666699666666666666996666666666669966666996699999999669966666996666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
666996666669966999999996666666669666666666999999996666666699999996699999999666999666699999999666666666666666666
666699666699666999999996666666699966666666999999996666666699999999699666699666699666699666699666666666666666666
666669966996666996666666666666996996666666996666996666666666666699699966699666699666699966699666666666666666666
666666999966666999999996666669966699666666999999996666666666666996699696699666699666699696699666666666666666666
666666699666666999999996666699999999966666999999996666666666669966699669699666699666699669699666666666666666666
666666699666666996666666666999999999996666996996666666666666996666699666999666699666699666999666666666666666666
666666699666666999999996669966666666699666996699666666666699999999699666699666699666699666699666666666666666666
666666699666666999999996699666666666669966996666996666666699999999699999999666999966699999999666666666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666

Wish you all A Happy New Year 2010 .



...Cheers...

Sunday, December 6, 2009

Difference between TIMESTAMP WITH TIMEZONE and TIMESTAMP WITH LOCAL TIMEZONE in oracle 10g:

Difference between TIMESTAMP WITH TIMEZONE and TIMESTAMP WITH LOCAL TIMEZONE in oracle 10g:


The TIMESTAMP WITH TIME ZONE data type data is normalized to the database time zone when it is saved into the database and users see the data in their local session time zone when they select from it.

TIMESTAMP WITH TIME ZONE: The data will not be normalized when data is being saved into database but it has time zone indicator to which refers.

All other DATE, TIMESTAMP data type’s data is normalized to DB time zone when it is saved and data remain unchanged when selected.


NLS_DATE_FORMAT and NLS_TERRITORY parameter values can be used to format the data in desired format.


Difference between Schema and User in oracle

A schema is a collection of database objects, schema is owned by a database user and has same name as that user. By default user has all the access on its own schema objects and other schemas objects based on the grants been granted.
There is 1 to 1 relationship between schema and user.

...

..

Difference between TIMESTAMP WITH TIMEZONE and TIMESTAMP WITH LOCAL TIMEZONE in oracle 10g:

Difference between TIMESTAMP WITH TIMEZONE and TIMESTAMP WITH LOCAL TIMEZONE in oracle 10g:


The TIMESTAMP WITH TIME ZONE data type data is normalized to the database time zone when it is saved into the database and users see the data in their local session time zone when they select from it.

TIMESTAMP WITH TIME ZONE: The data will not be normalized when data is being saved into database but it has time zone indicator to which refers.

All other DATE, TIMESTAMP data type’s data is normalized to DB time zone when it is saved and data remain unchanged when selected.


NLS_DATE_FORMAT and NLS_TERRITORY parameter values can be used to format the data in desired format.


Difference between Schema and User in oracle

A schema is a collection of database objects, schema is owned by a database user and has same name as that user. By default user has all the access on its own schema objects and other schemas objects based on the grants been granted.
There is 1 to 1 relationship between schema and user.

...

..

Thursday, December 3, 2009

How to display background processes,remote, local user processes in oracle 10g database.

How to display oracle background processes,remote, local user processes in oracle 10g database at shell command prompt:

Occasionally we may require to see the background processes, remote, local users processes started against oracle database in server system and the way to find those is below.

The way to find is different from unix systems to windows system, but in unix it is just running PS commond and which shows everything.

On unix , use the ps command to display them.

ps -ef |grep ora10g -- ora10g is the databasename or SID

you would see many ora__ora10g, these are all background processes.

How to see remote user processes:

Any process ID that include (LOCAL=NO) ,which is an indication that the server process is servicing a remote user process.

How to see local user processes:

Any process ID that has (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beg))), which is an indication that the user process is running on the same db server machine which means it did not come via listener.

On windows, server processes are threads within the single oracle.exe process and can be seen within windows task manager.

The following query can be used to list out all the processes/sessions started in database.

SELECT ses.sid,ses.serial#,pro.spid,ses.osuser,ses.type,
ses.username,
ses.program
FROM v$process pro,
v$session ses
WHERE pro.addr = ses.paddr;

Note: there is no username shown for backgrund processs and it is normal.

The best way to kill sessions which I feel should be incase of heavy load on the dB system very rarley or if any user request dba to do so most of the cases in development environment, the best way i see is to login into dB system and kill those using
ALTER SYSTEM KILL SESSION 'SID,SERIAL#' -- best way
OR
ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;

KILLING ORACLE USER PROCESSES AT UNIX COMMAND PROMPT:
oracle spid can be found using ps -ef | grep ora command
$ kill spid

IN WINDOWS COMMAND PROMPT:

orakill sid spid

sid,Spid can be taken from running above select statement.
Note: however killing oracle sessions at OS command prompt is NOT suggestable as it may crash database systems.. so please avoid it all the time... always login into dba sql plus command prompt to do dba activities...

-- cheers...

How to display background processes,remote, local user processes in oracle 10g database.

How to display oracle background processes,remote, local user processes in oracle 10g database at shell command prompt:

Occasionally we may require to see the background processes, remote, local users processes started against oracle database in server system and the way to find those is below.

The way to find is different from unix systems to windows system, but in unix it is just running PS commond and which shows everything.

On unix , use the ps command to display them.

ps -ef |grep ora10g -- ora10g is the databasename or SID

you would see many ora__ora10g, these are all background processes.

How to see remote user processes:

Any process ID that include (LOCAL=NO) ,which is an indication that the server process is servicing a remote user process.

How to see local user processes:

Any process ID that has (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beg))), which is an indication that the user process is running on the same db server machine which means it did not come via listener.

On windows, server processes are threads within the single oracle.exe process and can be seen within windows task manager.

The following query can be used to list out all the processes/sessions started in database.

SELECT ses.sid,ses.serial#,pro.spid,ses.osuser,ses.type,
ses.username,
ses.program
FROM v$process pro,
v$session ses
WHERE pro.addr = ses.paddr;

Note: there is no username shown for backgrund processs and it is normal.

The best way to kill sessions which I feel should be incase of heavy load on the dB system very rarley or if any user request dba to do so most of the cases in development environment, the best way i see is to login into dB system and kill those using
ALTER SYSTEM KILL SESSION 'SID,SERIAL#' -- best way
OR
ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;

KILLING ORACLE USER PROCESSES AT UNIX COMMAND PROMPT:
oracle spid can be found using ps -ef | grep ora command
$ kill spid

IN WINDOWS COMMAND PROMPT:

orakill sid spid

sid,Spid can be taken from running above select statement.
Note: however killing oracle sessions at OS command prompt is NOT suggestable as it may crash database systems.. so please avoid it all the time... always login into dba sql plus command prompt to do dba activities...

-- cheers...