You are on page 1of 85

Faqs from1 – 21 pages

HP Bangalore / Chennai 1 march 2010

1. How many databases you support. What is the platform? Are you familiar
with windows environment?

Two databases I support and size is 400 GB, Linux / oracle 9i. Yes, I am
familiar with windows environment.

2. Are you comfortable working with data guard?

Yes, I am comfortable working with data guard.

3. You are working on two databases; it has two nodes, if you


want that some users get connected to Node A and some users get
connected to Node B. Both Nodes are on same servers.

I will give the path (URL), so that some users are connected to Node A and
similarly some users are connected to Node B.

4. Tell me any wait events that you have worked with?

V$event_name (i) Buffer busy wait event


(ii) Log file switch event
V$session_event
V$session_wait

5. I have a redo log that is corrupted and how will I get repair / rectify the redo
log?

I will rollback to a previous transaction. I will create a redo log of bigger size
and I will do log switch and when the present redo becomes deactive and the
new redo log becomes active then I will delete the old redo log.
If the redo log is corrupted then I will not be able to do a log switch. In such
scenario, I have to rollback the old redo log to a previous transaction.

6. There are certain blocks that are corrupted? How will I rectify the corrupted
blocks?

I will use this view V$block_corruption and then I will come to know which
blocks are corrupted and then I will rectify the corrupted blocks.
This is the rman setup that you talking about, if rman setup is not there, how
you will rectify the corrupted blocks.

7. Are you familiar with ITIL certification? Are you aware with the concepts?

1
8. One client has got the problem the computer is working slowly? How will you
rectify the problem?

I will login through remotely through remote desktop connection- I will delete
cookies, fragmentation wizard – data is consolidated at one location.

1. Tell me any wait event that you have worked.

Wait event queue – It means that certain processes that are running are time
consuming. Processes are waiting for certain resources to get free.

2. What you infer by Oracle Inventory and where it is located.

3. The result of v$ views that you get where it is stored and from where it is
fetched from?

The result of V$ views is stored and retrieved from Data Dictionary views.

You need to support the client on 24x7 basis. Databases you have to support
will be in 9i/10g /Linux/windows environment. The client gets registered and locks
a compliant and will be issued a ticket no. The client’s problem you have to
rectify on ticket basis.

HCL Interview questions 12 may 2010

• Tell about your qualification and current project that you are working.

as National Consultant (MIS and Oracle DBA) with World Health


Organization (WHO), New Delhi – Presently I am working on
implementation of Global System Management ERP, an Oracle based
application in WHO SEARO Region. It involves training of personnel’s,
monitoring, resolving user’s queries and maintaining Oracle database.
Other assignments handled, developing & implementation of MIS for
Vaccine Management & Cold Chain; Data Analysis and Management of
Integrated Disease Surveillance Project (IDSP).

WHO ERP is being rolled out and implemented in WHO SEARO region.
The platform is in oracle and ERP is being developed by satyam
computers. My present profile involves training of personnel’s, monitoring
of oracle database 24x7 support , resolving user’s queries and maintaining
Oracle database. Development of MIS. (In-house development of
application)

2
• Are you working on production environment / application support?

Yes I am working on production environment.

• What is the difference between PCTfree and PCTused? Are the


PCTfree and PCTused parameters only related to datafile or to any
other logical unit?

PCTfree is the no of blocks that are free in the data file and pctused is the
no of blocks that are being used in the datafile. Suppose I have a upper
limit that when the PCTused become 80% then I have to increase the size
of datafile or add another datafile. Datafile is the physical structure and
tablespace, segment, extent, oracle blocks; OS blocks are logical unit of
database.

• What is the difference between SGA and PGA?

System global area / Shared global area

Program global area

• What the daily functions that you perform as a DBA?

• How you will calculate the database size? What command I will run
to find it?

There is two query in oracle. V$dba_data_files and dba_free_space. You


can join both views to retrieve information of database.

select ROUND(ddf.BYTES,2) "DB Size (GB)" , ROUND(ddf.bytes-


dfs.BYTES,2) "Used Space (GB)" , ROUND(dfs.BYTES,2) "Free Space
(GB)",to_char(sysdate,'dd-Mon-yyyy hh24:mi:ss') "Timestamp" from
(select SUM(BYTES)/(1024*1024*1024) bytes from dba_data_files) ddf,
(select SUM(BYTES)/(1024*1024*1024) bytes from dba_free_space) dfs;

• The CPU is being utilized 90% or above 90%? What measures I will
take to improve the performance of database?

You can use top -h or top or glance command


Through this command you have check which session or process is using
more CPU or if that session is not important then you can kill that session
or ask to admin to kill same session.

3
• How you will check the connectivity status?

there is a command to check databases availability in UNIX server.


then you have to write to check database status::--->
ps -ef|grep smon

• If I change the block size then how it will affect the performance of
database?

If I change the default block size then it will badly affect the performance
of database badly.
8 OS blocks = 1 Oracle block
8 Oracle Block = 1 extent
8 extent = 1 segment
8 segment = 1 tablespace
1 tablespace is a logical unit, 1 data file is physical unit
In a database there can be maximum 1024 tablespace and 1024 data file

• What is init.ora and spfile? How will I implement changes in spfile


through init.ora and is it possible to do that?

Init.ora is the file where initial parameters are defined. Spfile is the
dynamic parameter file and pfile is the static parameter file. I can make
changes to the pfile and then apply the alter command and make the
changes implemented to the database dynamically through spfile.

• Who has written the rman script?

The rman script is being written by previous DBA’s and it is an automatic


script.

• How you can check the performance of database?

V$instance, V$database, V$datafile

IBM India Pvt. Ltd. 13 feb 2010

1. Tell me about yourself, qualification and exp

2. In WHO, what daily activities you perform

GSM is Oracle based ERP solution which is implemented in SEARO region. I


provide training to personnel, solve user queries, monitor database and act as
Oracle DBA.

4
3. How you will resolve user queries?

I resolve user queries telephonically.

4. Have you worked on any ticketing system?

5. What tools you have used?

sql*plus, OEM, telnet,

6. If you have to upgrade the client database how you will do it.

I will send the link to the client by email. The client will click on the link; the
database upgrade will start automatically.

7. In past six months, you have encountered any problem and how you
resolve it.

List out differences between Oracle Server 9i and Oracle Server 10g.
10 G supports grid computing ASM (Automatic storage management) and
Memory management.

Oracle 10g is higher version of 9i Oracle 10g has added a following features

Transparent Data Encryption


Async commits
CONNECT ROLE can not only connect
Passwords for DB Links are encrypted
New asmcmd utility for managing ASM storage
Grid computing - an extension of the clustering feature (Real Application
Clusters)
Manageability improvements (self-tuning features)
Performance and scalability improvements
Automated Storage Management (ASM)
Automatic Workload Repository (AWR)
Automatic Database Diagnostic Monitor (ADDM)
Flashback operations available on row transaction table or database level
Ability to UNDROP a table from a recycle bin
Ability to rename tablespaces
Ability to transport tablespaces across machine types (E.g. Windows to Unix)
New 'drop database' statement
New database scheduler - DBMS_SCHEDULER
DBMS_FILE_TRANSFER Package

5
Support for bigfile tablespaces that is up to 8 Exabytes in size
Data Pump - faster data movement with expdp and impdp.

In Oracle 9i after drop we can't rollback but we can do it in 10g.


Moreover 10g has additional 149 features than 9i.

10g uses CBO whereas 9i uses RBO

List out differences between Oracle Server 9i and Oracle Server 10g.
Network Management
• Back Up Directory Naming Entries to Local Naming File.
• Dynamic Connection Manager Configuration.
• Easy Connect Naming Method.
• Improved Network Outage Detection.
• Automatic LDAP Discovery for Clients.
• Improved Connection Manager Access Rules.
• Automatic Shared Server Configuration.
• Simplified Shared Server Configuration Parameters.

Manageability Infrastructure
• Database Features Usage Tracking.
• Enhanced Database Time Model.
• End-to-End Application Tracing.
• JDBC: End-to-End Tracing.
• SYSAUX Tablespace.
• Automatic Routine Administration Tasks.
• Server-Generated Alerts.
• Automatic Workload Repository.
• Enhanced Wait Model.
• Threshold-Based Alerts.

Storage Management
• Multiple Default Temporary Tablespace Support for SQL Operations.
• Automatic Storage Management.
• Rename Tablespace.

Backup and Recovery Manageability


• Enhanced RMAN Reporting.
• Backup Compression.
• Bounded Backup Window.
• RMAN Scripts Manageability.
• Recovery Area Full Alert.

Performance and Scalability


• Index-Organized Table (IOT) Partitioning Enhancements.

6
• Eliminate Duplicated Columns in Index on an Index-Organized Table.
• Configurable TCP/IP Send and Receive Buffer Size.
• Single-Set Aggregates in DML Returning Clause.
• High-Speed Infiniband Network Support.
• Sorted Hash Clusters.
• Windows Fiber Support.
• Optimized 64-bit Database.
• SQL Tuning Advisor.
• SQL Access Advisor.
• Materialized View Tuning API.
• Automatic Optimizer Statistics Collection.

Backup and Recovery


• Flash Backup and Recovery.
• Drop Database.
• RMAN Database Deregistration.
• Backup and Restore of Standby Control File.
• Automatic TSPITR.
• Simplified Recovery Manager Cataloging of Backup Files.
• Automatic Channel Failover for Backup and Restore.
• Automatic File Creation During Recovery.
• Simplified Backups to Disk.
• Proxy Copy Backup of Archivelogs.
• Incrementally Updated Backups.
• Simplified Recovery Through Resetlogs.
• Restore Tolerates Corrupt or Missing Backups.
• Full Database Begin Backup Command.
• Change-Aware Incremental Backups.

Improved Administration
• DML Support in FGA.
• Communication over SASL.
• Unified User Model.
• Easy Database Registration.
• Extended and Uniform Audit Trail.
• Oracle Label Security Directory Integration.

Data Mining Support for Analytic Applications


• Frequent Itemsets.
• DBMS_DATA_MINING PL/SQL Interface for Oracle Data Mining.
• Features Extraction using Non-Negative Matrix Factorization Algorithm.
• Enhanced Data Preprocessing.
• Enhanced Adaptive Bayes Network.
• Multi-User Access Control.
• Oracle Data Mining Client (DM4J).

7
• Support Vector Machines (SVM).

Oracle DBA questions*

My database is running in Linux 4.0 /oracle 9i /10 g /400 gb / cluster RAC 2


nodes.

DB1 DBII
Node 1 Node II

DBA task that I perform in a day

1. I check the health of the database


• Whether database is running properly
• All connectivity status is ok or not.

Oracle tools is SSH / Telnet / SQL* net / OEM /


SSH – Secured Socket Host Name

$ ps –ef | grep ora


This command tells the oracle connectivity status
PS – processes
Ef-
Grep- combined

$ top (top command will tell each user particular process, how much time is used
by a particular process). I delete / kill the process that is consuming 60% of
memory.

$ Lsnrctl –listener (connectivity & status information)


Error 1503 alert log

II DBA daily responsibility

• Health check of the database – all database connectivity, spacing is


adequate is not. (File space, disk space is available or not, how much
space is available in the disk.)

$ df –h
Df – disk file
The command shows / tells the DBA how much space is available in the data file
or not.

8
III Command to kill a particular process

$ kill -9 process no

IV Database Export and Import

Oracle:\> exp / imp filename= testfile log = testlog direct =y statistics =


none

Export / Import are a logical backup.

V) 2 databases rman backup I use to take daily.

Important: Incremental backup I use to take through rman and logical


backup I use to take through export / Import.

VI I use to clear the archive log through OEM. 1 week archive log I use to
maintain – username/password
OEM login – username/password
Server name files gets listed.

Archive log 10 (old archive log I use to delete)

Q In alert log, what problem you face & how you resolve it.

I encounter spacing problem. It actually depends on the condition.


For example – sql query long / lengthy / short tune sql query / else I write a
different shorter query.

VII Database is running on RAC

Q. How you check the status of clusters

Sql:\> CRS –Stat -t


CRS – cluster ready services
Stat- statistics
T- Terminal
This command is used to check whether the cluster is running properly or not.
Node Information, Connectivity status is mentioned.

Information
Oracle application-SRM, SUN, ERP
ITIL –email task & data center (how to manage)

9
Q. Information Technology Infrastructure library (ITIL)

 ITIL is a set of concepts and practices


 Managing IT Services (ITSM)
 IT Development
 IT Operations
It gives detailed descriptions of a no of important IT practices and
provides comprehensive checklists, tasks and procedures that any IT
organization can tailor to its needs.

Q. Content Management System

A CMS is a collection of procedures used to manage workflow in a


collaborative environment. These can be manual / computer based. The
procedures are designed to:

1. Allow large no of people to contribute to & share stored data


2. Control access to data based on user roles.
3. Aid in easy storage & retrieval of data.
4. Reduce repetitive duplicate input.
5. Improve the ease of report writing.
6. Improve communication between users.

Q. Web Content Management Systems

A web content management system is a CMS designed to simplify the


publication of web content to websites & mobile devices, allowing content
creators to submit content without requiring technical knowledge of HTML
or the uploading of Files.

Q. How many transactions take place in your database?

Q. How you will decide the spacing requirement of your database if your
database size is 400GB and it is growing at the rate of 10 gb per month.
How you will decide the future spacing requirement.

Nucleus Oracle DBA 21 Jan 2008

1. work Exp and qualification.


2. 1 yr exp in Oracle DBA and Linux/ Windows Platform
3. Tell command to add space in datafile

10
Alter Database
Datafile ‘/u01/oradata/userdata02.dbf.dbf’ resize 5M;135

