Вы находитесь на странице: 1из 16

DBA (Database Administrator) Interview

Questions
1. What are the differences between database designing and database modeling?
2. If the large table contains thousands of records and the application is accessing 35% of the
table, which method do you use: index searching or full table scan?
3. In which situation whether peak time or off peak time you will execute the ANALYZE
TABLE command. Why?
4. How to check to memory gap once the SGA is started in Restricted mode?
5. All the users are complaining that their application is hanging. How you will resolve this
situation in OLTP?
6. If the SQL * Plus hangs for a long time, what is the reason?
7. Shall we create procedures to fetch more than one record?
8. How do you increase the performance of %LIKE operator?
9. You are regularly changing the package body part. How will you create or what will you do
before creating that package?
10.
How can you see the source code of the package?
11.
Dual table explain. Is any data internally storing in dual table.
12.
Lot of users are accessing select sysdate from dual and they getting some millisecond
differences. If we execute SELECT SYSDATE FROM EMP; what error will we get. Why?
13.
In exception handling we have some NOT_FOUND and OTHERS. In inner layer we
have some NOT_FOUND and OTHERS. While executing which one whether outer layer or
inner layer will check first?
14.
What is mutated trigger, is it the problem of locks. In single user mode we got
mutated error, as a DBA how you will resolve it?
15.
Schema A has some objects and created one procedure and granted to Schema B.
Schema B has the same objects like schema A. Schema B executed the procedure like
inserting some records. In this case where the data will be stored whether in Schema A or
Schema B?
16.
What is bulk SQL?
17.
How to do the scheduled task/jobs in Unix platform?
18.
If the entire disk is corrupted how will you and what are the steps to recover the
database?
19.
How will you monitor rollback segment status?
20.
List the sequence of events when a large transaction that exceeds beyond its optimal
value when an entry wraps and causes the rollback segment to expand into another extend?
21.
What is redo log file mirroring?
22.
How can we plan storage for very large tables?
23.
When will be a segment released?
24.
What are disadvantages of having raw devices?
25.
List the factors that can affect the accuracy of the estimate?

26.
What is the difference between $$DATE$$ & $$DBDATE$$? - $$DBDATE$$
retrieves the current database date$$date$$ retrieves the current operating system.
27.
How to prevent unauthorized use of privileges granted to a Role?
28.
What is a deadlock and Explain?
29.
What are the basic element of base configuration of an Oracle database?
30.
What is an index and How it is implemented in Oracle database?
31.
What is the use of redo log information?
32.
What is a schema?
33.
What is Parallel Server?
34.
What is a database instance and Explain?
35.
What is a datafile?
36.
What is a temporary segment?
37.
What are the uses of rollback segment?

1) How to install patches? And what are pre-requsites?


2) How to upgrade 10.2.0.1 to 10.2.0.4 AND 11.2.0.1 to 11.2.0.3 and 10.2.0.4 to 11.2.0.1?
3) How to take the backup of oracle_home and oracle_inventory?
4) What is OCR & voting disk?
5) How to take backup of OCR and voting?
6) Which one take backup if OCR and voting disk?
7) Suppose lose OCR what happen...
1.1 Q- Which are the default passwords of SYSTEM/SYS?
A- MANAGER / CHANGE_ON_INSTALL
1.2 Q- How can you execute a script file in SQLPLUS?
A- To execute a script file in SQLPlus, type @ and then the file name.
1.3 Q- Where can you find official Oracle documentation?
A- tahiti.oracle.com
1.4 Q- What is the address of the Official Oracle Support?
A- metalink.oracle.com or support.oracle.com
1.5 Q- What file will you use to establish Oracle connections from a remote client?
A- tnsnames.ora
1.6 Q- How can you check if the database is accepting connections?
A- lsnrctl status or lsnrctl services
1.7 Q- Which log would you check if a database has a problem?
A- Alert log
1.8 Q- Name three clients to connect with Oracle, for example, SQL Developer:
A- SQL Developer, SQL-Plus, TOAD, dbvisualizer, PL/SQL Developer There are several, but an
experienced dba should know at least three clients.
1.9 Q- How can you check the structure of a table from sqlplus?
A- DESCRIBE or DESC
1.10 Q- What command will you start to run the installation of Oracle software on Linux?
A- runInstaller

