Thursday, 6 February 2014

RMAN STATUS from db

select session_key,
       input_type,
       status,
       to_char(start_time,'yyyy-mm-dd hh24:mi') start_time,
       to_char(end_time,'yyyy-mm-dd hh24:mi')   end_time,
       output_bytes_display,
       time_taken_display
from v$rman_backup_job_details
order by session_key asc;

http://oracledbabhuvan.blogspot.in/2011/11/rman-query-to-find-backup-details.html

gathering schema status of object


select count(*) from dba_tables where  owner != 'SYS' and 
to_char(last_analyzed,'DD/MM/YYYY HH24:MI:SS') > '09/04/2012 16:017:052 '

select sysdate-1/24 from dual

DBA with linux

intora file location /test/TEST/testdb/tech_st/11.1.0/dbs

adpatch   log file location /test/TEST/testapps/apps_st/appl/admin/TEST/log


strings -a APListXml.xml |grep '$Header'




[applerpp@finprod10 AP_Diag]$ cd $AP_TOP
Find file in Unix
[applerpp@finprod10 12.0.0]$ find . -name apgdfalb.pls
./patch/115/sql/apgdfalb.pls
[applerpp@finprod10 12.0.0]$ cd patch/115/sql/
Find Version of File
[applerpp@finprod10 sql]$ strings -a apgdfalb.pls | grep '$Header'
/* $Header: apgdfalb.pls 120.1 2008/03/10 09:49:15 serabell noship $ */