4. Create tablespace Command

Create Tablespace userdata


Datafile ‘/U01/oradata/userdata01.dbf’ size 5M;

5. Alter tablespace add more memory to tablespace

Alter tablespace userdata02


Add datafile ‘/U01/oradata/userdata03.dbf’ size 5M;

6. What is PGA_Aggregate_Target

PGA_Aggregate_Target parameter is set to specify the target aggregate


amt of PGA memory available to the instance. This parameter is only a
target & can be dynamically modified at the instance level. It will accept a
no of bytes, KB, MB,GB. When these parameters are set, sizing of work
areas becomes automatic & all *_area_size.

7. tell v$views that will give memory statistics.

V$datafile, DBA_data_files, dba_free_space

8. Tell O/S level command(Linux) for memory statistics

V$instance

9. In Statspack report, which parameters you look for I/O contention.

10. In default database how many Control files are made.

One control file

11. I have created a database that has no pfile, I what to view system
parameters.

We will create pfile from spfile.

Create pfile from spfile

12. Tell me any situation in which your database has faced any problem.

13. tasks of DBA.

11
14. OEM / Sql prompt from where you work.

15. I have Emp table it has two columns

Emp
Name DOB
Xyz 1-dec-1979
100 records are appearing. HR whats to celebrate bday of those
employees whose bday falls on todays date.

Select name
From emp
Where trunc to_year(‘sysdate’) = trunc to_year(‘DOB’);
Check this query.

Your query will display list of employees who born on today. Drop year portion
RRRR in your query to display list of employees whose birthday falls on todays
date.
select * from emp where to_char(dob,'ddmm')=to_char(sysdate,'ddmm');

CMC Screening Round (1st round)


1. How can we remove duplicate of records.

Delete from emp


Where rowid not in (select max(rowid)
From emp
Group by emp_id);

2. What are views. Why we need view.

3. What are different types of backup? (Hot, Cold, logical, Physical)

Hot backups are when database is up and running you take backup(DB has to be
in archive log mode in order to do that.) Cold backups are shutdown the
database and copy data files, control files and save them some place safer(on a
different server) Good dba should do that at least once a month. When you rman
backups benefit is that it only backup blocks that have been used, empty data
block does not get backed up. This is very efficient as far as space issues go.

4. Difference between Cost Based Optimizer & Rule Based Optimizer.