2. Moderate (Standard knoledge for a daily-work of every DBA. He could fail one or two questions,
but not more)
2.1 Q- What should you do if you encounter an ORA-600?
A- Contact Oracle Support
2.2 Q- Explain the differences between PFILE and SPFILE
A- A PFILE is a Static, text file that initialices the database parameter in the moment that its
started. If you want to modify parameters in PFILE, you have to restart the database.
A SPFILE is a dynamic, binary file that allows you to overwrite parameters while the database is
already started (with some exceptions)
2.3 Q- In which Oracle version was Data Pump introduced?
A- Oracle 10g
2.4 Q- Say two examples of DML, two of DCL and two of DDL
A- DML: SELECT, INSERT, UPDATE, DELETE, MERGE, CALL, EXPLAIN PLAN, LOCK
TABLE
DDL: CREATE, ALTER, DROP, TRUNCATE, COMMENT, RENAME
DCL: GRANT, REVOKE
2.5 Q- You want to save the output of an Oracle script from sqlplus. How would you do it?
A- spool script_name.txt
select * from your_oracle_operations;
spool off;
2.6 Q- What is the most important requirement in order to use RMAN to make consistent hot
backups?
A- Your database has to be in ARCHIVELOG mode.
2.7 Q- Can you connect to a local database without a listener?
A- Yes, you can.
2.8 Q- In which view can you find information about every view and table of oracle dictionary?
A- DICT or DICTIONARY
2.9 Q- How can you view all the users account in the database?
A- SELECT USERNAME FROM DBA_USERS;
2.10 Q- In linux, how can we change which databases are started during a reboot?
A- Edit /etc/oratab
3. Advanced (A 3+ year experienced DBA should have enough knowledge to answer these
questions. However, depending on the work he has done, he could still fail up to 4 questions)
3.1 Q- When a user process fails, what Oracle background process will clean after it?
A- PMON
3.2 Q- How can you reduce the space of TEMP datafile?
A- Prior to Oracle 11g, you had to recreate the datafile. In Oracle 11g a new feature was introduced,
and you can shrink the TEMP tablespace.
3.3 Q- How can you view all the current users connected in your database in this moment?
A- SELECT COUNT(*),USERNAME FROM V$SESSION GROUP BY USERNAME;
3.4 Q- Explain the differences between SHUTDOWN, SHUTDOWN NORMAL, SHUTDOWN
IMMEDIATE AND SHUTDOWN ABORT
A- SHUTOWN NORMAL = SHUTDOWN : It waits for all sessions to end, without allowing new