[testappl@finprod10 sql]$ strings -a apgdfalb.pls |grep '$Header'
/* $Header: apgdfalb.pls 120.1.12010000.30 2011/01/30 06:53:42 gagrawal ship $ *

$ORACLE_HOME
/test/TEST/testapps/tech_st/10.1.2

TRACE FILE LOCATION
$FORMS_TRACE_DIR

 /test/TEST/testinst/apps/TEST_finprod10/logs/ora/10.1.2/forms



ls -l
du -h
pwd cd ..
cd


To find environment variable

printenv

$appl_top

background_dump_dest

core_dump_dest

user_dump_dest



Kill process
cd /data/ERPP/erppdb/tech_st/11.1.0/admin/ERPP_finprod10/diag/rdbms/erpp/ERPP/trace
tail -100f  alert.log


list oracle process
ps -ef |grep LOCAL=NO

command is to see oracle instance process on linux server
ps- ef | grep pmon
export ORACLE_SID=orcl

ps -ef|grep testora|grep LOCAL=NO
kill -9 PID

kill all proesses
kill -9 ps -ef|grep LOCAL=NO|grep INSTANCE NAME|awk ‘{print $2}’`

Loaction of arch log
Prod
/data/ERPP_dbarch1/database/ERPP/arch
Test
/test/ERPP_dbarch2/database/ERPP/arch

zip the files
gzip *.arc

HTML FORMAT Report Coversion in R12





BINARY TO HTML FORMAT
java -cp $ORACLE_HOME/forms/java/frmxlate.jar oracle.forms.diagnostics.Xlate datafile=forms_31560.trc outputfile=trace_forms_31560.html outputclass=WriteOutHTML

java -cp $ORACLE_HOME/forms/java/frmxlate.jar oracle.forms.diagnostics.Xlate datafile=forms_31560.trc outputfile=trace_forms_31560.html outputclass=WriteOutHTML


How To Collect And Use Forms Trace (FRD) in Oracle Applications Release 12 [ID 373548.1]


$ORACLE_HOME
/test/TEST/testapps/tech_st/10.1.2

TRACE FILE LOCATION
$FORMS_TRACE_DIR

 /test/TEST/testinst/apps/TEST_finprod10/logs/ora/10.1.2/forms




----------------------------------------
ls -l
du -h
pwd cd ..
cd
--------------------------------------

1.Generate  Trace file
Profile -> System
USER SYSADMIN
PARAMETER  Forms Runtime Parameters

record=forms tracegroup=medium

Reproduce the error and check trc file

BINARY TO HTML FORMAT
java -cp $ORACLE_HOME/forms/java/frmxlate.jar oracle.forms.diagnostics.Xlate datafile=forms_31560.trc outputfile=trace_forms_31560.html outputclass=WriteOutHTML

java -cp $ORACLE_HOME/forms/java/frmxlate.jar oracle.forms.diagnostics.Xlate datafile=forms_31560.trc outputfile=trace_forms_31560.html outputclass=WriteOutHTML

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

Forms Runtime Diagnostics (FRD)
Profile -> System
USER SYSADMIN
PARAMETER  Forms Runtime Parameters
record=collect

after changing parameter in profile for sysadmin user

restart apps
stop_appltest

start_appltest

login as sysadmin

after logout collect_Processid file is created in $FORMS_TRACE_DIR

no need to convert collect file.
=====================================================

How To Trace a Concurrent Request And Generate TKPROF File [ID 453527.1]


How To Trace a Concurrent Request And Generate TKPROF File [ID 453527.1]
TKPROF filename_source filename_output EXPLAIN=[username/password] SYS=[YES/No] TABLE=[tablename]
$tkprof raw_trace_file.trc output_file explain=apps/apps
sort=(exeela,fchela) sys=no
Where:
raw_trace_file.trc: Name of trace file
output_file:        tkprof out file
explain:            This option provides the explain plan for the sql  
                   statements
sort:               This provides the sort criteria in which all sql  
                   statements will be sorted.  This will bring the bad
sql at  
                   the top of the outputfile.
sys=no:             Disables sql statements issued by user SYS
TKPROF_APPS.htm For R12
TKPROF.htm For Database
tkprof  ERPP_ora_16286_i351307.trc output_file_name explain =apps/apps sys=no

INVALID OBJECTS IN R12




http://onlineappsdba.com/index.php/2010/06/03/how-to-compile-apps-schema-invalid-objects-in-r12/

https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&doctype=HOWTO&id=314538.1

http://myappsdba.com/how-to-compile-apps-forms-library-modules-or-pll-files-in-11i-applications/


1. How many invalid objects are in the Database ?


select owner,object_type,COUNT(*)
from dba_objects
where owner = 'APPS'
and status = 'INVALID'"
from dba_objects
where status='INVALID'
group by owner, object_type;


select object_name,object_type,owner
from dba_objects
where owner = 'APPS'
and status = 'INVALID'


2. Check for details about the invalid objects :

column owner format A9
column object_name format A31
column object_type format A15
column last_ddl_time format A10
spool invalids.lst
select OWNER, OBJECT_NAME,OBJECT_TYPE,LAST_DDL_TIME
from dba_objects where status='INVALID'
order by owner;



Validating invalid objects

invalid objects in the E-Business Suite Environment 11i and 12.mht

Compile_Objects_apps_schema_files.mht Using adadmin

Recomplie_FORM_LIB_PLL_Using_Adadmin.mht Using adadmin

linux cmd



Location of arch files in prod
cd /data/ERPP_dbarch1/database/ERPP/arch
Location of arch files in test
 cd /test/ERPP_dbarch2/database/ERPP/arch/


count of number of files

ls -l *.arc |wc -l

find files that are more than 90 days
count the size of specic files find *.arc -mtime +90
du -c -h *.arc

zip the files
gzip *.arc


ls - lrth

tail  -100f


crontab -l

free -m
cat /proc/meminfo
top -c

vmstat


strings -a $AU_TOP/forms/US/sachin_test.fmb | grep '$Header

find . -name file name

locate exact_file_name

df -h

VIEW ORACLE INSTANCE ON LINUX
ps -ef|grep pmon
echo $ORACLE_SID
export Oracle_SID=TEST

calling sqlplus in testora

. /test/TEST/testdb/tech_st/11.1.0/TEST_finprod10.env
which located in start_oratest

Kill process
cd /data/ERPP/erppdb/tech_st/11.1.0/admin/ERPP_finprod10/diag/rdbms/erpp/ERPP/trace
tail -100f  alert.log view log
/test/TEST/testdb/tech_st/11.1.0/admin/TEST_finprod10/diag/rdbms/test/TEST/trace

list oracle process
ps -ef |grep LOCAL=NO ps -ef|grep FNDLBR

command is to see oracle instance process on linux server
ps- ef | grep pmon
export ORACLE_SID=orcl

ps -ef|grep testora|grep LOCAL=NO
kill -9 PID kill pid no

kill all proesses
kill -9 ps -ef|grep LOCAL=NO|grep INSTANCE NAME|awk ‘{print $2}’`


remove files from weekly retention

on month basis

List of file in Jul Month
ls -lrth *201207*

Total size of files in Jul Month
du -c -h *201207*

Remove files in Jul Month
rm -f *201207*

rm -f *20120701*

`

relation between linux process and oracle process and sid


*****************************  *******************************
relation between linux process and oracle process and sid

http://docs.oracle.com/cd/B13789_01/server.101/b10755/dynviews_2073.htm

select sid,paddr, sql_id,client_identifier,osuser  from v$session where
status = 'ACTIVE'

sid sessin id
paddr = process id
sql_id = current running sql

** addr = paddr
select spid from v$process where addr ='00000000DC687DB8'

** spid = pid (linux procss )

ps -ef|grep pid = 117

** sql_id = sql_id
select * from V$sql where sql_id = '7b5w34atn8q1h'

returns sql query

kill sessions

1) To determine what session has a lock on this record, please execute the following steps:

a) Run the following to determine what tables are locked:

647

SELECT a.object_id, a.session_id, substr(b.object_name, 1, 40)
FROM v$locked_object a, dba_objects b
WHERE a.object_id = b.object_id
AND b.object_name like 'AP_%'
ORDER BY b.object_name;

b) Look at the results and insert whatever AP_% tables are returned from a) into the script below:

SELECT l.*, o.owner object_owner, o.object_name
FROM SYS.all_objects o, v$lock l
WHERE l.TYPE = 'TM'
AND o.object_id = l.id1
AND o.object_name in ('AP_INVOICES_ALL', 'AP_INVOICE_LINES_ALL', 'AP_INVOICE_DISTRIBUTIONS_ALL');

c) SELECT SID, SERIAL#
FROM v$session
WHERE SID in (647);

2) Once the locking sessions have been identified, please use the below command to kill such sessions.

ALTER SYSTEM KILL SESSION '647,38937' IMMEDIATE;

Find user in oracle apps by which table is locked.

select client_identifier from V$session where sid = 783

ADR Utility

 SQL*Plus: Release 11.1.0.7.0 - Production on Fri Aug 31 12:09:09 2012

Copyright (c) 1982, 2008, Oracle.  All rights reserved.

Enter user-name: apps
Enter password:

Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64
bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[testora@finprod10 ~]$
[testora@finprod10 ~]$
[testora@finprod10 ~]$
[testora@finprod10 ~]$ . /test/TEST/testdb/tech_st/11.1.0/TEST_finprod10.env
[testora@finprod10 ~]$ %]adrci
-bash: fg: %]adrci: no such job
[testora@finprod10 ~]$ adrci

ADRCI: Release 11.1.0.7.0 - Production on Fri Aug 31 12:10:54 2012

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

ADR base = "/test/TEST/testdb/tech_st/11.1.0/admin/TEST_finprod10"
adrci> show home
ADR Homes:
diag/rdbms/test/TEST
adrci> set homepath diag/rdbms/test/TEST
adrci> show problem

ADR Home = /test/TEST/testdb/tech_st/11.1.0/admin/TEST_finprod10/diag/rdbms/test/TEST:
*************************************************************************
PROBLEM_ID           PROBLEM_KEY                                                 LAST_INCIDENT        LASTINC_TIME
-------------------- ----------------------------------------------------------- -------------------- ----------------------------------------
3                    ORA 7445 [kgldpo0()+1424]                                   93290                2011-11-30 15:01:10.642448 +05:30
2                    ORA 7445 [dbgrmqmqpk_query_pick_key()+2171]                 77194                2011-04-21 16:45:29.875489 +05:30
1                    ORA 7445 [ptkin()+350]                                      43472                2010-07-10 11:05:05.646824 +05:30
3 rows fetched

adrci> ips pack probelm in /tmp
DIA-48415: Syntax error found in string [ips pack probelm] at column [16]

adrci> ips pack problem in /tmp
DIA-48415: Syntax error found in string [ips pack problem in] at column [19]
DIA-48438: [in] is not a valid number

adrci> ips pack problem in /tmp
DIA-48415: Syntax error found in string [ips pack problem in] at column [19]
DIA-48438: [in] is not a valid number

adrci> IPS PACK PROBLEM IN /tmp
DIA-48415: Syntax error found in string [IPS PACK PROBLEM IN] at column [19]
DIA-48438: [IN] is not a valid number

adrci> IPS PACK PROBLEM 3 IN /tmp
Generated package 1 in file /tmp/IPSPKG_20120831121647_COM_1.zip, mode complete
adrci>

Recomplie object by script



    1. SQL>Shutdown immediate
     2. SQL>Startup upgrade
     3. SQL>@?/rdbms/admin/utlirp.sql
     4. SQL>shutdown immediate
     5. SQL>startup restrict
     6. SQL>@?/rdbms/admin/utlrp
     7. SQL>Shutdown immediate
     8. SQL>Startup 




ORA-7445[kgldpo0] Error Raised While Executing Utlrp.sql Script or Compile of Package [ID 1142918.1]

oracle table size in mb

https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:266215435203
SELECT
   owner, table_name, TRUNC(sum(bytes)/1024/1024) Meg
FROM 
(SELECT segment_name table_name, owner, bytes
 FROM dba_segments
 WHERE segment_type = 'TABLE' and owner = 'AP' )
 group by table_name, owner
 order by 3 desc 
 
 
 select TABLE_NAME, ROUND((AVG_ROW_LEN * NUM_ROWS / 1024), 2) ROW_SIZE_KB, (BLOCKS * 8)  BLOCK_SIZE_KB  
from all_TABLES where  owner = 'AP'
order by TABLE_NAME

Alert and Listener logs

Select from Alert and Listener logs using V$DIAG_ALERT_EXT
# Selecting from the Alert log :-
SQL> select ORIGINATING_TIMESTAMP, MESSAGE_TEXT
from V$DIAG_ALERT_EXT
WHERE ORIGINATING_TIMESTAMP > sysdate -1/24
and trim(COMPONENT_ID)='rdbms'; 
# Selecting from the Listener log :-
SQL> select ORIGINATING_TIMESTAMP,MESSAGE_TEXT
from V$DIAG_ALERT_EXT
WHERE ORIGINATING_TIMESTAMP > sysdate -1/24
and trim(COMPONENT_ID)='tnslsnr';  
1- First view for rdbms log entries:
create or replace view my_db_alert_log as
select ORIGINATING_TIMESTAMP,HOST_ID,HOST_ADDRESS,DETAILED_LOCATION,MODULE_ID,
CLIENT_ID,PROCESS_ID,USER_ID,MESSAGE_ID,MESSAGE_GROUP,MESSAGE_TEXT,PROBLEM_KEY,FILENAME
from V$DIAG_ALERT_EXT WHERE trim(COMPONENT_ID)='rdbms';
2- Another one for listener log entries:
create or replace view my_lsnr_alert_log as
select ORIGINATING_TIMESTAMP,HOST_ID,HOST_ADDRESS,DETAILED_LOCATION,MODULE_ID,
CLIENT_ID,PROCESS_ID,USER_ID,MESSAGE_ID,MESSAGE_GROUP,MESSAGE_TEXT,PROBLEM_KEY,FILENAME
from V$DIAG_ALERT_EXT WHERE trim(COMPONENT_ID)='tnslsnr';
http://blog.contractoracle.com/2013/01/select-from-alert-and-listener-logs.html
http://laurent-leturgez.com/2011/11/16/read-rdbms-and-listener-log-xml-from-sqlplus-prompt/
http://psoug.org/reference/dyn_perf_view.html

ORA-12012: error on auto execute of job “SYS”.”BSLN_MAINTAIN_STATS_JOB”

ORA-12012: error on auto execute of job “SYS”.”BSLN_MAINTAIN_STATS_JOB”

Posted: April 17, 2012 in ORA- error
8
Error in Alert log
Errors in file /wload/test/app/oracle/diag/rdbms/TEST/TEST/trace/TEST_j000_7733378.trc:
ORA-12012: error on auto execute of job “SYS”.”BSLN_MAINTAIN_STATS_JOB”
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at “DBSNMP.BSLN_INTERNAL”, line 2073
ORA-06512: at line 1
Sat Mar 24 23:01:18 2012
Error from trace file
*** 2012-03-24 23:00:13.943
*** SESSION ID:(23.6871) 2012-03-24 23:00:13.943
*** CLIENT ID:() 2012-03-24 23:00:13.943
*** SERVICE NAME:(SYS$USERS) 2012-03-24 23:00:13.943
*** MODULE NAME:(DBMS_SCHEDULER) 2012-03-24 23:00:13.943
*** ACTION NAME:(BSLN_MAINTAIN_STATS_JOB) 2012-03-24 23:00:13.943
ORA-12012: error on auto execute of job “SYS”.”BSLN_MAINTAIN_STATS_JOB”
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at “DBSNMP.BSLN_INTERNAL”, line 2073
ORA-06512: at line 1
Cause
Table DBSNMP.BSLN_BASELINES contains inconsistent information that is causing the job to fail.
Check the job status
SQL> select log_date,status from dba_scheduler_job_run_details where job_name=’BSLN_MAINTAIN_STATS_JOB’;
LOG_DATE STATUS
————————————————————————— ——————————
10-MAR-12 11.00.13.501250 PM +00:00 FAILED
03-MAR-12 11.00.10.603238 PM +00:00 FAILED
17-MAR-12 11.00.14.793987 PM +00:00 FAILED
24-MAR-12 11.00.13.980545 PM +00:00 FAILED
Role of BSLN_MAINTAIN_STATS_JOB
This job runs the BSLN_MAINTAIN_STATS_PROG program on the BSLN_MAINTAIN_STATS_SCHED schedule.  The program BSLN_MAINTAIN_STATS_PROG will keep the default baseline’s statistics up-to-date
Check the DBSNMP.BSLN_BASELINES table
SQL> select * from DBSNMP.BSLN_BASELINES;
DBID INSTANCE_NAME BASELINE_ID BSLN_GUID TI A STATUS LAST_COMP
———- —————- ———– ——————————– — – —————- ———
1166314350 FTEST 0 4AC774574F6C7D60D4ADF390356098C1 NX Y ACTIVE 27-NOV-10
1166314350 TEST 0 CEF9782DC11EE02FCB9E1D821B49FB3F HX Y ACTIVE 27-NOV-10
So on our database we should just have the entry for TEST so we need to delete the entry for FTEST.
Delete the inconsistent entry
SQL> delete from DBSNMP.BSLN_BASELINES where INSTANCE_NAME=’FTEST’;
1 row deleted.
SQL> select * from DBSNMP.BSLN_BASELINES;
DBID INSTANCE_NAME BASELINE_ID BSLN_GUID TI A STATUS LAST_COMP
———- —————- ———– ——————————– — – —————- ———
1166314350 TEST 0 CEF9782DC11EE02FCB9E1D821B49FB3F HX Y ACTIVE 27-NOV-10
Now re-run the job.
SQL> exec dbms_scheduler.run_job(‘BSLN_MAINTAIN_STATS_JOB’,false);
PL/SQL procedure successfully completed.
The job has now successfully run.
SQL> select log_date,status from dba_scheduler_job_run_details where job_name=’BSLN_MAINTAIN_STATS_JOB’;
LOG_DATE STATUS
————————————————————————— ——————————
10-MAR-12 11.00.13.501250 PM +00:00 FAILED
29-MAR-12 01.11.43.054124 PM +01:00 SUCCEEDED
03-MAR-12 11.00.10.603238 PM +00:00 FAILED
17-MAR-12 11.00.14.793987 PM +00:00 FAILED
24-MAR-12 11.00.13.980545 PM +00:00 FAILED


========================================
http://oracledbazone.com/2012/04/17/ora-12012-error-on-auto-execute-of-job-sys-bsln_maintain_stats_job-2/

creating password file

http://satya-dba.blogspot.in/2009/08/rollback-segments-in-oracle.html

http://docs.oracle.com/cd/B28359_01/server.111/b28310/dba007.htm#ADMIN11061

http://newgendba.blogspot.in/2009/03/connect-to-oracle-as-sys-via-toad-or.html

orapwd utility for accessing sys as sysdba by using toad


orapwd file=orapwHOT password=manager 

and

-- Setting up the Init.Ora file To enable remote SYSDBA connections set the init.ora parameters thus:

Set REMOTE_LOGIN_PASSWORDFILE to either EXCLUSIVE or SHARED.


Connect to Oracle as sys via toad or any other third party software

A remote connect as a privileged user requires the database to be configured to allow remote DBA operations. The remote user will HAVE to supply a password in order to connect AS SYSDBA. 

Ie: In Oracle to perform a remote connect AS SYSDBA you must use the syntax

'CONNECT 
SYS/PASSWORD@ORACLE_SID AS SYSDBA'

To allow remote SYSDBA connections you must:
- Set up a password file for the database on the server
- Set up any relevant init.ora parameters

-- Setting up a Password File:
The password protection is controlled by an Oracle 'Password' file. To create a password file log in as the Oracle software owner and issue the command:

orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=mypasswd

using the required password. The file name is important and should specified as above. You should create this file when the database is shut down.

To change a password:
- shut down the database,
- Rename the $ORACLE_HOME/dbs/orapw$ORACLE_SID file
- Issue a new orapwd command with a new password

Alternatively, when the database is open use:

ALTER USER SYS IDENTIFIED BY &NEWPASSWORD;

This will propagate the (hashed) password to the existing password file.

-- Setting up the Init.Ora file To enable remote SYSDBA connections set the init.ora parameters thus:

Set REMOTE_LOGIN_PASSWORDFILE to either EXCLUSIVE or SHARED.
EXCLUSIVE forces the password file to be tied exclusively to a single instance. To disable remote internal connections set REMOTE_LOGIN_PASSWORDFILE to NONE. 


NOTE: The setting of REMOTE_OS_AUTHENT does NOT affect the ability to connect AS SYSDBA from a remote machine. 

http://newgendba.blogspot.in/2009/03/connect-to-oracle-as-sys-via-toad-or.html
============================================================================
http://satya-dba.blogspot.in/2009/11/password-file-in-oracle.html

Password file (orapwd utility) in Oracle

Oracle password file stores passwords for users with administrative privileges.

If the DBA wants to start up an Oracle instance there must be a way for Oracle to authenticate the DBA. Obviously, DBA password cannot be stored in the database, because Oracle cannot access the database before the instance is started up. Therefore, the authentication of the DBA must happen outside of the database. There are two distinct mechanismsto authenticate the DBA:
(i) Using the password file or
(ii) Through the operating system (groups). Any OS user under dba group, can login as SYSDBA.

The default location for the password file is:
$ORACLE_HOME/dbs/orapw$ORACLE_SID on Unix, %ORACLE_HOME%\database\PWD%ORACLE_SID%.ora on Windows.

REMOTE_LOGIN_PASSWORDFILE
The init parameter REMOTE_LOGIN_PASSWORDFILE specifies if a password file is used to authenticate the Oracle DBA or not. If it set either to SHARED or EXCLUSIVE, password file will be used.

REMOTE_LOGIN_PASSWORDFILE is a static initialization parameter and therefore cannot be changed without bouncing the database.

Following are the valid values for REMOTE_LOGIN_PASSWORDFILE:

NONE - Oracle ignores the password file if it exists i.e. no privileged connections are allowed over non secure connections. If REMOTE_LOGIN_PASSWORDFILE is set to EXCLUSIVE or SHARED and the password file is missing, this is equivalent to setting REMOTE_LOGIN_PASSWORDFILE to NONE.

EXCLUSIVE (default) - Password file is exclusively used by only one (instance of the) database. Any user can be added to the password file. Only an EXCLUSIVE file can be modified. EXCLUSIVE password file enables you to add, modify, and delete users. It also enables you to change the SYS password with the ALTER USER command.

SHARED - The password file is shared among databases. A SHARED password file can be used by multiple databases running on the same server, or multiple instances of an Oracle Real Application Clusters (RAC) database. However, the only user that can be added/authenticated is SYS.
  • Blogs
  •  
  • Answer Interview
  •  
  • Interview
  •  
  • Examples
  •  
  • Utility
  •  
  • Google+
  •  
  • Administrative Assistants


A SHARED password file cannot be modified i.e. you cannot add users to a SHARED password file. Any attempt to do so or to change the password of SYS or other users with the SYSDBA or SYSOPER or SYSASM (this is from Oracle 11g) privileges generates an error. All users needing SYSDBA or SYSOPER or SYSASM system privileges must be added to the password file when REMOTE_LOGIN_PASSWORDFILE is set to EXCLUSIVE. After all users are added, you can change REMOTE_LOGIN_PASSWORDFILE to SHARED.

This option is useful if you are administering multiple databases or a RAC database.

If a password file is SHARED or EXCLUSIVE is also stored in the password file. After its creation, the state is SHARED. The state can be changed by setting REMOTE_LOGIN_PASSWORDFILE and starting the database i.e. the database overwrites the state in the password file when it is started up.

ORAPWD
You can create a password file using orapwd utility. For some Operating systems, you can create this file as part ofstandard installation.

Users are added to the password file when they are granted the SYSDBA or SYSOPER or SYSASM privilege.

The Oracle orapwd utility assists the DBA while granting SYSDBA, SYSOPER and SYSASM privileges to other users. By default, SYS is the only user that has SYSDBA and SYSOPER privileges. Creating a password file, via orapwd, enables remote users to connect with administrative privileges.

orapwd file=password_file_name [password=the_password] [entries=n] [force=Y|N] [ignorecase=Y|N] [nosysdba=Y|N]

Examples:
$ orapwd file=orapwSID password=sys_password force=y nosysdba=y
$ orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=secret
$ orapwd file=orapwprod entries=30 force=y
C:\orapwd file=%ORACLE_HOME%\database\PWD%ORACLE_SID%.ora password=2012 entries=20
C:\orapwd file=D:\oracle11g\product\11.1.0\db_1\database\pwdsfs.ora password=id entries=6 force=y
$ orapwd file=orapwPRODB3 password=abc123 entries=10 ignorecase=n
$ orapwd file=orapwprodb password=oracle1 ignorecase=y

There are no spaces permitted around the equal-to (=).

The following describe the orapwd command line arguments.

FILE
Name to assign to the password file, which will hold the password information. You must supply complete path. If you supply only filename, the file is written to the current directory. The contents are encrypted and are unreadable. This argument is mandatory.

The filenames allowed for the password file are OS specific. Some operating systems require the password file to adhere to a specific format and be located in a specific directory. Other operating systems allow the use of environment variables to specify the name and location of the password file.

If you are running multiple instances of Oracle Database using Oracle Real Application Clusters (RAC), the environment variable for each instance should point to the same password file.

It is critically important to secure password file.

PASSWORD
This is the password the privileged users should enter while connecting as SYSDBA or SYSOPER or SYSASM.

ENTRIES
Entries specify the maximum number of distinct SYSDBA, SYSOPER and SYSASM users that can be stored in the password file.

This argument specifies the number of entries that you require the password file to accept. The actual number of allowable entries can be higher than the number of users, because the orapwd utility continues to assign password entries until an OS block is filled. For example, if your OS block size is 512 bytes, it holds four password entries. The number of password entries allocated is always a multiple of four.

Entries can be reused as users are added to and removed from the password file. When you exceed the allocated number of password entries, you must create a new password file. To avoid this necessity, allocate a number of entries that is larger than you think you will ever need.

FORCE
(Optional) If Y, permits overwriting an existing password file. An error will be returned if password file of the same name already exists and this argument is omitted or set to N.

IGNORECASE
(Optional) If Y, passwords are treated as case-insensitive i.e. case is ignored when comparing the password that the user supplies during login with the password in the password file.

NOSYSDBA
(Optional) For Oracle Data Vault installations.

Granting SYSDBA or SYSOPER or SYSASM privileges


Use the V$PWFILE_USERS view to see the users who have been granted SYSDBA or SYSOPER or SYSASM system privileges for a database.


SQL> select * from v$pwfile_users;
USERNAME SYSDBA SYSOPER SYSASM
-------- ------ ------- ------
SYS TRUE TRUE FALSE
The columns displayed by the view V$PWFILE_USERS are:


Column Description
 
USERNAME
This column contains the name of the user that is recognized by the password file.  
SYSDBAIf the value of this column is TRUE, then the user can log on with SYSDBA system privilege.  
SYSOPER If the value of this column is TRUE, then the user can log on with SYSOPER system privilege.  
SYSASMIf the value of this column is TRUE, then the user can log on with SYSASM system privilege.
  • Oracle Dba
  •  
  • Password
  •  
  • Multiple
  •  
  • Blogs
  •  
  • Answer Interview
  •  
  • Interview
  •  
  • Examples
  •  
  • Utility



If orapwd has not yet been executed or password file is not available, attempting to grant SYSDBA or SYSOPER or SYSASM privileges will result in the following error:
SQL> grant sysdba to satya;
ORA-01994: GRANT failed: cannot add users to public password file

If your server is using an EXCLUSIVE password file, use the GRANT statement to grant the SYSDBA or SYSOPER or SYSASM system privilege to a user, as shown in the following example:
SQL> grant sysdba to satya;

SQL> select * from v$pwfile_users;
USERNAME SYSDBA SYSOPER SYSASM
-------- ------ ------- ------
SYS TRUE TRUE FALSE
SATYA TRUE FALSE FALSE

SQL> grant sysoper to satya;
SQL> select * from v$pwfile_users;
USERNAME SYSDBA SYSOPER SYSASM
-------- ------ ------- ------
SYS TRUE TRUE FALSE
SATYA TRUE TRUE FALSE

SQL> grant sysasm to satya;
SQL> select * from v$pwfile_users;
USERNAME SYSDBA SYSOPER SYSASM
-------- ------ ------- ------
SYS TRUE TRUE FALSE
SATYA TRUE TRUE TRUE

When you grant SYSDBA or SYSOPER or SYSASM privileges to a user, that user's name and privilege information are added to the password file. If the server does not have an EXCLUSIVE password file (i.e. if the initialization parameter REMOTE_LOGIN_PASSWORDFILE is NONE or SHARED, or the password file is missing), Oracle issues an error if you attempt to grant these privileges.

Use the REVOKE statement to revoke the SYSDBA or SYSOPER or SYSASM system privilege from a user, as shown in the following example:
SQL> revoke sysoper from satya;

SQL> select * from v$pwfile_users;
USERNAME SYSDBA SYSOPER SYSASM
-------- ------ ------- ------
SYS TRUE TRUE FALSE
SATYA TRUE FALSE TRUE

A user's name remains in the password file only as long as that user has at least one of these three privileges. If you revoke all 3 privileges, Oracle removes the user from the password file.

Because SYSDBA, SYSOPER and SYSASM are the most powerful database privileges, the WITH ADMIN OPTION is not used in the GRANT statement. That is, the grantee cannot in turn grant the SYSDBA or SYSOPER or SYSASM privilege to another user. Only a user currently connected as SYSDBA can grant or revoke another user's SYSDBA or SYSOPER or SYSASM system privileges. These privileges cannot be granted to roles, because roles are available only after database startup.

If you receive the file full error (ORA-01996) when you try to grant SYSDBA or SYSOPER or SYSASM system privileges to a user, you must create a larger password file and regrant the privileges to the users.

Removing Password File
If you determine that you no longer require a password file to authenticate users, you can delete the password file and then optionally reset the REMOTE_LOGIN_PASSWORDFILE initialization parameter to NONE. After you remove this file, only those users who can be authenticated by the OS can perform SYSDBA or SYSOPER or SYSASM database administration operations.