Академический Документы
Профессиональный Документы
Культура Документы
OracleDBAInterviewQuestion&Answers|Oracledbablog
ISSES_MODIFIABLE VARCHAR2(5) Indicates whether the parameter can be changed with ALTER
SESSION (TRUE) or not (FALSE)
ISSYS_MODIFIABLE VARCHAR2(9) Indicates whether the parameter can be changed with ALTER
SYSTEM and when the change takes effect:
1/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
2/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
gender column
function based index: sum(salary), upper(ename), lower(ename)
reverse index: used mostly to increase the speed of inserts (its like btree only but the key is reverse).
7) What is synonym ?
Synonym is used to hide the complexity of the original object.
for example user a has table t which user a wants to hide the name but user b has to access it.
In this case user a can create a synonym on table t and give a select priviledge to user b.
SQL> create synonym aishu on t;
SQL> grant select on aishu to b;
View: DBA_SYNONYMS
Query: Select synonym_name from dba_synonyms;
8) What is sequence?
Sequence is a oracle object which used to create the unique and sequential numbering for a column
example: employee num,account id
create table employee(id number ,name varchar2(10),salary number);
create sequence aishu_seq start with 1 increment by 1;
insert into employee values (aishu_seq.nextval,paddu,120000);
9) Define different types of tablespaces you know?
Permanent: system table space,sys aux,user
undo: to store undo segments
temp: to store the sort segments
10) What is the difference between Locally managed tablespace and dictionary managed tablespace?
LMT: Locally Managed Table space stores all the extent mapping or allocation details in the header of the
data file
DMT:Dictionary Managed Table space stores all the extent mapping or allocation details in the dictionary
table called UET$ and FET$
Since everytime an allocation of extents generate some recursive sql on UET$ and FET$ this is contention in
dictionary cache, hence this is not good for performance of database, but LMT can store this outside of
https://ishudbablog.wordpress.com/interviewquestions/462/
3/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
4/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
PROPERTY_NAME
PROPERTY_VALUE
DEFAULT_TEMP_TABLESPACE
TEMP2
17) How to see what is the default block size for a database ?
SQL> show parameter block_size;
NAME TYPE VALUE
db_block_size integer 8192
18) Is it possible to have multiple blocksizes in a database if so how? Explain
Yes it is possible but we have to create multiple DB buffer pools while setting the required block size
parameter.To do that it require database bounce.
For example if you want to have 2k size along with default 8k
SQL> show parameter db_2k_cache_size
SQL>alter system set db_2k_cache_size=100M scope=spfile;
SQL>shut immediate
Now we can create the table space using new 2k block size
example:SQL>
create tablespace test_2k datafile /u01/oradata/paddu/test2k.dbf size 100M block size 2k;
19) What is the oracle block, can you explain?
Oracle block is the lowest level of storage structure where it contains the data(business/oracle data)
The block has divided into many sections starting from block header,row header,row directory,ITL
list(Intrested Transaction List),free space.
20) Can you change the blocksize once the database is created?
Obsolutely no becoz once the datafiles is formatted into 8k we cannot change the database block sizes , if
https://ishudbablog.wordpress.com/interviewquestions/462/
5/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
you need, you have to create fresh database with new block size and restore from backup or import.
6/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
7/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
8/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
9/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
role_sys_privs can used to know what are all the system privileges assigned to that role.
role_tab_privs can be used to know what are all the object privileges assigned to that role
dba_role_privs can be used to know the grantees assigned to that role
For privileges:dba_tab_privs: can be used to know what all privileges assigned to a user
SQL> select grantee,owner,table_name,grantor,privilege from dba_tab_privs where grantee=AISHU';
dba_sys_privs: to know what all system privileges assigned to a user
SQL> select grantee,privilege from dba_sys_privs where grantee=AISHU';
32) What is the difference between with grant option and with admin option while assigning
privileges?
Grant option : We can grant that grant to other user
admin option : can be used for sysdba privileges to grant other
grant select on T to aishu with grant option;
Aishu can grant select on table T to any one;
grant dba to aishu with admin option;
aishu can grant or manage dba role and assign to anyone.
34) How to reovoke privilege or role?
revoke select on T from aishu;
revoke suresh from aishu;(suresh is a role here )
33) How to change the default tablespace for a user?
alter user aishu default tablespace t;
34) How to give a tablespace quota to a user?
alter user aishu grant unlimited quota on tablespace t;
https://ishudbablog.wordpress.com/interviewquestions/462/
10/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
36) What are constraints? Can you list them and when will you use them?
Constrains in oracle are use to protect the integrity of the data.
for example a not null constraint will not allow any null value in the column
a unique constraint will not allow any duplicate value in the column
a primary key constraint will not allow any duplicate value and null in the column.
a foreign key constraint will be from the one of the primary key of the table which means data must resides
in the primary key table(Master list table)
Master Table (a table that contains primary key)
SQL> create table pincode (area varchar2(30), pincodenum number primary key);
SQL> insert into pincode values (Miyapur,500049);
SQL> insert into pincode values(Ameerpet,500084);
Child Table ( aa table that is referred to primary key column)
SQL> Create table employee (empname varchar2(30),empid number unique,address1 varchar2(10)
check=Hyderabad, address2 varchar2(20),pincode number
constraint pin_fk foreign key(pincode) references pincode (pincodenum));
SQL> Insert into employee values(Aishu,1,Ameerpet,Line,500084);
37) What is Row chaining? When does it occur? where can you find it? What is the solution?
When the row is not adequate to fit in the block while inserting oracle will insert half row in one block and
half in another block leaving a pointer between these two blocks.
select table_name,chain_cnt from dba_tables where table_name=tablename';
Solutions:
create a table with bigger the block size
1) Create tablespace ts data file /u01/oradata/aishu/paddu.dbf size 100m blocksize 16k;
2) alter table employee move to ts;
Here TS is the tablespace name with bigger size, before creating tablespace it is assumed that you have
created a db buffer cache for it.
38) What is row migration? When does it occur? Where can you find this information?
Row migration happens when update occurs at one column and the row is not adequate to fit in the block
then the entire row will be moved to the new block.
https://ishudbablog.wordpress.com/interviewquestions/462/
11/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
12/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
13/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
I have 1gb
I want to 100MB,
But the data in that datafile is upto 500MB
can i resize to 100mb?
Yes we can unless the data is not above 100MB in the datafile.
48) How to add datafile to a tablepsace?
alter tablespace t add datafile /u01/oradata/paddu/tbs1 size 100M;
49) How to delete the datafile?
alter tablespace t drop datafile /u01/oradata/paddu/tbs1
Note:The drop datafile will only works if the datafile is empty
50) How to move datafiles from one location to another location? Can you provide the steps?
1.Connect as SYS DBA with CONNECT / AS SYSDBA command.
2.Make offline the affected tablespace with ALTER TABLESPACE <tablespace name> OFFLINE; command.
3.Copy the datafiles from old location to new location using OS cp
4.Modify the name or location of datafiles in Oracle data dictionary using following command syntax:
ALTER database RENAME DATAFILE
<old location>
TO
<new location>';
5.Bring the tablespace online again with ALTER TABLESPACE alter tablespace <tablespace name> ONLINE;
command
51) What is profile? what is the benefit of profile? Where do you see the information of profiles?
Provide an example of profile?
Profile is a set of properties assign to an user
For an example password complexity,password reuse,password expiry,idle time etc
SQL>desc dba_profiles;
SQL> select username,profile from dba_users;
52) How to change the profile of a user?
alter user username profile profile name
https://ishudbablog.wordpress.com/interviewquestions/462/
14/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
https://ishudbablog.wordpress.com/interviewquestions/462/
15/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
16/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
From 1-5 the locks are different types of levels which are some shared or table level locks
Row exclusive Any DML that happens on any row locks as exclusive so that no one can modify
Row shared Select statement ran, during that period the rows will be in shared mode so that no
modification to be done until that select retrieve all rows.
Table Lock When an update statement ran on column , no other can moidfy the structure of table, and
allow row exclusive
v$parameter Displays information about parametters in database
SQL>select name,value,ISSYS_MODIFIABLE from v$parameter where name=sga_target';
v$sgastat : Displays information about sga individual pool sizes and also displays free memory in the
sga
SQL> select * from v$sgastat;
v$sgainfo : Displays information about sga pool sizes
SQL> select * from v$sgainfo;
v$transaction: Displays information about the transactions that running in the database
SQL>select * from v$transaction;
v$pgaStat:displays about pga allocated in the database
SQL>select * from v$pgastat;
v$sga_resize_ops : Displays information about sga resize operation when sga target is set
SQL> select * from v$sga_resize_ops;
v$sysstat : Displays the systems statistics information
SQL> select * from v$sysstat;
v$sesstat : Displays the information about session statistics
SQL> select * from v$sesstat;
Display each statistics information from sysstat but for each session, so 604 statistics X each session
https://ishudbablog.wordpress.com/interviewquestions/462/
17/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
18/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
19/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
SQL> /
DBMS_METADATA.GET_DDL(TABLE,T,AISHU)
20/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
21/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
Until 10g,
As the database name is written in control file we have
to change the database name in control file and in init
file.
1. Alter Database backup control file to trace;
2. Above step will create a text control file in
user_dump_dest directory.
3. Change name of the Database in above file and in
init.ora file.
4. STARTUP NOMOUNT
5. Run the script that was modified in step 3
6. ALTER DATABASE OPEN RESETLOGS;
From 10g onwards
Using NID utility
If I am changing the database name , does mu backup
are valid?
Invalid, Your database name is changed so the old
backup backup in invalid as the name is old, rman
check with dbid and name.
https://ishudbablog.wordpress.com/interviewquestions/462/
22/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
23/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
80) Can you drop the normal tablespace, if so what happened to database?
Yes we can drop the normal table spaces but the associated objects will be dropped
but the table space should be empty if not we have to use
SQL>drop tablespace tablespace name including contents;
if you want to drop the associated datafiles also with table space we should use
SQL>drop tablespace tablespace name including contents and datafiles;
81) What is the difference between Oracle home and oracle base
ORACLE_BASE is the root directory for oracle. ORACLE_HOME located beneath ORACLE_BASE is where the
oracle products reside.
82) Where do you check the free space of objects?
SQL>dba_free_space;
select * from dba_free_space;
83) How to kill the blocking session, how to find the blocking session?
We have to find the blocking session information by using
SQL>select sid,username,serial#,status,event,blocing_session from v$session where username=SYS';
Now check the blocking_session column for the sid that is blocking and confirm with the application team to
kill
Now execute
SQL> alter system kill session sid,serial# immediate;
alternatively we can also find the lock informatin in v$lock
84) Can you kill the pmon or smon or ckpt ? what happens to database?
These are all the mandatory process to run the database.if we kill any of the process the DB will be crash.
85) Define the parameters for different pools of oracle instance?
shared pool:shared_pool_size;
DB buffer cache:db_cache_size;
java pool:java_pool_size;
largepool:large_pool_size;
stream pool:stream_pool_size;
Redolog buffer:log_buffer;
https://ishudbablog.wordpress.com/interviewquestions/462/
24/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
alternatively sga_max_size and sga_target should set to manage this pools automatically.
86) Consider the scenario below,
shared pool:shared_pool_size; 100m
DB buffer cache:db_cache_size; 100m
java pool:java_pool_size; 100m
largepool:large_pool_size; 100m
stream pool:stream_pool_size; 10m
Redolog buffer:log_buffer; 5m
Total SGA manually allocated in pools: 410M
I have also kept SGA_MAX_SIZE=400M in pfile and started the database which one the Oracle consider, 410M
or 400M
410M, if the sga_max_size is lesser than the all pools total if specified in pfile then sga_max_size parameter
is ignored.
86) List Process you follow to start looking into Performance issue at database level (If the application
is running very slow, at what points do you need to go about the database in order to improve the
performance?)
Answer ( Although i have never worked directly on performance issues, the below can be steps)
Run a TOP command in Unix to see CPU usage (identify CPU killer processes)
Run VMSTAT, SAR, and PRSTAT command to get more information on CPU and memory usage and possible
blocking
Run AWR report to identify:
1. TOP 5 WAIT EVENTS
2. RESOURCE intensive SQL statements
See if STATISTICS on affected tables needs to be re-generated
IF poorly written statements are culprit, run a EXPLAIN PLAN on these statements and see whether new
index or use of HINT brings the cost of SQL down.
https://ishudbablog.wordpress.com/interviewquestions/462/
25/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
26/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
https://ishudbablog.wordpress.com/interviewquestions/462/
27/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
Tablespace created.
SQL> show parameter undo_tablespace;
NAME TYPE VALUE
undo_tablespace string UNDOTBS3
SQL> alter system set undo_tablespace=UNDOTBS4 scope=spfile;
System altered.
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 263049216 bytes
Fixed Size 2212448 bytes
Variable Size 167775648 bytes
Database Buffers 88080384 bytes
Redo Buffers 4980736 bytes
Database mounted.
Database opened.
SQL> show parameter undo_tablespace;
NAME TYPE VALUE
undo_tablespace string UNDOTBS4
SQL>
100) Renaming schema
https://ishudbablog.wordpress.com/interviewquestions/462/
28/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
Fastest Way, since the original import will not happen only metadata creation will happen, as the
transportable import has been performed, In TTS the associated datafiles will be attached to new user
, hence the datafiles with existing object(tables/indexex etc) will be point to new user.
1. create user new_user
2. grant to new_user;
3. execute dbms_tts.transport_set_check();
4. alter tablespace read only;
5. exp transport_tablespace=y tablespaces=
6. drop tablespace including contents;
7. imp transport_tablespace=y tablespaces= datafiles= fromuser=old_user touser=newuser
8. create nondata objects in new_user schema
9. [drop user old_user cascade;]
10. alter tablespace read write;
Share this:
Like
Onebloggerlikesthis.
https://ishudbablog.wordpress.com/interviewquestions/462/
29/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
Mohammed
abuzar
Thanks
aishudba
BeingBiswar
anjan
pavan
30/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
Hi Pavan,
Happy to hear that the blog helping you out. Indeed to me as well to understand
more in oracle.
aishudba
-Thanks
Ishu
Can you please add even more of the sections covering different topics.
pavan
kumar
Thanks nd al da best .
Pavan
vishal raj
bangari
And waiting some more posts on advanced topics like DG,ASM etc .
vishal raj
https://ishudbablog.wordpress.com/interviewquestions/462/
31/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
bangari
This is an amazing blog. It has really helped and enlightened me. i like some of the
practicals and the explanations. thanks again. Nyamekeh
nyamekeh
Hi ishu,
it is good and simple much more helpful to all , why dont you start such more posts
updates every day your blog?
sadanand
udhayakum
ar
Shiva
https://ishudbablog.wordpress.com/interviewquestions/462/
32/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
good info
adithya
Nice Q/A for fresher Oracle DBA. There some tricky and real time scenario based
questions may be asked by interviewer to check your understanding critical
situations. I read some of those from Gitesh Trivedis book called Oracle DBA Interview
Questions And Answers 5th edition. It really helps to understand how interviewer can
confuse you during interview.
Mohsin
This is one of the finest and to-the-point bunch of questions I have ever come across
for DBAs. Icing on the cake are the answers provided right along with it. Cheers to the
author, youve sorted out a big deal for mass.
SS
DBA_SAM
manish
https://ishudbablog.wordpress.com/interviewquestions/462/
33/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
pendkiran
Thank you very much for doing great job sharing the knowledge..
SAHITHYA
nice article
Honda
Nice
annu
34/35
7/3/2015
OracleDBAInterviewQuestion&Answers|Oracledbablog
Thanks
aishudba
https://ishudbablog.wordpress.com/interviewquestions/462/
35/35