connections.
SHUTDOWN IMMEDIATE : Rollback current transactions and terminates every session.
SHUTDOWN ABORT : Aborts all the sessions, leaving the database in an inconsistent state. Its the
fastest method, but can lead to database corruption.
3.5 Q- Is it possible to backup your database without the use of an RMAN database to store the
catalog?
A- Yes, but the catalog would be stored in the controlfile.
3.6 Q- Which are the main components of Oracle Grid Control?
A- OMR (Oracle Management Repository), OMS (Oracle Management Server) and OMA (Oracle
Management Agent).
3.7 Q- What command will you use to navigate through ASM files?
A- asmcmd
3.8 Q- What is the difference between a view and a materialized view?
A- A view is a select that is executed each time an user accesses to it. A materialized view stores the
result of this query in memory for faster access purposes.
3.9 Q- Which one is faster: DELETE or TRUNCATE?
A- TRUNCATE
3.10 Q- Are passwords in oracle case sensitive?
A- Only since Oracle 11g.
4. RAC (Only intended for RAC-specific DBAs, with varied difficultied questions)
4.1 Q- What is the recommended method to make backups of a RAC environment?
A- RMAN to make backups of the database, dd to backup your voting disk and hard copies of the
OCR file.
4.2 Q- What command would you use to check the availability of the RAC system?
A- crs_stat -t -v (-t -v are optional)
4.3 Q- What is the minimum number of instances you need to have in order to create a RAC?
A- 1. You can create a RAC with just one server.
4.4 Q- Name two specific RAC background processes
A- RAC processes are: LMON, LMDx, LMSn, LKCx and DIAG.
4.5 Q- Can you have many database versions in the same RAC?
A- Yes, but Clusterware version must be greater than the greater database version.
4.6 Q- What was RAC previous name before it was called RAC?
A- OPS: Oracle Parallel Server
4.7 Q- What RAC component is used for communication between instances?
A- Private Interconnect.
4.8 Q- What is the difference between normal views and RAC views?
A- RAC views has the prefix G. For example, GV$SESSION instead of V$SESSION
4.9 Q- Which command will we use to manage (stop, start) RAC services in command-line
mode?
A- srvctl
4.10 Q- How many alert logs exist in a RAC environment?
A- One for each instance.

5. Master (A 3+ year experienced DBA would probably fail these questions, they are very specifid
and specially difficult. Be glad if hes able to answer some of them)
5.1 Q- How can you difference a usual parameter and an undocumented parameter?
A- Undocumented parameters have the prefix _. For example, _allow_resetlogs_corruption
5.2 Q- What is BBED?
A- An undocumented Oracle tool used for foresnic purposes. Stans for Block Browser and EDitor.
5.3 Q- The result of the logical comparison (NULL = NULL) will be And in the case of (NULL !
= NULL)
A- False in both cases.
5.4 Q- Explain Oracle memory structure
The Oracle RDBMS creates and uses storage on the computer hard disk and in random access
memory (RAM). The portion in the computer s RAM is called memory structure. Oracle has two
memory structures in the computer s RAM. The two structures are the Program Global Area (PGA)
and the System Global Area (SGA).
The PGA contains data and control information for a single user process. The SGA is the memory
segment that stores data that the user has retrieved from the database or data that the user wants to
place into the database.
5.5 Q- Will RMAN take backups of read-only tablespaces?
A- No
5.6 Q- Will a user be able to modify a table with SELECT only privilege?
A- He wont be able to UPDATE/INSERT into that table, but for some reason, he will still be able
to lock a certain table.
5.7 Q- What Oracle tool will you use to transform datafiles into text files?
A- Trick question: you cant do that, at least with any Oracle tool. A very experienced DBA should
perfectly know this.
5.8 Q- SQL> SELECT * FROM MY_SCHEMA.MY_TABLE;
SP2-0678: Column or attribute type can not be displayed by SQL*Plus
Why Im getting this error?
A- The table has a BLOB column.
5.9 Q- What parameter will you use to force the starting of your database with a corrupted resetlog?
A- _ALLOW_RESETLOGS_CORRUPTION
5.10 Q- Name the seven types of Oracle tables
A- Heap Organized Tables, Index Organized Tables, Index Clustered Tables, Hash Clustered Tables,
Nested Tables, Global Temporary Tables, Object Tables.

Collection of Most Common DBA Interview Questions


Hello Friends,
I know how tough it is to face the interviews inspite of being prepared well. Trust me even
after facing so many interviews the day the interview is scheduled I go totally numb and
cold feet. I really don't know what to revise and what to look into. I am sure you might be
facing the same things.

