ORA-07446: sdnfy: bad value '/db/app/oracle/Db_1/admin/orcldg/udump' for parameter user_dump_dest.
Reason: "udump" directory doesn't exist.
Solution: create directory.
"Teach Oracle Learn Oracle" -- Taj Contact me for support at askdbataj@gmail.com This blog is dedicated to all ORACLE Professionals and Learning Students.
ORA-07446: sdnfy: bad value '/db/app/oracle/Db_1/admin/orcldg/udump' for parameter user_dump_dest.
My Signature Article
1. WITH PASSWORD
2. WITHOUT PASSWORD
1. Oracle Database User must have SYSDBA privileges.
2. Operating System User must add in DBA group.
On windows: ORA_DBA group
On linux: DBA group
3. In sqlnet.ora file must content "NTS" in below line
SQLNET.AUTHENTICATION_SERVICES=(NTS)
1. Remove OS user from DBA group
2. Edit sqlnet.ora file and change "NONE" to "NTS" in below line
SQLNET.AUTHENTICATION_SERVICES=(NONE)
Default Value is NTS when sqlnet.ora file created.
In SQL*Plus you can automatically get a report on the execution path used by the SQL optimizer and the statement execution statistics. The report is generated after a successful SQL DML statement, such as SELECT, DELETE, UPDATE or INSERT. It is useful for monitoring and tuning the performance of these DML statements.
1. Change directory path and connect with SYSTEM user to database
C:\>cd c:\oracle\product\10.1.0\db_1\rdbms\admin
C:\Oracle\product\10.1.0\Db_1\RDBMS\ADMIN>sqlplus /nolog
SQL*Plus: Release 9.0.1.0.1 - Production on Tue Oct 16 17:08:20 2007
(c) Copyright 2001 Oracle Corporation. All rights reserved.
SQL> conn system/manager
Connected.
2. run UTLXPLAN.SQL script for plan table.
SQL> @utlxplan.sql
3. Create public synonym for plan table or grant all privilege.
SQL> create public synonym plan_table for plan_table;
SQL> grant all on plan_table to public;
Grant succeeded.
4. Exit and again change directory path and connect with SYS user to database
SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production
With the Partitioning option
JServer Release 9.0.1.1.1 - Production
C:\Oracle\product\10.1.0\Db_1\RDBMS\ADMIN>cd\
C:\>cd c:\oracle\product\10.1.0\db_1\sqlplus\admin
C:\Oracle\product\10.1.0\Db_1\sqlplus\admin>sqlplus /nolog
SQL*Plus: Release 9.0.1.0.1 - Production on Tue Oct 16 17:12:07 2007
(c) Copyright 2001 Oracle Corporation. All rights reserved.
SQL> conn sys as sysdba
Enter password:
Connected.
5. run plustrce script and script must be run with SYS user.
SQL> @plustrce
SQL>
SQL> drop role plustrace;
Role dropped.
SQL> create role plustrace;
Role created.
SQL>
SQL> grant select on v_$sesstat to plustrace;
Grant succeeded.
SQL> grant select on v_$statname to plustrace;
Grant succeeded.
SQL> grant select on v_$mystat to plustrace;
Grant succeeded.
SQL> grant plustrace to dba with admin option;
Grant succeeded.
SQL> set echo off
6. Grant plustrace role to public.
SQL> grant plustrace to public;
Grant succeeded.
SET AUTOTRACE OFF - No AUTOTRACE report is generated. This is the
default.
SET AUTOTRACE ON EXPLAIN - The AUTOTRACE report shows only the optimizer
execution path.
SET AUTOTRACE ON STATISTICS - The AUTOTRACE report shows only the SQL
statement execution statistics.
SET AUTOTRACE ON - The AUTOTRACE report includes both the
optimizer execution path and the SQL
statement execution statistics.
SET AUTOTRACE TRACEONLY - Like SET AUTOTRACE ON, but suppresses the
printing of the user's query output, if any.
recursive calls
Number of recursive calls generated at both the user and system level. Oracle maintains tables used for internal processing. When Oracle needs to make a change to these tables, it internally generates an internal SQL statement, which in turn generates a recursive call.
db block gets
Number of times a CURRENT block was requested.
consistent gets
Number of times a consistent read was requested for a block.
physical reads
Total number of data blocks read from disk. This number equals the value of "physical reads direct" plus all reads into buffer cache.
redo size
Total amount of redo generated in bytes.
bytes sent via SQL*Net to client
Total number of bytes sent to the client from the foreground processes.
bytes received via SQL*Net from client
Total number of bytes received from the client over Oracle Net.
SQL*Net roundtrips to/from client
Total number of Oracle Net messages sent to and received from the client.
sorts (memory)
Number of sort operations that were performed completely in memory and did not require any disk writes.
sorts (disk)
Number of sort operations that required at least one disk write.
rows processed
Number of rows processed during the operation.
SQL> set autotrace on
SQL> select * from dept;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 TABLE ACCESS (FULL) OF 'DEPT'
Statistics
----------------------------------------------------------
0 recursive calls
2 db block gets
2 consistent gets
0 physical reads
0 redo size
702 bytes sent via SQL*Net to client
503 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
4 rows processed
SQL> set autotrace traceonly
SQL> select * from dept;
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 TABLE ACCESS (FULL) OF 'DEPT'
Statistics
----------------------------------------------------------
0 recursive calls
2 db block gets
2 consistent gets
0 physical reads
0 redo size
702 bytes sent via SQL*Net to client
503 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
4 rows processed
SQL> set autotrace trace explain
SQL> select * from dept;
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 TABLE ACCESS (FULL) OF 'DEPT'
SQL> set autotrace trace statistics
SQL> select * from dept;
Statistics
----------------------------------------------------------
0 recursive calls
2 db block gets
2 consistent gets
0 physical reads
0 redo size
702 bytes sent via SQL*Net to client
503 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
4 rows processed
What is cursor_sharing parameters ?
CURSOR_SHARING determines what kind of SQL statements can share the same cursors.
What is possible values for this parameter ?
1. EXACT (default)
Only allows statements with identical text to share the same cursor.
2. FORCE
Forces statements that may differ in some literals, but are otherwise identical, to share a cursor, unless the literals affect the meaning of the statement.
3. SIMILAR
Causes statements that may differ in some literals, but are otherwise identical, to share a cursor, unless the literals affect either the meaning of the statement or the degree to which the plan is optimized.
When we have to / should use this parameter ?
Whenever you have lots of some sql statement to execute but differ in liternal and your application is not design to use BIND VARIABLE that time you can use CURSOR_SHARING=FORCE to share cursor for every sql statement which differ only in literal.
Consider setting CURSOR_SHARING to SIMILAR or FORCE if both of the following questions are true:
Are there statements in the shared pool that differ only in the values of literals?
Is the response time low due to a very high number of library cache misses?
Tom Kyte said "cursor_sharing=force" is not permanent solution for performance it is use for temporary basis during developer fix there bug in application... instead of this parameter use BIND VARIABLE.
Performance improvement when we set cursor_sharing=force ?
When your application use lots of similar sql statement but differ in literal then yes performance will improve when you set cursor_sharing=force.
Side Effects on database when set cursor_sharing=FORCE/SIMILAR
Forcing cursor sharing among similar (but not identical) statements can have unexpected results in some DSS applications, or applications that use stored outlines.
Oracle does not recommend setting CURSOR_SHARING to FORCE in a DSS environment or if you are using complex queries. Also, star transformation is not supported with CURSOR_SHARING set to either SIMILAR or FORCE. For more information, see the "OPTIMIZER_FEATURES_ENABLE Parameter".
BUG with cursor_sharing=FORCE/SIMILAR
In Oracle Version 8i there is bug when set cursor_sharing=force/similar.
We need to down our database to set this parameter
No, we can set this parameter when our database is open.
alter system set CURSOR_SHARING=force SCOPE=both;
No need to worry about it. it is information message ...SMON start recovery in parrallel but failed and done in serial mode.
we can check "v$controlfile_record_section" view or "controlfile_record_keep_time" parameters
Eg:
kccrsz: expanded controlfile section 11 from 224 to 252 records
Note: Section 11 is belong to log_history.
When we configure Oracle E-MAIL notification method through OEM then it is not include notification for DB shutdown or startup events. For these two events we have to configure manually.
Connect sys as sysdba user and run two scripts for install and configure utl_mail package
SQL> conn sys@orcl as sysdba
Enter password: ******
Connected.
SQL> @c:\oracle\product\10.1.0\db_1\rdbms\admin\utlmail.sql
Package created.
Synonym created.
SQL> @c:\oracle\product\10.1.0\db_1\rdbms\admin\prvtmail.plb;
Package body created.
No errors.
Set SMTP_OUT_SERVER parameter for smtp_exchange_server. This parameter is not modifiable means we have to bounce our database to set this parameter
SQL> alter system set smtp_out_server = 'smtp_exchange_server_name' scope=spfile;
System altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
Grant EXECUTE privs to user which use utl_mail package.
SQL> grant execute on utl_mail to scott;
Grant succeeded.
Create two trigger for startup and shutdown event on database which send us email notification
SQL> create or replace trigger scott.db_shutdown
2 before shutdown on database
3 begin
4 sys.utl_mail.send (
5 sender =>'star_taj@yahoo.com',
6 recipients =>'star_taj@yahoo.com',
7 subject => 'Oracle Database Server DOWN',
8 message => 'May be DB Server Down for maintenance’||
‘ but also contact to DBA for further details. ’
9 );
10 end;
11 /
Trigger created.
SQL> create or replace trigger scott.db_startup
2 after startup on database
3 begin
4 sys.utl_mail.send (
5 sender =>'star_taj@yahoo.com',
6 recipients =>'star_taj@yahoo.com',
7 subject => 'Oracle Database Server UP',
8 message => 'DB Server OPEN for normal use.'
9 );
10 end;
11 /
Trigger created.
when database running in NO ARCHIVE LOG MODE
1. Shutdown database with immediate,transactional,normal option.
2. through OS copy command copy controlfiles to backup location
3. startup database.
when database running in ARCHIVELOG MODE
Text based controlfile backup
SQL> alter session set tracefile_identifier = ctrlbkp;
Session altered.
SQL> alter database backup controlfile to trace;
Database altered.
Note
1. Tracefile created with tracefile_identifier name like "ORA_SID_XXX_ctrlbkp.trc".
2. Above created backup controlfile is text file.
Exact copy or binary controlfile backup
alter database backup controlfile to 'PATH';
Note
Above statement created binary format controlfile backup.
Oracle 9i
Default value for job_queue_processes is "0". so whenever we create any job through dbms_job we have to also modify job_queue_processes parameter > '0'.
job_queue_processes
Oracle 10g
In Oracle 10g Default value for job_queue_processes is "10". so whenever we create any job through dbms_job then we no need to modify job_queue_processes parameter. but in documentation show "0" is default value.
job_queue_processes
My Signature Article
1. We can able to take database backup ONLINE.
2. No Need to Down Oracle DB Server
3. We can better Manage our Backup Policy through RMAN
4. Limited DBA task
5. We can able to RECOVER our database point-in-time
When we create new database then database is created NOARCHIVELOG mode by default.
shutdown database
SQL>shutdown immediate;
Edit below parameters in pfile(init.ora) file.
1. LOG_ARCHIVE_START=TRUE
Create New SPFILE from Modified pfile(init.ora)
SQL> create SPFILE from PFILE;
Startup Database in Mount Mode
SQL> startup mount;
Change Database log mode from NOARCHIVELOG to ARCHIVELOG
SQL> alter database archivelog;
Open DB for normal use
SQL> alter database open;
check archive log status
Database log mode Archive Mode
Automatic archival Enabled
Archive destination C:\Oracle\product\RDBMS
Oldest online log sequence 0
Next log sequence to archive 1
Current log sequence 1
Default Archivelog destination is :$ORACLE_HOME/rdbms.
In 10g Archivelog mode enabling is easy becuase we need to just turn DB log mode and archive log is automatic start.
shutdown database
SQL> shutdown immediate;
startup database in mount mode
SQL> startup mount;
Change DB log mode
SQL> alter database archivelog;
Open DB for normal use
SQL> alter database open;
check archivelog status
SQL> archive log list
Default Archive log destination.
1. 10g introduce new feature called FRA (flashback recovery area) so all archivelog files created in FRA.
2. If your not using FRA then all files created in $ORACLE_HOME/database
We can check database archivelog mode through below query
SQL> select log_mode from v$database;
or
SQL> archive log list
The database must be mounted and closed.
SQL> select status from v$instance;
STATUS
------------
MOUNTED
The database must be mounted as RESTRICTED.
SQL> select logins from v$instance;
LOGINS
----------
RESTRICTED
SQL> drop database;
Database dropped.
Note: Manually delete below folder.
1. $ORACLE_BASE/oradata/[sid]
2. $ORACLE_BASE/admin/[sid]
3. $ORACLE_BASE/flash_recovery_area/[sid]
4. If database created through DBCA then you have to also delete ORACLE_SID through DBCA otherwise you will get error message when you create new database with same ORACLE_SID.
We have two options for Super User "SYS" password authentication
1. Operating System authentication
2. Password file authentication
When we use password file authentication then we have to create PASSWORD FILE for SYS user.
commandpromt>orapwd file=$ORACLE_HOME/database/orapwd.ora password=pwd entries=n force=y/n
Note:
entries=n "maximum number of distinct DBAs and OPERs (opt)"
force=y ""y" if password file already created"
When we using Password file authentication for "sys" user then we have to use "remote_login_password" parameter.
There are three value for this parameters
1. EXCLUSIVE
This is default value. if parameter set "exclusive" then we can use password file for authentication and connect to remote machine with sys user.Only an EXCLUSIVE file can contain the names of users other than SYS. Using an EXCLUSIVE password file lets you grant SYSDBA and SYSOPER system privileges to individual users and have them connect as themselves.
2. NONE
If this parameter set "NONE" means passwordfile doesn't exists
3. SHARED
A SHARED password file can be used by multiple databases running on the same server. However, the only user recognized by a SHARED password file is SYS. You cannot add users to a SHARED password file. All users needing SYSDBA or SYSOPER system privileges must connect using the same name, SYS, and password. This option is useful if you have a single DBA administering multiple databases.
1. spfile (Server Parameter File)
Name: spfile.ora
Located: $ORACLE_HOME/dbs/spfile.ora (*nix platform)
Located: $ORACLE_HOME/database/spfile.ora(win platform)
Note: Never ever edit directly SPFILE file otherwise it will corrupted.
2. pfile (ASCII text file)
Name: init.ora
Located: $ORACLE_HOME/dbs/spfile.ora (*nix platform)
Located: $ORACLE_HOME/database/spfile.ora(win platform)
Note: you can edit this file in default TEXT EDITOR
3. pfile (text file)
Name: init.ora
Located: $ORACLE_BASE\admin\pfile\init.ora
Note: you can directly edit this file in any editor.
During instance time Oracle Server check SPFILE if found then using this file instance started. If SPFILE is not found then check PFILE if found then using this file instance stared. if both files is not found then you will get below error
message.
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file 'C:\ORACLE\PRODUCT\10.1.0\DB_1\DATABASE
\INITORCL.ORA'
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string C:\ORACLE\PRODUCT\10.1.0\DB_1\
DATABASE\SPFILEORCL.ORA
Note: if parameter showing value mean spfile is currently used.
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string
Note: if parameter showing NULL in value column then PFILE(init.ora) is used.
1. alter system set [parameter_name] SCOPE=SPFILE
2. shutdown
3. startup
or
1. shutdown
2. edit parameter in pfile [init.ora]
3. create spfile from pfile
4. startup
My Signature Article
1. DBMS_DDL
2. DBMS_UTILITY
3. UTL_RECOMP
4. UTLRP.SQL
5. Manually Recompile
Definition
This procedure is equivalent to the following SQL statement:
ALTER PROCEDUREFUNCTIONPACKAGE [.] COMPILE [BODY]
Syntax
Exec dbms_ddl.alter_compile ( type , schema, name);
Type : Must be either PROCEDURE, FUNCTION, PACKAGE, PACKAGE BODY or TRIGGER.
Schema : Database Username
Name : Objects name
Example
SQL> exec dbms_ddl.alter_compile ('PROCEDURE','SCOTT','TEST');
PL/SQL procedure successfully completed.
Definition
This procedure compiles all procedures, functions, packages, and triggers in the specified schema.
Syntax
Exec dbms_utility.compile_schema ( schema,compile all)
Schema : Database Username
Compile All : Object type ( procedure, function, packages,trigger)
Example
SQL> exec dbms_utility.compile_schema('SCOTT');
PL/SQL procedure successfully completed.
Definition
This script is particularly useful after a major-version upgrade that typically invalidates all PL/SQL and Java objects.
Syntax
Exec UTL_RECOMP.RECOMP_SERIAL ();
Example
SQL> Exec UTL_RECOMP.RECOMP_SERIAL ();
PL/SQL procedure successfully completed.
Note: Required SYS user to run this package.
Definition
Recompiles all existing PL/SQL modules that were previously in an INVALID state, such as packages, procedures, and types.
Syntax
Located: $ORACLE_HOME/rdbms/admin
Example
SQL> @c:\oracle\product\10.1.0\db_1\rdbms\admin\UTLRP.SQL
TIMESTAMP
-----------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_BGN 2007-08-04 12:47:21
PL/SQL procedure successfully completed.
TIMESTAMP
-----------------------------------------------------------------------
COMP_TIMESTAMP UTLRP_END 2007-08-04 12:47:26
PL/SQL procedure successfully completed.
Note: Required SYS user to run this script.
Recommended: After upgrade or migrate database.
Spool recompile.sql
Select ‘alter ‘object_type’ ’object_name’ compile;’
From user_objects
Where status <> ‘VALID’
And object_type IN (‘VIEW’,’SYNONYM’,
‘PROCEDURE’,’FUNCTION’,
‘PACKAGE’,’TRIGGER’);
Spool off
@recompile.sql
Note: VIEW,SYNONYM,PROCEDURE,PACKAGE,FUNCTION,TRIGGER
Spool pkg_body.sql
Select ‘alter package ’object_name’ compile body;’
From user_objects
where status <> ‘VALID’
And object_type = ‘PACKAGE BODY’;
Spool off
@pkg_body.sql
Spool undefined.sql
select ‘alter materizlized view ’object_name’ compile;’
From user_objects
where status <> ‘VALID’
And object_type =‘UNDEFINED’;
Spool off
@undefined.sql
Spool javaclass.sql
Select ‘alter java class ’object_name’ resolve;’
from user_objects
where status <> ‘VALID’
And object_type =‘JAVA CLASS’;
Spool off
@javaclass.sql
Spool typebody.sql
Select ‘alter type ‘object_name’ compile body;’
From user_objects
where status <> ‘VALID’
And object_type =‘TYPE BODY’;
Spool off
@typebody.sql
Spool public_synonym.sql
Select ‘alter public synonym ‘object_name’ compile;’
From user_objects
Where status <> ‘VALID’
And owner = ‘PUBLIC’
And object_type = ‘SYNONYM’;
Spool off
@public_synonym.sql
Oracle Database : 10.1.0.2.0
OS : Windows XP sp2
My Signature Article
Create users
List users
Grant the webDba role
Remove users
Revoke the webDba role
Change user passwords
start ----> run ----> cmd [[hit enter]]
C:\>set ORACLE_HOME=c:\oracle\product\10.1.0\db_1
C:\>cd %ORACLE_HOME%\oc4j\j2ee\isqlplus\application-deployments\isqlplus
C:\Oracle\product\10.1.0\Db_1\oc4j\j2ee\isqlplus\application-deployments\isqlplus>
C:\Oracle\product\10.1.0\Db_1\oc4j\j2ee\isqlplus\application-deployments\isqlplus>
c:\oracle\product\10.1.0\db_1\jdk\bin\java -Djava.security.properties=
c:\oracle\product\10.1.0\db_1\sqlplus\admin\iplus\provider -jar
c:\oracle\product\10.1.0\db_1\oc4j\j2ee\home\jazn.jar
-user "iSQL*Plus DBA/admin" -password welcome -shell
JAZN:> adduser "iSQL*Plus DBA" taj oracle
JAZN:> listusers "iSQL*Plus DBA"
admin
taj
JAZN:> grantrole webDba "iSQL*Plus DBA" taj
JAZN:> exit
C:\Oracle\product\10.1.0\Db_1\oc4j\j2ee\isqlplus\application-deployments\isqlplu
s>isqlplusctl stop
iSQL*Plus 10.1.0.5.0
Copyright (c) 2005 Oracle. All rights reserved.
Stopping iSQL*Plus ...
iSQL*Plus stopped.
C:\Oracle\product\10.1.0\Db_1\BIN>isqlplusctl start
iSQL*Plus 10.1.0.5.0
Copyright (c) 2005 Oracle. All rights reserved.
Starting iSQL*Plus ...
iSQL*Plus started.