Mohamed Azar Shaj

Oracle DBA, azarmohds@gmail.com, Riyadh Kingdom Of Saudi Arabia

Oracle Certification ** Oracle-Base ** Export and Import ** Charater set migration

About Me

My photo
Database Administrator and like to read about hackers and them activities...and completed Oracle 10g Certified associate. Active member of Oracle Forum

Ora-12514 TNS: listener does not currently know of service

4:11 PM / Posted by Azar Mohamed Shaj / comments (0)

Due to error occur on Oracle Listner not properly mentioned

So.., you should check lisntener.ora file and modify

Example :-

(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = E:\oracle\product\10.2.0\db_1)
(PROGRAM = extproc)
)

< (SID_DESC =
(SID_NAME = localdb )
(ORACLE_HOME = E:\oracle\product\10.2.0\db_1)
(SID_NAME = localdb) >

Note : < ... > here check your service name either there or not?localdb -------- db name
And then go to
lsnrctl >stop

lsnrctl>start

Or

>set oracle_sid=localdb
>sqlplus
username : / as sysdba
>startup


& then you connect sys/sys@localdb as sysdba

Your service should be started
------------------------------------------------------------------------------------------
Thanks & Regards
S.Mohamed Azarudeen
azarmohds@gmail.com

Hit/Miss Ratios

3:49 PM / Posted by Azar Mohamed Shaj / comments (0)

Buffer Hit Ratio :-

Buffer hit ratio notes:


  • Consistent Gets - The number of blocks accesses made to the block buffer to retrive data in a consistent mode.
  • DB Blk gets - The number of blocks accessed via single block gets.
  • Physical Reads - The cumulative number of blocks read from disk.
  • Logical reads are the sum of consisent gets and db block gets.
  • the db block gets statstic value is incremented when a block is read for update and when segment header blocks are accessed.
  • Hit ratio should be > 80% , else increase db_block_buffers in init.ora

sql>select sum(decode(name, 'consistent gets',value,0)) "consistent gets",

sum(decode(name,'db block gets',value,0)) "db block gets",

sum(decode(name,'physical reads',value,0)) " physical reads",

round((sum(decode(name,'consistent gets',value,0)) +

sum(decode(name,'db block gets',value,0)) - sum(decode(name,'physical reads',value,0))) /

(sum(decode(name,'consistent gets',value,0)) +

sum(decode(name,'db block gets',value,0))) * 100,2) "Hit Ratio" from v$sysstat;

Data Dict Hit Ratio :-

  • Gets - Total number of requests for information on the data object.
  • Cache Misses -- Number of data requests resulting in cache misses.
  • Hit ratio should be > 90%,else increse Shared_pool_size in init.ora

Sql> Select sum(gets),sum(getmisses), round((1-(sum(getmisses)/sum(gets))) * 100,2) from v$rowcache;

Library Cache Miss Ratio :-

  • Executions - The number of times a pin was requested for objects of this namespace.
  • Cache misses - any pin of an object that is not the first pin performed since the object handle was created and which requires loading the object from disk.
  • Hit ratio should be <>

Sql> Select sum(pins) executions,sum(reloads) cache_misses,sum(reloads) / sum(pins) miss_ratio from v$librarycache;





Undo_Retention

3:18 PM / Posted by Azar Mohamed Shaj / comments (0)


Rollback Segments are renamed Undo logs.Traditionally transaction undo information stroed in rollback segments until a commit or rollback statment was issued.


Automatic undo management allows the dba to how long undo information should retained after commit.preventing 'snapshot-too old' error on long running queries.


This is done by undo_retention parameter.the default is 900 seconds(5minutes).you can set this parameter to gurantte that oracle keeps undo logs for extended period of time.


rather then having to define rollback segments,you can simply define an undo tablespace and oracle let take the rest and automatic tuning. Undo_management=AUTO
Calculate Undo_Retention:-
Actual undo size :-
sql> Select sum(a.bytes) "Undo_Size" from v$datafile a, v$tablespace b,dba_tablespaces c where c.contents='UNDO' and c.status='ONLINE' and b.name=c.tablespace_name and a.ts#=b.ts#;
Undo block per second :-
sql>select max(undoblks/((end_time-begin_time)*3600*24)) " Undo_block_per_second" from v$undostat;
Db_block_size:-
sql>select to_number(value) from 'db_block_size' from v$parameter where name='db_block_size';

**** 04/04/2008 Oracle 10g OCA 1z0-042 question
Your database is configured for automatic undo management.Undo_retention is set to three hours.You want to fashback a table that was created last year.how far back can the flash back query go?
a.3 hours
b.6months
c.until last year
d.until last commit
e.until the point when the undo tablespace was refreshed.
f.until the database is shutdown and the memory erased.
Ans : A .3 Hours



Interview

3:12 PM / Posted by Azar Mohamed Shaj / comments (0)

How Do you move table from sys tablespace to user tablespace :-

sql>alter table tablename move tablespace tablespacename;

Finding out Table and Tablespace Location :-

sql>select owner,table_name,tablespace_name from dba_tables where table_name='tablename';


How many memory layers are in the shared pool?

Shared poll consists of two layers.

  • Library Cache ---- parsed sql staments and cursor information its a symmentric check.
  • Data Dictionary Cache --- user account,privilege,segments,datafile and extend information stored in the data dictionary cache.

User and Privilege and Roles

3:35 PM / Posted by Azar Mohamed Shaj / comments (0)

Users Privilege :-

sql>create user azar idenitified by azar;

or

sql>create user azar idenitified by azar default tablespace temporary tablespace quota unlimited on password expire;

sql>grant create session,create table to azar;

or

sql>Grant connect,resource to azar;

sql>show user;
azar

sql>alter user azar account lock;

sql>alter user azar account unlock;

Password Change

sql>alter user azar identified by ;


sql>drop user azar cascade;


System Privilege

sql>Grant create any table to azar;

Revoke Privilege

sql>revoke create any table from azar;

View :- dba_sys_privs

sql>select * from dba_sys_privs where grantee= 'username';


Object Privilege :

sql>Grant select,update,insert,delete on to azar;

sql>Revoke select,update,insert,delete on from azar;

View :- dba_tab_privs


sql>grant dba to azar;

sql>revoke dba from azar;

sql>select * from dba_role_privs where grantee ='dba';

sql>select role from session_roles;


Managing Tablespace

3:39 PM / Posted by Azar Mohamed Shaj / comments (0)

Tablespace :-

Logical

database ---- > tablespace --- > segment ---- > extent ---- > Oracle block

* An Oracle Database can be logically grouped into smaller logical areas of space Known as Tablespace

* Tablespace Consists of one or more datafiles.

* It consists of zero or more segments


Creating Tablespace

sql>create tablespace azar datafile '\oracle\oradata\azar01.dbf' size 20m;

Check your tablespace view dba_tablespaces

sql>select * from dba_tablespaces;

sql>alter tablespace azar read only;

Your tablespace in read only mode you can drop your tablespace contents.

sql>select tablespace_name,status from dba_tablespaces;

sql>alter tablespace azar read write;

sql>select tablespace_name,status from dba_tablespaces;

sql>alter tablespace azar offline;

sql>alter tablespace azar online;

Increase your size tablespace in three Ways :-

sql>alter tablespace azar datafile '\oracle\oradata\azar01.dbf' size 20m autoextend on;

sql>alter tablespace azar add datafile '\oracle\oradata\azar02.dbf' size 10m;

sql>alter database datafile '\oracle\oradata\azar01.dbf' resize 30m;

View:-

dba_data_files

dba_free_space

Moving tablespace from one location to another location

  • Offline your tablespace
  • Cut your datafile and paste datafile in target place
  • sql>alter tablespace azar rename datafile '\oracle\oradata\azar01.dbf' to 'any path' ;
  • Online your tablespace

Create temporary tablespace :-

Using for only sort operation

sql> Create temporary tablespace azardba tempfile '\oracle\oradata\temp02.dbf' size 2m;

If you want change your temporary tablespace to default tablespace

sql>alter database default temporay tablespace azardba;

View:-

dba_temp_files

v$tempfile

v$temp_space_header

Redo Log FIle

6:24 PM / Posted by Azar Mohamed Shaj / comments (0)


Redo log File :-

* Redo log files record all changes made to data and provide a recovery mechanism from a system or media failure.

* Redo log files are organized into groups

* An Oracle database requires at least two groups

* Each redo log within a group is called a member.
Online Redo log groups :-
* A set of identical copies of online redo log file is called an Online redo log group.
* Log writer writes same information to all online redolog files in a group.
* Oracle Server Needs minimum two online redo log group.
Online Redo log Member :-
* Each online redol og file in a group called Online redo log member.
* Each member in a group has a identical log sequence number and same size.
* The log sequence number is assigned each time the oracle server starts writing to a log group to identify each redo log file uniquely.
* The current log sequence number is stored in the control file and header of all data files.
Redo logs Work :-
* When you redo log file is full, Logwriter will move to the next Log group is called Log switch
* Checkpoint occurs
* Information written to Control files
Logwriter Writes Under the Condition
  • When a transaction commits
  • Redolog buffer becomes one-third full
  • More than a megabytes of changed record in the redo log buffer
  • Before database writer writer to the datafile.
Forcing Log switch and Checkpoints :-
* Log switches and checkpoints are automatically done at certain operation point of the database.
but a DBA force to log switch or checkpoint occur.
sql> alter system switch logfile;
sql> alter system checkpoint;
Archive mode
sql> archive log list;
database log mode noarchive
automatic archival disable
Change your database from noarchive mode to archive mode
Mount stage
sql> shutdown immediate
sql> startup mount
sql> archive log list;
sql> alter database archivelog;
database altered
sql> archive log list;
database log mode archive mode
automatice archival disabled
sql> archive log start;
If you want set instance level
sql> show parameter log_archive_start
value
false
sql> alter system set log_archive_start=true scope=spfile
system altered
sql> shutdown immediate
sql> startup
sql> archive log list;
Change your archive destination
sql> alter system set log_archive_dest = '\oracle\admin\{sid}' scope=spfile
shutdown and startup
sql> archive log list;
Adding Group and Member :-
sql>alter database add logfile group 3
'\oracle\oradata\{sid}\redo03a.log' size 5m;
sql> alter database drop logfile group 3;
adding member
sql>alter database add logfile member '\oracle\oradata\{sid}\redo03b.dbf to group 3;
sql>alter database drop logfile member '\oracle\oradata\{sid}\redo03b.log' ;
View :-
V$log
v$logfile
Group and member status :-
active - archived ,instance required
Inactive -- archived but instance not required
curretn -- currently log writer writes data in a the group
********* drop your group only inactive state,you cannot drop current state.
If you want to drop current state you sholud log switch logfile.
sql>select archiver from v$instance;
started