Well the other night I had an interview call from one of the most renowned company in the
market but due to hectic and busy schedule I was not able to revise the topics that needs
to be done before an interview. After the interview I thought of maintaining the most basic
questions asked during a DBA interview ready for the next time so that even if I dont get
enough time a glance at the questions from my DATABANK would give me enough
confidence to face the interview. I am sure you too would be feeling the same. So here
goes most common DBA interview questions and there probable answers. Any
suggestions and corrections are most welcomed.
Here is the Collection and Answer to some Interesting ORACLE DBA Interview Questions
1. How many memory layers are in the shared pool?
Ans: The shared pool portion of the SGA contains three major areas: library
cache(contains
parsed
sql
statements,cursor
information,execution
plans),
dictionary cache
(contains
cache
-user
account
information,priveleges
information,datafile,segment and extent information), buffers for parallel execution
messages, and control structure.
2. How do you find out from the RMAN catalog if a particular archive log has been backedup?
Ans: list archivelog all;
3. How can you tell how much space is left on a given file system and how much space
each of the file systems subdirectories take-up?
Ans: df -kh and du-sh
4.
Define
the
SGA
and:
i) How you would configure SGA for a mid-sized OLTP environment?
ii) What is involved in tuning the SGA?
Ans: SGA: The System Global Area (SGA) is a group of shared memory areas that are
dedicated to an Oracle instance (an instance is your database programs and RAM). All
Oracle processes use the SGA to hold information. The SGA is used to store incoming
data (the data buffers as defined by the db_cache_size parameter), and internal control
information that is needed by the database. You control the amount of memory to be
allocated to the SGA by setting some of the Oracle initialization parameters. These
might include db_cache_size, shared_pool_size and log_buffer.
i) 40% of RAM can be used for sizing SGA rest is reserved for OS and others in 64 bit
machine and in 32 bit machine max SGA configured can be 1.5GB only.
ii) Check the statspack report. Check hit ratio of Data buffer. If it is less than 90%, then we
need to increase the Data buffer. Check hit ratio of Shared pool. If it is less than 95%, then
we need to increase the Shared pool. Check log buffer. If redo buffer allocation retries/redo
entries is greater than 1%, then we need to increase log_buffer.

5. What is the cache hit ratio, what impact does it have on performance of an Oracle
database and what is involved in tuning it?
Ans:
Buffer cache hit ratio: It calculates how often a requested block has been found in the
buffer cache without requiring disk access. This ratio is computed using data selected from
the dynamic performance view V$SYSSTAT. The buffer cache hit ratio can be used to
verify the physical I/O as predicted by V$DB_CACHE_ADVICE.

sql> select name, value From v$sysstat Where name in (db block gets, consistent gets,
physical reads);
The cache-hit ratio can be calculated as follows: Hit ratio = 1 (physical reads / (db block
gets + consistent gets)) If the cache-hit ratio goes below 90% then: increase the
initialisation parameter DB_CACHE_SIZE.
Library cache hit ratio: It calculates how often the parsed representation of the statement
can be reused. It also known as soft parse.
sql> select namespace, pins, pinhits, reloads, invalidations from v$librarycache order by
namespace;

Library Cache Hit Ratio = sum(pinhits) / sum(pins)


Dictionary cache hit ratio:It is a measure of the proportion of requests for information
from the data dictionary, the collection of database tables and views containing reference
information about the database, its structures, and its users. On instance startup, the data
dictionary cache contains no data, so any SQL statement issued is likely to result in cache
misses. As more data is read into the cache, the likelihood of cache misses should
decrease. Eventually the database should reach a "steady state" in which the most
frequently used dictionary data is in the cache.
6. Other than making use of the statspack utility, what would you check when you are
monitoring or running a health check on an Oracle 8i or 9i database?
Ans: Daily Monitoring activities and check different logs for any sort of errors.
7. How do you tell what your machine name is and what is its IP address?
Ans: hostname, uname -n and ifconfig
8. How would you go about verifying the network name that the local_listener is currently
using?
Ans: lsnrctl stat or ps-eaf|grep tns

