Tuesday, 20 November 2012

All Querries and scripts go to http://www.shutdownabort.com

To RESET A PASSWORD OF A USER

alter user user_name identified by new_password;
 
eg:
  
alter user ram identified by ram123;

Monday, 19 November 2012


CROSS CHECK DATABASE ARCHIVELOG FILES


Resolution:


The preferred method would be to run a crosscheck against the target database using RMAN.  To do this, start an RMAN session and connect to the target database as well as the recovery catalog.

For example:


RMAN> connect target sys/passwd@targetdb

RMAN> connect catalog rman/rman@rcat


Then issue either of the following two RMAN commands:


RMAN> change archivelog all crosscheck;

 or

RMAN> crosscheck archivelog all;


A session running a crosscheck would look like the example below:


[orahawk@hawk]$ rman target sys/sys@hawkdb catalog rman9i/rman9i@rcat

Recovery Manager: Release 9.2.0.1.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

connected to target database: HAWKDB (DBID=1675444669)
 connected to recovery catalog database

RMAN> crosscheck archivelog all;

allocated channel: ORA_DISK_1
 channel ORA_DISK_1: sid=16 devtype=DISK
 validation succeeded for archived log
 archive log filename=/opt/OraHome2/dbs/arch1_59.dbf recid=298 stamp=584875495
 validation succeeded for archived log
 archive log filename=/opt/OraHome2/dbs/arch1_60.dbf recid=299 stamp=585039020
 validation failed for archived log
 archive log filename=/opt/OraHome2/dbs/arch1_61.dbf recid=300 stamp=585206201
 validation succeeded for archived log
 archive log filename=/opt/OraHome2/dbs/arch1_62.dbf recid=301 stamp=585373816
 validation succeeded for archived log
 archive log filename=/opt/OraHome2/dbs/arch1_63.dbf recid=302 stamp=585542363
 validation succeeded for archived log
 archive log filename=/opt/OraHome2/dbs/arch1_64.dbf recid=303 stamp=585680372
 validation succeeded for archived log
 archive log filename=/opt/OraHome2/dbs/arch1_65.dbf recid=304 stamp=585742234
 validation succeeded for archived log
 archive log filename=/opt/OraHome2/dbs/arch1_66.dbf recid=305 stamp=585742245
 validation succeeded for archived log
 archive log filename=/opt/OraHome2/dbs/arch1_67.dbf recid=306 stamp=585742434
 Crosschecked 9 objects

RMAN>


Another method would be to uncatalog the logs from RMAN.  If only one archive log file is missing, it can be "uncataloged" from RMAN so it doesn't try to backup the file.  If there are a number of missing logs, then all the logs can be uncataloged from RMAN.  A FULL backup of the database MUST follow to ensure recoverability.  This process does not require shutting down the target database.  The process to do this is as follows:

 To uncatalog the archive log, connect to the catalog using RMAN from the target database server.

Then uncatalog the archive log using the following RMAN command substituting the FULL PATH to the file for <ARCHIVELOG FILE> using quotes.


RMAN> change archivelog <ARCHIVELOG FILE> uncatalog;


If there are too many logs missing then the word all can be used for the file descriptor and all logs will be uncataloged.


RMAN> change archivelog all uncatalog;


If scheduled downtime can be achieved another method is to reset the catalog & database.  This requires shutting the database down and restarting it in mount mode.  Issue a recover database using backup control file until cancel.  Then alter database open reset logs.  After which from rman, reset database.  This will reset the archive logs back to 1 and resync it with the catalog.

On the Target Database server, shut down the database, then startup the database in mount mode.  Connect to the database and run the following.


sqlplus> startup mount
 sqlplus> recover database using backup controlfile until cancel;
 sqlplus> cancel;
 sqlplus> alter database open resetlogs;
 sqlplus> exit


This resets the Archive logs on the database back to 1.

 To reset the catalog, connect to it from the target database server:


(This example assumes a catalog connect string of rman/rman@rcatdb and a database connect string of internal/internal@hawkdb)


Substitute with your actual connect strings.


On the Target Server issue the following command at the command prompt:


rman catalog rman/rman@rcatdb target internal/internal@hawkdb


This will connect to the catalog and output something like the following:


[oraclece@hawk]$ rman catalog rman/rman@rcatdb target internal/internal@hawkdb
     Recovery Manager: Release 8.1.6.0.0 - Production
 RMAN-06005: connected to target database: HAWKDB (DBID=1548722245)
     RMAN-06008: connected to recovery catalog database
 RMAN>


To reset the database in the catalog, issue the following command at the RMAN prompt:


RMAN> reset database;

URL:

All Querries and scripts go to http://www.shutdownabort.com

Thursday, 1 November 2012

File Versions Script in Oracle

SELECT fi.file_id,
filename,
version
FROM apps.ad_files fi,
apps.ad_file_versions ve
WHERE filename LIKE 'POXRESPO%'
AND ve.file_id = fi.file_id
AND version =
(SELECT MAX(version)
FROM apps.ad_file_versions ven
WHERE ven.file_id = fi.file_id
)


Replace the files without extension for other files in 'POXRESPO'


Output : 


   FILE_ID        FILENAME                     VERSION

--------------------------------------------------------------------
     23562        POXRESPO.pls              110.72.12010000.5

    194753      
POXRESPO
.pls              115.22