(CBO is the default optimizer.)
5. Write export query.
Export = `select dept_id=9’;

12
6. How will you tune SQL?
I will tune my SQL through Query Analyzer.

7. Whether you have done any type of recovery.


Time based, cancel based, Change Based.

10. Explain all Codd rule.(ACID Properties). 9i & 10 G how many rules are
satisfied.
11.5 rules are satisfied in 9i & 10G.

11. Whether you implemented / configured RAC.


12. Linux Installation (O/S Configuration). Which files you need to modify so that
you can install Oracle. (Preparation of server for Oracle configuration).
Security/limits.conf, redhat_release, .bash profile.
Linux 4 = p2,p3 machine, 256mb RAM, Hard Disk 6GB,
Linux 5 = p2,p3 machine, 512mb RAM, Hard Disk 6GB,

Interview with DBA Head (Mrs. Promila)

1. How many servers do you have in your company. What is the Server
Configuration. How many CPUs you have. What kind is the kind of setup.
Whether it is Client Server, Internet Based.
I have 2 servers & I have 30 CPUs The setup is Internet Based.
2. How you spend a day as a DBA. (DBA activities)
3. Whether you have done any backup /recovery.

4. When was your last database was shutdown. Why it was shutdown. (due
to maintenance work) What kind of maintenance work.
Daily my Database gets shutdown. I have an 8 hrs shift. I take incremental
backup daily.

5. For errors which file you look (alert log). Tell me any errors you encounter
and what precautionary step you took.

6. When you take backup. (Evening 6 O’clock). What is your backup strategy
(daily, weekly, monthly).
The backup strategy is daily.

7. Whether you have created Metalinks. Whether you have


worked on Metalinks.
Developer side deals with metalinks.

8. Any experience you remember as Oracle DBA in past one


year you would like to share.

9. What is your company database size.

13
10. What is a failover Server? What kind of setup you have in your company.
Server configured: hardware clusters, Active/ passive, RAC implemented.

11. What kind of applications are running on your server.


(Banking, Finance, Sales, Logistics)

12. Whether you take backup on servers or Disk/ tape. Whether there is enough
space on servers.
(I take backup on tape. The is rewritable.)

Nexzen Consultancy Pvt. Ltd.

1. What is a correlated Query.


2. In DBMS, what is a relation.
3. Where do you store TNS.ora file. In which directory.
D:\Oracle\ora92\network\admin\tnsnames.ora

4. What is incremental backup.


5. What is a subquery.
6. Mention name of some tablespace.
7. Can we create as many tablespace as we require. What is the limit.
What is the default size of tablespace. (System and User tablespace)
No. we can’t create as many tablespace as we require. Limit (1024
tablespace and 1022 datafile)
8. I have a database named EDP-MJS and I have one table. Now how
this table is related to the database.)
Ans. One tablespace is equal to one datafile.
Tablespace->segment->extent->Oracle Blocks->OS Blocks.

9. Syntax for creation of tablespace.


Ans. Create Tablespace userdata
Datafile ‘/U01/oradata/userdata01.dbf’ size 5M;
10. How do you rate yourself in SQL on a scale of 1to 10.
11. How is set theory linked to DBMS (Union, intersection, minus, logical)
12. What is the difference between SOME, ANY, IN, BETWEEN.
13. These Words Database, Instance, Server all are same. Whether there
is any difference.
14. Redo log, control files, data files How many control files we should
have in our databases. (more than 1 i.e. 2).
15. What is a link server.
16.What is Oracle reserved memory and Unreserved memory. What is the
size of Oracle reserved memory.
17. What should be the size of tablespace.
Ans. The size of tablespace is equal to that of datafile.

14
TCS

1. How you will create redolog.


2. How you will create recovery catalog and how you will register database.
(describe the complete process since recovery catalog till registering
databse.)
3. Whether you run scripts or you run commands.
4. what errors you will get in alert log.
5. How you will manage the space in LMT(through Bitmaps blocks)
6. What all activities you will do as Oracle DBA.
7. Tell me about the database and what its concept. Explain.
8. Which version of Oracle and OS platform the database is running. (Oracle
9i / Linux Version 4.0/ Windows XP)

Veritas
4. Question relating to 1115 error.
5. Question relating to 257 error.
6. What is simple replication and advance replication. Difference between
the two. How can we do simple replication.
7. What are snapshots / materialized views.
8. What are different types of materialized views.
(Refreshing, Force)
9. What are triggers. What are different types of triggers.
10. What is a mutating error? How can we overcome this error.
(Developer Section)
11. I have configured sqlnet file. Which file I will configure on client machine.
(tnsnames.ora)
12. I have a control file that is corrupted. The Junior corrupted the control file
while playing this command: alter system copy control file. DBA was
informed that all my copies of control files are corrupted. Now how will you
recover the lost control file.
Ans. I will recover from trace file. I will copy the trace file. I will shutdown the
database & then start the database.

10. I have two redo logs. How can I increase the size of redo log.
Ans. I will create the redo logs (new) of bigger size. I will make a log switch (alter
system switch log file;), when present redo log become inactive. I will delete the
old redo log. Now the new bigger redo log will become active.

11. How will I look for system statistics(at OS level & Database level) and how
will I get to know how many instances are up. (V$instances, V$Database)

12. Which parameter info I will look for in order to know my system statistics.
V$sgastat.

15
13. The ratio of disk (sort) is high. Whether it is good or bad. Why. How will I
reduce disk(sort).
Ans. The disk sort is bad.

14. I have increased the SGA size. The users are connected online. There is
heavy load. The database performance is terrific. How will I overcome this
problem?

15. I am taking a hot backup of database. I have not started the archiving. The
database is not in archive log mode. What problem I will encounter. The redo
logs are not being archived.
Ans. I can’t take hot backup my database until I will start archiving of database. I
have to put my database in archive log mode.

16. To see what are the initialization parameters. Which file I will look for.
Parameter file and init.ora

17. I have encountered some errors. Which file I will refer for errors (alert log). If I
have to look for detailed information about particular error, which file I will look
for.
Ans. For background Processes refer trace file of each process for detailed
information.

Others Questions

1. What is transaction lock.


2. Describe 4 properties of database isolation. In which situation lock
contention will happen.
3. Difference between Dynamic SQL / Stored Procedure. Which one is better
& why.
4. What is the size of database. 400 GB
5. How many users you have. 20 users
6 What kind of setup you have in your organization. Whether it is Client server,
Internet based, etc
7. What is recovery catalog. Tell command for creation of catalog.

Info: The Hot backup is online backup. When I will start rman I have to start
archiving. Rman does’t work without being in archivelog mode. So we can’t take
hot backup without starting archiving. Current redo logs need to be archived. So
it has to be in archivelog mode.
In user managed backup, I have to take database in mount state. Then only I can
take offline backup(Cold Backup).

16
The current redo logs, I can’t increase the size of online redo logs. I have to do
log switch(alter system switch logfile). Stop archiving and then create new redo
logs with increased size.

I can increase the size of redo logs that our offline. It means that they are not
current. If we have more than 2 redo logs, in that case we can increase the size.

Ques. What applications are running on your database.

It means in which domain you are working. Whether it is banking, Insurance,


finance, sales etc
Ques. What is a deadlock. How you will overcome this deadlock situation. What
is the command for ending this deadlock situation.

Ques. Mention steps of Data Migration.

Telephonic Round

1. What is Oracle. What is the difference between Oracle/SQL Server. SQL also
provides security features. What is the key difference between the two.

2. Difference between RDBMS & DBMS.

3. What are Oracle Blocks. What is locally managed Tablespace. Difference


between LMT / DMT. (LMT Bitmap blocks)

4. Whether I can take hot backup while my database is not in archivelog mode.
(No, We have to start archivelog, inorder to take hot backup. Online backup is
only possible while my database is in archivelog mode and I have started
RMAN.)

5. What activities you perform as DBA.

♦ Verified Raw Device Permission(s) & owner


♦ Verified Cluster(s) are running successfully
♦ Verified all instances & database is up
♦ Verified enough free space in data files
♦ Verified free space in Archive log destination
♦ Looked for any new alert log entries
♦ Verified Success of Recovery Manager Backup(s)
♦ Verified Success of export Backup(s)
♦ Verified all DBSNMP are running successfully
♦ Any other task done during the day

I analyze database for excessive paging, swapping. I monitor indexes, whether


unused indexes are slowing down my database. I tune my SQL Queries. If I have

17
tuned my SQL Queries then 70% of my performance tuning is done. (I should
avoid using HAVING/ BETWEEN clauses. It slows down my database
performance.) I monitor my database through various V$ views Like V$instance,
V$database, V$sgastats. How much CPU space is consumed by different
database objects. I generate Stats pack report. I look for errors in the alert log
file. It actually reflects the health of database.

Ques: Show one instance one you have encountered an error in alert log and
you overcome that error. What actions you took to overcome that error.

Ques. Tell me any instance when your database encountered any problem. How
you dealt with that problem.

Ques. What is Cache Fusion Technology.

Cache Fusion is a new technology that uses a high speed interprocess


communication (IPC) interconnect to provide cache to cache transfers of data
blocks between instances in a cluster. This eliminates disk I/O (which is
inherently slow, since it is a mechanical process) and optimizes read/write
concurrency. Block reads take advantage of the speed of IPC and an
interconnecting network. Cache Fusion also relaxes the requirements of data
partitioning.

What is standby databases? Difference between Physical and logical standby


databases

A standby database is a transactionally consistent copy of the primary database.


Using a backup copy of the primary database, you can create up to nine standby
databases.

A standby database can be either a physical standby database or a logical


standby database.

A Physical standby database provides a physically identical copy of the primary


database, with on disk database structures that are identical to the primary
database. This standby database is kept synchronized with the primary database
by recovering/applying the redo data received from the primary database.

A Logical standby database has same logical information as the production


database, although the physical organization and structure of the data can be
different. The logical standby database is kept synchronized with the primary
database by transforming the data in the redo received from the primary
database into SQL statements and then executing the SQL statements on the
standby database.

18
DBMS_meta_data Parameter

DBMS_meta_data. This parameter is very usefull. What you infer from this
parameter. What info you will find in that. explain in detail.

To find the structure of a external table we used this package.


syntax is below:
SELECT DBMS_METADATA.GET_DDL ('TABLE','<Table Name in
CAPS>')||';' FROM DUAL

What is a flash back query? This feature is also available in 9i. whats the
difference between 9i and 10g (related to flash back query).
Oracle 10g offers significant enhancements that help insure the high availability
of any Oracle database, as well as improvements in the database disaster
recovery arena. This paper explores one of the most intriguing new features of
Oracle 10g: Flashback Backup and Recovery. Oracle 9i provided the capability to
"Flash back" to a prior view of the database via queries performed against
specific logical entities. This capability was limited, of course, by the amount of
UNDO data retained in the database's UNDO segments and bounded by the time
frame specified by the UNDO_RETENTION initialization parameter. Oracle 10g
expands these logical flashback capabilities significantly.

Determine Number of Blocks Corrupted

You have a database. You have a datafile and some blocks are corrupted in the
datafile. What statement will you issue to know how many blocks are corrupted?
You can check the "V_$DATABASE_BLOCK_CORRUPTION" view to
determine the corrupted blocks

• live query – like company structure, database size, backup information


and some real time question like your environments details

• Definately all interviewer will ask about basic concept of oracle

• If you have RAC and data guard concept that will be better for your
selection. Because all need same requirements. At least take a basic concept
of same topic.

19
General questions

 What is the difference apps dba and core dba? What applications are
managed by application dba?
App DBA means you have to knowledge about application like PL-SQL, and
oracle application but in core DBA you have to manage only oracle database.

 What kind of oracle applications.


Application means they managed Oracle application and database also. So
application DBA demands higher package. You can manage front end that
use oracle database.

 which is better apps dba / core dba. Which has higher demand.
Both are better. Apps DBA is good. App DBA + Core DBA = App DBA. It has
a dual advantage. If you will give interview of Apps DBA then they will ask lots
of things related to application.

 what all is expected from an apps dba-related to application like PL/SQL


/what applications like D2K.
Every thing like oracle developer. It is a combination of Developer +DBA.

Accenture faqs 8 june 2010

 I have a table emp and it has 150 associated child table. I have to drop the
emp table with all associated child table in a single syntax. (It means that
there are associated child records in the base table that would not allow you
to delete the base /primary table.)

Drop table EMP;

 What are different types of indexes/constraints/tables? What data structures i


can apply indexes. (tables, views, met views) Can I apply indexes on views?
Yes/no.

 I have applied indexes on views and can I save the result of the view that is
retrieved.

 what is the concept of high water mark

Read this concept for HWM :- just create a table with 1,000,000 rows (or
create any table with a large number of rows), and then execute a SELECT
COUNT(*) from this table. Now, DELETE every row in it and you will find that
the SELECT COUNT(*) takes just as long (or longer, if you need to clean out
the block! Refer to the 'Block Cleanout' section of Chapter 9) to count 0 rows
as it did to count 1,000,000. This is because Oracle is busy reading all of the

20
blocks below the HWM to see if they contain data. You should compare this
to what happens if you used TRUNCATE on the table instead of deleting
each individual row. TRUNCATE will reset the HWM of a table back to 'zero'
and will truncate the associated indexes on the table as well. If you plan on
deleting every row in a table, TRUNCATE. There is a good concept in DB1 for
HWM- High Water Mark.

 Difference between Delete, truncate, drop statement (DDL / DML). Whether


the data & structure both will be deleted and what I can recall data / structure.

 A query is run on 2-3 tables, & data is retrieved from 2-3 tables. Earlier the
query use to run 15 seconds, but now it takes 1 hour to run. As a DBA what
all appropriate steps you will take? Why such a thing happen. What are the
reasons behind it?
 What is default optimizer mode in 10 G.? If you use CHOOSE parameter it
will also use CBO as default optimizer. RBO is almost obsolete parameter
now.

 Some blocks are corrupted. How will I find that which blocks are corrupted
V$block_corruption, how will I rectify those blocks. If block is corrupted then I
will not be able to retrieve the data. How will I repair corrupted blocks. What
are steps involved in that. I will retrieve corrupted block no. and I will retrieve
data from redo log and archive log.

 I have made use of explain plan. Where is the analyses report stored and
from where it is retrieved. Plan_table syntax that is being used. I can fetch the
statistics report from table_analysis.

answer - the query that is written is optimized. Explain plan is used.


Index rebuild. Choose- CBO will be the default optimizer mode. When
the query is runned again, it will rewrite the analysis based upon recent
changes.

 DBA will analyze the table. It is a routine analysis that is being done as a part
of dba activity. There are some reasons behind it. Why dba analyze the table
on routine basis. In production environment table_analysis is a part of dba
activity.

 Whether you have worked on rebuilding of indexes. Suppose 31 Jan query


retrieve 1 min but the experienced client told to rebuild indexes. Now it is
taking 3 mins. What you will do as a dba.

May be HWM is the cause of same issue. So as to resolve same issue. Move
the table and rebuild then it will not take much time.

21
Oracle India 18 June 2010

 What are the different types of pool in 9i SGA. Which is the biggest pool in
SGA you think?

Shared Pool Data Dictionary cache


Library Cache
DB Buffer
Redo Log Buffer
Java Pool

Biggest pool is DB Buffer.

 Log writer will right to log file in what all scenarios?

1 MB redo is generated
1/3 of redo log buffer is full
Before DBWR writes to data file

 If I commit some data then what processes will happen?

LGWR will write to redo log file then DBWR will write to data file. Once a
transaction is committed then it can’t be rolled back.
What is automatic_Undo_Management?

What is undo tablespace? Is there a redo tablespace NO

Whether a redo will be generated once I run a DDL, DML, DCL?

Yes, redo will be generated when I run DDL(create, alter), DMLs(Insert,


Update, Delete) & DCL (Truncate, drop) commands.

 What are the different types of file in a database?

Data file, control file, redo log file, Alter Log, Password file, Pfile (static
init.ora), SP file (dynamic), trace file.

What is the frontend / backend of the database?

D2k, ASP/ Oracle

 Whether salary is a nominal, personal or real a/c?


nominal a/c
Salary a/c amt
To
Aditya amt

22
 In Oracle is it essential to take backup through RMAN? Whether I can take
incremental backup of the DB through user managed backup?

No, it is not essential to take backup through RMAN. I can take user managed
backup also. But RMAN provides facility through which I can take incremental
backup of the DB.
No, I can not take incremental backup of the DB through user managed
backup.

What is incremental backup of the database?

Incremental backup of the database means that I have taken full backup of
DB today and tomorrow when I will take backup of DB then I can take
incremental backup of the database ie only those blocks will be updated on
which some changes have been performed. It is less time consuming.

What is Block tracking file?

How you take backup on disk / tape? You can take backup of DB directly on
disk & no need to configure the software.

I take backup on rewritable tape. You can not take backup directly on tape
through RMAN, MML has to be configured?
It is mandatory to configure MML. Software provided by VERITAS, Tivoli, has
to configured with database. What is the name of software?

 What is level zero backup, level 1 backup, level 2 backup?

Level zero backup is the complete backup of the DB. Level 1 backup is the
incremental backup of DB when changes have taken place from the time level
zero to till the time I am taking level 1 backup only those blocks will be
updated in the database. Similarly is the concept hold true for level 2 backup.

PT
 The db is running slowly now you will do as a dba?

I will go the alert log file. Where is the alert log file? Alert log file will be
situated in background dump destination. Alert log only provide info about the
events and not about transactions.
I can also refer trace file for additional info.
Where is the trace file located specify destination.
First of all you need to activate the trace file. Auto_trace_on = true. I will make
changes in pfile / spfile. The trace file grows too big in a short span of time
and it is difficult to manage. Trace file have to be converted into readable
format.

23
 What is stats pack report? What is the first thing you will look for in statspack
report?
I will look for the load profile information. What is the load on the server, when
the transactions are fired on the DB?

Snapshot of a duration of say 2 hrs


@spcreate.sql
Begin snapshot
End snapshot

Oracle Books Definition and syntax

Maintenance of Alert log file

The alert log file consists of chronological log of messages and errors.
• Check the alert log regularly to:
o Detect internal errors (ORA-600) and block corruption errors
o Monitor database operations
o View the non default initialization parameters
• Remove or trim the file regularly after checking

The following info is logged in the alert log file:

• Internal errors (ORA-600) and block corruption errors (ORA-1578 or ORA-


1498)
• Operations that affect database structures, parameters and statements such
as CREATE DATABASE, STARTUP, SHUTDOWN, ARCHIVELOG
and RECOVER.
• The values of all non default initialization parameters at instance startup.
• The location of the alert log file is given by the
BACKGROUND_DUMP_DEST Parameter.

Alert log file

Each oracle instance has an alert log. If not already created, it is created during
instance startup. The alert log file must be managed by the DBA. It continues to
grow while the database continues to work. The alert log file should be the first
place you look when diagnosing day to day operations / errors. The alert log file
also contains pointers to trace files for more detailed information.

The alert log file keeps a record of the following information:

• When the database was started or shutdown


• A list of all non default initialization parameters

24
• The start up of background processes
• The thread being used by the instance.
• The log sequence no LGWR is writing to
• Information regarding a log switch
• Creation of tablespace and undo segments
• Alter statements that have been issued
• Info regarding error messages such as ORA-600 and extent errors.
• The alert_SID.log location is defined by the BACKGROUND_DUMP_DEST
initialization parameter.

1. Tell me any wait event you have worked with?

Oracle wait events

• A collection of wait events provide information on the sessions that had to


wait or must wait for different reason.
These events are listed in v$event_name view, which has following columns:
• Event#
• Name
• Parameter1
• Parameter 2
• Parameter 3

There are about 290 wait events in the oracle server including:
• Free Buffer wait
• Latch free
• Buffer Busy Waits
• DB file sequential read
• DB file scattered read
• DB file parallel write
• Undo segment Tx slot – Transaction –Tx
• Undo segment Extension

SQL>select name, parameter1, parameter2, parameter3


From v$event_name;
• Buffer busy wait event
• Log file switch (checkpoint incomplete) event

Buffer busy wait event – The buffer busy wait event records waits for a buffer
to become available. This wait indicates that there are some buffers in the
buffer cache that multiple processes are attempting to access concurrently.

This event is accomplished by three parameters:

25
• File# and Block#: These parameters identify the block no in the data file
that is identified by the file number for the block for which the server
needs to wait.
• ID: The buffer busy wait event is called from different places in the
session. Each place in the kernel points to a different reason. ID refers to
the place in the session calling this event.
The log file switch (checkpoint incomplete) event- The log file switch
(checkpoint Incomplete) waits for a long switch because the session can
‘t wrap into the next log. Wrapping can’t be performed because the
checkpoint for that log has not completed. This event has no parameter.

Statistics event views

• V$Session_event: Waits for an event for each session that had to wait.
• V$Session_wait - Waits for an event for current active sessions that are
waiting.
• V$System_event -Total waits for an event all sessions together.

What activities you perform as DBA

Tasks of a DBA

• To plan and create database


• To manage database availability
• To manage physical and logical structures
• To manage storage based on design
• To manage security
• Network Administration
• Backup and recovery
• Database tuning

Other Admin tasks

Planning and creating databases, managing database availability, managing


memory, physical and logical structures and managing users and privileges.

Materialized views

Dbms_mview.refresh.refresh_all_views;
Refresh all materialized views that are due to be refreshed.

II Refresh MV based on one or more base tables;


Dbms_mview.refresh_dependent(‘Sales’);

III Refresh specific materialized views

26
Dbms_mview.refresh(‘cust_sales’,parallelism=>10);

Using the dbms_mview package

The package contains the following procedures:

• Explain_mview
• Explain_rewrite
• Refresh
• Refresh_all_mviews

Q. What are views? Why we need a view?

Views are database objects whose contents are derived from another table.
• A view contains no data of its own.
• The command for creating a view is CREATE VIEW command.
• The changes in the table are automatically reflected in the VIEWS.

A view is like a ‘window’ through which data on a table can be viewed or


changed. It is a virtual table that is – it does not have any data of its own, but
derives the data from the table it is associated with. It manipulates data in the
underlying base table.

When the create VIEW command is executed the SELECT statement which
follows AS is not executed; instead the definition is simply stored in the data
dictionary. A VIEW is queried just like querying a table. Most of the operations
on a table can also be carried out with VIEWS with some restrictions.

Any updations of rows in the table will automatically reflect in the VIEWS. A
user can not distinguish between a table and a VIEW.
The syntax for creating a view is

CREATE [OR REPLACE] VIEW <view name> [(column1,


column2…)]
AS
<Select statement>
column1, column2 etc are the names to be given to columns in the view and
must correspond to the items in the select list. A VIEW can be derived from
another VIEW.
Advantages of a VIEW

1. Views restrict access to the database. SELECTING from a view can display a
restricted portion of the database.
2. As a VIEW does not store any data, the redundancy does not arise.

27
3. Critical data in the base table is safeguarded as access to such data can be
controlled using VIEWS by not selecting those columns during the creation of
a VIEW.
4. A VIEW allows users to make simple queries to retrieve the results from
complicated queries. For eg: Views allow users to select info from multiple
tables without knowing how to perform a JOIN.
5. Views provide data independence for adhoc users and application programs.
One view can be used to transparently retrieve data from several tables. Also
views allow the same data to be seen by different users in different ways.
Eg: create a view for the employees belonging to department 20:

Create VIEW dept20 AS


Select * from emp
Where deptno = 20;

• After creating a VIEW, it can be queried just like querying a table.

SELECT * from dept20;


When the FROM clause contains the name of a VIEW, the query associated
with it is executed on the underlying base table(s).
Note: A view can not contain an ORDER BY clause. The ORDER BY clause
is specified when you SELECT from the VIEW.

Q. Explain all CODD rules (ACID properties) In 9i & 10G how many rules are
satisfied. (11.5 rules are satisfied in 9i and 10 g).

A RDBMS has the following properties:

1. Represents data in the form of tables.


2. Does not hard code relationships between tables.
3. Does not require the user to understand its physical implementation.
4. Provide information about its content and structure in system table.
5. Supports the concept of NULL values.

The 12 rules for an RDBMS (CODD’s rules)


1. Information representation
2. Guaranteed Access
3. Systematic treatment of NULL values
4. Database description rule
5. Comprehensive Data sub language
6. View updating
7. High level Update, Insert and Delete
8. Physical Data Independence
9. Logical Data Independence
10. The Distribution Rule
11. Non Subversion

28
12. Integrity Rule

E.F. Codd formulated 12 rules for RDBMS in 1970. In addition to the 12 rules,
there exits a rule, called rule zero, which states-

“A relational system must be able to manage databases entirely through its


relational capabilities. Any DBMS that advises users to the some non-
relational methods to achieve acceptable performance should be interpreted
as an apology by the vendor”.

Q. Difference between CBO (Cost Based Optimizer) and RBO (Rule Based
Optimizer)?

CBO is the default optimizer

SQL statement Tuning chapter 11 Performance tuning

 To provide methods to determine the resources used by SQL


statements
 OEM
 Stats pack
 Explain plan
 SQL trace & TKPROF
 Auto trace
 To determine which sql statements possibly require tuning
 Not to tune actual statements

Optimzer Modes
There are two types of optimizer modes:
Rule Based
 Uses a ranking system
 Syntax and data dictionary driven

RBO
In this mode, the server process chooses its access path to the data by
examining the query. This optimizer has a complete set of rules for ranking
access paths. The RBO is syntax driven, in that it uses the stmt syntax in
combination with data dictionary information about the data structures to
determine which execution plan to use. This optimizer mode is supported for
backward compatibility.

CBO
 Chooses the path with lowest cost
 Statistics driven

29
In this mode, the optimizer examines each statement and identifies all possible
access paths to the data. The resource cost of each access path is calculated
and the least expensive one is chosen. The cost is based mainly on the no. of
logical reads. The CBO is statistics driven in that it uses statistics generated for
the objects involved in the SQL statement to determine the most effective
execution plan you should use this optimizer mode for new applications,
particularly if they use the parallel query feature, bitmap indexes or bitmap join
indexes.

SETTING THE OPTIMIZER MODE

 At the instance level:


- Optimizer_mode= {choose|rule|first_rows|first_rows_n|
all_rows}

 At the session level:


- Alter session SET optimizer_mode = {choose|rule|first_rows|
first_rows_n|all_rows}

 At the statement level:


- using hints

The optimizer mode can be set at the:

 Instance level by using the OPTIMIZER_MODE parameter


 Session level, by using the ALTER SESSION command
 Statement level, by using HINTS.

The DBA is responsible for setting the OPTIMIZER_MODE parameter at the


instance level because this requires restarting the instance. Typically
application developers can set OPTIMIZER_MODE at the session level, as
well as use hints in SQL statements.

The OPTIMIZER_MODE parameter

The default value is choose. This means that the optimizer uses the Cost
Based mode (All_rows) if statistics are available for at least one of the tables
involved. Otherwise it uses Rule Based optimization. The other possible
values are Rule, First _rows, First_rows_n, and All_rows. The first one forces
rule based optimization regardless of the existence of any statistics. The last
two represent different ways of using cost based optimization.

Note- If any table involved has a degree of parallelization greater than 1 or a


parallel hint then the default behaviour for the statement is Cost Based
Optimization (CBO).

30
The OPTIMIZER_MODE at the session level

SQL> ALTER SESSION SET OPTIMIZER_MODE = value;

OEM – Maintaining Stored Outlines

You can use the OEM console to maintain stored outlines on a database.
From this manager you can create, drop / modify stored outlines.

Overview of Diagnostics Tools

 Stats pack
 Explain Plan
 SQL Trace & TKPROF
 SQL * Plus auto trace feature
 Oracle SQL Analyze (Oracle Expert purchase separate)

Numerous diagnostics tools are available for evaluating the performance of SQL
statements and PL/SQL modules. Each tool provides a developer or DBA with a
varying degree of information.

1. Stats pack
This utility collects info regarding database statistics and SQL statements.

2. Explain Plan
This is executed within a session for a SQL statement.

3. SQL Trace
This utility provides detailed info regarding the execution of SQL Statements.

4. TKPROF
This is an OS utility that takes the output from a SQL Trace Session and
formats it into a readable format.

5. Auto trace
This is a SQL*plus feature. Auto trace generates an execution plan for a
SQL statement and provides statistics relative to the processing of that
statement.

6. Oracle SQL analyze


This is part of the OEM Tuning pack and it provides a powerful user
interface for tuning SQL statements.
SQL Reports in Statspack

The following reports on statements are provided by statspack:

31
1. SQL ordered by Gets (lookup)
2. SQL ordered by Reads
3. SQL ordered by Executions
4. SQL ordered by Parse calls

Statspack give four different views based on SQL statements stored in the
shared pool at the time of either the beginning of snapshot or the ending
snapshot. The report provides these statements in four different sessions.

These reports can be examined to which SQL statements are having the most
impact on the performance of the database. These are the best SQL statements
to tune because tuning them is most likely to improve performance dramatically.

TKPROF Statistics

1. COUNT – Number of execution calls


2. CPU – CPU seconds used
3. Elapsed – Total elapsed time
4. Disk – Physical reads
5. Query – Logical reads for consistent read
6. Current – Logical reads in current mode
7. Rows – Rows processed

SQL*plus Autotrace

1. Create the Plan–table


2. Create and Grant the Plustrace role

SQL> @$ORACLE_HOME/sqlplus/admin/plustrce.sql
SQL>Grant plustrace to Scott;

Autotrace syntax

SET AUTOTRACE [OFF|ON|Traceonly]


[Explain|Statistics]

Maintaining online Redo log files

Alter system switch logfile;

Checkpoints are forced by

Fast_start_MTTR_Target=600(sec)
Alter system checkpoint;

32
Adding online redo log file group

Alter Database add logfile Group3


(‘$HOME/ORADATA/U01/log3a.rdo’,
‘$HOME/ORADATA/U02/log3b.rdo’)
SIZE 1M;

33
34
35
36
Relocating or renaming online redo log files
1. SQL>SHUTDOWN
2. Copy online redo log files to new location
3. SQL>CONNECT / as sysdba
SQL>STARTUP MOUNT

4. Alter Database rename file


‘$Home/Oradata/U01/log2a.rdo’
TO ‘$Home/Oradata/U02/log1c.rdo’;

5. SQL> Alter Database open;

37
Clearing online redo log files

Alter Database clear logfile Group2;


 Use the unarchived keyword to avoid archiving the corrupted online redo log
file

Alter Database Clear Unarchived Logfile Group2;


Managing online redo log files with OMF

 Define the DB_CREATE_ONLINE_LOG_DEST_n parameter

DB_CREATE_ONLINE_LOG_DEST_1
DB_CREATE_ONLINE_LOG_DEST_2
 A group can be added with number file specification

Alter Database Add Logfile


Dropping a group

Alter Database Drop Logfile Group3;


Note
The default size is 100 MB

Obtaining Group and Member Information

 Information about group and its members can be obtained by averaging the following
views:

V$log
V$logfile
 Information about archived logs can be obtained from V$Instance

SQL>Select archiver from V$Instance;


Managing Tablespace & Data File
CREATING TABLESPACES

Create tablespace userdata


Datafile ‘/u01/oradata/userdata01.dbf’ size 5M;

38
Locally Managed Tablespace (LMT)

1. Reduced contention on data dictionary tables


2. No undo generated when space allocation or de allocation occurs.
3. No coalescing required

Create tablespace userdata


Datafile ‘/u01/oradata/userdata01.dbf’ size 500M
Extent management LOCAL uniform size 128k;
No LMT DMT
1 Free extents are managed in Free extents are managed by the data
tablespace. dictionary.
2 Bitmap is used to record free Appropriate tables are updated when
extents extents are allocated / deallocated.
3 Each bit corresponds to a block
or group of blocks.
4 Bit value indicate free / used.
5 LMT is default in Oracle 9i.

Dictionary Managed Tablespace (DMT)

1. Extents are managed in the data dictionary.


2. Each segment is stored in the tablespace can have a different storage clause.
3. Coalescing is required.

Create tablespace userdata


Datafile ‘/u01/oradata/userdata01.dbf’
Size 500M extent management DICTIONARY default storage
(initial 1 M Next 1M PCTINCREASE 0);
Migrating a Dictionary Managed System Tablespace to Locally Managed
Tablespace

DBMS_SPACE_ADMIN.TABLESPACE_MIGRATE_TO_LOCAL(‘S
YSTEM’);
UNDO TABLESPACE

Create temporary tablespace temp


Tempfile ‘/u01/oradata/temp01.dbf’ size 20 M
Extent Management LOCAL UNIFORM SIZE 4M;

 No permanent schema objects can reside in a temporary tablespace.

39
Alter database
Default temporary tablespace default temp2;

Select * from Database_properties;


Read only Tablespaces

 Use the following command to place a tablespace in read only mode

Alter tablespace userdata READ ONLY;


 Causes a Checkpoint
 Data available only for read operations
 Objects can be dropped from tablespace

Taking a tablespace offline

Alter tablespace Userdata OFFLINE;

 To bring a tablespace online

Alter tablespace Userdata ONLINE;

Alter tablespace Userdata MINIMUM EXTENT 2M;

Alter Tablespace Userdata


Default storage (INITIAL 2M NEXT 2M max extents 999);

HP Emphasis Bangalore (Shankar)


1. Describe about yourself , your past experience.

2. How you will rate yourself for RAC on a scale of 1 to 10.

3. How you will rate yourself for Data guard on a scale of 1 to 10.

4. How you will rate yourself for oracle DBA on a scale of 1 to 10.

5. While implementation of RAC, how SSS (Secured Socket Shell) is being


configured. What are the steps.

6. How dataguard is being implemented. Concept of dataguard.

7. How you will rate yourself in backup and recovery on a scale of 1 to 10.

8. One scenario – Archive log DB – every Monday backup of DB is taken at


8 am. Today offline backup is taken due to H/w maintenance. After 2/3

40
hrs DB got crashed due to h/w electric failure. Now how you will do
point in recovery. Tell me command to do point in time recovery.

The offline backup complete Db till 8 am and I will recover through this
and then I will apply archive logs for 2 hrs. This way I will do point in
time recovery.

9. During hotbackup of DB, why more archive logs are generated than
RMAN.

It is due, the checkpointing info is written at the header of datafile and


control file. Due to this, when customers are making transactions, then
in order to save data in blocks, more archive logs are being generated.
In RMAN takes backup of only those blocks that are occupied. It
consumes less time.

10.While hot backup was going on DB got crashed. Now how will I start
the DB.

11.Have you done any DB setup.

12.Export / Import User A and User B. I have to do export / import user A


schema to UserB schema. What are the steps and how will I do in 10g.

13.Have you done any performance tuning.

14.Why do we need to rebuid an index and on what basis I will decide to


rebuild an index.

15.Tell me name of V$ events.

HCL, Noida location (Shankar)


1. How you will rate yourself in oracle architecture

2. How you will rate yourself in Designing oracle.

3. Have you worked on RAC, Dataguard and Streams.

4. Have you worked in Backup recovery and RMAN.

5. Tell me what are new features of 10g ADDM/ AGWR

6. In oracle 10g how a data pumped by oracle export / Import utility. How
data is moved explain complete concept. There is a 300 mb of data that
needs to be moved from /to oracle DB.

41
Exp / Imp utility works at OS level.

7. Are you into development / technology.

8. DB size is 60 GB. You have created a new DB 60GB. How you will set the
sga size.

9. The DB version is 10.2.0.2, You plan to upgrade the database to 11g.

High Availability Architectures


This chapter describes high availability architectures in an Oracle environment. It
includes the following sections:

• Oracle Database High Availability Architectures


• Choosing the Correct HA Architecture
• Assessing Other Architectures

Oracle Database High Availability Architectures

42
This section defines the top five database architectures that address various high
availability business needs. The architectures described are:

• Database only: This is a single instance production database on a standalone


machine and uses all of the HA features that come with the Oracle database.
Flashback technology can recover quickly from user and logical errors. Online
redefinition and reorganization can reduce downtime for most scheduled
maintenance activities. Oracle's sophisticated backup and recovery framework
with RMAN can be customized for each customer's recovery requirements.
• RAC only: This involves a RAC database. RAC environments can provide
continuous service for both planned and unplanned outages within the cluster. If a
node or instance fails, then the application service fails over to existing RAC
instances quickly and transparently.
• Data Guard only: The primary site contains a production database. The
secondary site contains one or more standby databases. If there is a primary site
failure or database failure or any failure that cannot be resolved quickly at the
local site, then you can use Data Guard to fail over or switch over to a standby
database.
• Maximum Availability Architecture (MAA): The primary site contains a RAC
production database. The secondary site contains a cluster that hosts both logical
and physical standby databases. This architecture provides the most
comprehensive set of solutions for both unscheduled and scheduled outages
because it inherits the capabilities and advantages of both the RAC and the Data
Guard architectures.
• Streams: The primary site contains a production database. The secondary site
contains a replicated database using Streams technology. Both sites can be active,
and transactions can be synchronized in both directions. The platforms can also be
heterogeneous.

Oracle provides a wide array of HA architectural solutions. The "Database only"


architecture is not highly available, but it contains many availability features and assets
that are used by all other architectures. The "Database only" architecture is the starting
point for most customers. "RAC only", "Data Guard only", and Streams architectures
provide additional HA capabilities in addition to the "Database only" capabilities. MAA
incorporates both RAC and Data Guard advantages and represents the architecture with
maximum availability. Figure 4-1 illustrates the hierarchy of the different HA
architectures.

Figure 4-1 Hierarchy of HA Architectures

43
Text description of the illustration maxav032.gif

The following sections describe each architecture and their advantages in more detail:

• "Database Only" Architecture


• "RAC Only" Architecture
• "Data Guard Only" Architecture
• Maximum Availability Architecture
• Streams Architecture

"Database Only" Architecture

Oracle provides HA features that can be used in any of the database architectures. These
features make the standalone database on a single machine attractive and available. These
features are described in Table 4-1. Chapter 9, "Recovering from Outages" describes
when to use these features to resolve different outages, while Chapter 10, "Detailed
Recovery Steps" contains details about how to use the features to recover.

Table 4-1 High Availability Features of the Oracle Database

Feature Description
Reduced downtime for • One-step cloning of database objects for faster
application and Oracle online redefinition during upgrades
upgrades • Eliminates PL/SQL package invalidation after
changes to underlying objects

• Handles data definition language (DDL) locks on


busy tables
Flashback capabilities to • Flashback Version Query retrieves metadata and
protect from user errors and historical data for a specific time interval
logical corruptions • Flashback Transaction Query retrieves metadata

44
Feature Description
and historical data for a specific transaction or for
all transactions within a specific time interval
• Flashback Table recovers a table to its state at a
previous point in time
• Flashback Drop recovers a dropped table

• Flashback Database provides a more efficient


alternative to database point-in-time recovery
Online redefinition and • Any physical attribute of a table can be changed
reconfiguration for minimal or online. The table can be moved to a new location.
no scheduled downtime for The table can be partitioned. The table can be
changes to object structures or converted from one type of organization (such as
applications heap-organized) to another (such as index-
organized).
• Many logical attributes can be changed. Column
names, types, and sizes can be changed. Columns
can be added, deleted, or merged. (The primary
key of the table cannot be modified.)
• Secondary indexes can be created and rebuilt on
index-organized tables (IOTs). Secondary indexes
support efficient use of block hints (physical
guesses). Invalid physical guesses can be repaired
online.
• Index can be created online and analyzed at the
same time.

• CLOB and BLOB datatypes have extended support.


Manage backup and recovery • Automated disk-based backup and recovery that
operations automatically provides a simplified and unified storage location
for backups, archived redo log files, flashback
logs, and other files required for recovery
• RMAN backup capabilities such as backup
standby control file support, simplified cataloging
of backup files, simplified backups to disk, and
improved incremental backups to avoid scanning
an entire datafile

• RMAN recovery capabilities such as automated


file creation during recovery, simplified recovery
through resetlogs, and the ability to flash back and
recover to different points in time
Fast and efficient object re- Data Pump
creation features

45
Feature Description
Fast-start recovery during Fast-start checkpointing can be used to reduce instance
startup recovery time
Simple and integrated • Easy GUI for installation, set-up, and
management framework with configuration
Oracle Enterprise Manager
• Integrated monitoring and management practices

"RAC Only" Architecture

"RAC only" architecture uses Real Application Clusters and is an inherently high
availability system.The clusters that are typical of RAC environments can provide
continuous service for both planned and unplanned outages. RAC build higher levels of
availability on top of the standard Oracle features. All single instance HA features, such
as flashback technologies and online reorganization, apply to RAC as well.

In addition to the standard Oracle features, RAC exploits the redundancy that is provided
by clustering to deliver availability with n - 1 node failures in an n-node cluster. All users
have access to all as long as there is one available node in the cluster.

This architecture provides the following benefits:

• Fast node and instance failover (measured in seconds)


• Integrated and intelligent connection and service failover across various instances
• Planned node, instance, and service switchover and switchback
• Rolling patch upgrades
• Multiple active instance availability and scalability across multiple nodes
• Comprehensive manageability that integrates database and cluster features

Figure 4-2 shows "RAC only" architecture.

Figure 4-2 "RAC only" Architecture

46
Text description of the illustration maxav015.gif

"Data Guard Only" Architecture

Data Guard provides a rich set of HA solutions and addresses the requirements of the
business community for a disaster recovery solution. Data Guard supports Data Guard
Redo Apply and Data Guard SQL Apply technologies to enable two distinct kinds of
standby databases: physical standby database and logical standby database.

Physical standby databases have provided HA solutions to thousands of applications


since Oracle version 6. The introduction of Oracle Data Guard in Oracle8i and further
enhancements in the Oracle9i and Oracle Database 10g releases have provided a simple
and sophisticated HA suite. Data Guard physical standby architectures are the most
efficient and simplest standby database environments. Logical standby databases,
introduced in Oracle9i, enable recovery of transactions while permitting read and write
operations to occur simultaneously in the same database. Logical standby databases
require additional processing, but for some applications, they can be a very suitable HA
solution or can complement other solutions. For some customers, both physical and
logical standby databases can be used as part of an HA solution, which is recommended
in MAA. The physical standby database becomes the initial switchover and failover
target, while the logical standby database is used for reporting, queries, and additional

47
processing to relieve the load on the production database. The logical standby database
can also be targeted for switchovers, failovers, and rolling database upgrades.

Physical standby databases provide these advantages:

• Protection from user errors and logical corruptions


• Protection from disasters and site failures if located remotely
• Fast site and database failover (measured in minutes)
• Fast site and database planned switchovers for maintenance
• Backups can be taken from the physical standby database instead of the
production database, relieving the load on the production database
• Read-only capability, resulting in better use of system resources

In addition to disaster recovery and data protection, logical standby databases provide the
following benefits:

• Enable the standby database to be open for normal operations with both read-only
and read/write accessibility
• Enable additional objects to be built and maintained
• Enable rolling database upgrades of the production database

A recommended configuration for many cases includes both physical and logical standby
databases. They can reside on the same database machine or cluster, but they should be
remote from the production database. The physical standby database can be reserved for
failovers in case of disaster, and the logical standby database can continue to be used for
reporting. The physical standby database provides a faster apply technology because redo
logs do not have to be converted to SQL.

Figure 4-3 shows the production database at the primary site and the standby databases at
the secondary site.

Figure 4-3 "Data Guard Only" Architecture on Primary and Secondary Sites

48
Text description of the illustration maxav020.gif

See Also:

• Oracle Data Guard Concepts and Administration for more


information about datatypes supported by logical standby
databases

• The papers about standby databases at


http://otn.oracle.com/deploy/availability/htdocs/maa.htm

Maximum Availability Architecture

RAC and Data Guard provide the basis of the database MAA solution. MAA provides the
most comprehensive architecture for reducing downtime for scheduled outages and
preventing, detecting, and recovering from unscheduled outages. The recommended
MAA has two identical sites. The primary site contains the RAC database, and the
secondary site contains both a physical standby database and a logical standby database
on RAC.

49
Identical site configuration is recommended to ensure that performance is not sacrificed
after a failover or switchover. Symmetric sites also enable processes and procedures to be
kept the same between sites, making operational tasks easier to maintain and execute.

Figure 4-4 provides an overview of the architecture.

Figure 4-4 Maximum Availability Architecture

Text description of the illustration maxav004.gif

Streams Architecture

Streams is meant for information sharing and distribution. It can also provide an efficient
and highly available architecture.

Streams provides granularity and control over what is replicated and how it is replicated.
It supports bidirectional replication, data transformations, subsetting, custom apply
functions, and heterogeneous platforms. It also gives users complete control over the
routing of change records from the primary database to a replica database. This enables
users to build hub and spoke network configurations that can support hundreds of replica
databases.

Streams should be evaluated if one or more of the following conditions are true:

50
• A full active/active site configuration is required including bidirectional changes
• Site configurations are on heterogeneous platforms
• Fine control of information and data sharing are required
• More investment to build an integrated HA solution is available

For disaster recovery, Data Guard is Oracle's recommended disaster recovery solution.

Figure 4-5 shows Streams architecture.

Figure 4-5 Using Streams in an HA Environment

Text description of the illustration maxav019.gif

Choosing the Correct HA Architecture


This section summarizes the advantages of the HA architectures discusses in this chapter
and then provides guidelines for you to choose the correct HA architecture for your
business.

51
Table 4-2 summarizes the advantages of the five basic HA architectures described in this
chapter.

Table 4-2 HA Architecture Advantages

Database HA Architecture Advantages


Database only Reduced downtime for application and Oracle upgrades

Production database on a Flashback capabilities to protect from user errors, and


standalone machine logical corruptions

Online redefinition and reconfiguration to minimize


scheduled downtime

Backup and recovery capabilities

Fast and efficient object re-creation features

Simple and integrated management framework with


Oracle Enterprise Manager

Note: All of these advantages are available for the other


architectures described in this table, but they will not be
repeated.
RAC only RAC HA advantages

RAC production database Transparent to the application

See Also: ""RAC Only" Architecture"


Data Guard only Data Guard HA advantages

Production database (not RAC) Transparent to the application


on the primary site
See Also: ""Data Guard Only" Architecture"
Standby databases on the
secondary or disaster recovery
site
MAA RAC HA advantages

RAC production database on the Data Guard HA advantages


primary site
Transparent to the application
Standby databases on the
secondary or disaster recovery See Also: ""RAC Only" Architecture" and ""Data

52
Database HA Architecture Advantages

site Guard Only" Architecture"


Streams Full active/active configuration

Primary site: Production database Database configurations can be heterogeneous


platforms
Secondary or additional sites:
Database replicated using See Also: "Streams Architecture"
Streams

"RAC only" and "Data Guard only" are the most common Oracle HA architectures, and
each provides very significant HA advantages. MAA provides the most redundant and
robust HA architecture. It prevents, detects, and recovers from different outages within a
small mean time to recover (MTTR), as well as preventing or minimizing downtime for
maintenance. The Streams architecture is an alternative high availability solution, but it
requires more customization and may not be as transparent to the application.

You must consider your service level agreements in your decision about which HA
architecture to implement. To decide whether to implement an Oracle HA architecture
that includes RAC or Data Guard, consider the following questions about your service
level agreements:

1. Does your production system need to be available 24 hours each day, 7 days each
week, 365 days each year?

2. Does your scheduled maintenance currently exceed your service levels?

3. Is disaster recovery required?

Table 4-3 shows the recommended architecture for each set of answers to the questions.

Table 4-3 Service Level Agreements and Recommended HA Architectures

Answer 1 Answer 3
(Local Site Answer 2 (Rolling (Disaster Recommended
HA) Maintenance) Recovery) Architecture
No No No Database only
Yes No No RAC only
No Yes No Data Guard only
No No Yes Data Guard only

53
Answer 1 Answer 3
(Local Site Answer 2 (Rolling (Disaster Recommended
HA) Maintenance) Recovery) Architecture
Yes Yes No MAA
Yes No Yes MAA
No Yes Yes Data Guard only
Yes Yes Yes MAA

If your business requires any of the following, then you should evaluate Oracle Streams
in more depth:

• Full active/active site configuration with bidirectional replication


• Heterogeneous platforms across sites
• Fine control of information and data sharing

Assessing Other Architectures


There are other Oracle and non-Oracle HA solutions. This section focuses on the most
common variants. Table 4-4 describes each alternative HA proposal, its disadvantages
and the recommended Oracle HA architecture.

Table 4-4 Comparison of HA Architectures

Alternative Recommended
Architecture Disadvantages Solutions
Primary site: Oracle No RAC HA capability 1. RAC
database on hardware
cluster No Data Guard capability 2. MAA

Note: This is known as


cold failover.
Primary site: Production No RAC HA capability 1. Data Guard
database
No Data Guard capability 2. MAA
Secondary site: Remote
mirrored database High network utilization

No Oracle switchover and failover


integration

54
Alternative Recommended
Architecture Disadvantages Solutions

Customization required

Remote mirroring solution must be part


of the Oracle Storage Compatibility
Program (OSCP)
Primary site: RAC Performance impact because of latency 1. Data Guard or
production database between nodes Streams
(RAC geo-cluster)
No disaster recovery protection for data 2. MAA
Secondary site: At least or media failures or database corruptions
one node of RAC geo- because there are no separate standby
cluster databases
Primary site: RAC No protection from site disasters and site MAA
production database and failures
local Data Guard
Primary site: Production No RAC HA capabilities
database and local Data
Guard No protection from disasters and site
failures

55
This is a collection of 17 FAQs for Oracle DBA on fundamental concepts. The clear
answers and sample scripts provided can be used as learning tutorials or interview
preparation guides. Topics included in this FAQ are:
1. What Is Oracle?
2. What Is an Oracle Database?
3. What Is an Oracle Instance?
4. What Is a Parameter File?
5. What Is a Server Parameter File?
6. What Is a Initialization Parameter File?
7. What is System Global Area (SGA)?
8. What is Program Global Area (PGA)?
9. What Is a User Account?
10. What Is the Relation of a User Account and a Schema?
11. What Is a User Role?
12. What is a Database Schema?
13. What Is a Static Data Dictionary?
14. What Is a Dynamic Performance View?
15. What Is SQL*Plus?
16. What Is What Is Transport Network Substrate (TNS)?
17. What Is Open Database Communication (ODBC)?
Descriptions of some key concepts are based on Oracle documentations.

What Is Oracle?
Oracle is a company. Oracle is also a database server, which manages data in a very
structured way. It allows users to store and retrieve related data in a multiuser
environment so that many users can concurrently access the same data. All this is
accomplished while delivering high performance. A database server also prevents
unauthorized access and provides efficient solutions for failure recovery.

What Is an Oracle Database?


An Oracle database is a collection of data treated as a big unit in the database server.

What Is an Oracle Instance?


Every running Oracle database is associated with an Oracle instance. When a
database is started on a database server (regardless of the type of computer), Oracle
allocates a memory area called the System Global Area (SGA) and starts one or more
Oracle processes. This combination of the SGA and the Oracle processes is called an
Oracle instance. The memory and processes of an instance manage the associated
database's data efficiently and serve the one or multiple users of the database.

What Is a Parameter File?


A parameter file is a file that contains a list of initialization parameters and a value for
each parameter. You specify initialization parameters in a parameter file that reflect
your particular installation. Oracle supports the following two types of parameter files:

56
• Server Parameter Files - Binary version. Persistent.
• Initialization Parameter Files - Text version. Not persistent.

What Is a Server Parameter File?


A server parameter file is a binary file that acts as a repository for initialization
parameters. The server parameter file can reside on the machine where the Oracle
database server executes. Initialization parameters stored in a server parameter file
are persistent, in that any changes made to the parameters while an instance is
running can persist across instance shutdown and startup.

What Is a Initialization Parameter File?


An initialization parameter file is a text file that contains a list of initialization
parameters. The file should be written in the client's default character set. Sample
initialization parameter files are provided on the Oracle distribution medium for each
operating system. A sample file is sufficient for initial use, but you will probably want to
modify the file to tune the database for best performance. Any changes will take effect
after you completely shut down and restart the instance.

What is System Global Area (SGA)?


The System Global Area (SGA) is a memory area that contains data shared between
all database users such as buffer cache and a shared pool of SQL statements. The
SGA is allocated in memory when an Oracle database instance is started, and any
change in the value will take effect at the next startup.
(Continued on next part...)
Continued from previous part...)

What is Program Global Area (PGA)?


A Program Global Area (PGA) is a memory buffer that is allocated for each
individual database session and it contains session specific information such as
SQL statement data or buffers used for sorting. The value specifies the total
memory allocated by all sessions, and changes will take effect as new sessions
are started.

What Is a User Account?


A user account is identified by a user name and defines the user's attributes,
including the following:
• Password for database authentication
• Privileges and roles
• Default tablespace for database objects
• Default temporary tablespace for query processing work space

What Is the Relation of a User Account and a Schema?


User accounts and schemas have a one-to-one relation. When you create a
user, you are also implicitly creating a schema for that user. A schema is a
logical container for the database objects (such as tables, views, triggers, and

57
so on) that the user creates. The schema name is the same as the user name,
and can be used to unambiguously refer to objects owned by the user.

What Is a User Role?


A user role is a group of privileges. Privileges are assigned to users through
user roles. You create new roles, grant privileges to the roles, and then grant
roles to users.

What is a Database Schema?


A schema is a collection of logical structures of data, or schema objects. A
schema is owned by a database user and has the same name as that user.
Each user owns a single schema. Schema objects can be created and
manipulated with SQL and include: tables, views, and other types of data
objects.

What Is a Database Table?


A database table is a basic unit of data logical storage in an Oracle database.
Data is stored in rows and columns. You define a table with a table name, such
as employees, and a set of columns. You give each column a column name,
such as employee_id, last_name, and job_id; a datatype, such as VARCHAR2,
DATE, or NUMBER; and a width. The width can be predetermined by the
datatype, as in DATE. If columns are of the NUMBER datatype, define
precision and scale instead of width. A row is a collection of column information
corresponding to a single record.

What Is a Table Index?


Index is an optional structure associated with a table that allow SQL statements
to execute more quickly against a table. Just as the index in this manual helps
you locate information faster than if there were no index, an Oracle Database
index provides a faster access path to table data. You can use indexes without
rewriting any queries. Your results are the same, but you see them more
quickly.

What Is an Oracle Tablespace?


An Oracle tablespace is a big unit of logical storage in an Oracle database. It is
managed and used by the Oracle server to store structures data objects, like
tables and indexes.
Each tablespace in an Oracle database consists of one or more files called
datafiles, which are physical structures that conform to the operating system in
which Oracle is running.

What Is an Oracle Data File?


An Oracle data file is a big unit of physical storage in the OS file system. One or
many Oracle data files are organized together to provide physical storage to a
single Oracle tablespace.

58
What Is a Static Data Dictionary?
Data dictionary tables are not directly accessible, but you can access
information in them through data dictionary views. To list the data dictionary
views available to you, query the view DICTIONARY. Many data dictionary
tables have three corresponding views:
• An ALL_ view displays all the information accessible to the current user,
including information from the current user's schema as well as
information from objects in other schemas, if the current user has access
to those objects by way of grants of privileges or roles.
• A DBA_ view displays all relevant information in the entire database.
DBA_ views are intended only for administrators. They can be accessed
only by users with the SELECT ANY TABLE privilege. This privilege is
assigned to the DBA role when the system is initially installed.
• A USER_ view displays all the information from the schema of the current
user. No special privileges are required to query these views.
(Continued on next part...)
Continued from previous part...)

What Is a Dynamic Performance View?


Oracle contains a set of underlying views that are maintained by the database
server and accessible to the database administrator user SYS. These views are
called dynamic performance views because they are continuously updated
while a database is open and in use, and their contents relate primarily to
performance. Although these views appear to be regular database tables, they
are not. These views provide data on internal disk structures and memory
structures. You can select from these views, but you can never update or alter
them.

What Is a Recycle Bin?


Recycle bin is a logical storage to hold the tables that have been dropped from
the database, in case it was dropped in error. Tables in recycle bin can be
recovered back into database by the Flashback Drop action. Oracle database
recycle save the same purpose as the recycle bin on your Windows desktop.
Recycle bin can be turned on or off in the recyclebin=on/off in your parametere
file.

What Is SQL*Plus?
SQL*Plus is an interactive and batch query tool that is installed with every
Oracle Database Server or Client installation. It has a command-line user
interface, a Windows Graphical User Interface (GUI) and the iSQL*Plus web-
based user interface.

What Is Transport Network Substrate (TNS)?

59
TNS, Transport Network Substrate, is a foundation technology, built into the
Oracle Net foundation layer that works with any standard network transport
protocol.

What Is Open Database Communication (ODBC)?


ODBC, Open Database Communication, a standard API (application program
interface) developed by Microsoft for Windows applications to communicate
with database management systems.
Oracle offers ODBC drivers to allow Windows applications to connect Oracle
server through ODBC.

Oracle DBA FAQ - Introduction to Oracle Database 10g Express Edition


By: FYIcenter.com

Part: 1 2 3 4
This is a collection of FAQ for Oracle DBA on Oracle 10g Express
Edition with installation and basic introduction. The clear answers and sample scripts
provided can be used as learning tutorials or interview preparation guides. Topics
included in this FAQ are:
1. What is Oracle Database 10g Express Edition?
2. What Are the Limitations Oracle Database 10g XE?
3. What Operating Systems Are Supported by Oracle Database 10g XE?
4. How To Download Oracle Database 10g XE?
5. How To Install Oracle Database 10g XE?
6. How To Check Your Oracle Database 10g XE Installation?
7. How To Shutdown Your 10g XE Server?
8. How To Start Your 10g XE Server?
9. How Much Memory Your 10g XE Server Is Using?
10. How To Start Your 10g XE Server from Command Line?
11. How To Shutdown Your 10g XE Server from Command Line?
12. How To Unlock the Sample User Account?
13. How To Change System Global Area (SGA)?
14. How To Change Program Global Area (PGA)?
15. What Happens If You Set the SGA Too Low?
16. What To Do If the StartBD.bat Failed to Start the XE Instance?
17. How To Login to the Server without an Instance?
18. How To Use "startup" Command to Start Default Instance?
19. Where Are the Settings Stored for Each Instance?
20. What To Do If the Binary SPFile Is Wrong for the Default Instance?
21. How To Check the Server Version?

What is Oracle Database 10g Express Edition?

60
Based on Oracle Web site: Oracle Database 10g Express Edition (Oracle Database
XE) is an entry-level, small-footprint database based on the Oracle Database 10g
Release 2 code base that's free to develop, deploy, and distribute; fast to download;
and simple to administer. Oracle Database XE is a great starter database for:
• Developers working on PHP, Java, .NET, and Open Source applications
• DBAs who need a free, starter database for training and deployment
• Independent Software Vendors (ISVs) and hardware vendors who want a starter
database to distribute free of charge
• Educational institutions and students who need a free database for their
curriculum

What Are the Limitations Oracle Database 10g XE?


Oracle Database XE is free for runtime usage with the following limitations:
• Supports up to 4GB of user data (in addition to Oracle system data)
• Single instance only of Oracle Database XE on any server
• May be installed on a multiple CPU server, but only executes on one processor
in any server
• May be installed on a server with any amount of memory, but will only use up to
1GB RAM of available memory

What Operating Systems Are Supported by Oracle Database 10g XE?


Oracle Database 10g Express Edition is available for two types of operating Systems:
• Linux x86 - Debian, Mandriva, Novell, Red Hat and Ubuntu
• Microsoft Windows

How To Download Oracle Database 10g XE?


If you want to download a copy of Oracle Database 10g Express Edition, visit
http://www.oracle.com/technology/software/products/database/xe/.
If you are using Windows systems, there are downloads available for you:
• Oracle Database 10g Express Edition (Western European) - Single-byte LATIN1
database for Western European language storage, with the Database Homepage
user interface in English only.
• Oracle Database 10g Express Edition (Universal) - Multi-byte Unicode database
for all language deployment, with the Database Homepage user interface
available in the following languages: Brazilian Portuguese, Chinese (Simplified
and Traditional), English, French, German, Italian, Japanese, Korean and
Spanish.
• Oracle Database 10g Express Client
You need to download the universal edition, OracleXEUniv.exe, (216,933,372 bytes)
and client package, OracleXEClient.exe (30,943,220 bytes).

How To Install Oracle Database 10g XE?


To install 10g universal edition, double click, OracleXEUniv.exe, the install wizard
starts. It will guide you to finish the installation process. You should take notes about:
• The SYSTEM password you selecte: fyicenter.
• Database server port: 1521.
• Database HTTP port: 8080.

61
• MS Transaction Server port: 2030.
• The directory where 10g XE is installed: \oraclexe\
• Hard disk space taken: 1655MB.

How To Check Your Oracle Database 10g XE Installation?


If you want to check your fresh installation of 10g Express Edition without using any
special client programs, you can use a Web browser with this address,
http://localhost:8080/apex/.
You will see the login page. Enter SYSTEM as the user name, and the password
(fyicenter), you selected during the installation to log into the server.
Visit different areas on your 10g XE server home page to make sure your server is
running OK.
You can also get to your 10g XE server home page by going through the start menu.
Select All Programs, then Oracle Database 10g Express Edition, and then Go To
Database Home Page.

How To Shutdown Your 10g XE Server?


If you want to shutdown your 10g Express Edition server, go to the Services manager
in the control panel. You will a service called OracleServiceXE, which represents your
10g Express Edition server.
Select OracleServiceXE, and use the right mouse click to stop this service. This will
shutdown your 10g Express Edition server.
You can also shutdown your 10g XE server through the start menu. Select All
Programs, then Oracle Database 10g Express Edition, and then Stop Database.
(Continued on next part...)

(Continued from previous part...)

How To Start Your 10g XE Server?


Go to the Start menu, select All Programs, Oracle Database 10g Express Edition, and
Start Database.

How Much Memory Your 10g XE Server Is Using?


Your 10g XE Server is using about 180MB of memory even there is no users on the
server. The server memory usage is displayed on your server home page, if you log in
as SYSTEM.

How To Start Your 10g XE Server from Command Line?


You can start your 10g XE server from command line by:
• Open a command line window.
• Change directory to \oraclexe\app\oracle\product\10.2.0\server\BIN\.
• Run StartDB.bat.
The batch file StartDB.bat contains:
net start OracleXETNSListener
net start OracleServiceXE

62
@oradim -startup -sid XE -starttype inst > nul 2>&1

How To Shutdown Your 10g XE Server from Command Line?


You can shutdown your 10g XE server from command line by:
• Open a command line window.
• Change directory to \oraclexe\app\oracle\product\10.2.0\server\BIN\.
• Run StopDB.bat.
The batch file StopDB.bat contains:
net stop OracleServiceXE

How To Unlock the Sample User Account?


Your 10g XE server comes with a sample database user account called HR. But this
account is locked. You must unlock it before you can use it:
• Log into the server home page as SYSTEM.
• Click the Administration icon, and then click Database Users.
• Click the HR schema icon to display the user information for HR.
• Enter a new password (hr) for HR, and change the status to Unlocked.
• Click Alter User to save the changes.
Now user account HR is ready to use.

How To Change System Global Area (SGA)?


Your 10g XE server has a default setting for System Global Area (SGA) of 140MB.
The SGA size can be changed to a new value depending on how many concurrent
sessions connecting to your server. If you are running this server just for yourself to
improve your DBA skill, you should change the SGA size to 32MB by:
• Log into the server home page as SYSTEM.
• Go to Administration, then Memory.
• Click Configure SGA.
• Enter the new memory size: 32
• Click Apply Changes to save the changes.
• Re-start your server.

How To Change Program Global Area (PGA)?


Your 10g XE server has a default setting for Program Global Area (PGA) of 40MB. The
PGA size can be changed to a new value depending on how much data a single
session should be allocated. If you think your session will be short with a small amount
of data, you should change the PGA size to 16MB by:
• Log into the server home page as SYSTEM.
• Go to Administration, then Memory.
• Click Configure PGA.
• Enter the new memory size: 16
• Click Apply Changes to save the changes.
• Re-start your server.

What Happens If You Set the SGA Too Low?

63
Let's you made a mistake and changed to SGA to 16MB from the SYSTEM admin
home page. When you run the batch file StartDB.bat, it will return a message saying
server stated. However, if you try to connect to your server home page:
http://localhost:8080/apex/, you will get no response. Why? Your server is running, but
the default instance XE was not started.
If you go the Control Panel and Services, you will see service OracleServiceXE is
listed not in the running status.
(Continued on next part...)

Continued from previous part...)

What To Do If the StartBD.bat Failed to Start the XE Instance?


If StartBD.bat failed to start the XE instance, you need to try to start the instance with
other approaches to get detail error messages on why the instance can not be started.
One good approach to start the default instance is to use SQL*Plus. Here is how to
use SQL*Plus to start the default instance in a command window:
>cd (OracleXE home directory)
>.\bin\startdb
>.\bin\sqlplus
Enter user-name: SYSTEM
Enter password: fyicenter
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
The first "cd" is to move the current directory the 10g XE home directory. The second
command ".\bin\startdb" is to make sure the TNS listener is running. The third
command ".\bin\sqlplus" launches SQL*Plus. The error message "ORA-27101" tells
you that there is a memory problem with the default instance.
So you can not use the normal login process to the server without a good instance.
See other tips on how to log into a server without any instance.

How To Login to the Server without an Instance?


If your default instance is in trouble, and you can not use the normal login process to
reach the server, you can use a special login to log into the server without any
instance. Here is how to use SQL*Plus to log in as as a system BDA:
>cd (OracleXE home directory)
>.\bin\startdb
>.\bin\sqlplus
Enter user-name: SYSTEM/fyicenter AS SYSDBA
Connected to an idle instance

SQL> show instance


instance "local"
The trick is to put user name, password and login options in a single string as the user
name. "AS SYSDBA" tells the server to not start any instance, and connect the session
the idle instance.

64
Log in as SYSDBA is very useful for performing DBA tasks.

How To Use "startup" Command to Start Default Instance?


If you logged in to the server as a SYSDBA, you start the default instance with the
"startup" command. Here is how to start the default instance in SQL*Plus in SYSDBA
mode:
>.\bin\sqlplus
Enter user-name: SYSTEM/fyicenter AS SYSDBA
Connected to an idle instance

SQL> show instance


instance "local"

SQL> startup
ORA-00821: Specified value of sga_target 16M is too small,
needs to be at least 20M
Now the server is telling you more details about the memory problem on your default
instance: your SGA setting of 16MB is too small. It must be increased to at least
20MB.

Where Are the Settings Stored for Each Instance?


Settings for each instance are stored in a file called Server Parameter File (SPFile).
Oracle supports two types of parameter files, Text type, and Binary type. parameter
files should be located in $ORACLE_HOME\database directory. A parameter file
should be named like "init$SID.ora", where $SID is the instance name.

What To Do If the Binary SPFile Is Wrong for the Default Instance?


Let's say the SPFile for the default instance is a binary file, and some settings are
wrong in the SPFile, like SGA setting is bellow 20MB, how do you change a setting in
the binary file? This seems to be a hard task, because the binary SPFile is not allowed
to be edited manually. It needs to be updated by the server with instance started. But
you can not start the instance because the SPFile has a wrong setting.
One way to solve the problem is to stop using the binary SPFile, and use a text version
of the a parameter file to start the instance. Here is an example of how to use the
backup copy (text version) of the parameter file for the default instance to start the
instance:
>.\bin\sqlplus
Enter user-name: SYSTEM/fyicenter AS SYSDBA
Connected to an idle instance

SQL> startup
PFILE=$ORACLE_HOME\config\scripts\initXETemp.ora;

ORACLE instance started.

Total System Global Area 146800640 bytes


Fixed Size 1286220 bytes

65
Variable Size 58724276 bytes
Database Buffers 83886080 bytes
Redo Buffers 2904064 bytes
Database mounted.
Database opened.
As you can see, 10g XE is distributed with a backup copy of the parameter file for the
default instance XE. The "startup" can take an option called PFILE to let you use a
SPFILE from any location. The default instance is running correctly now.
(Continued on next part...)
(Continued from previous part...)

How To Check the Server Version?


Oracle server sersion information is stored in a table called:
PRODUCT_COMPONENT_VERSION. You can use a simple SELECT statement to
view the version information like this:
>.\bin\sqlplus
Enter user-name: SYSTEM/fyicenter AS SYSDBA
Connected to an idle instance

SQL> COL PRODUCT FORMAT A35


SQL> COL VERSION FORMAT A15
SQL> COL STATUS FORMAT A15
SQL> SELECT * FROM PRODUCT_COMPONENT_VERSION;

PRODUCT VERSION STATUS


----------------------------------- ----------- ----------
NLSRTL 10.2.0.1.0 Production
Oracle Database 10g Express Edition 10.2.0.1.0 Product
PL/SQL 10.2.0.1.0 Production
TNS for 32-bit Windows: 10.2.0.1.0 Production

66
Oracle DBA FAQ - Managing Oracle Tablespaces and Data Files
By: FYIcenter.com

Part: 1 2 3 4
A collection of 19 FAQs on creating and managing tablespaces
and data files. Clear answers are provided with tutorial exercises on creating
and dropping tablespaces; listing available tablespaces; creating and dropping
data files; setting tablespaces and data files offline; removing corrupted data
files. Topics included in this FAQ are:
1. What Is an Oracle Tablespace?
2. What Is an Oracle Data File?
3. How a Tablespace Is Related to Data Files?
4. How a Database Is Related to Tablespaces?
5. How To View the Tablespaces in the Current Database?
6. What Are the Predefined Tablespaces in a Database?
7. How To View the Data Files in the Current Database?
8. How To Create a new Oracle Data File?
9. How To Create a New Tablespace?
10. How To Rename a Tablespace?
11. How To Drop a Tablespace?
12. What Happens to the Data Files If a Tablespace Is Dropped?
13. How To Create a Table in a Specific Tablespace?
14. How To See Free Space of Each Tablespace?
15. How To Bring a Tablespace Offline?
16. How To Bring a Tablespace Online?
17. How To Add Another Datafile to a Tablespace?
18. What Happens If You Lost a Data File?
19. How Remove Data Files befor opening a Database?
Sample scripts used in this FAQ assumes that you are connected to the server
with the SYSTEM user account on the default database instance XE. See other
FAQ collections on how to connect to the server.

What Is an Oracle Tablespace?


An Oracle tablespace is a big unit of logical storage in an Oracle database. It is
managed and used by the Oracle server to store structures data objects, like
tables and indexes.

What Is an Oracle Data File?

67
An Oracle data file is a big unit of physical storage in the OS file system. One or
many Oracle data files are organized together to provide physical storage to a
single Oracle tablespace.

How a Tablespace Is Related to Data Files?


Each tablespace in an Oracle database consists of one or more files called
datafiles, which are physical structures that conform to the operating system in
which Oracle is running.

How a Database Is Related to Tablespaces?


A database's data is collectively stored in the datafiles that constitute each
tablespace of the database. For example, the simplest Oracle database would
have one tablespace and one datafile. Another database can have three
tablespaces, each consisting of two datafiles (for a total of six datafiles).

How To View the Tablespaces in the Current Database?


If you want to get a list of all tablespaces used in the current database instance,
you can use the DBA_TABLESPACES view as shown in the following SQL
script example:
SQL> connect SYSTEM/fyicenter
Connected.

SQL> SELECT TABLESPACE_NAME, STATUS, CONTENTS


2 FROM USER_TABLESPACES;
TABLESPACE_NAME STATUS CONTENTS
------------------------------ --------- ---------
SYSTEM ONLINE PERMANENT
UNDO ONLINE UNDO
SYSAUX ONLINE PERMANENT
TEMP ONLINE TEMPORARY
USERS ONLINE PERMANENT

What Are the Predefined Tablespaces in a Database?


When you create a new database, Oracle server will create 4 required
tablespaces for the new database:
• SYSTEM Tablespace - Every Oracle database contains a tablespace
named SYSTEM, which Oracle creates automatically when the database
is created. The SYSTEM tablespace is always online when the database
is open.
• SYSAUX Tablespace - The SYSAUX tablespace was installed as an
auxiliary tablespace to the SYSTEM tablespace when you created your
database. Some database components that formerly created and used
separate tablespaces now occupy the SYSAUX tablespace.

68
• UNDO Tablespace - UNDO tablespaces are special tablespaces used
solely for storing undo information. You cannot create any other segment
types (for example, tables or indexes) in undo tablespaces. Each
database contains zero or more undo tablespaces. In automatic undo
management mode, each Oracle instance is assigned one (and only one)
undo tablespace. Undo data is managed within an undo tablespace using
undo segments that are automatically created and maintained by Oracle.
• TEMP Tablespace - When the SYSTEM tablespace is locally managed,
you must define at least one default temporary tablespace when creating
a database. A locally managed SYSTEM tablespace cannot be used for
default temporary storage.

How To View the Data Files in the Current Database?


If you want to get a list of all tablespaces used in the current database instance,
you can use the DBA_TABLESPACES view as shown in the following SQL
script example:
SQL> connect SYSTEM/fyicenter
Connected.

SQL> col tablespace_name format a16;


SQL> col file_name format a36;
SQL> SELECT TABLESPACE_NAME, FILE_NAME, BYTES
2 FROM DBA_DATA_FILES;
TABLESPACE_NAME FILE_NAME BYTES
--------------- ------------------------------- ---------
USERS \ORACLEXE\ORADATA\XE\USERS.DBF 104857600
SYSAUX \ORACLEXE\ORADATA\XE\SYSAUX.DBF 461373440
UNDO \ORACLEXE\ORADATA\XE\UNDO.DBF 94371840
SYSTEM \ORACLEXE\ORADATA\XE\SYSTEM.DBF 356515840
(Continued on next part...)

Continued from previous part...)

How To Create a new Oracle Data File?


There is no dedicated statement to create a data file. Data files are created as part of
statements that manages other data structures, like tablespace and database.

How To Create a New Tablespace?


If you want a new dataspace, you can use the CREATE TABLESPACE ... DATAFILE
statement as shown in the following script:
SQL> CREATE TABLESPACE my_space
2 DATAFILE '/temp/my_space.dbf' SIZE 10M;
Tablespace created.

69
SQL> SELECT TABLESPACE_NAME, STATUS, CONTENTS
2 FROM USER_TABLESPACES;
TABLESPACE_NAME STATUS CONTENTS
---------------- --------------- ---------
SYSTEM ONLINE PERMANENT
UNDO ONLINE UNDO
SYSAUX ONLINE PERMANENT
TEMP ONLINE TEMPORARY
USERS ONLINE PERMANENT
MY_SPACE ONLINE PERMANENT

SQL> SELECT TABLESPACE_NAME, FILE_NAME, BYTES


2 FROM DBA_DATA_FILES;
TABLESPACE_NAME FILE_NAME BYTES
--------------- -------------------------------- ---------
USERS \ORACLEXE\ORADATA\XE\USERS.DBF 104857600
SYSAUX \ORACLEXE\ORADATA\XE\SYSAUX.DBF 461373440
UNDO \ORACLEXE\ORADATA\XE\UNDO.DBF 94371840
SYSTEM \ORACLEXE\ORADATA\XE\SYSTEM.DBF 356515840
MY_SPACE \TEMP\MY_SPACE.DBF 10485760
So one statement created two structures: a tablespace and a data file. If you check
your file system with Windows file explorer, you will see the data file is located in the
\temp directory of. The data file size is about 10MB. Its contents should be blank and
full of \x00 at this time.

How To Rename a Tablespace?


You can easily rename a tablespace by using the ALTER TABLESPACE ... RENAME
TO statement as shown in the example below:
SQL> CREATE TABLESPACE my_space
2 DATAFILE '/temp/my_space.dbf' SIZE 10M;
Tablespace created.

SQL> ALTER TABLESPACE my_space RENAME TO your_space;


Tablespace created.

SQL> SELECT TABLESPACE_NAME, STATUS, CONTENTS


2 FROM USER_TABLESPACES;
TABLESPACE_NAME STATUS CONTENTS
---------------- --------------- ---------
SYSTEM ONLINE PERMANENT
UNDO ONLINE UNDO
SYSAUX ONLINE PERMANENT
TEMP ONLINE TEMPORARY
USERS ONLINE PERMANENT
YOUR_SPACE ONLINE PERMANENT

70
How To Drop a Tablespace?
If you have an existing tablespace and you don't want it anymore. You can delete a
tablespace by using the DROP TABLESPACE statement as shown in the example
below:
SQL> CREATE TABLESPACE my_space
2 DATAFILE '/temp/my_space.dbf' SIZE 10M;
Tablespace created.

SQL> DROP TABLESPACE my_space;


Tablespace dropped.

What Happens to the Data Files If a Tablespace Is Dropped?


If a tablespace is dropped, what happens to its data files? By default, data files will
remain in OS file system, even if the tablespace they are mapped is dropped. Of
course, you delete the data files using OS commands, if they are no longer needed.
Another way of deleting data files is to use the INCLUDING clause in the DROP
TABLESPACE statement. Here is a SQL sample script:
SQL> CREATE TABLESPACE my_space
2 DATAFILE '/temp/my_space.dbf' SIZE 10M;
Tablespace created.

SQL> DROP TABLESPACE my_space INCLUDING CONTENTS


2 AND DATAFILES;
Tablespace dropped.
With the INCLUDING CONTENTS AND DATAFILES clause, all contents and mapped
data files are also deleted.
(Continued on next part...)

Continued from previous part...)

How To Create a Table in a Specific Tablespace?


After you have created a new tablespace, you can give it to your users for them to
create tables in the new tablespace. To create a table in a specific tablespace, you
need to use the TABLESPACE clause in the CREATE TABLE statement. Here is a
sample script:
SQL> connect SYSTEM/fyicenter
Connected.

SQL> CREATE TABLESPACE my_space


2 DATAFILE '/temp/my_space.dbf' SIZE 10M;
Tablespace created.

SQL> connect HR/fyicenter


Connected.

71
SQL> CREATE TABLE my_team TABLESPACE my_space
2 AS SELECT * FROM employees;
Table created.

SQL> SELECT table_name, tablespace_name, num_rows


2 FROM USER_TABLES
3 WHERE tablespace_name in ('USERS', 'MY_SPACE');

TABLE_NAME TABLESPACE_NAME NUM_ROWS


------------------------------ ---------------- ----------
MY_TEAM MY_SPACE -
EMPLOYEES USERS 107
...

How To See Free Space of Each Tablespace?


One of the important DBA tasks is to watch the storage usage of all the tablespaces to
make sure there are enough free space in each tablespace for database applications
to function properly. Free space information can be monitored through the
USER_FREE_SPACE view. Each record in USER_FREE_SPACE represents an
extent, a contiguous area of space, of free space in a data file of a tablespace.
Here is SQL script example on how to see free space of a tablespace:
SQL> connect HR/fyicenter
Connected.

SQL> SELECT TABLESPACE_NAME, FILE_ID, BYTES


2 FROM USER_FREE_SPACE
3 WHERE TABLESPAE_NAME IN ('USERS', 'MY_SPACE');
TABLESPACE_NAME FILE_ID BYTES
------------------------------ ---------- ----------
MY_SPACE 5 10354688
USERS 4 101974016
USERS 4 65536
USERS 4 65536
USERS 4 65536
USERS 4 65536
USERS 4 65536
USERS 4 65536
USERS 4 65536
USERS 4 65536
USERS 4 65536
USERS 4 65536
USERS 4 65536
USERS 4 65536
This tells us that:
• MY_SPACE has a single free extent of 10MB.

72
• USERS has one big free extent of 100MB, and many small free extents of 64KB.

How To Bring a Tablespace Offline?


If you want to stop users using a tablespace, you can bring it offline using the ALTER
TABLESPACE ... OFFLINE statement as shown in the following script:
SQL> connect HR/fyicenter
Connected.

SQL> CREATE TABLESPACE my_space


2 DATAFILE '/temp/my_space.dbf' SIZE 10M;
Tablespace created.

SQL> ALTER TABLESPACE my_space OFFLINE NORMAL;


Tablespace altered.
After bringing a tablespace offline, you can backup or rename the data file safely.
(Continued on next part...)
(Continued from previous part...)

How To Bring a Tablespace Online?


If you have brought a tablespace offline, now you want to make it available to users again, you
can use the ALTER TABLESPACE ... ONLINE statement as shown in the following script:
SQL> connect HR/fyicenter

SQL> CREATE TABLESPACE my_space


2 DATAFILE '/temp/my_space.dbf' SIZE 10M;
Tablespace created.

SQL> ALTER TABLESPACE my_space OFFLINE NORMAL;


Tablespace altered.

...

SQL> ALTER TABLESPACE my_space ONLINE;


Tablespace altered.

How To Add Another Datafile to a Tablespace?


If you created a tablespace with a data file a month ago, now 80% of the data file is used, you
should add another data file to the tablespace. This can be done by using the ALTER
TABLESPACE ... ADD DATAFILE statement. See the following sample script:
SQL> connect HR/fyicenter

SQL> CREATE TABLESPACE my_space


2 DATAFILE '/temp/my_space.dbf' SIZE 10M;
Tablespace created.

SQL> ALTER TABLESPACE my_space


2 DATAFILE '/temp/my_space_2.dbf' SIZE 5M;
Tablespace altered.

73
SQL> SELECT TABLESPACE_NAME, FILE_NAME, BYTES
2 FROM DBA_DATA_FILES;
TABLESPACE_NAME FILE_NAME BYTES
--------------- --------------------------------- ---------
USERS C:\ORACLEXE\ORADATA\XE\USERS.DBF 104857600
SYSAUX C:\ORACLEXE\ORADATA\XE\SYSAUX.DBF 461373440
UNDO C:\ORACLEXE\ORADATA\XE\UNDO.DBF 94371840
SYSTEM C:\ORACLEXE\ORADATA\XE\SYSTEM.DBF 356515840
MY_SPACE C:\TEMP\MY_SPACE.DBF 10485760
MY_SPACE C:\TEMP\MY_SPACE_2.DBF 5242880

SQL> SELECT TABLESPACE_NAME, FILE_ID, BYTES


2 FROM USER_FREE_SPACE
3 WHERE TABLESPAE_NAME IN ('MY_SPACE');
TABLESPACE_NAME FILE_ID BYTES
------------------------------ ---------- ----------
MY_SPACE 6 5177344
MY_SPACE 5 10354688
This script created one tablespace with two data files.

What Happens If You Lost a Data File?


After you shuting down an Oracle database, you accidently deleted a data file from the
operating system. If you try to start the database again you will get error when Oracle tries to
open the database after mounting the database. The following tutorial examples shows you
what will happen if the data file c:\temp\my_space.dbf is deleted. Oracle can still start the
database instance and mount the database. But it will fail on openning the database as shown
below in a SQL*Plus session:
>sqlplus /nolog

SQL> connect SYSTEM/fyicenter AS SYSDBA

SQL> STARTUP
ORACLE instance started.

Total System Global Area 100663296 bytes


Fixed Size 1285956 bytes
Variable Size 58720444 bytes
Database Buffers 37748736 bytes
Redo Buffers 2908160 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 5 - see DBWR
trace file
ORA-01110: data file 5: 'C:\TEMP\MY_SPACE.DBF'

SQL> SHUTDOWN;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.

74
How Remove Data Files befor opening a Database?
Let's say you have a corrupted data file or lost a data file. Oracle can mount the database. But
it will not open the database. What you can do is to set the bad data file as offline befor opening
the database. The tutorial exercise shows you how to set two data files offline and open the
database without them:
>sqlplus /nolog

SQL> connect SYSTEM/fyicenter AS SYSDBA

SQL> STARTUP MOUNT;


ORACLE instance started.

Total System Global Area 100663296 bytes


Fixed Size 1285956 bytes
Variable Size 58720444 bytes
Database Buffers 37748736 bytes
Redo Buffers 2908160 bytes
Database mounted.

SQL> ALTER DATABASE DATAFILE '\temp\my_space.dbf'


2 OFFLINE DROP;
Database altered.

SQL> ALTER DATABASE DATAFILE '\temp\my_space_2.dbf'


2 OFFLINE DROP;
Database altered.

SQL> ALTER DATABASE OPEN;


Database altered.

SQL> col file_name format a36;


SQL> col tablespace_name format a16;
SQL> SELECT TABLESPACE_NAME, FILE_NAME, BYTES
2 FROM DBA_DATA_FILES;

TABLESPACE_NAME FILE_NAME BYTES


--------------- --------------------------------- ---------
USERS C:\ORACLEXE\ORADATA\XE\USERS.DBF 104857600
SYSAUX C:\ORACLEXE\ORADATA\XE\SYSAUX.DBF 503316480
UNDO C:\ORACLEXE\ORADATA\XE\UNDO.DBF 94371840
SYSTEM C:\ORACLEXE\ORADATA\XE\SYSTEM.DBF 367001600
MY_SPACE C:\TEMP\MY_SPACE.DBF
MY_SPACE C:\TEMP\MY_SPACE_2.DBF
At this point, if you don't care about the data in MY_SPACE, you can drop it now with the
database opened.

75
In order to check client connection - $lsnrctl is correct is correct or not?
ravi: no..it not correct ?what is meaning of client connection?
Sent at 11:26 AM on Thursday
ravi: 1. where is the client install...in same unix server or different unix server?
Sent at 11:28 AM on Thursday
me: if it is on same unix server
Sent at 11:33 AM on Thursday
ravi: yes..1. check database availability..
2. check listener status..
3. then u can check tnsping command..
4. you can also check. tns entry
me: if the client is connected on different UNIX server
Sent at 11:42 AM on Thursday
ravi: simple...1) check database availability 2) tnsping command ex:- tnsping
database1
me: right
If I change the block size then how it will affect the performance of database?
Sent at 11:48 AM on Thursday
ravi: why we want change..every thing depend on which server is using? no it
will not affect...
Sent at 11:52 AM on Thursday
me: if i want to change the block size so that database will perform better and
also to calculate the future database spacing requirement
ravi: there you have also look into os block size..
there is a big concept of pagging and swapping..
it is a work of senior DBA..
? not as a 4 yrs exp..
me: he asked me this question yesterday at 4 yrs exp
he was also talking about os block size also
Sent at 12:00 PM on Thursday
ravi: that...right..we can't change the DB block size..but before changing you
have to look OS block size first..
Sent at 12:01 PM on Thursday
ravi: if your OS block size is 8 k then you can set your DB block size as equal of
OS block size or multiple of OS block size..
Sent at 12:02 PM on Thursday
ravi: any query..
?
Sent at 12:05 PM on Thursday
me: what is the concept of pageing and swapping

76
ravi ranjan to me
show details 5:20 PM (23 hours ago)

2:20 PM me: hi
important
what is the difference apps dba and core dba
2:21 PM what applications are managed by application dba and they are
managed
2:22 PM ravi: ok..App DBA means .you have to knowledge about application like
PL-SQL , and oracle application ...but in core DBA ..you have to managed only
oracle database..
2:23 PM me: oracle application like
ravi: Application menas they managed Oracle application and database also..so
Application DBA demands to much package..
You can se front end that use oracle database..
2:24 PM me: which is better apps dba / core dba.which has higher demand
ravi: Both are better..Apps DBA is good.
2:25 PM me: ok
thank you
i ahve technical round with Accenture for apps dba
ravi: Core DBA ---(1)
me: 2.30 pm
2:26 PM ravi: App DBA + Core DBA = App DBA
me: it has a dual advantage.
ravi: If you will give interview of Apps DBA then they will asl lots of things related
to application
2:27 PM yes..that why .they demands 12+ package
me: but i have told that i am working as core dba
but ready to shift to apps dba
2:28 PM what all is expected from an apps dba-related to application like PL/SQL
/what applications D2K
2:30 PM ravi: every thing like Oracle developer
it is a combination og Developer +DBA
2:31 PM me: ok

16 minutes

2:47 PM me: hi
you have solved the quessionare
2:48 PM when you plan to solve and give it to me

77
12 minutes

3:00 PM ravi: currently I am very busy as I told, one Sr DBA has been left. if i will
free then i will solve that paper

40 minutes

3:40 PM me: fine

45 minutes

4:26 PM me: i have a table emp and it has 150 child table. i have to drop the emp
table with all child table in one sysntax.
4:27 PM drop table emp inclusive child tables
what is the correct syntax
ravi: sorry..I don't have idea about child table...
4:28 PM me: what are different types of indexes/constraints/tables
good
4:29 PM it means that there are associated child records in the base table that
would't allow you to delete the base /primary table.
4:30 PM on what data structures i can apply indexes. tables, views, metviews.
Can i apply indexes on views? Yes/no
4:35 PM ravi: yes..

7 minutes

4:42 PM me: I have applied indexes on views and can i save the result of the
view that is retrieved
4:43 PM applied with index
4:44 PM what is the concept of high water mark
Difference between DDL/DML/Drop statements
4:45 PM * whether the data & structure both will be deleted and what i can recall
data / structure.
4:47 PM *a query is run on 2-3 tables, & data is retrieved from 2-3 tables. Earlier
the query use to run 15 seconds, but now it takes 1 hour to run. As a DBA what
all appropriate steps you will take? why such a thing happen.
4:48 PM What is default optimzer mode in 10G.If you choose parameter it will
also use CBO as default optimizer.
RBO is almost obslete paramer now.
4:50 PM ravi: All are nice question but if you will give interview as a senior DBA..
4:51 PM HWM :- there isnice concept in oracle...
we have to learn saome basic thing
me: *some blocks are corrupted. How will i find that which blocks are corrupted
V$block_corruption, how will i rectify those blocks. If block is corrupted then i will
not be able to retrieve the data. How will i repair corrupted blocks. What are

78
steps involved in that. I will retrieve corrupted block no. and i will retrieve data
from redo log and archive log
4:52 PM ravi: Read this concept for HWM :- just create a table with 1,000,000
rows (or create any table with a large number of rows), and then execute a
SELECT COUNT(*) from this table. Now, DELETE every row in it and you will
find that the SELECT COUNT(*) takes just as long (or longer, if you need to
clean out the block! Refer to the 'Block Cleanout' section of Chapter 9) to count 0
rows as it did to count 1,000,000. This is because Oracle is busy reading all of
the blocks below the HWM to see if they contain data. You should compare this
to what happens if you used TRUNCATE on the table instead of deleting each
individual row. TRUNCATE will reset the HWM of a table back to 'zero' and will
truncate the associated indexes on the table as well. If you plan on deleting every
row in a table, TRUNCATE.
4:54 PM there is a good concept in DB1 for HWH
HWM
4:56 PM me: HWH full form
4:57 PM ravi: High Water Mark
HWM
5:00 PM me: *I have made use of expalin plan. Where is the analyses report
stored and from where it is retrieved. Plan_table syntax that is being used.I can
fetech the statistics report from table_ analysis.
5:02 PM *DBA will analyze the table It is a routine analysis that is being done as
a part of dba activity. There are some reasons behind it. Why dba analyze the
table on rotine basis. In production environment table_analysis is a part of dba
activity.
5:04 PM *whether you have worked on rebuilding of indexes. Suppose 31 jan
query retrieve 1 min but the client experienced told to rebuild indexes. Now it is
taking 3 mins. What you will do as a dba.
5:06 PM ravi: May be HWM is the caused of same issue
so to resolve same issue ..move the table and rebuild ..
then it will not take much time..

5 minutes

5:12 PM me: answer - the query that is written is optimized. Explain plan is used.
Index rebuild. Choose- CBO will be the default optimizer mode. When the query
is runned again, it will rewrite the analysis based upon recent changes.

6 minutes

5:18 PM ravi: it a documented steps not a real environments work..yes you can
do all above step if you will give interview after 5 or 6 yrs experience..
How many experience you are giving as a DBA?
5:19 PM me: 4 years
5:20 PM if you have answers to my questions do provide it

79
ravi: ok...how many yrs you have worked as a DBA..on real environments..
ok..sure..
5:21 PM me: oracle dba knowledge i have try to update it
5:22 PM ravi: never use 4+..bcoz it will be very tough
5:23 PM one of the friend joined wipro on 4+ yrs ..before..

80
81
82
83
84
85