9. You have 4 instances running on the same UNIX box. How can you determine which
shared memory and semaphores are associated with which instance?
Ans:
SQL>
oradebug
setmypid
SQL>
oradebug
ipc
SQL>oradebug tracfile_name
Also you can check the spfile. The parameters will start with instance_name.
parameter_name naming.
10. What view(s) do you use to associate a users SQLPLUS session with his o/s
process?
Ans:
v$process
and
v$session
sql> select a.spid from v$process a, v$session b where a.addr = b.addr and
b.audsid=userenv(sessionid);
11. What is the recommended interval at which to run statspack snapshots, and why?
Ans: Should be in minutes (15-20 mins approx) because where the time between the two
snapshots is measured in hours, the events that caused serious performance issues for 20
minutes during peak processing dont look so bad when theyre spread out over an 8-hour
window. Its also true with STATSPACK that measuring things over too long of a period
tends to level them off over time. Nothing will stand out and strike you as being wrong.
12. What spfile/init.ora file parameter exists to force the CBO to make the execution path
of a given statement use an index, even if the index scan may appear to be calculated as
more costly?
Ans: OPTIMIZER_INDEX_COST_ADJ= FORCE
13. Assuming today is Monday, how would you use the DBMS_JOB package to schedule
the execution of a given procedure owned by SCOTT to start Wednesday at 9AM and to
run subsequently every other day at 2AM.
Ans:
dbms_job.submit(:jobno,'statspack.snap;',trunc(sysdate)
+9/24,'trunc(SYSDATE+1/24,''HH'')', TRUE, :instno);
14. How would you edit your CRONTAB to schedule the running of /test/test.sh to run
every other day at 2PM?
Ans: 00 02 * * * /test/test.sh
15. In which dictionary table or view would you look to determine at which time a snapshot
or MVIEW last successfully refreshed?
Ans: SQL> SELECT MVIEW_NAME,LAST_REFRESH_DATE from USER_MVIEWS;
16. How would you best determine why your MVIEW couldnt FAST REFRESH?
Ans: Possibly by checking the MVIEW LOG for errors.

20. How would you begin to troubleshoot an ORA-3113 error?


Ans: End of File Communication Error. Check Alert Logfile. CheckNetwrok Latency. Check
sqlnet.ora file has expire_time = 0, delete unwanted files and check the swap and temp
spaces.
21. Which dictionary tables and/or views would you look at to diagnose a locking issue?
Ans: v$lock, v$session, v$process
22. An automatic job running via DBMS_JOB has failed. Knowing only that its failed, how
do you approach troubleshooting this issue?
Ans:Check the log and possible reason for the JOB failed.
23. How would you extract DDL of a table without using a GUI tool?
Ans: select dbms_metadata.get_ddl('OBJECT','OBJECT_NAME') from dual;
24. Youre getting high busy buffer waits - how can you find whats causing it?
Ans: Buffer busy wait means that the queries are waiting for the blocks to be read into the
db cache.There could be the reason when the block may be busy in the cache and
session is waiting for it. It could be undo, data block or segment header wait.

Run the following query to find out the p1,p2 and p3 of a session causing buffer busy wait

sql> select p1 "File #",p2 "Block #",p3 "Reason Code" from v$session_wait where event =
'buffer
busy
waits';

After that running the following query to find the segment causing buffer busy wait:-

sql> select owner,segment_name,segment_type from dba_extents where file_id = &P1


and &P2 between block_id and block_id + blocks -1;
25. What query tells you how much space a tablespace named test is taking up, and how
much space is remaining?
Ans:
SET
SERVEROUTPUT
ON
SET
LINESIZE
1000
SET
FEEDBACK
OFF
rem column dummy noprintcolumn pct_used format 999.9
heading "%|Used"
column
name
format
a25
heading
"Tablespace
Name"

column
Kbytes
format
999,999,999
heading
"MBytes"
column
used
format
999,999,999
heading
"Used(MB)"
column
free
format
999,999,999
heading
"Free(MB)"
column
largest
format
999,999,999
heading
"Largest"
break
on
report
compute
sum
of
kbytes
on
report
compute
sum
of
free
on
report
compute
sum
of
used
on
report
set
pagesize
100
select
nvl(b.tablespace_name,
nvl(a.tablespace_name,'UNKOWN'))
name,(kbytes_alloc/1024)
kbytes,
((kbytes_alloc-nvl(kbytes_free,0))/1024)
used,(nvl(kbytes_free,0)/1024)
free,
((kbytes_alloc-nvl(kbytes_free,0))/kbytes_alloc)*100
"%used",
nvl(largest,0)/1024
largest
from
(
select
sum(bytes)/1024
Kbytes_free,
max(bytes)/1024
largest,
tablespace_name
from
sys.dba_free_space
group
by
tablespace_name
)
a,
(
select
sum(bytes)/1024
Kbytes_alloc,
tablespace_name
from
sys.dba_data_files
group
by
tablespace_name
)b
where
a.tablespace_name
(+)
=
b.tablespace_name
order
by
1
/
26. Database is hung. Old and new user connections alike hang on impact. What do you
do? Your SYS SQLPLUS session is able to connect.
Ans: Log into the system and find whether there are any deadlocks in the system using
the following query.
select 'SID ' || l1.sid ||' is blocking ' || l2.sid blocking
from v$lock l1, v$lock l2
where l1.block =1 and l2.request > 0
and l1.id1=l2.id1
and l1.id2=l2.id2
/
If so kill the processes caught in deadlock
alter system kill session 'SID,SERIAL#' immediate;
Also find out which wait events exist in the system using following commands and go in
detail as to what events are causing these waits and take appropriate actions.
select event,count(*) from v$session group by event
/

select u.sid,u.serial#, u.username,p.spid,to_char(u.logon_time,'DD-MONYYYY:HH24:MI:SS') from v$session u, v$session w,v$process p where u.sid = w.sid and
w.event like '%&a%' and u.paddr = p.addr
/

27. Database crashes. Corruption is found scattered among the file system neither of your
doing nor of Oracles. What database recovery options are available? Database is in
archive
log
mode.
Ans: First of all secure all the archives and all the backups you have on the tape or other
system. Then run fschk to check the filesystem. If the corruption is detected at the
filesystem level and is not recoverable by fschk format the file system and restore the
database
through
RMAN.

28. Illustrate how to determine the amount of physical CPUs a Unix Box possesses
(LINUX
and/or
Solaris).
Ans:

29. How do you increase the OS limitation for open files (LINUX and/or Solaris)?
Ans: Set the file-max parameter is /etc/sysctl.conf to the number you want.Save the file
and
execute
it
by
using
command
/etc/sysctl.conf-p

30. Provide an example of a shell script which logs into SQLPLUS as SYS, determines the
current date, changes the date format to include minutes & seconds, issues a drop table
command, displays the date again, and finally exits.
Ans:
export ORACLE_BASE=/oracle
export ORACLE_HOME=/oracle/ora10g
export ORACLE_SID=ora10g
export path=$ORACLE_HOME/lib
sqlplus sys as sysdba << EOF
@/oracle/date.sql
exit;
Now the contents of /oracle/date.sql
select SYSDATE from dual;

select
to_char(SYSDATE,'dd-mon-yyyy
hh24:mi:ss')
drop
table
tablename
cascade
select to_char(SYSDATE,'dd-mon-yyyy hh24:mi:ss') from dual;
/

from

dual;
constraints;

31. Explain how you would restore a database using RMAN to Point in Time?
Ans:
restore database
until time "to_date('Aug 27 2001 02:00:00','Mon DD YYYY HH24:MI:SS')";
recover database

32. How does Oracle guarantee data integrity of data changes?


Ans: Oracle enables you to define and enforce data integrity constraints like PRIMARY
KEY CONSTRAINTS, FOREIGN KEY CONSTRAINTS and UNIQUE CONSTRAINTS.
33. Which environment variables are absolutely critical in order to run the OUI?
Ans: ORACLE_BASE, ORACLE_HOME, ORACLE_SID,path and library path
34. What SQL query from v$session can you run to show how many sessions are logged
in
as
a
particular
user
account?
Ans: select count(1) from v$session where USERNAME='username';
35. Why does Oracle not permit the use of PCTUSED with indexes?
Ans: Imagineyou'vegotanindexonpeople'snames.And,justforthesakeofargument,only4
entries

can

fit

in

block.
So

you

have

Adam
Bob
Charles
David
and
Edward
Frank
Graham
Howard
You want to insert a new entry in the table (and hence into the index on that table) of
Zebedee.

As things stand, both blocks of the index are full, so Zebedee has to go into a third block
all
on
his
own.
Now

say

you

delete

some

existing

rows:

delete from employees where name in ('Bob', 'Charles', 'David'). You're left in this state:
Block

1:

Adam
Block

2:

Edward
Frank
Graham
Howard
That means block 1 has 3 empty slots for new entries. So you still want to insert a record
for someone called Zebedee: can it go into the first block, with all that empty space? No.
Because
if
it
did,
you'd
end
up
with
an
index
that
ran:
Adam
Zebedee
Edward
Frank
Graham
Howard
...and you might notice that the alphabetical order has been screwed to buggery at this
point. So no, although the first block contains lots of empty space, it's still defined as an
"A-ish" sort of block. It actually has to have entries between Adam and Edward, and it can't
suddenly
decide
to
accept
entries
from
Wilma,
Susan
or
Mary.
So when can block 1 be used to house those sorts of entries? When Adam gets deleted.
Because
when
that
row
goes,
you're
in
this
position:
Block
Block

1:
2:

values

completely
from
E

to

empty
G

Being completely empty, there's no "A or B'ness' about block 1 any more. So suddenly, it
can accept any entry at all. Now, physically, block 1 might come "before" block 2... but we
jig things around in the root and branch blocks so that doesn't matter. Therefore, you can
now insert all those other records you wanted and get this situation:

Block
Mary
Susan
Wilma
Zebedee

1:

Block
Edward
Frank
Graham
Howard

2:

And we have a branch block (actually, in this case, the root node) which says:
A
M

->
->

L:
Z:

goto
goto

block
block

2
1

So, once we deleetd Adam, we were allowed to insert new items into all that empty space.
But of course, once we deleted Adam, the first block was completely and utterly empty.
And what does a completely empty block equate to in PCTUSED terms? Er, 0%.
It has to be 0% PCTUSED, in other words, because entries in an index have to be
organised according to some order. Allowing you to reuse space 'out of order' would
destroy the point of an index. And you can only say, "Order is irrelevant at this point" when
no
entries
exist
at
all...
which
equates
to
PCTUSED
of
0.
PCTFREE is fine to set, because that simply says when to stop filling one block and start
filling another. In indexes, it reserves space that might come in handy for preventing block
splits. So there's a use for PCTFREE, definitely. Imagine we'd set PCTFREE of 25%. Then
the
earlier
index
would
be:
Block

1:

Adam
Bob
Charles
Block
David
Edward
Frank

2:

Block

3:

Graham
Howard
With a PCTFREE of 25% and only 4 entries allowed per block, we end up only storing 3
entries per block: the missing entry being reserved as 'free space'. Now insert a guy called
'Brian': is there room to fit him between Bob and Charles? In this new index, yes: block 1 is
allowed to grow to holding 4 records, and there's only currently 3, so yup: there's room to
accomodate
the
new
guy.
But in the earlier example? No, the block was allowed to hold four records. It's holding four
records. You want to insert a new one that HAS to go between two existing records... we
have to perform a block split and reorganisation to allow that to happen. Block splits are
costly affairs. PCTFREE would have saved us from having to do one.
So yes, PCTFREE in an index is useful. PCTUSED is meaningless. Once you impose an
order on rows, they cannot just go anywhere. Space reserved for future inserts is fine. But
a flag to say 'insert away!' when inserting would disrupt a carefully-achieved ordering is a
complete no-no.

Вам также может понравиться