Oracle DBA ALL Interview questions and answers..

Oracle DBA ALL Interview questions and answers..

Flash back interview questions:
**************************************


Questions you always wanted to ask about Flashback Database…
Nov 6, 2009 / By André Araujo

Tags: Oracle

Last Friday in the Sydney Oracle Meetup I talked about Oracle Flashback technology and how it helps to reduce downtime. The session generated great interest among the attendees, which led to interesting discussions and many questions about the subject.

Some of the questions couldn’t be answered during the meeting so I’ve followed up on them and I’m posting the answers here since they may be of interest for many others.

Q: Is there a separate background process for writing flashback logs?

A: Yes. RVWR (Recovery Writer, a.k.a Flashback Writer) was introduced in Oracle 10g to write flashback data from the Flashback Buffer in the SGA to the flashback database logs on disk.

Q: Do I need to shutdown and mount the database to turn flashback on?

A: ALTER DATABASE FLASHBACK ON is an online operation in 11g Release 2. In 10g Release 2 the database must be mounted, but not open.

Once flashback is turned on Oracle starts to save the before-images of the database blocks before they are changed. This guarantees that the database can be flashbacked to the exact point-in-time when the flashback mode was turned on.

Q: What happens if RVWR cannot write to disk?

A: It depends on the context where the write error occurs:

If there’s a Guaranteed Restore Point, the database crashes to ensure the restore point guarantee is not voided.
If there isn’t a Guaranteed Restore Point and it’s a primary database, the Flashback Mode will be automatically turned off for the database, which will continued to operate normally.
If there isn’t a Guaranteed Restore Point and it’s a standby database, the database will hang until the cause of the write failure is fixed.

Q: Is it possible to specify the size of the Flashback Buffer in the SGA?

A: Yes, but indirectly. The size of the Flashback Buffer is set to 2 * LOG_BUFFER.
For performance reasons, it’s recommended to set LOG_BUFFER to at least 8MB for
databases running in Flashback Mode.

UPDATE: For large 11.1.0.7+ databases with more than a 4GB SGA, you may consider setting LOG_BUFFER to values in the range of 32-64 MB.

Q: Can RMAN be used to backup flashback logs?

A: No. Flashback Logs are not backed up. Even if the command BACKUP RECOVERY AREA is used to backup the contents of the FRA to tape only the following file types are backed up: full and incremental backup sets, control file autobackups, datafile copies, and archived redo logs.

Flashback Logs are considered to be transient files and cannot be backed up by RMAN. They are not needed for media recovery.

Q: When are the flashback logs deleted?

A: Flashback logs are managed by Oracle only. Oracle will try to keep as much Flashback logs as needed to satisfy the DB_FLASHBACK_RETENTION_TARGET parameter. However, if there’s space pressure in the Flash Recovery Area (FRA), flashback logs may be deleted to make room for other things, like backups and archived logs, for example.

If the fast recovery area has enough space, then a flashback log is created whenever necessary to satisfy the flashback retention target.
If a flashback log is old enough that it is no longer needed to satisfy the flashback retention target, then a flashback log is reused.
If the database must create a new flashback log and the fast recovery area is full or there is no disk space, then the oldest flashback log is reused instead.
If the fast recovery area is full, then an archived redo log that is reclaimable according to the FRA rules may be automatically deleted by the fast recovery area to make space for other files. In this case, any flashback logs that would require the use of that redo log file for the use of FLASHBACK DATABASE are also deleted.
No file in the fast recovery area is eligible for deletion if it is required to satisfy a guaranteed restore point. Thus, retention of flashback logs and other files required to satisfy the guaranteed restore point, in addition to files required to satisfy the backup retention policy, can cause the fast recovery area to fill completely.
Other than that flashback logs are deleted according to the below:

When flashback mode is turned off all flashback logs are deleted ONLY if there’s no guaranteed restore points. If there’s at least one guaranteed restore point, no flashback logs are deleted.
When the oldest guaranteed restore point is deleted and flashback mode is off, all flashback logs older than the second oldest guaranteed restore point are deleted. If flashback mode is on for the database OR the guaranteed restore point is not the oldest no flashback logs are deleted.

Q: How to list restore points in RMAN?

A: In RMAN you can use the LIST RESTORE POINT [ALL|restore_point_name] command. If you use a recovery catalog you can use the view RC_RESTORE_POINT in the recovery catalog repository, or the command the V$RESTORE_POINT in the target database..

Q: After flashback’ing to a point-in-time before a RESETLOGS operation is it possible to flash forward to the incarnation after the RESETLOGS?

A: Yes, it’s perfectly possible.

Q: Can you see the progress of a FLASHBACK DATABASE operation?

A: Yes, you can. During a FLASHBACK DATABASE operation you can query V$SESSION_LONGOPS from another session to see the progress of the flashback.

The FLASHBACK DATABASE operation has two distinct phases: the actual flashback and the media recovery that happens afterwards to bring the database to a consistent state.

While the actual flashback is running you’ll see the following message in V$SESSION_LONGOPS, on Oracle 11gR2:

Flashback Database: Flashback Data Applied : 238 out of 282 Megabytes done

During the media recovery, the following messages will be seen:

Media Recovery: Redo Applied : 263 out of 0 Megabytes done
Media Recovery: Average Apply Rate : 1164 out of 0 KB/sec done
Media Recovery: Last Applied Redo : 626540 out of 0 SCN+Time done
Media Recovery: Elapsed Time : 232 out of 0 Seconds done
Media Recovery: Active Time : 116 out of 0 Seconds done
Media Recovery: Active Apply Rate : 1859 out of 0 KB/sec done
Media Recovery: Maximum Apply Rate : 1859 out of 0 KB/sec done
Media Recovery: Log Files : 15 out of 0 Files done
Media Recovery: Apply Time per Log : 7 out of 0 Seconds done

Q: How should I set the database to improve Flashback performance?

A: Oracle’s recommendations are:

Use a fast file system for your flash recovery area, preferably without operating system file caching. It is recommended to use a file system that avoids operating system file caching, such as ASM.
Configure enough disk spindles for the file system that will hold the flash recovery area. For large production databases, multiple disk spindles may be needed to support the required disk throughput for the database to write the flashback logs effectively.
If the storage system used to hold the flash recovery area does not have non-volatile RAM, try to configure the file system on top of striped storage volumes, with a relatively small stripe size such as 128K. This will allow each write to the flashback logs to be spread across multiple spindles, improving performance
For large, production databases, set the init.ora parameter LOG_BUFFER to be at least 8MB. This makes sure the database allocates maximum memory (typically 16MB) for writing flashback database logs.




***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************




ASM Interview questions:
*****************************

1) What are the background processes in ASM

Ans:

RABL- Rebalancer: It opens all the device files as part of disk discovery and coordinates the ARB processes for rebalance activity.

ARBx - Actual Rebalancer: They perform the actual rebalancing activities. 
The number of ARBx processes depends on the ASM_POWER_LIMIT init parameter.

ASMB - ASM Bridge: This process is used to provide information to and from the Cluster Synchronization Service (CSS) used by ASM to manage the disk resources. 
It is also used to update statistics and provide a heartbeat mechanism.


2) What is the use of ASM (or) Why ASM preferred over filesystem?

ANS: ASM provides striping and mirroring.


3) What are the init parameters related to ASM?

ANS:
INSTANCE_TYPE = ASM
ASM_POWER_LIMIT = 11
ASM_DISKSTRING = '/dev/rdsk/*s2', '/dev/rdsk/c1*'
ASM_DISKGROUPS = DG_DATA, DG_FRA


4) What is rebalancing (or) what is the use of ASM_POWER_LIMIT?

ANS:

ASM_POWER_LIMIT is dynamic parameter, which will be useful for rebalancing the data across disks.
Value can be 1(lowest) to 11 (highest).


5) What are different types of redundancies in ASM and  explain?

ANS:

External redundancy,
Normal redundancy,
High redundancy.

6) How to copy file to/from ASM from/to filesystem?

ANS:

By using ASMCMD cp command

7) How to find out the databases, which are using the ASM instance?

ANS:

ASMCMD> lsct
DB_Name   Status     Software_Version  Compatible_version  Instance_Name  Disk_Group
amxdcmp1  CONNECTED        11.2.0.2.0          11.2.0.2.0  amxdcmp1       DG1_DCM_DATA
amxddip1  CONNECTED        11.2.0.2.0          11.2.0.2.0  amxddip1       DG1_DDI_DATA
ASMCMD>

(or)

select DB_NAME from V$ASM_CLIENT;

8) What are different types of stripings in ASM & their differences?

ANS:

Fine-grained striping
Coarse-grained striping

ASMCMD>lsdg
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  EXTERN  N         512   4096  1048576   6835200  1311391                0         1311391              0             N  DG1_DCM_DATA/
MOUNTED  EXTERN  N         512   4096  1048576    486400   154487                0          154487              0             N  DG1_DDI_DATA/
ASMCMD>


SQL> select NAME,ALLOCATION_UNIT_SIZE/1024/1024 "MB" from v$asm_diskgroup;

NAME                                   MB
------------------------------ ----------
DG1_DCM_DATA                            1
DG1_DDI_DATA                            1



9) What is allocation unit and what is default value of au_size and how to change?

ANS:


Every ASM disk is divided into allocation units (AU). 
An AU is the fundamental unit of allocation within a disk group. 
A file extent consists of one or more AU. An ASM file consists of one or more file extents.
CREATE DISKGROUP disk_group_2 EXTERNAL REDUNDANCY DISK '/dev/sde1' ATRRIBUTE 'au_size' = '32M';

10) What process does the rebalancing?

ANS:

RBAL, ARBn

11) How to add/remove disk to/from diskgroup?

ANS:

add disk:

ALTER DISKGROUP DG1_ZABBIX_DATA ADD DISK 
'/zabbix_u03/oradata/zbxprd1/ZBX_DATA_DISK009' name ZBX_DATA_DISK009,
'/zabbix_u04/oradata/zbxprd1/ZBX_DATA_DISK010' name ZBX_DATA_DISK010,
'/zabbix_u05/oradata/zbxprd1/ZBX_DATA_DISK011' name ZBX_DATA_DISK011;

remove disk:

alter diskgroup DG1_CIE_DATA drop disk
DG_CIE_DATA_DISK001, 
DG_CIE_DATA_DISK002, 
DG_CIE_DATA_DISK003, 
DG_CIE_DATA_DISK004; 


*******************************************************************************************************************************************


Oracle RMAN Interview Questions/FAQs:
**************************************

1) Difference between catalog and nocatalog?

ANS: CATALOG is used when you use a repository database as catalog.
NOCATALOG is used when you used the controlfile to register your backup information.
Default in NOCATALOG.

2) Difference between using recovery catalog and control file?

ANS:

When new incarnation happens, the old backup information in control file will be lost. 
It will be preserved in recovery catalog.
In recovery catalog, we can store scripts.
Recovery catalog is central and can have information of many databases.


3) Can we use same target database as catalog?

ANS:


No. 

The recovery catalog should not reside in the target database (database to be backed up),
because the database can't be recovered in the mounted state.


4) How do u know how much RMAN task has been completed?

ANS:

By querying v$rman_status or v$session_longops


5) From where list and report commands will get input

LIST:

The primary purpose of the LIST command is to list backup and copies. For example, you can list:
Backups and proxy copies of a database, tablespace, datafile, archived redo log, or control file
Backups that have expired
Backups restricted by time, path name, device type, tag, or recoverability
Archived redo log files and disk copies

REPORT:

You can use the REPORT command to answer important questions, such as:
Which files need a backup?
Which files have had unrecoverable operations performed on them?
Which backups are obsolete and can be deleted?
What was the physical schema of the target database or a database in the Data Guard environment at some previous time?
Which files have not been backed up recently?


6) Command to delete archive logs older than 7days?

ANS:

RMAN>delete archivelog all completed before sysdate-7;


7) What is the use of crosscheck command in RMAN?

ANS:

Crosscheck will be useful to check whether the catalog information is intact with OS level information.


8) What are the differences between crosscheck and validate commands

ANS:

Use the CROSSCHECK command to synchronize the physical reality of backups and copies with their logical records in the RMAN repository.
Use the VALIDATE command to check for corrupt blocks and missing files, or to determine whether a backup set can be restored.

9) Which is one is good, differential (incremental) backup or cumulative (incremental) backup?

ANS:

A differential backup, which backs up all blocks changed after the most recent incremental backup at level 1 or 0

A cumulative backup, which backs up all blocks changed after the most recent incremental backup at level 0

10) What is Level 0, Level 1 backup?

ANS:

A level 0 incremental backup, which is the base for subsequent incremental backups, copies all blocks containing data, 
backing the datafile up into a backup set just as a full backup would. 
A level 1 incremental backup can be either of the following types:
A differential backup, which backs up all blocks changed after the most recent incremental backup at level 1 or 0
A cumulative backup, which backs up all blocks changed after the most recent incremental backup at level 0


11)  Can we perform level 1 backup without level 0 backup?

ANS:

If no level 0 backup is available, then the behavior depends upon the compatibility mode setting. 
If compatibility <10 .0.0="" 0="" a="" at="" backup.="" backup="" contents="" file="" font="" generates="" level="" nbsp="" of="" rman="" the="" time="">
If compatibility is >= 10.0.0, RMAN copies all blocks changed since the file was created, and stores the results as a level 1 backup. 
In other words, the SCN at the time the incremental backup is taken is the file creation SCN.


12) Will RMAN put the database/tablespace/datafile in backup mode ?

RMAN does not require you to put the database in backup mode.

13) What is snapshot control file?

ANS:

The snapshot CONTROLFILE is a copy of the CONTROLFILE that RMAN utilizes during long running operation (such as backup). 
RMAN needs a read consistent view of the CONTROLFILE for the backup operation, but by its nature the control file is extremely volatile.  
Instead of putting lock on the control file and causing all kinds of db enqueue problems, RMAN makes a copy of controlfile called snapshot controlfile.  
The snapshot is refreshed at the beginning of every backup.


14) what is controlfile auto backup?

ANS:

then RMAN automatically backs up the control file and server parameter file after every backup and after database structural changes. 
The control file autobackup contains metadata about the previous backup, which is crucial for disaster recovery.


15) What is the difference between backup set and backup piece?

ANS:

Backup set is logical and backup piece is physical.


16) What is obsolete backup and expired backup?

A status of "expired" means that the backup piece or backup set is not found in the backup destination.
A status of "obsolete" means the backup piece is still available, but it is no longer needed. 
The backup piece is no longer needed since RMAN has been configured to no longer need this piece after so many days have elapsed, 
or so many backups have been performed.

17)  What is the difference between hot backup and RMAN backup?

For hot backup, we have to put database in begin backup mode, then take backup.
RMAN won’t put database in backup mode.


18)  How to put manual/user-managed backup in RMAN (recovery catalog)?
By using catalog command.
RMAN>CATALOG START WITH '/tmp/backup.ctl';


19)  What is the difference between auxiliary channel and maintenance channel ?


AUXILIARY:
Specifies a connection between RMAN and an auxiliary database instance.
An auxiliary instance is used when executing the DUPLICATE or TRANSPORT TABLESPACE command, 
and when performing TSPITR with RECOVER TABLESPACE . When specifying this option, the auxiliary instance must be started but not mounted.
See Also: DUPLICATE to learn how to duplicate a database, and CONNECT to learn how to connect to a duplicate database instance

CHANNEL:

Specifies a connection between RMAN and the target database instance. 
The channel_id is the case-sensitive name of the channel. 
The database uses the channel_id to report I/O errors.
Each connection initiates an database server session on the target or auxiliary instance: this session performs the work of backing up, restoring, or recovering RMAN backups. 
You cannot make a connection to a shared server session.
Whether ALLOCATE CHANNEL allocates operating system resources immediately depends on the operating system. 
On some platforms, operating system resources are allocated at the time the command is issued. 
On other platforms, operating system resources are not allocated until you open a file for reading or writing.
Each channel operates on one backup set or image copy at a time. 
RMAN automatically releases the channel at the end of the job.


20) 

*******************************************************************************************************************************************

Oracle RAC Interview Questions/FAQs Part1 :

----------------------------------------------

1) What is the use of RAC

ANS:

Oracle RAC allows multiple computers to run Oracle RDBMS software simultaneously while accessing a single database, thus providing clustering.

2) What are the prerequisites for RAC setup ?


3) What are Oracle Clusterware/Daemon processes and what they do?

Ans:
ocssd, crsd, evmd, oprocd, racgmain, racgimon

4) What are the special background processes for RAC (or) what is difference in stand-alone database & RAC database background processes?

ANS:

DIAG, LCKn, LMD, LMSn, LMON 

5) What are structural changes in 11g R2 RAC?

Ans:
http://satya-racdba.blogspot.com/2010/07/new-features-in-9i-10g-11g-rac.html
Grid & ASM are on one home, 
Voting disk & ocrfile can be on the ASM,
SCAN,
By using srvctl, we can mange diskgroups, home, ons, eons, filesystem, srvpool, server, scan, scan_listener, gns, vip, oc4j,GSD

6) What is cache fusion?

Ans:
Transferring of data between RAC instances by using private network. 
Cache Fusion is the remote memory mapping of Oracle buffers, 
shared between the caches of participating nodes in the cluster.
When a block of data is read from datafile by an instance within the cluster and another instance is in need of the same block, 
it is easy to get the block image from the instance which has the block in its SGA rather than reading from the disk.



7) What is the purpose of Private Interconnect?

Ans:

Clusterware uses the private interconnect for cluster synchronization (network heartbeat) and daemon communication between the clustered nodes. This communication is based on the TCP protocol. 
RAC uses the interconnect for cache fusion (UDP) and inter-process communication (TCP).



8) What are the Clusterware components?

Ans:

Voting Disk - Oracle RAC uses the voting disk to manage cluster membership by way of a health check and arbitrates cluster ownership among the instances in case of network failures. The voting disk must reside on shared disk.

Oracle Cluster Registry (OCR) - Maintains cluster configuration information as well as configuration information about any cluster database within the cluster. The OCR must reside on shared disk that is accessible by all of the nodes in your cluster. 
The daemon OCSSd manages the configuration info in OCR and maintains the changes to cluster in the registry.

Virtual IP (VIP) - When a node fails, the VIP associated with it is automatically failed over to some other node 
and new node re-arps the world indicating a new MAC address for the IP. 
Subsequent packets sent to the VIP go to the new node, which will send error RST packets back to the clients. 
This results in the clients getting errors immediately.
crsd – Cluster Resource Services Daemon
cssd – Cluster Synchronization Services Daemon
evmd – Event Manager Daemon
oprocd / hangcheck_timer – Node hang detector



9) What is OCR file?

Ans:
RAC configuration information repository that manages information about the cluster node list and instance-to-node mapping information. 
The OCR also manages information about Oracle Clusterware resource profiles for customized applications.
Maintains cluster configuration information as well as configuration information about any cluster database within the cluster. 
The OCR must reside on shared disk that is accessible by all of the nodes in your cluster. 
The daemon OCSSd manages the configuration info in OCR and maintains the changes to cluster in the registry.


10) What is Voting file/disk and how many files should be there?

Ans:
Voting Disk File is a file on the shared cluster system or a shared raw device file. 
Oracle Clusterware uses the voting disk to determine which instances are members of a cluster. 
Voting disk is akin to the quorum disk, which helps to avoid the split-brain syndrome. 
Oracle RAC uses the voting disk to manage cluster membership by way of a health check and arbitrates cluster ownership among the instances 
in case of network failures. The voting disk must reside on shared disk.

11) How to take backup of OCR file?

Ans:
#ocrconfig -manualbackup
#ocrconfig -export file_name.dmp
#ocrdump -backupfile my_file
$cp -p -R /u01/app/crs/cdata /u02/crs_backup/ocrbackup/RAC1


12) How to recover OCR file?

Ans:
#ocrconfig -restore backup_file.ocr
#ocrconfig -import file_name.dmp


13) What is local OCR?

Ans:
/etc/oracle/local.ocr
/var/opt/oracle/local.ocr


14) How to check backup of OCR files?

Ans:
#ocrconfig –showbackup


15) How to take backup of voting file?

Ans:
dd if=/u02/ocfs2/vote/VDFile_0 of=$ORACLE_BASE/bkp/vd/VDFile_0
crsctl backup css votedisk         -- from 11g R2

16)  How do I identify the voting disk location?

Ans:
# crsctl query css votedisk

17) How do I identify the OCR file location?

check /var/opt/oracle/ocr.loc or /etc/ocr.loc

Ans:
# ocrcheck


18) If voting disk/OCR file got corrupted and don’t have backups, how to get them?

Ans:
We have to install Clusterware.


19) Who will manage OCR files?

Ans:
cssd will manage OCR.



20)  Who will take backup of OCR files?

Ans:
crsd will take backup.


21) What is split brain syndrome?

Ans:
Will arise when two or more instances attempt to control a cluster database. 
In a two-node environment, one instance attempts to manage updates simultaneously while the other instance attempts to manage updates.


22) What are various IPs used in RAC? Or How may IPs we need in RAC?

Ans:
Public IP, Private IP, Virtual IP, SCAN IP


23) What is the use of virtual IP?

Ans:
When a node fails, 
the VIP associated with it is automatically failed over to some other node and new node re-arps the world indicating a new MAC address for the IP. 
Subsequent packets sent to the VIP go to the new node, which will send error RST packets back to the clients. 
This results in the clients getting errors immediately.

Without using VIPs or FAN, clients connected to a node that died will often wait for a TCP timeout period (which can be up to 10 min) before getting an error. 
As a result, you don't really have a good HA solution without using VIPs.

24) What is the use of SCAN IP (SCAN name) and will it provide load balancing?

Ans:
Single Client Access Name (SCAN) is a new Oracle Real Application Clusters (RAC) 11g Release 2, 
feature that provides a single name for clients to access an Oracle Database running in a cluster. 
The benefit is clients using SCAN do not need to change if you add or remove nodes in the cluster.

25)  How many SCAN listeners will be running?

Ans:
Three SCAN listeners only.

26) What is FAN?

Ans:
Applications can use Fast Application Notification (FAN) to enable rapid failure detection, balancing of connection pools after failures, 
and re-balancing of connection pools when failed components are repaired. 
The FAN process uses system events that Oracle publishes when cluster servers become unreachable or if network interfaces fail.


27) What is FCF?

Ans:
Fast Connection Failover provides high availability to FAN integrated clients, such as clients that use JDBC, OCI, or ODP.NET. 
If you configure the client to use fast connection failover, then the client automatically subscribes to FAN events and can react to database UP and DOWN events. 
In response, Oracle gives the client a connection to an active instance that provides the requested database service.


30) What is TAF and TAF policies?

Ans:
Transparent Application Failover (TAF) - A runtime failover for high availability environments, 
such as Real Application Clusters and Oracle Real Application Clusters Guard, TAF refers to the failover and re-establishment of application-to-service connections. 
It enables client applications to automatically reconnect to the database if the connection fails, and optionally resume a SELECT statement that was in progress. 
This reconnect happens automatically from within the Oracle Call Interface (OCI) library.

31) What are nodeapps?

Ans:
VIP, listener, ONS, GSD


32) What is gsd (Global Service Daemon)?   [ http://www.datadisk.co.uk/html_docs/rac/rac_cs.htm ]

runs on each node with one GSD process per node. 
The GSD coordinates with the cluster manager to receive requests from clients such as the DBCA, EM, and the SRVCTL utility to execute administrative job tasks such as instance startup or shutdown. 
The GSD is not an Oracle instance background process and is therefore not started with the Oracle instance

33) How to do load balancing in RAC?


Client Side Connect-Time Load Balance:
---------------------------------------
The client load balancing feature enables clients to randomize connection requests among the listeners. 
This is done by client Tnsnames Parameter: LOAD_BALANCE.
The (load_balance=yes) instructs SQLNet to progress through the list of listener addresses in the address_list section of the net service name in a random sequence. When set to OFF, instructs SQLNet to try the addresses sequentially until one succeeds. 

Client Side Connect-Time failover 
-------------------------------------
This is done by client Tnsnames Parameter: FAILOVER
The (failover=on) enables clients to connect to another listener if the initial connection to the first listener fails. Without connect-time failover, Oracle Net attempts a connection with only one listener. 

Server Side Listener Connection Load Balancing.
-------------------------------------------------
With server-side load balancing, the listener directs a connection request to the best instance currently providing the service.
Init parameter remote_listener should be set. When set, each instance registers with the TNS listeners running on all nodes within the cluster. 

There are two types of server-side load balancing: 
--------------------------------------------------
Load Based — Server side load balancing redirects connections by default depending on node load. This id default.
Session Based — Session based load balancing takes into account the number of sessions connected to each node and then distributes the connections to balance the number of sessions across the different nodes.

From 10g release 2 the service can be setup to use load balancing advisory. This mean connections can be routed using SERVICE TIME and THROUGHPUT. Connection load balancing means the goal of a service can be changed, to reflect the type of connections using the service. 

Transparent Application Failover (TAF) :
----------------------------------------------
Transparent Application Failover (TAF) is a feature of the Oracle Call Interface (OCI) driver at client side. It enables the application to automatically reconnect to a database, if the database instance to which the connection is made fails. In this case, the active transactions roll back. 
Tnsnames Parameter: FAILOVER_MODE

e.g (failover_mode=(type=select)(method=basic)) 
Failover Mode Type can be Either SESSION or SELECT.

Session failover will have just the session to failed over to the next available node. With SELECT, the select query will be resumed.
TAF can be configured with just server side service settings by using dbms_service package.

Fast Connection Failover (FCF):
-----------------------------------
Fast Connection Failover is a feature of Oracle clients that have integrated with FAN HA Events.
Oracle JDBC Implicit Connection Cache, Oracle Call Interface (OCI), and Oracle Data Provider for .Net (ODP.Net) include fast connection failover. 

With fast connection failover, when a down event is received, cached connections affected by the down event are immediately marked invalid and cleaned up.



34) What are the uses of services? How to find out the services in cluster?

Ans:
Applications should use the services to connect to the Oracle database. 
Services define rules and characteristics (unique name, workload balancing, failover options, and high availability) to control how users and applications connect to database instances.

35) How to find out the nodes in cluster (or) how to find out the master node?

Ans:

# olsnodes  -- Which ever displayed first, is the master node of the cluster.

select MASTER_NODE from v$ges_resource;

To find out which is the master node, you can see ocssd.log file and search for "master node number".


36) How to know the public IPs, private IPs, VIPs in RAC?

Ans:
# olsnodes -n -p -i
node1-pub       1       node1-prv       node1-vip
node2-pub       2       node2-prv       node2-vip


37) What utility is used to start DB/instance?

Ans:
srvctl start database –d database_name
srvctl start instance –d database_name –i instance_name


38) How can you shutdown single instance?

Ans:
Change cluster_database=false

srvctl stop instance –d database_name –i instance_name

39) What is HAS (High Availability Service) and the commands?

Ans:
HAS includes ASM and database instance and listeners.

crsctl check has
crsctl config has
crsctl disable has
crsctl enable has
crsctl query has releaseversion
crsctl query has softwareversion
crsctl start has
crsctl stop has [-f]


40) How many nodes are supported in a RAC Database?

Ans:
10g Release 2, support 100 nodes in a cluster using Oracle Clusterware, and 100 instances in a RAC database.



41) What is fencing?

Ans:
I/O fencing prevents updates by failed instances, and detecting failure and preventing split brain in cluster. 
When a cluster node fails, the failed node needs to be fenced off from all the shared disk devices or diskgroups. 
This methodology is called I/O Fencing, sometimes called Disk Fencing or failure fencing.


42) Why Clusterware installed in root (why not oracle)?

Oracle Clusterware works closely with the operating system, system administrator access is required for some of the installation tasks. 
In addition, some of the Oracle Clusterware processes must run as the special operating system user, root.


43) What are the wait events in RAC?

Ans:
http://satya-racdba.blogspot.com/2012/10/wait-events-in-oracle-rac-wait-events.html

http://orainternals.wordpress.com/2009/12/23/rac-performance-tuning-understanding-global-cache-performance/

gc buffer busy
gc buffer busy acquire
gc current request 
gc cr request
gc cr failure 
gc current block lost
gc cr block lost
gc current block corrupt
gc cr block corrupt
gc current block busy
gc cr block busy
gc current block congested
gc cr block congested.
gc current block 2-way
gc cr block 2-way
gc current block 3-way
gc cr block 3-way
(gc current/cr block n-way, n is number of nodes)
gc current grant 2-way
gc cr grant 2-way
gc current grant busy
gc current grant congested
gc cr grant congested
gc cr multi block read
gc current multi block request
gc cr multi block request
gc cr block build time
gc current block flush time
gc cr block flush time
gc current block send time
gc cr block send time
gc current block pin time
gc domain validation 
gc current retry
ges inquiry response
gcs log flush sync


44) What are the initialization parameters that must have same value for every instance in an Oracle RAC database?
Ans:
http://satya-racdba.blogspot.com/2012/09/init-parameters-in-oracle-rac.html

ACTIVE_INSTANCE_COUNT
ARCHIVE_LAG_TARGET
COMPATIBLE
CLUSTER_DATABASE
CLUSTER_DATABASE_INSTANCE
CONTROL_FILES
DB_BLOCK_SIZE
DB_DOMAIN
DB_FILES
DB_NAME
DB_RECOVERY_FILE_DEST
DB_RECOVERY_FILE_DEST_SIZE
DB_UNIQUE_NAME
INSTANCE_TYPE
PARALLEL_MAX_SERVERS
REMOTE_LOGIN_PASSWORD_FILE
UNDO_MANAGEMENT


45) What is the difference between cr block and cur (current) block?



46) New features in Oracle Clusterware 12c ?


Oracle Flex ASM - This feature of Oracle Clusterware 12c claims to reduce per-node overhead of using ASM instance. 
Now the instances can use remote node ASM for any planned/unplanned downtime. ASM metadata requests can be converted by non-local instance of ASM.

ASM Disk Scrubbing - From RAC 12c, ASM comes with disk scrubbing feature so that logical corruptions can be discovered. 
Also Oracle 12c ASM can automatically correct this in normal or high redundancy diskgroups.

Oracle ASM Disk Resync & Rebalance enhancements.
Commands Databases Supporting To the application Gameing Game What is raid

Application Continuity (AC) - is transparent to the application and in-case the database or the infrastructure is unavailable, this new features which work on JDBC drivers, masks recoverable outages. 
This recovers database session beneath the application so that the outage actually appears to be delayed connectivity or execution. 
Transaction guard (improvements of Fast Application Notification).

IPv6 Support - Oracle RAC 12c now supports IPv6 for Client connectivity, Interconnect is still on IPv4.

Per Subnet multiple SCAN - RAC 12c, per-Subnet multiple SCAN can be configured per cluster.

Each RAC instance opens the Container Database (CDB) as a whole so that versions would be same for CDB as well as for all of the Pluggable Databases (PDBs). PDBs are also fully compatible with RAC.

Oracle installer will run root.sh script across nodes. We don't have to run the scripts manually on all RAC nodes. 

new "ghctl" command for patching.



47) New features in Oracle 9i/10g/11g RAC ?  [ http://satya-racdba.blogspot.in/2010/07/new-features-in-9i-10g-11g-rac.html ]


Oracle Real Application Clusters New features

Oracle 9i RAC:
---------------------
OPS (Oracle Parallel Server) was renamed as RAC
CFS (Cluster File System) was supported
OCFS (Oracle Cluster File System) for Linux and Windows
watchdog timer replaced by hangcheck timer

Oracle 10g R1 RAC :
-------------------
Cluster Manager replaced by CRS
ASM introduced
Concept of Services expanded
ocrcheck introduced
ocrdump introduced
AWR was instance specific

Oracle 10g R2 RAC :
-------------------
CRS was renamed as Clusterware
asmcmd introduced
CLUVFY introduced
OCR and Voting disks can be mirrored
Can use FAN/FCF with TAF for OCI and ODP.NET
The Waiting The Wait Latest News Resource Manager Installing Music Downloads


Oracle 11g R1 RAC :
---------------------
--> Oracle 11g RAC parallel upgrades - Oracle 11g have rolling upgrade features whereby RAC database can be upgraded without any downtime.
-->Hot patching - Zero downtime patch application.
-->Oracle RAC load balancing advisor - Starting from 10g R2 we have RAC load balancing advisor utility. 
11g RAC load balancing advisor is only available with clients who use .NET, ODBC, or the Oracle Call Interface (OCI).
-->ADDM for RAC - Oracle has incorporated RAC into the automatic database diagnostic monitor, for cross-node advisories. 
The script addmrpt.sql run give report for single instance, will not report all instances in RAC, this is known as instance ADDM. 
But using the new package DBMS_ADDM, we can generate report for all instances of RAC, this known as database ADDM.
--> Optimized RAC cache fusion protocols - moves on from the general cache fusion protocols in 10g to deal with specific scenarios where the protocols could be further optimized.
--> Oracle 11g RAC Grid provisioning - The Oracle grid control provisioning pack allows us to "blow-out" a RAC node without the time-consuming install, using a pre-installed "footprint".

Oracle 11g R2 RAC :
-----------------------
--> We can store everything on the ASM. We can store OCR & voting files also on the ASM.
--> ASMCA
--> Single Client Access Name (SCAN) - eliminates the need to change tns entry when nodes are added to or removed from the Cluster. 
RAC instances register to SCAN listeners as remote listeners. SCAN is fully qualified name.
Oracle recommends assigning 3 addresses to SCAN, which create three SCAN listeners.
--> Clusterware components: crfmond, crflogd, GIPCD.
--> AWR is consolidated for the database.
--> 11g Release 2 Real Application Cluster (RAC) has server pooling technologies so it’s easier to provision and manage database grids. 
This update is geared toward dynamically adjusting servers as corporations manage the ebb and flow between data requirements for datawarehousing and applications.By default, LOAD_BALANCE is ON.
--> GSD (Global Service Deamon), gsdctl introduced.
--> GPnP profile.
--> Cluster information in an XML profile.
--> Oracle RAC OneNode is a new option that makes it easier to consolidate databases that aren’t mission critical, but need redundancy.
--> raconeinit - to convert database to RacOneNode.
--> raconefix - to fix RacOneNode database in case of failure.
--> racone2rac - to convert RacOneNode back to RAC.
--> Oracle Restart - the feature of Oracle Grid Infrastructure's High Availability Services (HAS) to manage associated listeners, ASM instances and Oracle instances.
--> Oracle Omotion - Oracle 11g release2 RAC introduces new feature called Oracle Omotion, an online migration utility. 
This Omotion utility will relocate the instance from one node to another, whenever instance failure happens.
Omotion utility uses Database Area Network (DAN) to move Oracle instances. 
Database Area Network (DAN) technology helps seamless database relocation without losing transactions.
--> Cluster Time Synchronization Service (CTSS) is a new feature in Oracle 11g R2 RAC, which is used to synchronize time across the nodes of the cluster. --> CTSS will be replacement of NTP protocol.
--> Grid Naming Service (GNS) is a new service introduced in Oracle RAC 11g R2. With GNS, Oracle Clusterware (CRS) can manage Dynamic Host Configuration Protocol --> (DHCP) and DNS services for the dynamic node registration and configuration.
--> Cluster interconnect: Used for data blocks, locks, messages, and SCN numbers.
--> Oracle Local Registry (OLR) - From Oracle 11gR2 "Oracle Local Registry (OLR)" something new as part of Oracle Clusterware. OLR is node’s local repository, --> similar to OCR (but local) and is managed by OHASD. It pertains data of local node only and is not shared among other nodes.
--> Multicasting is introduced in 11gR2 for private interconnect traffic.
--> I/O fencing prevents updates by failed instances, and detecting failure and preventing split brain in cluster. When a cluster node fails, the failed node needs to be fenced off from all the shared disk devices or diskgroups. This methodology is called I/O Fencing, sometimes called Disk Fencing or failure fencing.
--> Re-bootless node fencing (restart)? - instead of fast re-booting the node, a graceful shutdown of the stack is attempted.
--> Clusterware log directories: acfs*
--> HAIP (IC VIP).
--> Redundant interconnects: NIC bonding, HAIP.
--> RAC background processes: DBRM – Database Resource Manager, PING – Response time agent.
--> Virtual Oracle 11g RAC cluster - Oracle 11g RAC supports virtualization.


48) 


*************************************************************************************************************************************************************

Oracle GoldenGate Interview Questions/FAQs :
**********************************************

1) What are processes/components in GoldenGate?

Ans:

Manager, Extract, Replicat, Data Pump

2) What is Data Pump process in GoldenGate ?

he Data Pump (not to be confused with the Oracle Export Import Data Pump) is an optional secondary Extract group that is created on the source system. When Data Pump is not used, the Extract process writes to a remote trail that is located on the target system using TCP/IP. When Data Pump is configured, the Extract process writes to a local trail and from here Data Pump will read the trail and write the data over the network to the remote trail located on the target system.

The advantages of this can be seen as it protects against a network failure as in the absence of a storage device on the local system, the Extract process writes data into memory before the same is sent over the network. Any failures in the network could then cause the Extract process to abort (abend). Also if we are doing any complex data transformation or filtering, the same can be performed by the Data Pump. It will also be useful when we are consolidating data from several sources into one central target where data pump on each individual source system can write to one common trail file on the target.


3) What is the command line utility in GoldenGate (or) what is ggsci?


ANS: Golden Gate Command Line Interface essential commands – GGSCI

GGSCI   -- (Oracle) GoldenGate Software Command Interpreter


4) What is the default port for GoldenGate Manager process?

ANS:

7809

5) What are important files GoldenGate?

GLOBALS, ggserr.log, dirprm, etc ...


6) What is checkpoint table?

ANS:

Create the GoldenGate Checkpoint table

GoldenGate maintains its own Checkpoints which is a known position in the trail file from where the Replicat process will start processing after any kind of error or shutdown. 
This ensures data integrity and a record of these checkpoints is either maintained in files stored on disk or table in the database which is the preferred option.


7) How can you see GoldenGate errors?

ANS:

ggsci>VIEW GGSEVT
ggserr.log file


*************************************************************************************************************************************************************

Oracle Data Guard Interview Questions/FAQs :
************************************************


1)  How to setup Data Guard?

2) What are different types of modes in Data Guard and which is default?

ANS:

Maximum performance:
This is the default protection mode. 
It provides the highest level of data protection that is possible without affecting the performance of a primary database. 
This is accomplished by allowing transactions to commit as soon as all redo data generated by those transactions has been written to the online log.

Maximum protection:
This protection mode ensures that no data loss will occur if the primary database fails. 
To provide this level of protection, the redo data needed to recover a transaction must be written to both the online redo log and to at least one standby database before the transaction commits. 
To ensure that data loss cannot occur, the primary database will shut down, rather than continue processing transactions.

Maximum availability:
This protection mode provides the highest level of data protection that is possible without compromising the availability of a primary database. 
Transactions do not commit until all redo data needed to recover those transactions has been written to the online redo log and to at least one standby database.


3) How many standby databases we can create (in 10g/11g)?

ANS:

Till Oracle 10g, 9 standby databases are supported.
From Oracle 11g R2, we can create 30 standby databases..

4) What are the parameters we’ve to set in primary/standby for Data Guard ?

ANS:

DB_UNIQUE_NAME
LOG_ARCHIVE_CONFIG
LOG_ARCHIVE_MAX_PROCESSES
DB_CREATE_FILE_DEST
DB_FILE_NAME_CONVERT
LOG_FILE_NAME_CONVERT
LOG_ARCHIVE_DEST_n
LOGARCHIVE_DEST_STATE_n
FAL_SERVER
FAL_CLIENT
STANDBY_FILE_MANAGEMENT


5) What is the use of fal_server and fal_client, is it mandatory to set these ?


ANS:

FAL_SERVER
specifies the FAL (fetch archive log) server for a standby database. The value is an Oracle Net service name, which is assumed to be configured properly on the standby database system to point to the desired FAL server.


FAL_CLIENT
specifies the FAL (fetch archive log) client name that is used by the FAL service, configured through the
FAL_SERVER initialization parameter, to refer to the FAL client. 
The value is an Oracle Net service name, which is assumed to be configured properly on the FAL server system to point to the FAL client (standby database).


6) What are differences between physical, logical, snapshot standby and ADG (or) what are different types of standby databases?

Physical standby – in mount state, MRP will apply archives
ADG – in READ ONLY state, MRP will apply archives
Logical standby – in READ ONLY state, LSP will run
Snapshot standby databases – Physical standby database can be converted to snapshot standby database, which will be in READ WRITE mode, can do any kind of testing, then we can convert back snapshot standby database to physical standby database and start MRP which will apply all pending archives.

7) How to find out backlog of standby?

select round((sysdate - a.NEXT_TIME)*24*60) as "Backlog",m.SEQUENCE#-1 "Seq Applied",m.process, m.status 
from v$archived_log a, (select process,SEQUENCE#, status from v$managed_standby where process like '%MRP%')m where a.SEQUENCE#=(m.SEQUENCE#-1);

8) If you didn't have access to the standby database and you wanted to find out what error has occurred in a data guard configuration, what view would you check in the primary database to check the error message?

ANS:

You can check the v$dataguard_status view. 
select message from v$dataguard_status;


9) How can u recover standby which far behind from primary (or) without archive logs how can we make standby sync?

ANS:

By using RMAN  incremental backup.


10) What is snapshot standby (or) How can we give a physical standby to user in READ WRITE mode and let him do updates and revert back to standby?

ANS:

Till Oralce 10g, create guaranteed restore point, open in read write, let him do updates, flashback to restore point, start MRP.

From Oracle 11g, convert physical standby to snapshot standby, let him do updates, convert to physical standby, start MRP.


11)  What are new features in 11g Data Guard?

ANS:

Here is some data guard category and there enhancement

1) Data Protection
Advanced Compression
Lost-write protection
Fast-Start Failover
2) Increase ROI
Active Data Guard
Snapshot Standby
3) High Availability
Faster Redo Apply
Faster failover & switchover
Automatic Failover using ASYNC
4) Manageability
Mixed Windows/Linux

12) What are the uses of standby redo log files


A standby redo log is required for the maximum protection and maximum availability modes and the LGWR ASYNC transport mode is recommended for all databases. 
Data Guard can recover and apply more redo data from a standby redo log than from archived redo log files alone.

If the real-time apply feature is enabled, log apply services can apply redo data as it is received, without waiting for the current standby redo log file to be archived. 
This results in faster switchover and failover times because the standby redo log files have been applied already to the standby database by the time the failover or switchover begins.

13) What is dg_config ?

ANS:

Specify the DG_CONFIG attribute to identify the DB_UNIQUE_NAME for the primary database and each standby database in the Data Guard configuration.
The default value of this parameter enables the primary database to send redo data to remote destinations and enables standby databases to receive redo data.

14) What is RTA (real time apply) mode MRP? 

ANS:

real-time apply where before log shipping the LGWR process writes to a standbylog file simultaneously along with the online redolog file. 
This standby logfile is written to standby log file on standby server. There is no loss of any committed transaction whatsoever in Real-Time Apply scenario.

•In Real Time Apply, once a transaction is committed on the Primary, the committed changes will be available on the Standby in Real Time even without switching the log at the Primary

MRP - Managed recovery process - For Data Guard, the background process that applies archived redo log to the standby database.

15)  What is the difference between normal MRP (managed apply) and RTA MRP (real time apply)?

ANS:


The difference between Redo Apply and Real-Time Apply
------------------------------------------------------
Normally, by default, Archiver processes will be responsible for Redo Transport from Primary to Standby.

Once a log switch happens on the Primary, the online redo log is archived in the Local Archive destination as pointed to by Log_archive_dest_1 
by an Archiver process. 
Another Archiver process will then transmit the redo to the remote standby destination as indicated by Log_archive_dest_2. 
Data Guard Remote File Server (RFS) Process on the Standby then writes redo data from the Standby redo log file to archive redo log file. 
Log apply services then makes use of Managed Recovery Process (MRP) process to apply the redo to the standby database.
This method of propagating redo from the primary to standby is called Redo Apply and it happens only on log switch at the Primary.
When using Redo Apply mode, the status of MRP in v$managed_standby view will show as WAIT_FOR_LOG.

Real Time Apply, in contrast, uses either LGWR or Archiver on the Primary to write redo data to Standby Redo log on the Standby and Log Apply Services can apply the redo data in real-time without the need of the current standby redo log being archived. Once a transaction is committed on the Primary, the committed changes will be available on the Standby in Real Time even without switching the log.

When using Real Time Apply mode, the status of MRP in v$managed_standby view will show as APPLYING_LOG.


16) What is the difference between SYNC/ASYNC, LGWR/ARCH, and AFFIRM/NOAFFIRM ?

ANS:

Specifies that network I/O is to be done synchronously (SYNC) or asynchronously (ASYNC) when archival is performed using the log writer process (LGWR).

Specifies whether redo transport services use archiver processes (ARCn) or the log writer process (LGWR) to collect transaction redo data and transmit it to standby destinations. If neither the ARCH or LGWR attributes are specified, the default is ARCH.

Controls whether redo transport services use synchronous or asynchronous I/O to write redo data to disk

AFFIRM—specifies that all disk I/O to archived redo log files and standby redo log files is performed synchronously and completes successfully before the log writer process continues.

NOAFFIRM—specifies that all disk I/O to archived redo log files and standby redo log files is performed asynchronously; the log writer process on the primary database does not wait until the disk I/O completes before continuing.


17) What is StaticConnectIdentifier property used for?

ANS:

11gr2 new database property, StaticConnectIdentifier, which allows the user to specify a static connect identifier that the DGMGRL client will use to start database instances.

18) What is failover/switchover (or) what is the difference between failover and switchover

ANS:

Switchover – This is done when both primary and standby databases are available. It is pre-planned.
Failover – This is done when the primary database is NO longer available (ie in a Disaster). It is not pre-planned.


29) What are the background processes involved in Data Guard?

ANS:

MRP, LSP,  


21) 


*************************************************************************************************************************************************************

Oracle Export/Import (exp/imp)- Data Pump (expdp/imp) Interview Questions/FAQs :

*******************************************************************************************



1) What is use of CONSISTENT option in exp?

Cross-table consistency. Implements SET TRANSACTION READ ONLY. Default value N.

2) What is use of DIRECT=Y option in exp?

Setting direct=yes, to extract data by reading the data directly, bypasses the SGA, 
bypassing the SQL command-processing layer (evaluating buffer), so it should be faster. Default value N.


3) What is use of COMPRESS option in exp?

Imports into one extent. Specifies how export will manage the initial extent for the table data. 
This parameter is helpful during database re-organization. 
Export the objects (especially tables and indexes) with COMPRESS=Y. 
If table was spawning 20 Extents of 1M each (which is not desirable, taking into account performance), if you export the table with COMPRESS=Y, the DDL generated will have initial of 20M. Later on when importing the extents will be coalesced. 
Sometime it is found desirable to export with COMPRESS=N, in situations where you do not have contiguous space on disk (tablespace), and do not want imports to fail.


4) How to improve exp performance?

ANS:

a). Set the BUFFER parameter to a high value. Default is 256KB.
b). Stop unnecessary applications to free the resources.
c). If you are running multiple sessions, make sure they write to different disks.
d). Do not export to NFS (Network File Share). Exporting to disk is faster.
e). Set the RECORDLENGTH parameter to a high value.
f). Use DIRECT=yes (direct mode export).


5) How to improve imp performance?

ANS:

a). Place the file to be imported in separate disk from datafiles.
b). Increase the DB_CACHE_SIZE.
c). Set LOG_BUFFER to big size.
d). Stop redolog archiving, if possible.
e). Use COMMIT=n, if possible.
f). Set the BUFFER parameter to a high value. Default is 256KB.
g). It's advisable to drop indexes before importing to speed up the import process or set INDEXES=N and building indexes later on after the import.
Indexes can easily be recreated after the data was successfully imported.
h). Use STATISTICS=NONE
i). Disable the INSERT triggers, as they fire during import.
j). Set Parameter COMMIT_WRITE=NOWAIT(in Oracle 10g) or COMMIT_WAIT=NOWAIT (in Oracle 11g) during import.


6) What is use of INDEXFILE option in imp?

ANS:

Will write DDLs of the objects in the dumpfile into the specified file.

7) What is use of IGNORE option in imp?

ANS:

Will ignore the errors during import and will continue the import.


8) What are the differences between expdp and exp (Data Pump or normal exp/imp)?

ANS:

Data Pump is server centric (files will be at server).
Data Pump has APIs, from procedures we can run Data Pump jobs.
In Data Pump, we can stop and restart the jobs.
Data Pump will do parallel execution.
Tapes and pipes are not supported in Data Pump.
Data Pump consumes more undo tablespace.
Data Pump import will create the user, if user doesn’t exist.


9) Why expdp is faster than exp (or) why Data Pump is faster than conventional export/import?

Data Pump is block mode, exp is byte mode. 
Data Pump will do parallel execution.
Data Pump uses direct path API.


10)  How to improve expdp performance?

ANS:

Using parallel option which increases worker threads. This should be set based on the number of cpus.


11) How to improve impdp performance?

ANS:

Using parallel option which increases worker threads. This should be set based on the number of cpus.


12) In Data Pump, where the jobs info will be stored (or) if you restart a job in Data Pump, how it will know from where to resume?

Whenever Data Pump export or import is running, Oracle will create a table with the JOB_NAME and will be deleted once the job is done. 
From this table, Oracle will find out how much job has completed and from where to continue etc.

Default export job name will be SYS_EXPORT_XXXX_01, where XXXX can be FULL or SCHEMA or TABLE.
Default import job name will be SYS_IMPORT_XXXX_01, where XXXX can be FULL or SCHEMA or TABLE.


13) What is the order of importing objects in impdp?

 Tablespaces
 Users
 Roles
 Database links
 Sequences
 Directories
 Synonyms
 Types
 Tables/Partitions
 Views
 Comments
 Packages/Procedures/Functions
 Materialized views



14) How to import only metadata?

ANS:

CONTENT= METADATA_ONLY


15) How to import into different user/tablespace/datafile/table?

ANS:

REMAP_SCHEMA
REMAP_TABLESPACE
REMAP_DATAFILE
REMAP_TABLE 
REMAP_DATA

16) Using Data Pump, how to export in higher version (11g) and import into lower version (10g), can we import to 9i?

ANS:

Import data pump can always read export datapump dumpfile sets created by older versions of database. In your case it works, 
normal expdp on 10g and impdp on 11g
VERSION parameter in datapump is for other way around, if you want to import data taken from 11g into 10g database you need
to specify VERSION while taking backup.



17) How to do transport tablespaces (and across platforms) using exp/imp or expdp/impdp?

ANS: [http://satya-dba.blogspot.in/2010/01/oracle-transportable-tablespaces-tts.html ]

We can use the transportable tablespaces feature to copy/move subset of data (set of user tablespaces), from an Oracle database and plug it in to another Oracle database. The tablespaces being transported can be either dictionary managed or locally managed.

With Oracle 8i, Oracle introduced transportable tablespace (TTS) technology that moves tablespaces between databases. Oracle 8i supports tablespace transportation between databases that run on same OS platforms and use the same database block size.

With Oracle 9i, TTS (Transportable Tablespaces) technology was enhanced to support tablespace transportation between databases on platforms of the same type, but using different block sizes.

With Oracle 10g, TTS (Transportable Tablespaces) technology was further enhanced to support transportation of tablespaces between databases running on different OS platforms (e.g. Windows to Linux, Solaris to HP-UX), which has same ENDIAN formats. Oracle Database 10g Release 1 introduced cross platform transportable tablespaces (XTTS), which allows data files to be moved between platforms of different endian format. XTTS is an enhancement to the transportable tablespace (TTS). If ENDIAN formats are different we have to use RMAN (e.g. Windows to Solaris, Tru64 to AIX).

select * from v$transportable_platform order by platform_id;



18) 


*************************************************************************************************************************************************************

Oracle Performance Related Interview Questions/FAQs :
**********************************************************

1) What you’ll check whenever user complains that his session/database is slow?


2) What is the use of statistics?

ANS:

Optimizer statistics are a collection of data that describe more details about the database and the objects in the database. 
These statistics are used by the query optimizer to choose the best execution plan for each SQL statement.


3) How to generate explain plan?

ANS:

EXPLAIN PLAN FOR ;


4) How to check explain plan of already ran SQLs?

ANS:

select * from TABLE(dbms_xplan.display_cursor('&SQL_ID'));


5) How to find out whether the query has ran with RBO or CBO?


ANS:

ts very simple..from sql alone you cannot tell wheather they used CBO or RBO..its like this

If your optimizer_mode=choose
then all sql statements will use the CBO 
when the tables they are acessing will have statistics collected..
then all sql statements will use the RBO
when the tables they are acessing will have no statistics..


6) What are top 5 wait events (in AWR report) and how you will resolve them?

ANS:

http://satya-dba.blogspot.in/2012/10/wait-events-in-oracle-wait-events.html

db file sequential read  => tune indexing, tune SQL (to do less I/O), tune disks, increase buffer cache. This event is indicative of disk contention on index reads. Make sure all objects are analyzed. Redistribute I/O across disks. The wait that comes from the physical side of the database. It related to memory starvation and non selective index use. Sequential read is an index read followed by table read because it is doing index lookups which tells exactly which block to go to.
db file scattered read => disk contention on full table scans. Add indexes, tune SQL, tune disks, refresh statistics, and create materialized view. Caused due to full table scans may be because of insufficient indexes or unavailability of updated statistics.
db file parallel read  => tune SQL, tune indexing, tune disk I/O, increase buffer cache. If you are doing a lot of partition activity then expect to see that wait even. It could be a table or index partition.
db file parallel write  => if you are doing a lot of partition activity then expect to see that wait even. It could be a table or index partition.
db file single write  => if you see this event than probably you have a lot of data files in your database.

control file sequential read
control file parallel write

log file sync    => committing too often, archive log generation is more. Tune applications to commit less, tune disks where redo logs exist, try using nologging/unrecoverable options, log buffer could be too large.
log file switch completion => May need more log files per group.
log file parallel write  => Deals with flushing out the redo log buffer to disk. Disks may be too slow or have an I/O bottleneck. Look for log file contention.
log buffer space   => Increase LOG_BUFFER parameter or move log files to faster disks. Tune application, use NOLOGGING, and look for poor behavior that updates an entire row when only a few columns change.
log file switch (checkpoint incomplete) => May indicate excessive db files or slow IO subsystem.
log file switch (archiving needed)    => Indicates archive files are written too slowly.
redo buffer allocation retries  => shows the number of times a user process waited for space in the redo log buffer. 
redo log space wait time  => shows cumulative time (in 10s of milliseconds) waited by all processes waiting for space in the log buffer.

buffer busy waits/ read by other session  => Increase DB_CACHE_SIZE. Tune SQL, tune indexing, we often see this event along with full table scans, if the SQL is inserting data, consider increasing FREELISTS and/or INITRANS, if the waits are on segment header blocks, consider increasing extent sizes.
free buffer waits  => insufficient buffers, process holding buffers too long or i/o subsystem is over loaded. Also check you db writes may be getting clogged up.
cache buffers lru chain  => Freelist issues, hot blocks.
no free buffers   => Insufficient buffers, dbwr contention.

latch free
latch: session allocation
latch: in memory undo latch  => If excessive could be bug, check for your version, may have to turn off in memory undo.
latch: cache buffer chains  => check hot objects.
latch: cache buffer handles  => Freelist issues, hot blocks.
direct path write => You wont see them unless you are doing some appends or data loads.
direct Path reads => could happen if you are doing a lot of parallel query activity.
direct path read temp or direct path write temp => this wait event shows Temp file activity (sort,hashes,temp tables, bitmap) check pga parameter or sort area or hash area parameters. You might want to increase them.
library cache load lock
library cache pin => if many sessions are waiting, tune shared pool, if few sessions are waiting, lock is session specific.
library cache lock  => need to find the session holding the lock, look for DML manipulating an object being accessed, if the session is trying to recompile PL/SQL, look for other sessions executing the code.
undo segment extension  => If excessive, tune undo.
wait for a undo record   => Usually only during recovery of large transactions, look at turning off parallel undo recovery.

enque wait events   => Look at V$ENQUEUE_STAT

SQL*Net message from client
SQL*Net message from dblink
SQL*Net more data from client
SQL*Net message to client
SQL*Net break/reset to client



7) What are the init parameters related to performance/optimizer?

ANS:

optimizer_mode = choose
optimizer_index_caching = 90
optimizer_index_cost_adj = 25
optimizer_max_permutations = 100
optimizer_use_sql_plan_baselines=true
optimizer_capture_sql_plan_baselines=true
optimizer_use_pending_statistics = true;
optimizer_use_invisible_indexes=true
_optimizer_connect_by_cost_based=false
_optimizer_compute_index_stats= true;



8) What are the values of optimizer_mode init parameters and their meaning?

ANS:

optimizer_mode = choose


9) What is the use of AWR, ADDM, ASH?

10)  How to generate AWR report and what are the things you will check in the report?

11). How to generate ADDM report and what are the things you will check in the report?

12). How to generate ASH report and what are the things you will check in the report?

13)  How to generate TKPROF report and what are the things you will check in the report?

ANS:


The tkprof tool is a tuning tool used to determine cpu and execution times for SQL statements. 
Use it by first setting timed_statistics to true in the initialization file and then turning on tracing for either the entire database via the sql_trace parameter or for the session using the ALTER SESSION command. 
Once the trace file is generated you run the tkprof tool against the trace file and then look at the output from the tkprof tool. 
This can also be used to generate explain plan output.


14) 



*************************************************************************************************************************************************************

UNIX Interview Questions/FAQs for Oracle DBAs:
************************************************

1) What’s the difference between soft link and hard link?

Ans:
A symbolic (soft) linked file and the targeted file can be located on the same or different file system while for a hard link they must be located on the same file system, because they share same inode number and an inode table is unique to a file system, both must be on the same file system.


2) How you will read a file from shell script?
Ans:
while read line
do
 echo $line
done < file_name


3) 3. What’s the use of umask?
ANS:
Will decide the default permissions for files.

4) What is crontab and what are the arguments?
Ans:
The entries have the following elements:
field             allowed values
-----             --------------
minute            0-59
hour                0-23
day of month   1-31
month             1-12
day of week     0-7 (both 0 and 7 are Sunday)
user                 Valid OS user
command         Valid command or script

? ? ? ? ? command
|  | |  | |_________day of the week (0-6, 0=Sunday)
|  | |  |___________month (1-12)
|  | |_____________day of the month (1-31)
|  |_______________hour (0-23)
|_________________minute (0-59)


5) How to find operating system (OS) version?
Ans:
uname –a

6)  How to find out the run level of the user?
Ans:
uname –r


7) How to delete 7 days old trace files?
Ans:
find ./trace –name *.trc –mtime +7 –exec rm {} \;

8) What is top command?
Ans:
top is a operating system command, it will display top processes which are taking high cpu and memory.


9) 8. How to get 10th line of a file (by using grep)?


10) 

*************************************************************************************************************************************************************

Architecture:

Oracle DBA Interview Questions/FAQs Part1 :


1) What is an instance?
ANS:

SGA + background processes.

2) What is SGA?
ANS:
System/Shared Global Area.

3) What is PGA (or) what is pga_aggregate_target?
ANS:
Programmable Global Area.

4) What are new memory parameters in Oracle 10g?
ANS:
SGA_TARGET, PGA_TARGET

5)  What are new memory parameters in Oracle 11g?
ANS:
MEMORY_TARGET

6) What are the mandatory background processes?
ANS:
DBWR LGWR SMON PMON CKPT RECO.

7)  What are the optional background processes?
ANS:

ARCH, MMAN, MMNL, MMON, CTWR, ASMB, RBAL, ARBx etc.

8) What are the new background processes in Oracle 10g?
ANS:
MMAN MMON MMNL CTWR ASMB RBAL ARBx

9) What are the new features in Oracle 9i?
http://satya-dba.blogspot.com/2009/01/whats-new-in-9i.html

10) . What are the new features in Oracle 10g?
http://satya-dba.blogspot.com/2009/01/whats-new-in-10g.html

11). What are the new features in Oracle 11g?
http://satya-dba.blogspot.com/2009/01/whats-new-in-11g.html

12). What are the new features in Oracle 11g R2?
http://satya-dba.blogspot.com/2009/09/whats-new-in-11g-release-2.html

13) What process will get data from datafiles to DB cache?

ANS:
Server process

14) What background process will writes data to datafiles?

ANS:
DBWR

15) What background process will write undo data?

ANS:
DBWR

16) What are physical components of Oracle database?

ANS:

Oracle database is comprised of three types of files. One or more datafiles, two or more redo log files, and one or more control files. 
Password file and parameter file also come under physical components.


17) What are logical components of Oracle database?
ANS:
Blocks, Extents, Segments, Tablespaces.

18) What is segment space management?
ANS:
LMTS and DMTS.

19)  What is extent management?

ANS:

Auto and Manual.

20) What are the differences between LMTS and DMTS?

Tablespaces that record extent allocation in the dictionary are called dictionary managed tablespaces, 
and tablespaces that record extent allocation in the tablespace header are called locally managed tablespaces.


*************************************************************************************************************************************************************

Oracle DBA Interview Questions/FAQs Part2 :
********************************************

1) What is a datafile?
ANS:
Every Oracle database has one or more physical datafiles. Datafiles contain all the database data. The data of logical database structures such as tables and indexes is physically stored in the datafiles allocated for a database.

2) What are the contents of control file?

ANS:
Database name, SCN, LSN, datafile locations, redolog locations, archive mode, DB Creation Time, RMAN Backup & Recovery Details, Flashback mode.

3) What is the use of redo log files?

ANS:

Online redo logs serve to protect the database in the event of an instance failure. Whenever a transaction is committed, the corresponding redo entries temporarily stored in redo log buffers of the system global area are written to an online redo log file by the background process LGWR.

4) What are the uses of undo tablespace or redo segments?

ANS:
Undo records are used to:

Roll back transactions when a ROLLBACK statement is issued
Recover the database
Provide read consistency
Analyze data as of an earlier point in time by using Flashback Query
Recover from logical corruptions using Flashback features

5) How undo tablespace can guarantee retain of required undo data?

ANS:

Alter tablespace undo_ts retention guarantee;


6) What is 01555 - snapshot too old error and how do you avoid it?

ANS:

http://www.dba-oracle.com/t_ora_01555_snapshot_old.htm

7) What is the use/size of temporary tablespace?

ANS:

Temporary tablespaces are used to manage space for database sort operations and for storing global temporary tables

8) What is the use of password file?

ANS:

If the DBA wants to start up an Oracle instance there must be a way for Oracle to authenticate this DBA. That is if (s)he is allowed to do so. Obviously, his password can not be stored in the database, because Oracle can not access the database before the instance is started up. Therefore, the authentication of the DBA must happen outside of the database. There are two distinct mechanisms to authenticate the DBA: using the password file or through the operating system.
The init parameter remote_login_passwordfile specifies if a password file is used to authenticate the DBA or not. If it set either to shared or exclusive a password file will be used.

9)  How to create password file?

ANS:

$ orapwd file=orapwSID password=sys_password force=y nosysdba=y

10) How many types of indexes are there?
ANS:

Clustered and Non-Clustered

1.B-Tree index
2.Bitmap index
3.Unique index
4.Function based index

Implicit index and explicit index.
Explicit indexes are again of many types like simple index, unique index, Bitmap index, Functional index, Organisational index, cluster index.


11)  What is bitmap index and when it’ll be used?

ANS:
Bitmap indexes are preferred in Data warehousing environment.
Preferred when cardinality is low.


12) What is B-tree index and when it’ll be used?

ANS:

B-tree indexes are preferred in OLTP environment.
Preferred when cardinality is high.


13) How you will find out fragmentation of index?

ANS:

AUTO_SPACE_ADVISOR_JOB will run in daily maintenance window and report fragmented indexes/Tables.

analyze index validate structure;

This populates the table ‘index_stats’. It should be noted that this table contains only one row and therefore only one index can be analysed at a time.

An index should be considered for rebuilding under any of the following conditions:

* The percentage of deleted rows exceeds 30% of the total, i.e. if
del_lf_rows / lf_rows > 0.3.
* If the ‘HEIGHT’ is greater than 4.
* If the number of rows in the index (‘LF_ROWS’) is significantly smaller than ‘LF_BLKS’ this can indicate a large number of deletes, indicating that the index should be rebuilt.


14) What is the difference between delete and truncate?

ANS:

Truncate will release the space. Delete won’t.
Delete can be used to delete some records. Truncate can’t.
Delete can be rollbacked.
Delete will generate undo (Delete command will log the data changes in the log file where as the truncate will simply remove the data without it. Hence data removed by Delete command can be rolled back but not the data removed by TRUNCATE).
Truncate is a DDL statement whereas DELETE is a DML statement.
Truncate is faster than delete.

15)  What's the difference between a primary key and a unique key?
ANS:

Both primary key and unique enforce uniqueness of the column on which they are defined.
But by default primary key creates a clustered index on the column, where unique key creates a nonclustered index by default.
Primary key doesn't allow NULLs, but unique key allows one NULL only.

16) What is the difference between schema and user?

Schema is collection of user’s objects.


17)  What is the difference between SYSDBA, SYSOPER and SYSASM?
ANS:

SYSOPER can’t create and drop database.
SYSOPER can’t do incomplete recovery.
SYSOPER can’t change character set.
SYSOPER can’t CREATE DISKGROUP, ADD/DROP/RESIZE DISK
SYSASM can do anything SYSDBA can do.

18) What is the difference between SYS and SYSTEM?
SYSTEM can’t shutdown the database.
SYSTEM can’t create another SYSTEM, but SYS can create another SYS or SYSTEM.

19) What is the difference between view and materialized view?

View is logical, will store only the query, and will always gets latest data.
Mview is physical, will store the data, and may not get latest data.


20) 

************************************************************************************************************************************************************

Oracle DBA Interview Questions/FAQs Part3 :
*********************************************

1) What are materialized view refresh types and which is default?
ANS:
Complete, fast, force(default)

2) How to find out when was a materialized view refreshed?

ANS:

Query dba_mviews or dba_mview_analysis or dba_mview_refresh_times
SQL>select MVIEW_NAME, to_char(LAST_REFRESH_DATE,'YYYY-MM-DD HH24:MI:SS') from dba_mviews;
(or)
SQL> select NAME, to_char(LAST_REFRESH,'YYYY-MM-DD HH24:MI:SS') from dba_mview_refresh_times;
(or)
SQL>select MVIEW_NAME, to_char(LAST_REFRESH_DATE,'YYYY-MM-DD HH24:MI:SS') from dba_mview_analysis;


3) What is atomic refresh in mviews?
ANS:
From Oracle 10g, complete refresh of single materialized view can do delete instead of truncate. 
To force the refresh to do truncate instead of delete, parameter ATOMIC_REFRESH must be set to false.

ATOMIC_REFRESH = FALSE, mview will be truncated and whole data will be inserted. The refresh will go faster, and no undo will be generated.
ATOMIC_REFRESH = TRUE (default), mview will be deleted and whole data will be inserted. Undo will be generated. We will have access at all times even while it is being refreshed.

SQL> EXEC DBMS_MVIEW.REFRESH('mv_emp', 'C', atomic_refresh=FALSE);

4) How to find out whether database/tablespace/datafile is in backup mode or not?
ANS:
Query V$BACKUP view.

5) What is row chaining?
ANS:
If the row is too large to fit into an empty data block in this case the oracle stores the data for the row in a chain of one or more data blocks. Can occur when the row is inserted.

6) What is row migration?
ANS:
An update statement increases the amount of data in a row so that the row no longer fits in its data blocks. 
Now the oracle tries to find another free block with enough space to hold the entire row if such a block is available oracle moves entire row to new block.


7) What are different types of partitions?
ANS:
With Oracle8, Range partitioning (on single column) was introduced.
With Oracle8i, Hash and Composite(Range-Hash) partitioning was introduced.
With Oracle9i, List partitioning and Composite(Range-List) partitioning was introduced.
With Oracle 11g, Interval partitioning, REFerence partitioning, Virtual column based partitioning, System partitioning and Composite partitioning [Range-Range, List-List, List-Range, List-Hash, Interval-Range, Interval-List, Interval-Interval] was introduced.

8)  What is local partitioned index and global partitioned index?
ANS:
A local index is an index on a partitioned table which is partitioned in the exact same manner as the underlying partitioned table. Each partition of a local index corresponds to one and only one partition of the underlying table.
A global partitioned index is an index on a partitioned or non partitioned tables which are partitioned using a different partitioning key from the table and can have different number of partitions. Global partitioned indexes can only be partitioned using range partitioning.

9) How you will recover if you lost one/all control file(s)?

10) Why more archivelogs are generated, when database is begin backup mode?

ANS:

During begin backup mode datafile headers get freezed and as result row information cannot be retrieved as a result the entire block is copied to redo logs as a result more redo generated and more log switch and in turn more archive logs. 
Normally only deltas (change vectors) are logged to the redo logs. 
When in backup mode, Oracle will write complete changed blocks to the redo log files.

Mainly to overcome fractured blocks. Most of the cases Oracle block size is equal to or a multiple of the operating system block size.

e.g. Consider Oracle blocksize is 2k and OSBlocksize is 4k. so each OS Block is comprised of 2 Oracle Blocks. Now you are doing an update when your db is in backup mode. An Oracle Block is updating and at the same time backup is happening on the OS block which is having this particular DB block. Backup will not be consistent since the one part of the block is being updated and at the same time it is copied to the backup location. In this case we will have a fractured block, so as to avoid this Oracle will copy the whole OS block to redo logfile which can be used for recovery. Because of this redo generation is more.

11) What UNIX kernel parameters you will set while Oracle installation?
ANS:
shmmax, shmmni, shmall, sem, 

12) What is the use of inittrans and maxtrans in table definition?

13) What are differences between dbms_job and dbms_schedular?

Through dbms_schedular we can schedule OS level jobs also.

14) What are differences between dbms_schedular and cron jobs?

Through dbms_schedular we can schedule database jobs, through cron we can’t set.

15) Difference between CPU and PSU patches?

CPU - Critical Patch Update - includes only Security related patches.
PSU - Patch Set Update - includes CPU + other patches deemed important enough to be released prior to a minor (or major) version release.

16)  What you will do if (local) inventory corrupted [or] opatch lsinventory is giving error?

17) What are the entries/location of oraInst.loc?
ANS:

/etc/oraInst.loc is pointer to central/local Oracle Inventory.


18) What is the difference between central/global inventory and local inventory?

ANS:


19) 

*************************************************************************************************************************************************************

Oracle DBA Interview Questions/FAQs Part4 :
**********************************************

1) What is the use of root.sh and oraInstRoot.sh?
Ans:
Changes ownership and permissions of oraInventory
Creating oratab file in the /etc directory
In RAC, starts the clusterware stack


2) How can you transport tablespaces across platforms with different endian formats?
Ans:
RMAN

3) What is transportable tablespace (and across platforms)?

4)  What is xtss (cross platform transportable tablespace)?

5)  What is the difference between restore point and guaranteed restore point?

6) How to find if your Oracle database is 32 bit or 64 bit?
Ans:
execute the command "file $ORACLE_HOME/bin/oracle", you should see output like /u01/db/bin/oracle: ELF 64-bit MSB executable SPARCV9 Version 1

means you are on 64 bit oracle.

If your oracle is 32 bit you should see output like below
oracle: ELF 32-bit MSB executable SPARC Version 1


7) How to find opatch Version ?
Ans:
opatch is utility to apply database patch, In order to find opatch version execute"$ORACLE_HOME/OPatch/opatch version"


8) suppose i created one table after few days i did some insert,update how can i know when will i did ddl or dml operation is undergone on that table ?

ANS:

DDL:

select OWNER,OBJECT_NAME,CREATED,LAST_DDL_TIME,from dba_objects where OBJECT_NAME='&object_name';


DML:

SQL> select max(ora_rowscn), scn_to_timestamp(max(ora_rowscn)) from PS_PAY_TAX;

MAX(ORA_ROWSCN) SCN_TO_TIMESTAMP(MAX(ORA_ROWSCN))
--------------- ---------------------------------------------------------------------------
     6016929147 04-JAN-12 08.41.20.000000000 AM

SQL>

SQL>select table_name, inserts, updates, deletes, timestamp,truncated  from user_tab_modifications where table_name='TEST1';

TABLE_NAME  INSERTS    UPDATE  DELETES   TIMESTAMP         TRU DROP_SEG

---------   --------  ------- -------- ------------------- --- --------

TEST1        4         0        0     04.08.2008 12:03:32  NO   0


==============================================================


PART=II
============

Oracle Interview Questions : The Interviewer’s Prespective

"We're interviewing an Oracle guy tomorrow, can you give me a few questions to ask him?"

Not an uncommon request. The problem is, there are literally thousands of potential Oracle questions, but it all depends on what are you trying to achieve. So I pushed back:

"What kind of Oracle-related skills would the candidate need that you want to ask for?"
"You tell us. We just want to know if he knows Oracle. Whatever an Oracle guy would need to know."

Pretty soon thereafter I figured out that it was a pointless conversation to continue, although I did love the way he summarized dozens of very different positions into that one term: "Oracle Guy."

Nevertheless, it got me thinking. What makes for a good technical question? I have conducted, or been invited to, several interviews, so it got me to thinking about which questions were most effective at getting to the heart of the matter: "Will this candidate succeed technically in this role?"

Elements of a Good Technical Interview Question.

1. Must require knowledge of the area, including domain and philosophy, to solve.

I don't think it's enough that a candidate demonstrates proficiency with the technology. I like to see if they understand the overall philosophy of the product (Oracle, in this case): What needs was it meant to provide, what kind of problems was it designed to solve, how does it accomplish those tasks.

2. Must require overall technical skill/experience/understanding to solve.

I mean to say that a good question shows if the candidate understands (for example) relational databases themselves, not just a particular relational database. Carrying this example, does your C++ developer understand algorithms and software design?

3. Does not require knowledge of precise syntax

In my mind, anyone can look something up in a manual. You don't need to walk into an empty boardroom and know exactly how something is called. I don't think knowledge of syntax is a reliable indicator of the suitability of a candidate.

For example, you could have a good candidate "blank out" on the syntactic details, and you could also have a bad candidate who swallowed a reference manual the night before the interview.

Now, I would be worried if the candidate didn't know BASIC syntax. But I don't want to waste precious time asking basic questions, and if he is truly is that inexperienced, I should be able to figure it out in other ways.

4. Can be answered quickly.

Time is precious in an interview, and you shouldn't need long, convoluted questions to determine whether or not a candidate "gets it." A good question demonstrates quickly if the candidate is on the right path, or wouldn't get it regardless of how much time he had.

5. Is not a "gotcha"

I've met some interviewers that seem to use the opportunity not to evaluate the candidate, but to prove how clever they are (either to the candidate or the manager). They do this by asking really obscure tricks, sometimes referred to as "gotchas."

The problem with asking questions in the obscure corners is that even very experienced candidates may not have worked in that area and, if they have, may not have stumbled across that particular gem.

Just remember, the purpose of the interview isn't to make YOU look clever, and asking silly questions might make a great candidate think "what kind of clown show am I getting myself into?"

6. Has many possible solutions and approaches

The most effective questions I have ever asked, or been asked, were the ones that triggered lively technical discussions between the interviewer and the candidate. Why? You get to catch a glimpse not only of the candidates thinking process, but also how he communicates. I also like the added benefit of not punishing (in fact, rewarding) those that approach problems differently than the interviewer.

7. Requires asking for more information (or make assumptions).

Personally, I believe one of the keys to success in IT is to define a problem before approaching it. That's why I lean towards these types of questions. Did the candidate come back, or just try to solve it? If he came back, what kind of questions did he ask? In the face of an incompletely-defined problem, did he get stuck, or did he make some assumptions and continue? If so, what assumptions did he make?

8. Is relevant to the business/job being considered

Would you hire a cleaning service with award-winning carpet cleaning if you had hardwood floors? Would you hire a running back who excels in bad weather if you played in a dome? Would you hire an accomplished science-fiction writer to author your biography? No? Then why probe for technical skills that don't directly apply to the position you're attempting to fill?

Closing Thoughts

Incidentally, in the end I referred the manager in question to a couple of links which have hundreds of Oracle-interview questions. You can pick your favourites but, more likely, you can read them until you come up with good ideas that suit your needs.

http://www.orafaq.com/forum/t/9760/2/
http://www.databasejournal.com/features/oracle/article.php/3085171

As an aside, that last article was written by one of my preferred columnists, James Koopmann. He hasn't written much recently, but check out his archives, he's got some great articles there. For instance, check out his series on Oracle Session Tracing.





The interview process can be quite stressful. Here is the first part of a two part series on helping you answer those tough questions that you might experience in your quest for an Oracle DBA position.

Ever since I wrote the past article on the Oracle Technical Interview, I have been bombarded with e-mails asking for help on getting through the interview questions that I presented. Most of you I have answered, others I was reluctant to post all of the answers so that you could begin your own quest for the answers. Now, however, I have decided to post the answers knowing that we can all benefit from them. If there are any questions here that you still need clarification on, please e-mail me and I will do my best to further explain the answer I have given. Please remember that as you go through the article, it is not enough to know the answer to a particular question, you must try and put yourself in an interview situation and experience answering the question for yourself. Therefore, after you have gone through the questions and answers read the question yourself and then answer it with your own words. As always, good luck, and cheers.

Personal
This part of the interview question is not to be regarded as insignificant. If the interviewer asks you these questions take it as a sign that they are interested in you, your qualities, and how you interact with people throughout the day. Take it as an opportunity to prove that you have been around the block a few times, are willing to work with other people, and enjoy the job you do. Many times people see DBA types as stuffy and pointed, not willing to work with others, and only concerned with the database and its day-to-day operational needs. Put aside the needs of the database and talk about how you work with people and the different departments in the organization and are concerned with providing them with top notch database services.

1.     What DBA activities did you to do today?

Wow, this is a loaded question and almost begs for you to answer it with "What DBA activities do you LIKE to do on a daily basis?." And that is how I would answer this question. Again, do not get caught up in the "typical" day-to-day operational issues of database administration. Sure, you can talk about the index you rebuilt, the monitoring of system and session waits that were occurring, or the space you added to a data file, these are all good and great and you should convey that you understand the day-to-day operational issues. What you should also throw into this answer are the meetings that you attend to provide direction in the database arena, the people that you meet and talk with daily to answer adhoc questions about database use, the modeling of business needs within the database, and the extra time you spend early in the morning or late at night to get the job done. Just because the question stipulates "today" do not take "today" to mean "today." Make sure you wrap up a few good days into "today" and talk about them. This question also begs you to ask the question of "What typical DBA activities are performed day to day within X Corporation?"

2.     What is your typical day like?

If you spend enough time on question 1, this question will never be asked. It is really a continuation of question 1 to try and get you to open up and talk about the type of things you like to do. Personally, I would continue with the theme of question 1 if you are cut short or this question is asked later in the interview process. Just note that this question is not all geared toward the day-to-day operational issues you experience as a DBA. This question also gives you the opportunity to see if they want to know about you as an individual. Since the question did not stipulate "on the job" I would throw in a few items like, I get up at 5:00am to get into work and get some quiet time to read up on new trends or you help coach your son/daughter's soccer team. Just test the waters to what is acceptable. If the interviewer starts to pull you back to "job" related issues, do not go to personal. Also, if you go to the office of the interviewer please notice the surroundings, if there are pictures of his/her family, it is probably a good idea to venture down the personal path. If there is a fly-fishing picture on the wall, do not say you like deep-sea fishing. You get the picture.

3.     What other parts of your organization do you interact with and how?

Again, if you have exhausted question 1 and 2 you may never get to this question. But if you have been apprehensive to opening up and explaining yourself, take note that you may have an issue and the interviewer might also be already getting tired of the interview process. If you get to this question consider yourself in trouble. You really need to forget all your hang-ups and start explaining what it is that you like to do as a DBA, and why you want to work for this particular company. You are going to have to reel this interviewer back into the interview process or you might not get to the true technical question part of the interview.

4.     Do you consider yourself a development DBA or a production DBA and why?

I take this as a trick question and explain it that way. Never in my database carrier have I distinguished between "development" and "production." Just ask your development staff or VP of engineering how much time and money is lost if development systems are down. Explain to the interviewer that both systems are equally important to the operation of the company and both should be considered as production systems because there are people relying on them and money is lost if either one of them is down. Ok you may be saying, and I know you are, that we lose more money if the production system is down. Ok, convey that to the interviewer and you won't get anyone to disagree with you unless your company sells software or there are million dollar deals on the table that are expecting the next release of your product or service.

5.     Are you a nuts-n-bolts DBA or a tools-n-props DBA

This question begs for me to give definition around the terms I basically group DBAs into. These are not good or bad groups but something I like to think about when talking to DBAs. A nuts-n-bolts DBA is the type that likes to figure out every little item about how the database works. He/she is a DBA who typically hates a GUI environment and prefers the command line to execute commands and accomplish tasks. A nuts-n-bolts DBA like to feel in control of the database and only feels comfortable at the command line and vi as an editor. The tools-n-props DBA is mostly the opposite of a nuts-n-bolts DBA, they like the feel of a GUI, the ease at which things can be accomplished without knowing much about the database. They want to get the job done with the least amount of intervention from having to figure out what everything is doing behind the scenes. Now the answer, I would explain myself as a combination of the two. I, having been in this business for over 20 years, have grown up in a command line era where the GUIs never seemed to work. There was high complexity in systems and not much good documentation on how things worked. Thus, I had to learn everything about most aspects of the database environment I was working in and thus became a nuts-n-bolts DBA. I was a true command line and vi bigot. Times have changed and the GUIs are very reliable, understand the environment they are installed on, and can generally get the job done quicker for individuals new to database administration. I too am slowly slipping over to the dark side of GUI administration. If you find yourself as a tools-n-props DBA, try to convey that you are aware of some tasks that require you to be a nuts-n-bolts DBA.

Technical – Oracle
This is the part you have all been waiting on. Please if you have just skipped to this section, go back to the personal section and read it. There is much to be gained by the personal section and conveying to your interviewer who you are and how you tick from day to day. Also, the answers I am giving here are off the cuff and are not intended to be the definitive answer to these questions. There are many aspects to these questions that just cannot be answered here and honestly, you will not have time to explain any of these questions fully in the interview process. It is up to you to make sure your interviewer understands that you understand the question and have given enough information that they know you understand the concept.

1.     Explain the difference between a hot backup and a cold backup and the benefits associated with each.

A hot backup is basically taking a backup of the database while it is still up and running and it must be in archive log mode. A cold backup is taking a backup of the database while it is shut down and does not require being in archive log mode. The benefit of taking a hot backup is that the database is still available for use while the backup is occurring and you can recover the database to any point in time. The benefit of taking a cold backup is that it is typically easier to administer the backup and recovery process. In addition, since you are taking cold backups the database does not require being in archive log mode and thus there will be a slight performance gain as the database is not cutting archive logs to disk.

2.     You have just had to restore from backup and do not have any control files. How would you go about bringing up this database?

I would create a text based backup control file, stipulating where on disk all the data files where and then issue the recover command with the using backup control file clause.

3.     How do you switch from an init.ora file to a spfile?

Issue the create spfile from pfile command.

4.     Explain the difference between a data block, an extent and a segment.

A data block is the smallest unit of logical storage for a database object. As objects grow they take chunks of additional storage that are composed of contiguous data blocks. These groupings of contiguous data blocks are called extents. All the extents that an object takes when grouped together are considered the segment of the database object.

5.     Give two examples of how you might determine the structure of the table DEPT.

Use the describe command or use the dbms_metadata.get_ddl package.

6.     Where would you look for errors from the database engine?

In the alert log.

7.     Compare and contrast TRUNCATE and DELETE for a table.

Both the truncate and delete command have the desired outcome of getting rid of all the rows in a table. The difference between the two is that the truncate command is a DDL operation and just moves the high water mark and produces a now rollback. The delete command, on the other hand, is a DML operation, which will produce a rollback and thus take longer to complete.

8.     Give the reasoning behind using an index.

Faster access to data blocks in a table.

9.     Give the two types of tables involved in producing a star schema and the type of data they hold.

Fact tables and dimension tables. A fact table contains measurements while dimension tables will contain data that will help describe the fact tables.

10. . What type of index should you use on a fact table?

A Bitmap index.

11. Give two examples of referential integrity constraints.

A primary key and a foreign key.

12. A table is classified as a parent table and you want to drop and re-create it. How would you do this without affecting the children tables?

Disable the foreign key constraint to the parent, drop the table, re-create the table, enable the foreign key constraint.

13. Explain the difference between ARCHIVELOG mode and NOARCHIVELOG mode and the benefits and disadvantages to each.

ARCHIVELOG mode is a mode that you can put the database in for creating a backup of all transactions that have occurred in the database so that you can recover to any point in time. NOARCHIVELOG mode is basically the absence of ARCHIVELOG mode and has the disadvantage of not being able to recover to any point in time. NOARCHIVELOG mode does have the advantage of not having to write transactions to an archive log and thus increases the performance of the database slightly.

14. What command would you use to create a backup control file?

Alter database backup control file to trace.

15. Give the stages of instance startup to a usable state where normal users may access it.

STARTUP NOMOUNT - Instance startup

STARTUP MOUNT - The database is mounted

STARTUP OPEN - The database is opened

16. What column differentiates the V$ views to the GV$ views and how?

The INST_ID column which indicates the instance in a RAC environment the information came from.

17. How would you go about generating an EXPLAIN plan?

Create a plan table with utlxplan.sql.

Use the explain plan set statement_id = 'tst1' into plan_table for a SQL statement

Look at the explain plan with utlxplp.sql or utlxpls.sql

18. How would you go about increasing the buffer cache hit ratio?

Use the buffer cache advisory over a given workload and then query the v$db_cache_advice table. If a change was necessary then I would use the alter system set db_cache_size command.

19. Explain an ORA-01555

You get this error when you get a snapshot too old within rollback. It can usually be solved by increasing the undo retention or increasing the size of rollbacks. You should also look at the logic involved in the application getting the error message.

20. Explain the difference between $ORACLE_HOME and $ORACLE_BASE.

ORACLE_BASE is the root directory for oracle. ORACLE_HOME located beneath ORACLE_BASE is where the oracle products reside.


December 12, 2003
Oracle Technical Interview Questions Answered - Part2
By James Koopmann



This is the second part of the two part series on helping you answer those tough questions that you might experience in your quest for an Oracle DBA position.

The Oracle Technical Interview can be quite daunting. You never quite know what to study for and how to prepare. I am fully aware of this, as I have received many emails since my original article on interview questions was released. While these questions are only guidelines as to what should and more than likely will be asked, I hope that you find some comfort in the review of them. As always, do not just memorize the answers, as there are jewels to be found in the quest of figuring out the answer from the question. As always, remember that as you go through the article, it is not enough to know the answer to a particular question; you must try to put yourself in an interview situation and experience answering the question for yourself. Therefore, after you have gone through the questions and answers read the question again and then answer it with your own words. As always, good luck, and cheers.

Technical - Oracle
Last time, we answered questions 1 thru 20 of the technical part of the interview. Here are the next 30 in this section. Depending on the mood of the interview and your ability to elaborate on the answer, try to give some insight that you know more than just the simple answer to some of these questions. Also, be sensitive to the interviewer getting tired of you talking too much. Well here they are.

21.  How would you determine the time zone under which a database was operating?

select DBTIMEZONE from dual;
22.  Explain the use of setting GLOBAL_NAMES equal to TRUE.

Setting GLOBAL_NAMES dictates how you might connect to a database. This variable is either TRUE or FALSE and if it is set to TRUE it enforces database links to have the same name as the remote database to which they are linking.

23.  What command would you use to encrypt a PL/SQL application?

WRAP

24.  Explain the difference between a FUNCTION, PROCEDURE and PACKAGE.

A function and procedure are the same in that they are intended to be a collection of PL/SQL code that carries a single task. While a procedure does not have to return any values to the calling application, a function will return a single value. A package on the other hand is a collection of functions and procedures that are grouped together based on their commonality to a business function or application.

25.  Explain the use of table functions.

Table functions are designed to return a set of rows through PL/SQL logic but are intended to be used as a normal table or view in a SQL statement. They are also used to pipeline information in an ETL process.

26.  Name three advisory statistics you can collect.

Buffer Cache Advice, Segment Level Statistics, & Timed Statistics

27.  Where in the Oracle directory tree structure are audit traces placed?

In unix $ORACLE_HOME/rdbms/audit, in Windows the event viewer

28.  Explain materialized views and how they are used.

Materialized views are objects that are reduced sets of information that have been summarized, grouped, or aggregated from base tables. They are typically used in data warehouse or decision support systems.

29.  When a user process fails, what background process cleans up after it?

PMON

30.  What background process refreshes materialized views?

The Job Queue Processes.

31.  How would you determine what sessions are connected and what resources they are waiting for?

Use of V$SESSION and V$SESSION_WAIT

32.  Describe what redo logs are.

Redo logs are logical and physical structures that are designed to hold all the changes made to a database and are intended to aid in the recovery of a database.

33.  How would you force a log switch?

ALTER SYSTEM SWITCH LOGFILE;
34.  Give two methods you could use to determine what DDL changes have been made.

You could use Logminer or Streams

35.  What does coalescing a tablespace do?

Coalescing is only valid for dictionary-managed tablespaces and de-fragments space by combining neighboring free extents into large single extents.

36.  What is the difference between a TEMPORARY tablespace and a PERMANENT tablespace?

A temporary tablespace is used for temporary objects such as sort structures while permanent tablespaces are used to store those objects meant to be used as the true objects of the database.

37.  Name a tablespace automatically created when you create a database.

The SYSTEM tablespace.

38.  When creating a user, what permissions must you grant to allow them to connect to the database?

Grant the CONNECT to the user.

39.  How do you add a data file to a tablespace?

ALTER TABLESPACE ADD DATAFILE SIZE
40.  How do you resize a data file?

ALTER DATABASE DATAFILE RESIZE ;
41.  What view would you use to look at the size of a data file?

DBA_DATA_FILES
42.  What view would you use to determine free space in a tablespace?

DBA_FREE_SPACE
43.  How would you determine who has added a row to a table?

Turn on fine grain auditing for the table.

44.  How can you rebuild an index?

ALTER INDEX REBUILD;
45.  Explain what partitioning is and what its benefit is.

Partitioning is a method of taking large tables and indexes and splitting them into smaller, more manageable pieces.

46.  You have just compiled a PL/SQL package but got errors, how would you view the errors?

SHOW ERRORS
47.  How can you gather statistics on a table?

The ANALYZE command.

48.  How can you enable a trace for a session?

Use the DBMS_SESSION.SET_SQL_TRACE or

Use ALTER SESSION SET SQL_TRACE = TRUE;

49.  What is the difference between the SQL*Loader and IMPORT utilities?

These two Oracle utilities are used for loading data into the database. The difference is that the import utility relies on the data being produced by another Oracle utility EXPORT while the SQL*Loader utility allows data to be loaded that has been produced by other utilities from different data sources just so long as it conforms to ASCII formatted or delimited files.

50.  Name two files used for network connection to a database.

TNSNAMES.ORA and SQLNET.ORA

Technical - UNIX
Every DBA should know something about the operating system that the database will be running on. The questions here are related to UNIX but you should equally be able to answer questions related to common Windows environments.

1.  How do you list the files in an UNIX directory while also showing hidden files?

ls -ltra
2.  How do you execute a UNIX command in the background?

Use the "&"

3.  What UNIX command will control the default file permissions when files are created?

Umask

4.  Explain the read, write, and execute permissions on a UNIX directory.

Read allows you to see and list the directory contents.

Write allows you to create, edit and delete files and subdirectories in the directory.

Execute gives you the previous read/write permissions plus allows you to change into the directory and execute programs or shells from the directory.

5.  the difference between a soft link and a hard link?

A symbolic (soft) linked file and the targeted file can be located on the same or different file system while for a hard link they must be located on the same file system.

6.  Give the command to display space usage on the UNIX file system.

df -lk
7.  Explain iostat, vmstat and netstat.

Iostat reports on terminal, disk and tape I/O activity.

Vmstat reports on virtual memory statistics for processes, disk, tape and CPU activity.

Netstat reports on the contents of network data structures.

8.  How would you change all occurrences of a value using VI?

Use :%s///g

9.  Give two UNIX kernel parameters that effect an Oracle install

SHMMAX & SHMMNI

10.  Briefly, how do you install Oracle software on UNIX.

Basically, set up disks, kernel parameters, and run orainst.

I hope that these interview questions were not too hard. Remember these are "core" DBA questions and not necessarily related to the Oracle options that you may encounter in some interviews. Take a close look at the requirements for any job and try to extract questions that interviewers may ask from manuals and real life experiences. For instance, if they are looking for a DBA to run their databases in RAC environments, you should try to determine what hardware and software they are using BEFORE you get to the interview. This would allow you to brush up on particular environments and not be caught off-guard. Good luck!

Set 1

Interview Questions for Oracle, DBA, Developer Candidates

PL/SQL Questions:

1. Describe the difference between a procedure, function and anonymous pl/sql block.
Level: Low

Expected answer : Candidate should mention use of DECLARE statement, a function must return a value while a procedure doesn?t have to.

2. What is a mutating table error and how can you get around it?
Level: Intermediate

Expected answer: This happens with triggers. It occurs because the trigger is trying to update a row it is currently using. The usual fix involves either use of views or temporary tables so the database is selecting from one while updating the other.

3. Describe the use of %ROWTYPE and %TYPE in PL/SQL
Level: Low

Expected answer: %ROWTYPE allows you to associate a variable with an entire table row. The %TYPE associates a variable with a single column type.

4. What packages (if any) has Oracle provided for use by developers?
Level: Intermediate to high

Expected answer: Oracle provides the DBMS_ series of packages. There are many which developers should be aware of such as DBMS_SQL, DBMS_PIPE, DBMS_TRANSACTION, DBMS_LOCK, DBMS_ALERT, DBMS_OUTPUT, DBMS_JOB, DBMS_UTILITY, DBMS_DDL, UTL_FILE. If they can mention a few of these and describe how they used them, even better. If they include the SQL routines provided by Oracle, great, but not really what was asked.

5. Describe the use of PL/SQL tables
Level: Intermediate

Expected answer: PL/SQL tables are scalar arrays that can be referenced by a binary integer. They can be used to hold values for use in later queries or calculations. In Oracle 8 they will be able to be of the %ROWTYPE designation, or RECORD.

6. When is a declare statement needed ?
Level: Low

The DECLARE statement is used in PL/SQL anonymous blocks such as with stand alone, non-stored PL/SQL procedures. It must come first in a PL/SQL stand alone file if it is used.

7. In what order should a open/fetch/loop set of commands in a PL/SQL block be implemented if you use the %NOTFOUND cursor variable in the exit when statement? Why?
Level: Intermediate

Expected answer: OPEN then FETCH then LOOP followed by the exit when. If not specified in this order will result in the final return being done twice because of the way the %NOTFOUND is handled by PL/SQL.

8. What are SQLCODE and SQLERRM and why are they important for PL/SQL developers?
Level: Intermediate

Expected answer: SQLCODE returns the value of the error number for the last error encountered. The SQLERRM returns the actual error message for the last error encountered. They can be used in exception handling to report, or, store in an error log table, the error that occurred in the code. These are especially useful for the WHEN OTHERS exception.

9. How can you find within a PL/SQL block, if a cursor is open?
Level: Low

Expected answer: Use the %ISOPEN cursor status variable.

10. How can you generate debugging output from PL/SQL?
Level:Intermediate to high

Expected answer: Use the DBMS_OUTPUT package. Another possible method is to just use the SHOW ERROR command, but this only shows errors. The DBMS_OUTPUT package can be used to show intermediate results from loops and the status of variables as the procedure is executed. The new package UTL_FILE can also be used.

11. What are the types of triggers?
Level:Intermediate to high

Expected Answer: There are 12 types of triggers in PL/SQL that consist of combinations of the BEFORE, AFTER, ROW, TABLE, INSERT, UPDATE, DELETE and ALL key words:
BEFORE ALL ROW INSERT
AFTER ALL ROW INSERT
BEFORE INSERT
AFTER INSERT etc.
DBA:

1. Give one method for transferring a table from one schema to another:
Level:Intermediate

Expected Answer: There are several possible methods, export-import, CREATE TABLE... AS SELECT, or COPY.

2. What is the purpose of the IMPORT option IGNORE? What is it?s default setting?
Level: Low

Expected Answer: The IMPORT IGNORE option tells import to ignore "already exists" errors. If it is not specified the tables that already exist will be skipped. If it is specified, the error is ignored and the tables data will be inserted. The default value is N.

3. You have a rollback segment in a version 7.2 database that has expanded beyond optimal, how can it be restored to optimal?
Level: Low

Expected answer: Use the ALTER TABLESPACE ..... SHRINK command.

4. If the DEFAULT and TEMPORARY tablespace clauses are left out of a CREATE USER command what happens? Is this bad or good? Why?
Level: Low

Expected answer: The user is assigned the SYSTEM tablespace as a default and temporary tablespace. This is bad because it causes user objects and temporary segments to be placed into the SYSTEM tablespace resulting in fragmentation and improper table placement (only data dictionary objects and the system rollback segment should be in SYSTEM).

5. What are some of the Oracle provided packages that DBAs should be aware of?
Level: Intermediate to High

Expected answer: Oracle provides a number of packages in the form of the DBMS_ packages owned by the SYS user. The packages used by DBAs may include: DBMS_SHARED_POOL, DBMS_UTILITY, DBMS_SQL, DBMS_DDL, DBMS_SESSION, DBMS_OUTPUT and DBMS_SNAPSHOT. They may also try to answer with the UTL*.SQL or CAT*.SQL series of SQL procedures. These can be viewed as extra credit but aren?t part of the answer.

6. What happens if the constraint name is left out of a constraint clause?
Level: Low

Expected answer: The Oracle system will use the default name of SYS_Cxxxx where xxxx is a system generated number. This is bad since it makes tracking which table the constraint belongs to or what the constraint does harder.

7. What happens if a tablespace clause is left off of a primary key constraint clause?
Level: Low

Expected answer: This results in the index that is automatically generated being placed in then users default tablespace. Since this will usually be the same tablespace as the table is being created in, this can cause serious performance problems.

8. What is the proper method for disabling and re-enabling a primary key constraint?
Level: Intermediate

Expected answer: You use the ALTER TABLE command for both. However, for the enable clause you must specify the USING INDEX and TABLESPACE clause for primary keys.

9. What happens if a primary key constraint is disabled and then enabled without fully specifying the index clause?
Level: Intermediate

Expected answer: The index is created in the user?s default tablespace and all sizing information is lost. Oracle doesn?t store this information as a part of the constraint definition, but only as part of the index definition, when the constraint was disabled the index was dropped and the information is gone.

10. (On UNIX) When should more than one DB writer process be used? How many should be used?
Level: High

Expected answer: If the UNIX system being used is capable of asynchronous IO then only one is required, if the system is not capable of asynchronous IO then up to twice the number of disks used by Oracle number of DB writers should be specified by use of the db_writers initialization parameter.

11. You are using hot backup without being in archivelog mode, can you recover in the event of a failure? Why or why not?
Level: High

Expected answer: You can?t use hot backup without being in archivelog mode. So no, you couldn?t recover.

12. What causes the "snapshot too old" error? How can this be prevented or mitigated?
Level: Intermediate

Expected answer: This is caused by large or long running transactions that have either wrapped onto their own rollback space or have had another transaction write on part of their rollback space. This can be prevented or mitigated by breaking the transaction into a set of smaller transactions or increasing the size of the rollback segments and their extents.

13. How can you tell if a database object is invalid?
Level: Low

Expected answer: By checking the status column of the DBA_, ALL_ or USER_OBJECTS views, depending upon whether you own or only have permission on the view or are using a DBA account.

14. A user is getting an ORA-00942 error yet you know you have granted them permission on the table, what else should you check?
Level: Low

Expected answer: You need to check that the user has specified the full name of the object (select empid from scott.emp; instead of select empid from emp;) or has a synonym that points to the object (create synonym emp for scott.emp;)

15. A developer is trying to create a view and the database won?t let him. He has the "DEVELOPER" role which has the "CREATE VIEW" system privilege and SELECT grants on the tables he is using, what is the problem?
Level: Intermediate

Expected answer: You need to verify the developer has direct grants on all tables used in the view. You can?t create a stored object with grants given through views.

16. If you have an example table, what is the best way to get sizing data for the production table implementation?
Level: Intermediate

Expected answer: The best way is to analyze the table and then use the data provided in the DBA_TABLES view to get the average row length and other pertinent data for the calculation. The quick and dirty way is to look at the number of blocks the table is actually using and ratio the number of rows in the table to its number of blocks against the number of expected rows.

17. How can you find out how many users are currently logged into the database? How can you find their operating system id?
Level: high

Expected answer: There are several ways. One is to look at the v$session or v$process views. Another way is to check the current_logins parameter in the v$sysstat view. Another if you are on UNIX is to do a "ps -ef|grep oracle|wc -l? command, but this only works against a single instance installation.

18. A user selects from a sequence and gets back two values, his select is:

SELECT pk_seq.nextval FROM dual;

What is the problem?
Level: Intermediate

Expected answer: Somehow two values have been inserted into the dual table. This table is a single row, single column table that should only have one value in it.

19. How can you determine if an index needs to be dropped and rebuilt?
Level: Intermediate

Expected answer: Run the ANALYZE INDEX command on the index to validate its structure and then calculate the ratio of LF_BLK_LEN/LF_BLK_LEN+BR_BLK_LEN and if it isn?t near 1.0 (i.e. greater than 0.7 or so) then the index should be rebuilt. Or if the ratio
BR_BLK_LEN/ LF_BLK_LEN+BR_BLK_LEN is nearing 0.3.

SQL/ SQLPlus

1. How can variables be passed to a SQL routine?
Level: Low

Expected answer: By use of the & symbol. For passing in variables the numbers 1-8 can be used (&1, &2,...,&8) to pass the values after the command into the SQLPLUS session. To be prompted for a specific variable, place the ampersanded variable in the code itself:
"select * from dba_tables where owner=&owner_name;" . Use of double ampersands tells SQLPLUS to resubstitute the value for each subsequent use of the variable, a single ampersand will cause a reprompt for the value unless an ACCEPT statement is used to get the value from the user.

2. You want to include a carriage return/linefeed in your output from a SQL script, how can you do this?
Level: Intermediate to high

Expected answer: The best method is to use the CHR() function (CHR(10) is a return/linefeed) and the concatenation function "||". Another method, although it is hard to document and isn?t always portable is to use the return/linefeed as a part of a quoted string.

3. How can you call a PL/SQL procedure from SQL?
Level: Intermediate

Expected answer: By use of the EXECUTE (short form EXEC) command.

4. How do you execute a host operating system command from within SQL?
Level: Low

Expected answer: By use of the exclamation point "!" (in UNIX and some other OS) or the HOST (HO) command.

5. You want to use SQL to build SQL, what is this called and give an example
Level: Intermediate to high

Expected answer: This is called dynamic SQL. An example would be:

set lines 90 pages 0 termout off feedback off verify off
spool drop_all.sql
select ?drop user ?||username||? cascade;? from dba_users
where username not in ("SYS?,?SYSTEM?);
spool off

Essentially you are looking to see that they know to include a command (in this case DROP USER...CASCADE;) and that you need to concatenate using the ?||? the values selected from the database.

6. What SQLPlus command is used to format output from a select?
Level: low

Expected answer: This is best done with the COLUMN command.

7. You want to group the following set of select returns, what can you group on?

Max(sum_of_cost), min(sum_of_cost), count(item_no), item_no
Level: Intermediate

Expected answer: The only column that can be grouped on is the "item_no" column, the rest have aggregate functions associated with them.

8. What special Oracle feature allows you to specify how the cost based system treats a SQL statement?
Level: Intermediate to high

Expected answer: The COST based system allows the use of HINTs to control the optimizer path selection. If they can give some example hints such as FIRST ROWS, ALL ROWS, USING INDEX, STAR, even better.

9. You want to determine the location of identical rows in a table before attempting to place a unique index on the table, how can this be done?
Level: High

Expected answer: Oracle tables always have one guaranteed unique column, the rowid column. If you use a min/max function against your rowid and then select against the proposed primary key you can squeeze out the rowids of the duplicate rows pretty quick. For example:

select rowid from emp e
where e.rowid > (select min(x.rowid)
from emp x
where x.emp_no = e.emp_no);

In the situation where multiple columns make up the proposed key, they must all be used in the where clause.

10. What is a Cartesian product?
Level: Low

Expected answer: A Cartesian product is the result of an unrestricted join of two or more tables. The result set of a three table Cartesian product will have x * y * z number of rows where x, y, z correspond to the number of rows in each table involved in the join.

11. You are joining a local and a remote table, the network manager complains about the traffic involved, how can you reduce the network traffic?
Level: High

Expected answer: Push the processing of the remote data to the remote instance by using a view to pre-select the information for the join. This will result in only the data required for the join being sent across.

12. What is the default ordering of an ORDER BY clause in a SELECT statement?
Level: Low

Expected answer: Ascending
13. What is tkprof and how is it used?
Level: Intermediate to high

Expected answer: The tkprof tool is a tuning tool used to determine cpu and execution times for SQL statements. You use it by first setting timed_statistics to true in the initialization file and then turning on tracing for either the entire database via the sql_trace parameter or for the session using the ALTER SESSION command. Once the trace file is generated you run the tkprof tool against the trace file and then look at the output from the tkprof tool. This can also be used to generate explain plan output.

14. What is explain plan and how is it used?
Level: Intermediate to high

Expected answer: The EXPLAIN PLAN command is a tool to tune SQL statements. To use it you must have an explain_table generated in the user you are running the explain plan for. This is created using the utlxplan.sql script. Once the explain plan table exists you run the explain plan command giving as its argument the SQL statement to be explained. The explain_plan table is then queried to see the execution plan of the statement. Explain plans can also be run using tkprof.

15. How do you set the number of lines on a page of output? The width?
Level: Low

Expected answer: The SET command in SQLPLUS is used to control the number of lines generated per page and the width of those lines, for example SET PAGESIZE 60 LINESIZE 80 will generate reports that are 60 lines long with a line width of 80 characters. The PAGESIZE and LINESIZE options can be shortened to PAGES and LINES.

16. How do you prevent output from coming to the screen?
Level: Low

Expected answer: The SET option TERMOUT controls output to the screen. Setting TERMOUT OFF turns off screen output. This option can be shortened to TERM.

17. How do you prevent Oracle from giving you informational messages during and after a SQL statement execution?
Level: Low

Expected answer: The SET options FEEDBACK and VERIFY can be set to OFF.

18. How do you generate file output from SQL?
Level: Low

Expected answer: By use of the SPOOL command

Tuning Questions:

1. A tablespace has a table with 30 extents in it. Is this bad? Why or why not.
Level: Intermediate

Expected answer: Multiple extents in and of themselves aren?t bad. However if you also have chained rows this can hurt performance.

2. How do you set up tablespaces during an Oracle installation?
Level: Low

Expected answer: You should always attempt to use the Oracle Flexible Architecture standard or another partitioning scheme to ensure proper separation of SYSTEM, ROLLBACK, REDO LOG, DATA, TEMPORARY and INDEX segments.

3. You see multiple fragments in the SYSTEM tablespace, what should you check first?
Level: Low

Expected answer: Ensure that users don?t have the SYSTEM tablespace as their TEMPORARY or DEFAULT tablespace assignment by checking the DBA_USERS view.

4. What are some indications that you need to increase the SHARED_POOL_SIZE parameter?
Level: Intermediate

Expected answer: Poor data dictionary or library cache hit ratios, getting error ORA-04031. Another indication is steadily decreasing performance with all other tuning parameters the same.

5. What is the general guideline for sizing db_block_size and db_multi_block_read for an application that does many full table scans?
Level: High

Expected answer: Oracle almost always reads in 64k chunks. The two should have a product equal to 64 or a multiple of 64.

6. What is the fastest query method for a table?
Level: Intermediate

Expected answer: Fetch by rowid
7. Explain the use of TKPROF? What initialization parameter should be turned on to get full TKPROF output?
Level: High

Expected answer: The tkprof tool is a tuning tool used to determine cpu and execution times for SQL statements. You use it by first setting timed_statistics to true in the initialization file and then turning on tracing for either the entire database via the sql_trace parameter or for the session using the ALTER SESSION command. Once the trace file is generated you run the tkprof tool against the trace file and then look at the output from the tkprof tool. This can also be used to generate explain plan output.

8. When looking at v$sysstat you see that sorts (disk) is high. Is this bad or good? If bad -How do you correct it?
Level: Intermediate

Expected answer: If you get excessive disk sorts this is bad. This indicates you need to tune the sort area parameters in the initialization files. The major sort are parameter is the SORT_AREA_SIZe parameter.

9. When should you increase copy latches? What parameters control copy latches?
Level: high

Expected answer: When you get excessive contention for the copy latches as shown by the "redo copy" latch hit ratio. You can increase copy latches via the initialization parameter LOG_SIMULTANEOUS_COPIES to twice the number of CPUs on your system.

10. Where can you get a list of all initialization parameters for your instance? How about an indication if they are default settings or have been changed?
Level: Low

Expected answer: You can look in the init.ora file for an indication of manually set parameters. For all parameters, their value and whether or not the current value is the default value, look in the v$parameter view.

11. Describe hit ratio as it pertains to the database buffers. What is the difference between instantaneous and cumulative hit ratio and which should be used for tuning?
Level: Intermediate

Expected answer: The hit ratio is a measure of how many times the database was able to read a value from the buffers verses how many times it had to re-read a data value from the disks. A value greater than 80-90% is good, less could indicate problems. If you simply take the ratio of existing parameters this will be a cumulative value since the database started. If you do a comparison between pairs of readings based on some arbitrary time span, this is the instantaneous ratio for that time span. Generally speaking an instantaneous reading gives more valuable data since it will tell you what your instance is doing for the time it was generated over.
12. Discuss row chaining, how does it happen? How can you reduce it? How do you correct it?
Level: high

Expected answer: Row chaining occurs when a VARCHAR2 value is updated and the length of the new value is longer than the old value and won?t fit in the remaining block space. This results in the row chaining to another block. It can be reduced by setting the storage parameters on the table to appropriate values. It can be corrected by export and import of the effected table.

13. When looking at the estat events report you see that you are getting busy buffer waits. Is this bad? How can you find what is causing it?
Level: high

Expected answer: Buffer busy waits could indicate contention in redo, rollback or data blocks. You need to check the v$waitstat view to see what areas are causing the problem. The value of the "count" column tells where the problem is, the "class" column tells you with what. UNDO is rollback segments, DATA is data base buffers.

14. If you see contention for library caches how can you fix it?
Level: Intermediate

Expected answer: Increase the size of the shared pool.

15. If you see statistics that deal with "undo" what are they really talking about?
Level: Intermediate

Expected answer: Rollback segments and associated structures.

16. If a tablespace has a default pctincrease of zero what will this cause (in relationship to the smon process)?
Level: High

Expected answer: The SMON process won?t automatically coalesce its free space fragments.

17. If a tablespace shows excessive fragmentation what are some methods to defragment the tablespace? (7.1,7.2 and 7.3 only)
Level: High

Expected answer: In Oracle 7.0 to 7.2 The use of the 'alter session set events 'immediate trace name coalesce level ts#';? command is the easiest way to defragment contiguous free space fragmentation. The ts# parameter corresponds to the ts# value found in the ts$ SYS table. In version 7.3 the ?alter tablespace coalesce;? is best. If the free space isn?t contiguous then export, drop and import of the tablespace contents may be the only way to reclaim non-contiguous free space.
18. How can you tell if a tablespace has excessive fragmentation?
Level: Intermediate

If a select against the dba_free_space table shows that the count of a tablespaces extents is greater than the count of its data files, then it is fragmented.

19. You see the following on a status report:

redo log space requests 23
redo log space wait time 0

Is this something to worry about? What if redo log space wait time is high? How can you fix this?
Level: Intermediate

Expected answer: Since the wait time is zero, no. If the wait time was high it might indicate a need for more or larger redo logs.

20. What can cause a high value for recursive calls? How can this be fixed?
Level: High

Expected answer: A high value for recursive calls is cause by improper cursor usage, excessive dynamic space management actions, and or excessive statement re-parses. You need to determine the cause and correct it By either relinking applications to hold cursors, use proper space management techniques (proper storage and sizing) or ensure repeat queries are placed in packages for proper reuse.

21. If you see a pin hit ratio of less than 0.8 in the estat library cache report is this a problem? If so, how do you fix it?
Level: Intermediate

Expected answer: This indicate that the shared pool may be too small. Increase the shared pool size.

22. If you see the value for reloads is high in the estat library cache report is this a matter for concern?
Level: Intermediate

Expected answer: Yes, you should strive for zero reloads if possible. If you see excessive reloads then increase the size of the shared pool.

23. You look at the dba_rollback_segs view and see that there is a large number of shrinks and they are of relatively small size, is this a problem? How can it be fixed if it is a problem?
Level: High
Expected answer: A large number of small shrinks indicates a need to increase the size of the rollback segment extents. Ideally you should have no shrinks or a small number of large shrinks. To fix this just increase the size of the extents and adjust optimal accordingly.

24. You look at the dba_rollback_segs view and see that you have a large number of wraps is this a problem?
Level: High

Expected answer: A large number of wraps indicates that your extent size for your rollback segments are probably too small. Increase the size of your extents to reduce the number of wraps. You can look at the average transaction size in the same view to get the information on transaction size.

25. In a system with an average of 40 concurrent users you get the following from a query on rollback extents:

ROLLBACK CUR EXTENTS
--------------------- --------------------------
R01 11
R02 8
R03 12
R04 9
SYSTEM 4

You have room for each to grow by 20 more extents each. Is there a problem? Should you take any action?
Level: Intermediate

Expected answer: No there is not a problem. You have 40 extents showing and an average of 40 concurrent users. Since there is plenty of room to grow no action is needed.

26. You see multiple extents in the temporary tablespace. Is this a problem?
Level: Intermediate

Expected answer: As long as they are all the same size this isn?t a problem. In fact, it can even improve performance since Oracle won?t have to create a new extent when a user needs one.

Installation/Configuration

1. Define OFA.
Level: Low

Expected answer: OFA stands for Optimal Flexible Architecture. It is a method of placing directories and files in an Oracle system so that you get the maximum flexibility for future tuning and file placement.

2. How do you set up your tablespace on installation?
Level: Low

Expected answer: The answer here should show an understanding of separation of redo and rollback, data and indexes and isolation os SYSTEM tables from other tables. An example would be to specify that at least 7 disks should be used for an Oracle installation so that you can place SYSTEM tablespace on one, redo logs on two (mirrored redo logs) the TEMPORARY tablespace on another, ROLLBACK tablespace on another and still have two for DATA and INDEXES. They should indicate how they will handle archive logs and exports as well. As long as they have a logical plan for combining or further separation more or less disks can be specified.

3. What should be done prior to installing Oracle (for the OS and the disks)?
Level: Low

Expected Answer: adjust kernel parameters or OS tuning parameters in accordance with installation guide. Be sure enough contiguous disk space is available.

4. You have installed Oracle and you are now setting up the actual instance. You have been waiting an hour for the initialization script to finish, what should you check first to determine if there is a problem?
Level: Intermediate to high

Expected Answer: Check to make sure that the archiver isn?t stuck. If archive logging is turned on during install a large number of logs will be created. This can fill up your archive log destination causing Oracle to stop to wait for more space.

5. When configuring SQLNET on the server what files must be set up?
Level: Intermediate

Expected answer: INITIALIZATION file, TNSNAMES.ORA file, SQLNET.ORA file

6. When configuring SQLNET on the client what files need to be set up?
Level: Intermediate

Expected answer: SQLNET.ORA, TNSNAMES.ORA

7. What must be installed with ODBC on the client in order for it to work with Oracle?
Level: Intermediate

Expected answer: SQLNET and PROTOCOL (for example: TCPIP adapter) layers of the transport programs.

8. You have just started a new instance with a large SGA on a busy existing server. Performance is terrible, what should you check for?
Level: Intermediate

Expected answer: The first thing to check with a large SGA is that it isn?t being swapped out.

9. What OS user should be used for the first part of an Oracle installation (on UNIX)?
Level: low

Expected answer: You must use root first.

10. When should the default values for Oracle initialization parameters be used as is?
Level: Low

Expected answer: Never

11. How many control files should you have? Where should they be located?
Level: Low

Expected answer: At least 2 on separate disk spindles. Be sure they say on separate disks, not just file systems.

12. How many redo logs should you have and how should they be configured for maximum recoverability?
Level: Intermediate

Expected answer: You should have at least three groups of two redo logs with the two logs each on a separate disk spindle (mirrored by Oracle). The redo logs should not be on raw devices on UNIX if it can be avoided.

13. You have a simple application with no "hot" tables (i.e. uniform IO and access requirements). How many disks should you have assuming standard layout for SYSTEM, USER, TEMP and ROLLBACK tablespaces?

Expected answer: At least 7, see disk configuration answer above.

Data Modeler:

1. Describe third normal form?
Level: Low

Expected answer: Something like: In third normal form all attributes in an entity are related to the primary key and only to the primary key

2. Is the following statement true or false:

"All relational databases must be in third normal form"

Why or why not?
Level: Intermediate

Expected answer: False. While 3NF is good for logical design most databases, if they have more than just a few tables, will not perform well using full 3NF. Usually some entities will be denormalized in the logical to physical transfer process.

3. What is an ERD?
Level: Low

Expected answer: An ERD is an Entity-Relationship-Diagram. It is used to show the entities and relationships for a database logical model.

4. Why are recursive relationships bad? How do you resolve them?
Level: Intermediate

A recursive relationship (one where a table relates to itself) is bad when it is a hard relationship (i.e. neither side is a "may" both are "must") as this can result in it not being possible to put in a top or perhaps a bottom of the table (for example in the EMPLOYEE table you couldn?t put in the PRESIDENT of the company because he has no boss, or the junior janitor because he has no subordinates). These type of relationships are usually resolved by adding a small intersection entity.

5. What does a hard one-to-one relationship mean (one where the relationship on both ends is "must")?
Level: Low to intermediate

Expected answer: This means the two entities should probably be made into one entity.

6. How should a many-to-many relationship be handled?
Level: Intermediate

Expected answer: By adding an intersection entity table

7. What is an artificial (derived) primary key? When should an artificial (or derived) primary key be used?
Level: Intermediate

Expected answer: A derived key comes from a sequence. Usually it is used when a concatenated key becomes too cumbersome to use as a foreign key.

8. When should you consider denormalization?
Level: Intermediate

Expected answer: Whenever performance analysis indicates it would be beneficial to do so without compromising data integrity.

UNIX:

1. How can you determine the space left in a file system?
Level: Low

Expected answer: There are several commands to do this: du, df, or bdf

2. How can you determine the number of SQLNET users logged in to the UNIX system?
Level: Intermediate

Expected answer: SQLNET users will show up with a process unique name that begins with oracle, if you do a ps -ef|grep oracle|wc -l you can get a count of the number of users.

3. What command is used to type files to the screen?
Level: Low

Expected answer: cat, more, pg

4. What command is used to remove a file?
Level: Low

Expected answer: rm

5. Can you remove an open file under UNIX?
Level: Low

Expected answer: yes

6. How do you create a decision tree in a shell script?
Level: intermediate

Expected answer: depending on shell, usually a case-esac or an if-endif or fi structure

7. What is the purpose of the grep command?
Level: Low

Expected answer: grep is a string search command that parses the specified string from the specified file or files

8. The system has a program that always includes the word nocomp in its name, how can you determine the number of processes that are using this program?
Level: intermediate

Expected answer: ps -ef|grep *nocomp*|wc -l

9. What is an inode?
Level: Intermediate

Expected answer: an inode is a file status indicator. It is stored in both disk and memory and tracts file status. There is one inode for each file on the system.

10. The system administrator tells you that the system hasn?t been rebooted in 6 months, should he be proud of this?
Level: High

Expected answer: Maybe. Some UNIX systems don?t clean up well after themselves. Inode problems and dead user processes can accumulate causing possible performance and corruption problems. Most UNIX systems should have a scheduled periodic reboot so file systems can be checked and cleaned and dead or zombie processes cleared out.

11. What is redirection and how is it used?
Level: Intermediate

Expected answer: redirection is the process by which input or output to or from a process is redirected to another process. This can be done using the pipe symbol "|", the greater than symbol ">" or the "tee" command. This is one of the strengths of UNIX allowing the output from one command to be redirected directly into the input of another command.

12. How can you find dead processes?
Level: Intermediate

Expected answer: ps -ef|grep zombie -- or -- who -d depending on the system.

13. How can you find all the processes on your system?
Level: Low

Expected answer: Use the ps command

14. How can you find your id on a system?
Level: Low

Expected answer: Use the "who am i" command.

15. What is the finger command?
Level: Low

Expected answer: The finger command uses data in the passwd file to give information on system users.

16. What is the easiest method to create a file on UNIX?
Level: Low

Expected answer: Use the touch command

17. What does >> do?
Level: Intermediate

Expected answer: The ">>" redirection symbol appends the output from the command specified into the file specified. The file must already have been created.

18. If you aren?t sure what command does a particular UNIX function what is the best way to determine the command?

Expected answer: The UNIX man -k command will search the man pages for the value specified. Review the results from the command to find the command of interest.

Oracle Troubleshooting:

1. How can you determine if an Oracle instance is up from the operating system level?
Level: Low

Expected answer: There are several base Oracle processes that will be running on multi-user operating systems, these will be smon, pmon, dbwr and lgwr. Any answer that has them using their operating system process showing feature to check for these is acceptable. For example, on UNIX a ps -ef|grep dbwr will show what instances are up.

2. Users from the PC clients are getting messages indicating :
Level: Low

ORA-06114: (Cnct err, can't get err txt. See Servr Msgs & Codes Manual)

What could the problem be?

Expected answer: The instance name is probably incorrect in their connection string.

3. Users from the PC clients are getting the following error stack:
Level: Low

ERROR: ORA-01034: ORACLE not available
ORA-07318: smsget: open error when opening sgadef.dbf file.
HP-UX Error: 2: No such file or directory

What is the probable cause?

Expected answer: The Oracle instance is shutdown that they are trying to access, restart the instance.

4. How can you determine if the SQLNET process is running for SQLNET V1? How about V2?
Level: Low

Expected answer: For SQLNET V1 check for the existence of the orasrv process. You can use the command "tcpctl status" to get a full status of the V1 TCPIP server, other protocols have similar command formats. For SQLNET V2 check for the presence of the LISTENER process(s) or you can issue the command "lsnrctl status".

5. What file will give you Oracle instance status information? Where is it located?
Level: Low

Expected answer: The alert.ora log. It is located in the directory specified by the background_dump_dest parameter in the v$parameter table.
6. Users aren?t being allowed on the system. The following message is received:
Level: Intermediate

ORA-00257 archiver is stuck. Connect internal only, until freed

What is the problem?

Expected answer: The archive destination is probably full, backup the archive logs and remove them and the archiver will re-start.

7. Where would you look to find out if a redo log was corrupted assuming you are using Oracle mirrored redo logs?
Level: Intermediate

Expected answer: There is no message that comes to the SQLDBA or SRVMGR programs during startup in this situation, you must check the alert.log file for this information.

8. You attempt to add a datafile and get:
Level: Intermediate

ORA-01118: cannot add anymore datafiles: limit of 40 exceeded

What is the problem and how can you fix it?

Expected answer: When the database was created the db_files parameter in the initialization file was set to 40. You can shutdown and reset this to a higher value, up to the value of MAX_DATAFILES as specified at database creation. If the MAX_DATAFILES is set to low, you will have to rebuild the control file to increase it before proceeding.

9. You look at your fragmentation report and see that smon hasn?t coalesced any of you tablespaces, even though you know several have large chunks of contiguous free extents. What is the problem?
Level: High

Expected answer: Check the dba_tablespaces view for the value of pct_increase for the tablespaces. If pct_increase is zero, smon will not coalesce their free space.

10. Your users get the following error:
Level: Intermediate

ORA-00055 maximum number of DML locks exceeded
What is the problem and how do you fix it?

Expected answer: The number of DML Locks is set by the initialization parameter DML_LOCKS. If this value is set to low (which it is by default) you will get this error. Increase the value of DML_LOCKS. If you are sure that this is just a temporary problem, you can have them wait and then try again later and the error should clear.

11. You get a call from you backup DBA while you are on vacation. He has corrupted all of the control files while playing with the ALTER DATABASE BACKUP CONTROLFILE command. What do you do?
Level: High
Expected answer: As long as all datafiles are safe and he was successful with the BACKUP controlfile command you can do the following:

CONNECT INTERNAL
STARTUP MOUNT
(Take any read-only tablespaces offline before next step ALTER DATABASE DATAFILE .... OFFLINE;)
RECOVER DATABASE USING BACKUP CONTROLFILE
ALTER DATABASE OPEN RESETLOGS;
(bring read-only tablespaces back online)

Shutdown and backup the system, then restart

If they have a recent output file from the ALTER DATABASE BACKUP CONTROL FILE TO TRACE; command, they can use that to recover as well.

If no backup of the control file is available then the following will be required:

CONNECT INTERNAL
STARTUP NOMOUNT
CREATE CONTROL FILE .....;

However, they will need to know all of the datafiles, logfiles, and settings for MAXLOGFILES, MAXLOGMEMBERS, MAXLOGHISTORY, MAXDATAFILES for the database to use the command.

SET 3

1.      To see current user name
 Sql> show user;

2.      Change SQL prompt name
 SQL> set sqlprompt “Manimara > “
Manimara >
Manimara >

3.      Switch to DOS prompt
 SQL> host

4.      How do I eliminate the duplicate rows ?
 SQL> delete from table_name where rowid not in (select max(rowid) from table group by duplicate_values_field_name);
or
SQL> delete from table_name ta where rowid >(select min(rowid)  from table_name tb where ta.dv=tb.dv and .....);
Example.
Table Emp
Empno Ename
101               Scott
102               Jiyo
103               Millor
104               Jiyo
105               Smith
delete from emp a where rowid < ( select max(rowid) from emp b where a.ename = b.ename );
The output like,
Empno Ename
101               Scott
103               Millor
104               Jiyo
105               Smith

5.      How do I display row number with records?
To achive this use rownum pseudocolumn with query, like SQL> SQL> select rownum, ename from emp;
Output:
1                    Scott
2                    Millor
3                    Jiyo
4                    Smith

6.      Display the records between two range
select rownum, empno, ename  from emp  where  rowid in
 (select rowid from emp where rownum <=&upto
 minus
 select rowid from emp where rownum<&Start);
Enter value for upto: 10
Enter value for Start: 7

   ROWNUM     EMPNO ENAME
--------- --------- ----------
        1      7782 CLARK
        2      7788 SCOTT
        3      7839 KING
        4      7844 TURNER

7.      I know the nvl function only allows the same data type(ie. number or char or date Nvl(comm, 0)), if commission is null then the text “Not Applicable”  want to display, instead of blank space. How do I write the query?

 SQL> select nvl(to_char(comm.),'NA') from emp;

Output :

NVL(TO_CHAR(COMM),'NA')
-----------------------
NA
300
500
NA
1400
NA
NA

8.      Oracle cursor : Implicit & Explicit cursors
Oracle uses work areas called private SQL areas to create SQL statements.
PL/SQL construct to identify each and every work are used, is called as Cursor.
For SQL queries returning a single row, PL/SQL declares all implicit cursors.
For queries that returning more than one row, the cursor needs to be explicitly declared.

9.      Explicit Cursor attributes
 There are four cursor attributes used in Oracle
cursor_name%Found, cursor_name%NOTFOUND, cursor_name%ROWCOUNT, cursor_name%ISOPEN

10.  Implicit Cursor attributes
 Same as explicit cursor but prefixed by the word SQL

SQL%Found, SQL%NOTFOUND, SQL%ROWCOUNT, SQL%ISOPEN

Tips : 1. Here SQL%ISOPEN is false, because oracle automatically closed the implicit cursor after executing SQL statements.
       : 2.  All are  Boolean attributes.

11.  Find out nth highest salary from emp table
 SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal);

Enter value for n: 2
      SAL
---------
     3700

12.  To view installed Oracle version information
 SQL> select banner from v$version;

13.  Display the number value in Words
 SQL> select sal, (to_char(to_date(sal,'j'), 'jsp'))
from emp;
the output like,

      SAL (TO_CHAR(TO_DATE(SAL,'J'),'JSP'))
--------- -----------------------------------------------------
      800 eight hundred
     1600 one thousand six hundred
     1250 one thousand two hundred fifty
If you want to add some text like,
Rs. Three Thousand only.
SQL> select sal  "Salary ",
 (' Rs. '|| (to_char(to_date(sal,'j'), 'Jsp'))|| ' only.'))
 "Sal in Words" from emp
/
Salary  Sal in Words
------- ------------------------------------------------------
    800  Rs. Eight Hundred only.
   1600  Rs. One Thousand Six Hundred only.
   1250  Rs. One Thousand Two Hundred Fifty only.

14.  Display Odd/ Even number of records
 Odd number of records:
select * from emp where (rowid,1) in (select rowid, mod(rownum,2) from emp);
1
3
5
Even number of records:
select * from emp where (rowid,0) in (select rowid, mod(rownum,2) from emp)
2
4
6

15.  Which date function returns number value?
 months_between

16.  Any three PL/SQL Exceptions?
 Too_many_rows, No_Data_Found, Value_Error, Zero_Error, Others

17.  What are PL/SQL Cursor Exceptions?
 Cursor_Already_Open, Invalid_Cursor

18.  Other way to replace query result null value with a text
 SQL> Set NULL ‘N/A’
to reset SQL> Set NULL ‘’

19.   What are the more common pseudo-columns?
 SYSDATE, USER , UID, CURVAL, NEXTVAL, ROWID, ROWNUM

20.   What is the output of SIGN function?
 1 for positive value,
0 for Zero,
-1 for Negative value.

21.  What is the maximum number of triggers, can apply to a single table?
 12 triggers.

Set 4 : PL/SQL interview questions

Which of the following statements is true about implicit cursors?
Implicit cursors are used for SQL statements that are not named.

Developers should use implicit cursors with great care.
Implicit cursors are used in cursor for loops to handle data processing.
Implicit cursors are no longer a feature in Oracle.

Which of the following is not a feature of a cursor FOR loop?
Record type declaration.

Opening and parsing of SQL statements.
Fetches records from cursor.
Requires exit condition to be defined.
A developer would like to use referential datatype declaration on a variable. The variable name is EMPLOYEE_LASTNAME, and the corresponding table and column is EMPLOYEE, and LNAME, respectively. How would the developer define this variable using referential datatypes?
Use employee.lname%type.

Use employee.lname%rowtype.
Look up datatype for EMPLOYEE column on LASTNAME table and use that.
Declare it to be type LONG.
Which three of the following are implicit cursor attributes?
%found

%too_many_rows
%notfound
%rowcount
%rowtype
If left out, which of the following would cause an infinite loop to occur in a simple loop?
LOOP

END LOOP
IF-THEN
EXIT
Which line in the following statement will produce an error?
cursor action_cursor is

select name, rate, action
into action_record
from action_table;
There are no errors in this statement.
The command used to open a CURSOR FOR loop is
open

fetch
parse
None, cursor for loops handle cursor opening implicitly.
What happens when rows are found using a FETCH statement
It causes the cursor to close

It causes the cursor to open
It loads the current row values into variables
It creates the variables to hold the current row values
Read the following code:

CREATE OR REPLACE PROCEDURE find_cpt
(v_movie_id {Argument Mode} NUMBER, v_cost_per_ticket {argument mode} NUMBER)
IS
BEGIN
  IF v_cost_per_ticket  > 8.5 THEN
SELECT  cost_per_ticket
INTO            v_cost_per_ticket
FROM            gross_receipt
WHERE   movie_id = v_movie_id;
  END IF;
END;
Which mode should be used for V_COST_PER_TICKET?

IN
OUT
RETURN
IN OUT
Read the following code:

CREATE OR REPLACE TRIGGER update_show_gross
      {trigger information}
     BEGIN
      {additional code}
     END;
The trigger code should only execute when the column, COST_PER_TICKET, is greater than $3. Which trigger information will you add?

WHEN (new.cost_per_ticket > 3.75)

WHEN (:new.cost_per_ticket > 3.75
WHERE (new.cost_per_ticket > 3.75)
WHERE (:new.cost_per_ticket > 3.75)
What is the maximum number of handlers processed before the PL/SQL block is exited when an exception occurs?
Only one

All that apply
All referenced
None
For which trigger timing can you reference the NEW and OLD qualifiers?
Statement and Row

Statement only
Row only
Oracle Forms trigger
Read the following code:

CREATE OR REPLACE FUNCTION get_budget(v_studio_id IN NUMBER)
RETURN number IS

v_yearly_budget NUMBER;

BEGIN
       SELECT  yearly_budget
       INTO            v_yearly_budget
       FROM            studio
       WHERE   id = v_studio_id;

       RETURN v_yearly_budget;
END;
Which set of statements will successfully invoke this function within SQL*Plus?

VARIABLE g_yearly_budget NUMBER
EXECUTE g_yearly_budget := GET_BUDGET(11);

VARIABLE g_yearly_budget NUMBER
EXECUTE :g_yearly_budget := GET_BUDGET(11);

VARIABLE :g_yearly_budget NUMBER
EXECUTE :g_yearly_budget := GET_BUDGET(11);

VARIABLE g_yearly_budget NUMBER
:g_yearly_budget := GET_BUDGET(11);
CREATE OR REPLACE PROCEDURE update_theater
(v_name IN VARCHAR v_theater_id IN NUMBER) IS
BEGIN
       UPDATE  theater
       SET             name = v_name
       WHERE   id = v_theater_id;
END update_theater;
When invoking this procedure, you encounter the error:

ORA-000: Unique constraint(SCOTT.THEATER_NAME_UK) violated.How should you modify the function to handle this error?

An user defined exception must be declared and associated with the error code and handled in the EXCEPTION section.

Handle the error in EXCEPTION section by referencing the error code directly.
Handle the error in the EXCEPTION section by referencing the UNIQUE_ERROR predefined exception.
Check for success by checking the value of SQL%FOUND immediately after the UPDATE statement.
Read the following code:

CREATE OR REPLACE PROCEDURE calculate_budget IS
v_budget        studio.yearly_budget%TYPE;
BEGIN
       v_budget := get_budget(11);
       IF v_budget < 30000
THEN
               set_budget(11,30000000);
       END IF;
END;
You are about to add an argument to CALCULATE_BUDGET. What effect will this have?

The GET_BUDGET function will be marked invalid and must be recompiled before the next execution.

The SET_BUDGET function will be marked invalid and must be recompiled before the next execution.
Only the CALCULATE_BUDGET procedure needs to be recompiled.
All three procedures are marked invalid and must be recompiled.
Which procedure can be used to create a customized error message?
RAISE_ERROR

SQLERRM
RAISE_APPLICATION_ERROR
RAISE_SERVER_ERROR
The CHECK_THEATER trigger of the THEATER table has been disabled. Which command can you issue to enable this trigger?
ALTER TRIGGER check_theater ENABLE;

ENABLE TRIGGER check_theater;
ALTER TABLE check_theater ENABLE check_theater;
ENABLE check_theater;
Examine this database trigger

CREATE OR REPLACE TRIGGER prevent_gross_modification
{additional trigger information}
BEGIN
       IF TO_CHAR(sysdate, DY) = MON
THEN
RAISE_APPLICATION_ERROR(-20000,Gross receipts cannot be deleted on Monday);
       END IF;
END;
This trigger must fire before each DELETE of the GROSS_RECEIPT table. It should fire only once for the entire DELETE statement. What additional information must you add?

BEFORE DELETE ON gross_receipt

AFTER DELETE ON gross_receipt
BEFORE (gross_receipt DELETE)
FOR EACH ROW DELETED FROM gross_receipt
Examine this function:

CREATE OR REPLACE FUNCTION set_budget
(v_studio_id IN NUMBER, v_new_budget IN NUMBER) IS
BEGIN
       UPDATE  studio
       SET             yearly_budget = v_new_budget
       WHERE   id = v_studio_id;

       IF SQL%FOUND THEN
               RETURN TRUEl;
       ELSE
               RETURN FALSE;
       END IF;

       COMMIT;
END;
Which code must be added to successfully compile this function?

Add RETURN right before the IS keyword.

Add RETURN number right before the IS keyword.
Add RETURN boolean right after the IS keyword.
Add RETURN boolean right before the IS keyword.
Under which circumstance must you recompile the package body after recompiling the package specification?
Altering the argument list of one of the package constructs

Any change made to one of the package constructs
Any SQL statement change made to one of the package constructs
Removing a local variable from the DECLARE section of one of the package constructs
Procedure and Functions are explicitly executed. This is different from a database trigger. When is a database trigger executed?
When the transaction is committed

During the data manipulation statement
When an Oracle supplied package references the trigger
During a data manipulation statement and when the transaction is committed
Which Oracle supplied package can you use to output values and messages from database triggers, stored procedures and functions within SQL*Plus?
DBMS_DISPLAY

DBMS_OUTPUT
DBMS_LIST
DBMS_DESCRIBE
What occurs if a procedure or function terminates with failure without being handled?
Any DML statements issued by the construct are still pending and can be committed or rolled back.

Any DML statements issued by the construct are committed
Unless a GOTO statement is used to continue processing within the BEGIN section, the construct terminates.
The construct rolls back any DML statements issued and returns the unhandled exception to the calling environment.
Examine this code

BEGIN
       theater_pck.v_total_seats_sold_overall := theater_pck.get_total_for_year;
END;
For this code to be successful, what must be true?

Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist only in the body of the THEATER_PCK package.

Only the GET_TOTAL_FOR_YEAR variable must exist in the specification of the THEATER_PCK package.
Only the V_TOTAL_SEATS_SOLD_OVERALL variable must exist in the specification of the THEATER_PCK package.
Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist in the specification of the THEATER_PCK package.
A stored function must return a value based on conditions that are determined at runtime. Therefore, the SELECT statement cannot be hard-coded and must be created dynamically when the function is executed. Which Oracle supplied package will enable this feature?
DBMS_DDL

DBMS_DML
DBMS_SYN
DBMS_SQL

Answers{
Thanks again for publishing my questions.

Tech Interviews comment by Sachin Rastogi (rsachin@krify.com)

1.1
2.2
3.1
4.(1,3,4)
5.2
6.3
7.4
8.2
9.2
10.(3,4)
11.1
12.4
13.1
14.1
15.3
16.3
17.1
18.(1,4)
19.4
20.3
21.4
22.2
23.4
24.3
25.4

please let me know how many answers are right. in this pl/sql test.

Thanks & Regards,
Sudhir Rao.

Tech Interviews comment by Sudhir

Answer to question-2 is 4

Tech Interviews comment by Unnamed

24 IS 4

Tech Interviews comment by dcz

The answer to the question 8 is wrong; should be 3.

Tech Interviews comment by Stephen Jacob

Answer to number 9 should be 4.
How can you check for the initial value, if there is no user input?

Tech Interviews comment by Stephen Jacob

The Answer to the question 8 is 3rd Choice.

Tech Interviews comment by Ahamed Tharik.N

Question 13 all the four answers are wrong , the function executed like this

SQL> select get_budget(11) into :g_yearly_budget from dual;

GET_BUDGET(11)
————–

Let me know, if you have any Suggestions.

Tech Interviews comment by Ahamed Tharik.N

The Answer to the question 5 is 4rd Choice.
If you are missing the END LOOP (2), the loop do not work, procedure does not compile.

Tech Interviews comment by Francisco J. Banda

The Answer to the question 5 is 1rd Choice.
Iti’s imposible that both 3 and 4 are correct. We do not need location (where) we need time (when).

Tech Interviews comment by Francisco J. Banda

The Answer to the question 5 is 3rd Choice.
The 4rd (Oracle Forms trigger) is in some way correct, but oracle triggers and Forms triggers are not the same. This question is about Oracle triggers (not Forms).

Tech Interviews comment by Francisco J. Banda

Hi Ahamed Tharik.N your answer is correct, but also answer number 2 works to be able to see the result uses SQL>print g_yearly_budget.

Tech Interviews comment by Francisco J. Banda

The answer to the question 13 should be 2.

I fully agree with Francisco J. Banda. For Francisco, your answers are right, just match question numbers.

I tried to do and here is the revised answer list. (T means correct answer choice)

1.)1 : T
2.)2 - 4 : 4 - T
3.)1 : T
4.)(1,3,4) - T
5.)2 - 4 : 4 - T
6.)3 - T
7.)4 - T
8.)2 - 3 - 3 : 3 - T
9.)2 - 4 : 4 - T
10.)(3,4) - 1
11.)1 - [I dont know correct answer]
12.)4 - 3 : 3 - T
13.)1 - ? : 2 - T

Thanks.

Tech Interviews comment by Pranav Vora

1.1
2.4
3.2
4.1,3,5
5.2
6.2,3
7.1
8.3
9.4
10.4
11.4
12.1
13.2
14.4
15.3
16.2
17.2
18.1
19.4
20.3
21.4
22.2
23.4
24.4
25.4

Tech Interviews comment by Arti Shah

The answer to the 23 is 4

Tech Interviews comment by vijay

answer for 22 is 2

Tech Interviews comment by vijay

answer for 18 is 1

Tech Interviews comment by oraguru

Right answer to QUS.5 is 4th option coz if end loop is missed in programming it wud through error while compiling , but if u missed EXIT , the program wud not know where to exit the loop …and loop wud go on

Tech Interviews comment by cobra

1. 1
2. 4
3. 1
4. 1,3,4
5. 2
6. 2,3
7. 4
8. 3
9. 4
10. 1
11. 2
12. 3
13. 2
14.4
15. 3
16. 3
17.2
18. 1
19. 3
20.3
21. 4
22. 2

Tech Interviews comment by aa

}

Set 5 : SQL ,PL/SQL & D2K Interview Questions
[message #27446] Fri, 03 October 2003 03:43
Gurusubramanyam
Messages: 78

1. How to implement ISNUMERIC function in SQL *Plus ?

Method 1:

Select length (translate (trim (column_name),' +-.0123456789',' ')) from dual ;

Will give you a zero if it is a number or greater than zero if not numeric (actually gives the count of non numeric characters)

Method 2:

select instr(translate('wwww',
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'),'X')
FROM dual;

It returns 0 if it is a number, 1 if it is not.

2. How to Select last N records from a Table?

select * from (select rownum a, CLASS_CODE,CLASS_DESC from clm)
where a > ( select (max(rownum)-10) from clm)

Here N = 10

The following query has a Problem of performance in the execution of the following query where the table ter.ter_master have 22231 records. So the results are obtained after hours.

Cursor rem_master(brepno VARCHAR2) IS
select a.* from ter.ter_master a
where NOT a.repno in (select repno from ermast) and
(brepno = 'ALL' or a.repno > brepno)
Order by a.repno

What are steps required tuning this query to improve its performance?

?Ï Have an index on TER_MASTER.REPNO and one on ERMAST.REPNO

?Ï Be sure to get familiar with EXPLAIN PLAN. This can help you determine the execution path that Oracle takes. If you are using Cost Based Optimizer mode, then be sure that your statistics on TER_MASTER are up-to-date.
?Ï Also, you can change your SQL to:

SELECT a.*
FROM ter.ter_master a
WHERE NOT EXISTS (SELECT b.repno FROM ermast b
WHERE a.repno=b.repno) AND
(a.brepno = 'ALL' or a.repno > a.brepno)
ORDER BY a.repno;

3. What is the difference between Truncate and Delete interms of Referential Integrity?

DELETE removes one or more records in a table, checking referential
Constraints (to see if there are dependent child records) and firing any
DELETE triggers. In the order you are deleting (child first then parent)
There will be no problems.

TRUNCATE removes ALL records in a table. It does not execute any triggers.
Also, it only checks for the existence (and status) of another foreign key
Pointing to the table. If one exists and is enabled, then you will get
The following error. This is true even if you do the child tables first.

ORA-02266: unique/primary keys in table referenced by enabled foreign keys

You should disable the foreign key constraints in the child tables before
issuing the TRUNCATE command, then re-enable them afterwards.

CLIENT/SERVER

What does preemptive in preemptive multitasking mean ?

Preemptive refers to the fact that each task is alloted fixed time slots and at the end of that time slot the next task is started.

What does the OLTP stands for ?

OLTP stands for On Line Transaction Processing

What is the most important requirement for OLTP ?

OLTP requires real time response.

In a client server environment, what would be the major work that the client deals with ?

The client deals with the user interface part of the system.

Why is the most of the processing done at the sever ?

To reduce the network traffic and for application sharing and implementing business rules.

What does teh term upsizing refer to ?

Applications that have outgrown their environment are re-engineered to run in a larger environment. This is upsizing.

What does one do when one is rightsizing ?

With rightsizing, one would move applications to the most appropriate server platforms.

What does the term downsizing refer to ?

A host based application is re-engineered to run in smaller or LAN based environment.

What is event trigger ?

An event trigger, a segment of code which is associated with each event and is fired when the event occurs.

Why do stored procedures reduce network traffic ?

When a stored procedure is called, only the procedure call is sent to the server and not the statements that the procedure contains.

What are the types of processes that a server runs ?

Foreground process and
Background process.

What is a event handler ?

An event handler is a routine that is written to respond to a particular event.

What is an integrity constraint ?

An integrity constraint allows the definition of certain restrictions, at the table level, on the data that is entered into a table.

What are the various uses of database triggers ?

Database triggers can be used to enforce business rules, to maintain derived values and perform value-based auditing.

What is a transaction ?

A transaction is a set of operations that begin when the first DML is issued and end when a commit or rollback is issued. BEGIN COMMIT/ROLLBACK are the boundries of a transaction.

Why are the integrity constraints preferred to database triggers ?

Because it is easier to define an integrity constraint than a database trigger.

Why is it better to use an integrity constraint to validate data in a table than to use a stored procedure ?

Because an integrity constraint is automatically checked while data is inserted into a table. A stored has to be specifically invoked.

What are the three components of a client server model ?

A Client,
A Server and
A Network/Communication software.

What are the advantages of client/server model ?

Flexibility of the system, scalability, cost saving, centralised control and implementation of business rules, increase of developers productivity, portability, improved network and resource utilization.

What are the disadvantages of the client/server model ?

Heterogeneity of the system results in reduced reliablity. May not be suitable for all applications. Managing and tuning networks becomes difficult.

What are the different topologies available for network ?

Star,
Bus,
Ring.

What is the first work of Client process ?

A client process at first establishes connection with the Server.

What are the responsibilities of a Server ?

1. Manage resources optimally across multiple clients.
2. Controlling database access and security.
3. Protecting the databse and recovering it from crashes.
4. Enforcing integrity rules globally.

In a Client/Server context, what does API (Application Programming Interface) refer to ?

An API, in a Client/Server context, is a specification of a set of functions for communication between the client and the server.

Give some examples of standard API¡Šs ?

Open Database Connectivity (ODBC),
Integrated Database Application Programming Interface (IDAPI),
XOpen
SQL/CLI

What is the main advantage of developing an application using an API ?

The application can be connected to any back end server that is supported by the API.

What is the main disadvantage of developing an application using an API ?

The application cannot use any special features of the backend server.

Why is an event driven program referred to a passive program ?

Because an event driven program is always waiting for something to happen before processing.

What are the four types of events ?

1. System Events.
2. Control Events
3. User Events
4. Other Events.

What is the difference between file server and a database server ?

A file server just transfers all the data requested by all its client and the client processes the data while a database server runs the query and sends only the query output.

What is inheritance ?

Inheritance is a method by which properties and methods of an existing object are automatically passed to any object derived from it.

What are the two components of ODBC ?

1. An ODBC manager/administrator and
2. ODBC driver.

What is the function of a ODBC manager ?

The ODBC Manager manages all the data sources that exists in the system.

What is the function of a ODBC Driver ?

The ODBC Driver allows the developer to talk to the back end database.

What description of a data source is required for ODBC ?

The name of the DBMS, the location of the source and the database dependent information.

How is a connection establised by ODBC ?

ODBC uses the description of the datasource available in the ODBC.INI file to load the required drivers to access that particular back end database.

RDBMS FUNDAMENTALS
I. INTRODUCING DATABASES :
Concept of a Database :
Traditional Approach : In this approach, independent application programs access their own independent data files. This results in many problems in data storage and retrieval.
Database Approach : In this approach, all application access a common database, which is a centralized data storage system. This approach has the following advantages :
Redundancy of data storage is reduced, Inconsistency in data is eliminated & Data sharing between applications is possible.
Interacting with a Database :
Database Management System (DBMS) : DBMS is a software that interfaces between applications and a database for all data processing activities.
Users of a DBMS : End Users, Application Programmers and Database Administrators use a DBMS, either directly or indirectly.
How users interact with a Database :
1. End users send queries to the DBMS through applications.
2. The DBMS translates the queries.
3. The DBMS retrieves data from the database.
4. The DBMS sends data to the application, which present the data to the end users.
Functions of a DBMS :
Function of DBMS Description Provided by using
Defining the data structure Defining structure of data to be stored in database Data Definition Language (DDL)
Manipulating Data Retrieving, adding, modifying, deleting data. Data Manipulation Language (DML)
Data Security Preventing unauthorized access to data. User-ids and Passwords.
Control of Data Access Allowing users to use only relevant data Data Control Language (DCL)
Architecture of a Database :
Need for an Architecture : The details about complexity and structure of data in a database in not required by end-users. Therefore, differentiating what the end-users see and what is actually there in a database is important.
Architecture of a Database : The architecture of a database comprises a set of three levels at which a database can be viewed.
External Level or View, Conceptual Level or View & Internal Level or View.
II. USING RELATIONAL DATABASE :
Basics of Relational Database :
Relational Database Management System (RDBMS) : RDBMS is the most popular form of DBMS used in the world. It uses a relational database to organize data. A relational database comprise relations, which are represented as tables.
Relation : A relation stores information about an object in the real world. A relation is represented as a table.
Attribute : Each attribute of a relation stores a piece of information about an object. Attributes are represented as columns in a tables and can be arranged in any order. Each attribute in a relation is unique and contain atomic values i.e. Atomic value contain a single value of data and Non-Atomic values contain a set of values. The number of attributes in a relation is called the degree of the relation.
Tuple : A row in a table is called a tuple of the relation. The number of tuples in a relation is known as the cardinality of the relation. Tuples in a table are unique and can be arranged in any order.
Domain : A domain is a set of valid atomic values that an attribute can take. Within a single database, an attribute cannot have different domains associated with it. A domain can include a null value, if the value for the domain is unknown or does not exist.
Identifiers for Relations :
Primary Key : An attribute that uniquely identifies a row in a table is called its primary key. A relation can have only one primary key. The primary key cannot have any null values. In case no unique key is found in a relation, two or more attributes can be treated as the primary key. Such keys are called Composite Keys.
Candidate Key : A relation can have more than one attribute that uniquely identifies a tuple. Any one of these keys can be selected as the primary key. All such attributes are called Candidate Keys. All candidate keys that are not primary keys are called Alternate Keys.
Foreign Key : An attribute that is not a candidate key is called a Nonkey. A nonkey attribute of a relation whose value matches the primary key in some other table is called Foreign Key OR is a column in a table that uniquely identifies rows from a different table.
III. INTERPRETING DATA :
Entities and Relationships :
Entity : An entity is an object that exists in the real world and is distinguishable from other objects. Each entity is represented as a table in a relational database.
Types of Entities : Entities can be classified in two ways - based on existence and based on subsets.
Based on existence, entities can be classified as Dominant and Weak entities.
Based on subsets, entities can be classifies as Supertypes and Subtypes.
Relationships : A relationship is an association between two entities.
Types of Relationships : Relationships are classified into three types based on the occurrence of the related entities.
One-to-One(1-1), One-to-Many(1-M) & Many-to-Many(M-M).
Using E/R Diagram : A E/R diagram represent entities and relationships in a database system.
Reducing E/R Diagrams to Relations :
Mapping Entities : A dominant entity is mapped to a new relation. A weak entity is mapped to a new relation. The primary key of the corresponding dominant entity is included as the foreign key in the weak entity relation.
Supertypes and subtypes are mapped to separate relations. The primary key of the supertype becomes the primary key of the subtype.
Mapping Relationships : A 1-1 relationship is mapped using a foreign key. The primary key of either of the entities is include as a foreign key in the relation of the other entity. This relationship is rare, because data elements related in this way are normally placed in the same table.
A 1-M or M-1 is mapped by introducing a foreign key. A primary key is the ¡¥one¡Š side of the relationship, and the foreign key is the ¡¥many¡Š side of the relationship. This relationship are most common.
A M-M involves the creation of a new relation. M-M are problematic and cannot be adequately expressed directly in a relational db. It is expressed using intersection tables. An intersection table contains two (or more) foreign keys, relating the primary key values of two (or more) tables to each other. The role of an intersection table is to convert the M-M into two 1-M relationships that can be easily handled by the database.
IV. SIMPLIFYING DATA :
Need for Simplifying Data :
Normalization : Normalization is a formal process of developing data structures in a manner that eliminates redundancy and promotes integrity. You need to simplify structure of data in relations for easy storage and retrieval. The process of simplifying relations is called normalization. The new relations that are obtained after normalization are called normalized relations.
Normalization has three well defined steps :
The relations that you get at the end of the first step are said to be in 1NF.
The relations that you get at the end of the second step are said to be in 2NF.
The relations that you get at the end of the third step are said to be in 3NF.
Simplifying Data to 1NF (Eliminate Repeating Groups) : A repeating group is a set of columns that store similar info that repeats in the same table. To simplify data to 1NF, you ensure that all attributes values in a relation have atomic values. If there are attributes in a relation with non-atomic values, move these attributes to a new relation and choose an appropriate primary key for it. E.g. SupItem Table Item field having atomic.
Simplifying Data to 2NF (Eliminate Redundant Data) :
Redundant data is data that is expressed multiple times unnecessarily, or depends only on part of a multi-valued key.
Functionally Dependent Attributes : Functionally Dependent Attributes are those that belong to a single entity or relationship and depend on its unique identifier. To simplify data to 2NF, you ensure that all nonkey attributes in a relation are functionally dependent on the whole key and not part of the key.
Conversion from 1NF to 2NF : To convert a relation in 1NF to 2NF, move all nonkey attributes that are not wholly dependent on the primary key, to a new relation. Then, choose an appropriate primary key for the new relation. E.g. Separating Sup. table and Item table.
Simplifying Data to 3NF (Eliminate Columns not Dependent on the Key) :
Columns in each table should be a group of columns in which the data in each column contributes to the description of each row in the table.
Transitively Dependent Attributes : Transitively Dependent Attributes in a relation are those that are dependent on a nonkey attribute and not the primary key. To simplify data to 3NF, you ensure that there are no attributes in a relation that are transitively dependent on other attributes.
Conversion from 2NF to 3NF : To convert a relation in 2NF to 3NF, move all transitively dependent attributes to a new relation. Then, choose an appropriate primary key for the new relation. E.g. Status is dependent on City in Sup. table, so move those two to separate table.
Simplifying Data to 4NF (Isolate Independent Multiple Relationships) :
V. STORING & RETRIEVING DATA :
Language Support for an RDBMS :
SQL :SQL is the language that provides command to interact with the data in the database. SQL consists of three components - DDL, DML & DCL.
DDL : DDL comprises commands you can use to create and modify the database structure.
DML : DML comprises commands you can use to add, modify, delete and query data in the database.
DCL : DCL comprises commands you can use to control the user access to the database.
Organizing the Database :
Base Tables : A database comprises base tables, which have the following features :
They physically exist on the disk, Each of them has a unique name & they contain data that is crucial to an organization.
Their attributes have data types such as character, integer, decimal, date and time.
CREATE TABLE : This is a DDL command in SQL that creates a new table in a database.
Syntax : CREATE TABLE table-name (column-name data-type [[size]]
NOT NULL/DEFAULT default-value]]
CHECK (column-name > 0)
UNIQUE (column-name)
PRIMARY KEY (column-name)
FOREIGN KEY (column-name) REFERENCES table-name)
ALTER TABLE : This is a DDL command in SQL that modifies the structure of an existing table.
Syntax : ALTER TABLE table-name
ADD (column-name data-type [[size]] [[NOT NULL DEFAULT]]...)
primary key definition / foreign key definition
DROP PRIMARY KEY / DROP FOREIGN KEY)
DROP TABLE : This is DDL command in SQL that deletes the an existing table. Once you delete a table, all data contained in it is lost and cannot be recovered. The storage space used by this table is also released.
Syntax : DROP TABLE table-name
Interacting with a Database :
SELECT : This is a DML command in SQL that retrieves data from the database in the form of query results. The command supports the following keywords and clauses :
FROM This keyword specifies the name of the table.
* This keyword selects all the columns of the table.
WHERE This keyword gives the search condition that specifies the data to be retrieved.
AND This operator is used to combine two or more search conditions.
ORDER BY This keyword sorts the query result on one or more columns.
GROUP BY This keyword groups the query result and lets you generate summary result for each group.
NULL values This value indicates that the data is not present.
Subquery This is the query that is place inside the main query. It passes its query result to the main query.
INSERT : This is a DML command in SQL that you use to add data in rows of a table.
SYNTAX : INSERT INTO table-name (column-names) VALUES (constant/NULL)
UPDATE : This is a DML command in SQL that you use to change data on rows of a table.
Syntax : UPDATE table-name SET column-name-value WHERE condition
DELETE : This is a DML command in SQL that removes one or more rows of data from a table.
Syntax : DELETE FROM table-name WHERE condition.
End-user's View of a Database :
Views : Views are relations that are derived from one or more source tables. Views have the following features:
Views let you restrict the access to data so that end-users see data relevant to them.
Views do not physically exist in the database and only their definition is stored by an RDBMS.
An RDBMS accesses the source tables for data to be retrieved from a view.
Any changes that users make to views do not reflect in the source tables if the view has been created using a Join condition.
Views created WITH CHECK OPTION allows for an added measure of security in a view. For example, the user will not be able to insert or update a row that could not be selected by the view-with check option prevents this from happening.
CREATE VIEW : A view can be created using the CREATE VIEW command.
Syntax : CREATE VIEW view-name (column-names) AS query.
Retrieving Data from a View : Once you create a view, you can retrieve data from it using the SELECT command, just as you do for a table.

Restricting Access to a Database :
GRANT : This is a DCL command in SQL that you use to grant a specific set of authorities to one or more users.
Syntax : GRANT (SQL command) (column-names) ON table-name TO user-name.
REVOKE : This is a DCL command in SQL that you use to take away a specific set of authorities from one or more users.
Syntax : REVOKE (SQL command) ON table-name TO user-name.
VI. ENSURING INTEGRITY OF DATA :
The concept of Data Integrity :
Data Integrity : Data Integrity refers to the correctness and completeness of data in a database.
Integrity Constraints : Integrity constraints allows only correct changes to be made to a database. There are two types of integrity constraints - entity integrity and referential integrity.
Entity Integrity : Entity Integrity ensures that for each row in a table, the value of the primary key is unique and is not null.
Referential Integrity : Referential Integrity ensures that for each row in a table, the value of the foreign key is present in the reference table.
Grouping commands related to a task :
Transaction Processing : A transaction is a sequence of one or more SQL commands that together form a logical task. Transaction Processing ensures that when the RDBMS is making changes related to a single task, either all changes are made as a unit or no changes are made.
Commit : Commit is an SQL command that indicates the successful end of a transaction. After an RDBMS executes this command all the changes are made to the database.
Rollback : Rollback is an SQL command that cancels a transaction before it is complete. The rollback command removes the changes of all previous commands in a transaction from the buffer.
Controlling Concurrent Data Access :
Concurrency Control : All RDBMS must ensure that the transactions of concurrent users do not interfere with each other. If it does not handle the transactions properly, the problems of lost update, uncommitted data, or inconsistent data might occur.
Lost Update Problem : Lost update problem occurs when an update made by a transaction is lost due to an update made by another transaction.
Uncommitted Data Problem : Uncommitted data problem occurs when a transaction accesses data that has been updated by a previous transaction that has not yet ended.
Inconsistent Data Problem : Inconsistent data problem occurs when a transaction accesses data from the database and simultaneously another transaction is changing that data.
Locking : Locking is a facility provided by an RDBMS to ensure that a transaction does not interfere with any other transaction. Locking prevents the problem of lost update, uncommitted data and inconsistent data. An RDBMS provided two types of locks for locking a part of the database - shared locks and exclusive locks.
Shared Locks : If a transaction is only reading data from a database, it gets a shared lock on that part of the database. Other transactions can also get a shared lock on that part of the database to read data. However, they cannot change the data.
Exclusive Locks : If a transaction is updating data in a database, it gets an exclusive lock on that part of the database. No other transaction can read or change this data.

Client Server Computing Model
I. Client Server Paradigm :
Introduction : In the past decade, organizations have restructured and become global. The globalization and restructuring have led to a need for distributed and flexible information access. That traditional computing paradigms like host-based and master/slave processing do not adequately address the information requirements of modern business. That the client/server model provides an architecture that harness contemporary technology to meet the computing needs of the modern business organization. Also called Distributed Application Processing or Co-Operative Application Processing
Host Based Processing - The Centralized Paradigm : Centralized computing treated applications as an integrated unit. Applications ran on a single processor. The same processor generated the user interface and manipulated data. Dumb terminals were used for data access and display. Disadvantages are : Data was centralized and often not accessible to those who needed it. The host computed did all the work, was frequently overloaded, and response times were often poor. Hardware choices and scalability were limited by proprietary architecture's. User interfaces were unfriendly, Data access was inflexible and governed by available 3GL programs.
Master/Slave - The First Distributed Computing Paradigm : As PC's and intelligent terminals became available, a limited amount of processing was transferred to the terminal. Intelligent terminals often validated data and provided editing functions. Such terminal were called Slaves. Slaves were controlled by Master computer which did the main processing and stored all data. It had one distinct advantage. It reduced the load on the main processor. However, the other problems associated with host-based processing remained.
Client/Server - A Distributed Computing Paradigm : The client/server paradigm evolved as an attempt to address the new computing needs of business and utilize new technologies.
Advantages : Client/Server makes it possible to harness the computing power available on PCs and other workstations in an organization. Response times are improved as processors are not overloaded. Hardware and software choices can be application oriented as they do not necessarily have to run on a proprietary computer. Network traffic is reduced because the processing power available at the end user terminal makes it unnecessary to send detailed instructions over the network as in the case of host based & master/slave systems. Computing power can be added in smaller units making the system easily scaleable.
Disadvantages :The inherent heterogeneity makes System Integration, Administration & Maintenance a formidable challenge.
ORACLE 7 is an exceptional RDBMS & also an excellent DB server because it supports all major OS
for both clients & servers i.e. MSDOS, Netware, Unixware, OS/2 etc. Oracle Network software SQL*NET support all major network communication protocols TCP/IP, SPX/IPS, Named Pipes & DECNET. It has got client server feature that developers can use to minimize network traffic between clients & servers. Has features that makes it easy to administer a complicated client server system.
Client/Server Approach : The client/server paradigm optimizes the use of computer resources by distributing application processing among multiple processors. The client/server model computers are classified as Clients and Servers, where Clients are requesters of services and Servers are provider of services. Typically, clients handle user interface function & server handle data management function.
Client/Server Architecture requires Processing to be distributed over more than one computing system. Client-initiated client/server interactions. Server control over the services that can be requested by the client. Servers to arbitrate between conflicting client requests. A communication system that enables clients & servers to communicate.
Multitasking can be defines as the capability of an OS to run multiple applications concurrently. A Multitasking OS allocates a certain amount of CPU time to each task. In Preemptive multitasking, the OS controls the amount of CPU time allocated to a task. In non-preemptive multitasking, the application controls the CPU time and the CPU is released only after the task is completed.
Multithreading is an extension of multitasking. It allows multitasking within an application. Programs and subroutines within a program can execute concurrently in a multithreaded environment. Several user process for a single server process.
Database Server should have preemptive multitasking & multithreading capability. Support a standard RDBMS. Support a standard Network Operating System.
Tools such as RDBMS, Application Software, Application Program Interfaces, Stored Procedures, Remote Procedure Call (RPC) & Application Development Tools are an important part of client/server systems. Such tools improve productivity and also play a role in making client/server systems more open. An API is a set of functions that translates client requests into a format that the server can understand. RPC is essentially a messaging system which allows stored procedures to be invoked. Many RPCs allows procedures to be invoked across heterogeneous platforms and also provide the required data translation services.
There are several application designs possible in the client/server model depending on how application processing is distributed.
In Distributed Presentation, the presentation function is divided between the client & the server. Useful in situations where PC or workstations are connected to mainframes. Used to enhance the user interface of mainframe based applications.
In Remote Presentation, the entire presentation part of the application resides on a different computer than the one that has the logic function. Used in applications where user interaction is completely static and predetermined.
In Distributed Logic, the logic function is placed on more than one platform thus, improving response time by allowing the logic to execute simultaneously on several processors.
In Remote Data Management, the application logic resides on different computer than the one that has the data and the DBMS. Easy to implement and often provide end-users with totally transparent access to data.
In Distributed Data Management, the data and DBMS is distributed among multiple nodes and distribution of application logic.
Goals of Client/Server Paradigm is the end-user. Client/Server seeks to provide end-user transparent access to the computing resources of the organization. The goal is referred to as single system image. There are four attributes of single system image :
Location Transparency : Users must be able to access data without knowing the location of the data. Users should not have to learn & use different commands for accessing data from different locations.
Interoperability requires that applications and processing tasks be freely portable across heterogeneous computing resources.
Consistent User Interfaces require that applications retain the same user interface across heterogeneous computing platforms. Common computing tasks are represented consistently across applications.
Enterprise-wide Resource Sharing is the common thread that links all of an enterprise's computing resource
II. Concepts for Client/Server :
Introduction : RDBMS's standardize data storage and access and are therefore ideal for implementing client/server systems. The physical structure of a network is called Network Topology i.e. refers to the way the cabling of a network is physically structured. The rules that govern the process of data transmission in a network are collectively referred to as Network Protocol. Graphical User Interfaces improve productivity because they reduce learning time
and are easier to use.
Distributed Database Support : The capability of an RDBMS to manage databases lying at more than one location. To provide distributed database support, an RDBMS must be able to provide transparent access to data, Join tables on different platforms, Handle and manage distributed queries and Ensure that transactions are successfully completed on all relevant databases.
Network : Network has six basic functions, Naming, Segmentation, Segmenting, Flow Control, Synchronization, Priority & Error Control. There are three types of network topologies, Bus, Star & Ring. There are three types of transmission media, Twisted Pair, Coaxial Cable & Optic Fibre. There are three types of data transmission methods, Centralized, Distributed & Random.
GUIs : GUI must support mouse events, keyboard events, menu events, resizing events, activation/deactivation events and initialize/terminate events. GUI should be portable, should support wide variety of development tools & be an industry standard.
III. Client/Server Software :
Back-end Software : It is made up of Database Servers & Network Operating Systems. The database server manages data on the system & maintains data integrity. Database server requires some special features. Compatibility i.e. must be able to work on different operating systems. SQL Implementation i.e. must support standard ANSI SQL since it can communicate with different SQL dialects. Stored Procedures i.e. must be able to use SP as they are analyzed, compiled and optimized. Referential Integrity i.e. allows the server to synchronize change to columns that are part of multiple tables. Declarative RI establishes precise rules for use of columns that are common across tables. Built into db software and enforced by default. In Procedural RI, each db command is associated with a trigger. When command is issued, the trigger sets of a series of commands that make the necessary changes. Disadvantage is programmers must write triggers leading to errors. Multithreading i.e. support execution of multiple tasks simultaneously. Distributed Database Support i.e. able to divide database tasks among multiple CPUs. Also, able to join tables located on different servers, & manage SQL queries sent to different servers. Concurrency Control i.e. support automatic escalation, the server locks a record, if a single record is being modified. A page, if several records are being modified. A table, if several pages are being modified. Transaction Control i.e. protect transactions from system failures. In two phase commit, all workstations are notified of database changes, and if system fails, all sites rollback.
NOS controls the transmission of data across the network and manages the sharing of hardware and software resource on the network. Four important features are Operating Environment Support, Workstation Support, Security & Protocol Support.
Development Tools are made up of SQL/3GL programming tools & Front-end development tools.
End User Tools are made up of Decision Support Tools and PC-based add-ons.
IV. Migrating to Client/Server :
Evaluating the Client/Server Option : To evaluate the following before deciding on client/server. Application requirements, Geographical requirements & Productivity Gains. Client/Server is most suitable for applications are decision support or on-line transaction processing (OLTP). The distances are site or city & both developer & end-user productivity are expected to increase.
Planning for Migration : Planning is needed to reduce problems with network load, training & systems maintenance. Migration plan must include analysis, selection, prototyping & implementation as activities. Planning must include end-users, developers and system administrators as resources. To specify system requirements for end-users, developers, system managers and the business as a whole. To evaluate business priorities to eliminate stagnation & disruption.
Implementing Client/Server : The Systems Integration Life Cycle (SILC) is made up of preparation, detailing and execution. Managing SILC projects involves planning, controlling & completing. System maintenance involves ensures reliability, ensuring serviceability and monitoring performance. The training must cover end-users, developers & system administrators.

ORACLE
I. SQL*PLUS :
SQL is an English like language consisting of commands to store, retrieve, maintain & regulate access to your database.
SQL*PLUS is an application that recognizes & executes SQL commands & specialized SQL*Plus commands that can customize reports, provide help & edit facility & maintain system variables.
NVL : Null value function converts a null value to a non-null value for the purpose of evaluating an expression.
Numeric Functions accept numeric I/P & return numeric values. They are MOD, SQRT, ROUND, TRUNC & POWER.
Date Functions are ADD_MONTHS, LAST_DAY, NEXT_DAY, MONTHS_BETWEEN & SYSDATE.
Character Functions are INITCAP, UPPER, LOWER, SUBSTR & LENGTH. Additional functions are GREATEST & LEAST.
Group Functions returns results based upon groups of rows rather than one result per row, use group functions. They are AVG, COUNT, MAX, MIN & SUM.
TTITLE & BTITLE are commands to control report headings & footers.
COLUMN command define column headings & format data values.
BREAK command clarify reports by suppressing repeated values, skipping lines & allowing for controlled break points.
COMPUTE command control computations on subsets created by the BREAK command.
SET command changes the system variables affecting the report environment.
SPOOL command creates a print file of the report.
JOIN is the form of SELECT command that combines info from two or more tables.
Types of Joins are Simple (Equijoin & Non-Equijoin), Outer & Self join.
Equijoin returns rows from two or more tables joined together based upon a equality condition in the WHERE clause.
Non-Equijoin returns rows from two or more tables based upon a relationship other than the equality condition in the WHERE clause.
Outer Join combines two or more tables returning those rows from one table that have no direct match in the other table.
Self Join joins a table to itself as though it were two separate tables.
Set Operators supported by Oracle are :
Union is the product of two or more tables.
Intersect is the product of two tables listing only the matching rows.
Minus is the product of two tables listing only the non-matching rows.
Correlated Subquery is a subquery that is evaluated once for each row processed by the parent statement. Parent statement can be Select, Update or Delete. Use CRSQ to answer multipart questions whose answer depends on the value in each row processed by parent statement.
Multiple columns can be returned from a Nested Subquery.
Sequences are used for generating sequence numbers without any overhead of locking. Drawback is that after generating a sequence number if the transaction is rolled back, then that sequence number is lost.
Synonyms is the alias name for table, views, sequences & procedures and are created for reasons of Security and Convenience. Two levels are Public - created by DBA & accessible to all the users. Private - Accessible to creator only. Advantages are referencing without specifying the owner and Flexibility to customize a more meaningful naming convention.
Indexes are optional structures associated with tables used to speed query execution and/or guarantee uniqueness. Create an index if there are frequent retrieval of fewer than 10-15% of the rows in a large table and columns are referenced frequently in the WHERE clause. Implied tradeoff is query speed vs. update speed. Oracle automatically update indexes. Concatenated index max. is 16 columns.
Data types :
Max. columns in a table is 255. Max. Char size is 255, Long is 64K & Number is 38 digits.
Cannot Query on a long column.
Char, Varchar2 Max. size is 2000 & default is 1 byte.
Number(p,s) p is precision range 1 to 38, s is scale -84 to 127.
Long Character data of variable length upto 2GB.
Date Range from Jan 4712 BC to Dec 4712 AD.
Raw Stores Binary data (Graphics Image & Digitized Sound). Max. is 255 bytes.
Mslabel Binary format of an OS label. Used primarily with Trusted Oracle.
Order of SQL statement execution : Where clause, Group By clause, Having clause, Order By clause & Select.
Transaction is defined as all changes made to the database between successive commits.
Commit is an event that attempts to make data in the database identical to the data in the form. It involves writing or posting data to the database and committing data to the database. Forms check the validity of the data in fields and records during a commit. Validity check are uniqueness, consistency and db restrictions.
Posting is an event that writes Inserts, Updates & Deletes in the forms to the database but not committing these transactions to the database.
Rollback causes work in the current transaction to be undone.
Savepoint is a point within a particular transaction to which you may rollback without rolling back the entire transaction.
Set Transaction is to establish properties for the current transaction.
Locking are mechanisms intended to prevent destructive interaction between users accessing data. Locks are used to achieve
Consistency : Assures users that the data they are changing or viewing is not changed until the are thro' with it.
Integrity : Assures database data and structures reflects all changes made to them in the correct sequence.
Locks ensure data integrity and maximum concurrent access to data. Commit statement releases all locks. Types of locks are given below.
Data Locks protects data i.e. Table or Row lock.
Dictionary Locks protects the structure of database object i.e. ensures table's structure does not change for the duration of the transaction.
Internal Locks & Latches protects the internal database structures. They are automatic.
Exclusive Lock allows queries on locked table but no other activity is allowed.
Share Lock allows concurrent queries but prohibits updates to the locked tables.
Row Share allows concurrent access to the locked table but prohibits for a exclusive table lock.
Row Exclusive same as Row Share but prohibits locking in shared mode.
Shared Row Exclusive locks the whole table and allows users to look at rows in the table but prohibit others from locking the table in share or updating them.
Share Update are synonymous with Row Share.
Deadlock is a unique situation in a multi user system that causes two or more users to wait indefinitely for a locked resource. First user needs a resource locked by the second user and the second user needs a resource locked by the first user. To avoid dead locks, avoid using exclusive table lock and if using, use it in the same sequence and use Commit frequently to release locks.
Mutating Table is a table that is currently being modified by an Insert, Update or Delete statement.
Constraining Table is a table that a triggering statement might need to read either directly for a SQL statement or indirectly for a declarative Referential Integrity constraints.
Pseudo Columns behaves like a column in a table but are not actually stored in the table. E.g. Currval, Nextval, Rowid, Rownum, Level etc.
SQL*Loader is a product for moving data in external files into tables in an Oracle database. To load data from external files into an Oracle database, two types of input must be provided to SQL*Loader : the data itself and the control file. The control file describes the data to be loaded. It describes the Names and format of the data files, Specifications for loading data and the Data to be loaded (optional). Invoking the loader sqlload username/password controlfilename

PL/SQL :
Data types are NUMBER, CHAR/VARCHAR2, DATE & BOOLEAN.
Arrays are not allowed & only one identifier per line is allowed.
Attributes of PL/SQL objects are %TYPE, %ROWTYPE.
PL/SQL Block is a standard PL/SQL code segment. Block consists of three parts.
Declarative Section for variables, constants & exceptions. This section is optional.
Executable Section which is mandatory.
Exception Handlers which is optional.
PL/SQL supports only DML i.e. INSERT, UPDATE, DELETE & SELECT...INTO.
SQL Functions can be referenced within a SQL statement i.e. Numeric (SQRT,ROUND,POWER),
Character (LENGTH,UPPER), DATE (ADD_MONTHS,MONTHS_BETWEEN) &
Group (AVG,MAX,COUNT). Most SQL functions are available outside SQL statement except for group functions.
Code Simple Loops repeats a sequence of statements multiple times.
Syntax : LOOP

END LOOP;
Code Numeric FOR Loops repeat a sequence of statements a fixed number of times.
Syntax : FOR IN [[ REVERSE ]] .. LOOP

END LOOP;
is implicitly of type number. Defined only within the loop & Value can be referenced in an expression, but a new value cannot be assigned to the index within the loop.
Code While Loops repeats a sequence of statements until a specific condition is no longer TRUE.
Syntax : WHILE LOOP

END LOOP;
can be any legal PL/SQL condition & statements will be repeated as long as condition evaluates to TRUE.
Code GOTO Statements jumps to a different place in the PL/SQL block.
Syntax : GOTO label_name;
Legally use a GOTO a statement that is in the same sequence of statements as the GOTO.
In the sequence of statements that encloses the GOTO statement (outer block).
Labels can label any statement. Used as targets for GOTO statements, use labels for blocks and loops, Label a block to allow referencing of DECLAREd objects that would otherwise not be visible because of scoping rules, Label a block to allow a variable to be referenced that might be hidden by a column name, Label a loop to allow an object to be reference that would otherwise not be visible because of scoping rules & Label an EXIT as a convenient way to specify exits from outer loops.
Cursors are associated with every SQL DML statement processed by PL/SQL. Two types are Explicit i.e. Multiple row SELECT statements & Implicit i.e. INSERT, UPDATE, DELETE & SELECT...INTO statements. Implicit cursor is called the SQL cursor-it stores info concerning the processing of the last SQL statement not associated with an explicit cursor. OPEN, FETCH & CLOSE do not apply. All cursor attributes apply.
Cursor has to be explicitly defined when a query returns multiple rows to process beyond the first row returned by the query & to keep track of which row is currently being processed.
Declare the cursor to associate its name with a SELECT statement.
Syntax : DECLARE
CURSOR
IS ;
Open the cursor to process the SELECT statement and store the returned rows in the cursor.
Syntax : OPEN ;
Fetch data from the cursor and store it in specified variables.
Syntax : FETCH INTO ;
Close the cursor to free up resources. Cursors must be closed before they can be reopened.
Syntax : CLOSE
Explicit Cursor Attributes are %NOTFOUND, %FOUND, %ROWCOUNT & %ISOPEN.
Reference the current cursor row with the WHERE CURRENT OF statement. The cursor must be declared with a FOR UPDATE OF clause.
Syntax : WHERE CURRENT OF
Reference Cursors FOR Loops to specify a sequence of statements to be repeated once for each row that is returned by the cursor with the Cursor FOR Loop.
Syntax : FOR IN LOOP
--statements to be repeated go here
END LOOP;
Cursor FOR loops (CFL) are similar to Numeric For Loops(NFL). CFL specify a set of rows from a table using the cursor's name. NFL specify an integer range. CFL record takes on vales of each row. NFL index takes on each value in the range. Record_name is implicitly declared as
record_name cursor_name%ROWTYPE
When a CFL is initiated, an implicit OPEN cursor_name is initiated.
For each row that satisfies the query associated with the cursor, an implicit FETCH is executed into the components of record_name.
When there are no more rows left to FETCH, an implicit CLOSE cursor_name is executed and the loop is exited.
Declare cursors to use parameters
Syntax : DECLARE
CURSOR [[(param_name param_type)]]
IS ;
Exception Handlers : In PL/SQL, errors are called exceptions. When an exception is raised, processing jumps to the exception handlers. An exception handler is a sequence of statements to be processed when a certain exception occurs. When an exception handler is complete, processing of the block terminates. Two types are Predefined Internal Exceptions which corresponds to approximately 20 common ORACLE errors & Raised automatically by PL/SQL in response to an ORACLE error.
Eg.too_many_rows,no_data_found,invalid_cursor,value_errori.e. arithmetic,numeric,string,conversion or constraint error occurred, zero_divide, dup_val_on_index,cursor_already_open etc.
User-Defined Exceptions must be declared & must be RAISEd explicitly.
Only one handler per block may be active at a time & If an exception is raised in a handler, the search for a handler for the new exception begins in the enclosing block of the current block.
Exception-Init : Exceptions may only be handled by name not ORACLE error number. So, name an ORACLE error so that a handler can be provided specifically for that error.
Syntax : PRAGMA EXCEPTION_INIT (, );
SQLCODE & SQLERRM provides info on the exception currently being handled & especially useful in the OTHERS handler.
SQLCODE returns the ORACLE error number of the exception, or 1 if it was a user-defined exception.
SQLERRM returns the ORACLE error message associated with the current value of SQLCODE & can also use any ORACLE error number as an argument.
SQLCODE & SQLERRM cannot be used within a SQL statement. If no exception is active SQLCODE = 0 & SQLERRM = 'normal, successful completion'.

Oracle :

1) What are the Back ground processes in Oracle and what are they.
This is one of the most frequently asked question.There are basically 9 Processes but in a general system we need to mention the first five background processes.They do the house keeping activities for the Oracle and are common in any system.
The various background processes in oracle are
a) Data Base Writer(DBWR) : Data Base Writer Writes Modified blocks from Database buffer cache to Data Files.This is required since the data is not written whenever a transaction is commited.
b) LogWriter(LGWR) : LogWriter writes the redo log entries to disk. Redo Log data is generated in redo log buffer of SGA. As transaction commits and log buffer fills, LGWR writes log entries into a online redo log file.
c) System Monitor(SMON) : The System Monitor performs instance recovery at instance startup.This is useful for recovery from system failure
d) Process Monitor(PMON) : The Process Monitor peforms process recovery when user Process fails. Pmon Clears and Frees resources that process was using.
e) CheckPoint(CKPT) : At Specified times, all modified database buffers in SGA are written to data files by DBWR at Checkpoints and Updating all data files and control files of database to indicate the most recent checkpoint
f) Archieves(ARCH) : The Archiver copies online redo log files to archival storal when they are busy.
g) Recoveror(RECO) : The Recoveror is used to resolve the distributed transaction in network
h) Dispatcher (Dnnn) : The Dispatcher is useful in Multi Threaded Architecture
i) Lckn : We can have upto 10 lock processes for inter instance locking in parallel sql.

2) How many types of Sql Statements are there in Oracle
There are basically 6 types of sql statments.They are
a) Data Defination Language(DDL) : The DDL statments define and maintain objects and drop objects.
b) Data Manipulation Language(DML) : The DML statments manipulate database data.
c) Transaction Control Statements : Manage change by DML
d) Session Control : Used to control the properties of current session enabling and disabling roles and changing .e.g Alter Statements,Set Role
e) System Control Statements : Change Properties of Oracle Instance .e.g:: Alter System
f) Embedded Sql : Incorporate DDL,DML and T.C.S in Programming Language.e.g:: Using the Sql Statements in languages such as 'C', Open,Fetch, execute and close

3) What is a Transaction in Oracle
A transaction is a Logical unit of work that compromises one or more SQL Statements executed by a single User. According to ANSI, a transaction begins with first executable statment and ends when it is explicitly commited or rolled back.

4) Key Words Used in Oracle
The Key words that are used in Oracle are
a) Commiting : A transaction is said to be commited when the transaction makes
permanent changes resulting from the SQL statements.
b) Rollback : A transaction that retracts any of the changes resulting from SQL
statements in Transaction.
c) SavePoint : For long transactions that contain many SQL statements, intermediate
markers or savepoints are declared. Savepoints can be used to divide a transactino into smaller points.
d) Rolling Forward : Process of applying redo log during recovery is called rolling
forward.
e) Cursor : A cursor is a handle ( name or a pointer) for the memory associated with a
specific stament. A cursor is basically an area allocated by Oracle for executing the Sql Statement. Oracle uses an implicit cursor statement for Single row query and Uses Explcit cursor for a multi row query.
f) System Global Area(SGA) : The SGA is a shared memory region allocated by the
Oracle that contains Data and control information for one Oracle Instance.It consists of Database Buffer Cache and Redo log Buffer.
g) Program Global Area (PGA) : The PGA is a memory buffer that contains data and
control information for server process.
h) Database Buffer Cache : Databese Buffer of SGA stores the most recently used
blocks of datatbase data.The set of database buffers in an instance is called Database Buffer Cache.
i) Redo log Buffer : Redo log Buffer of SGA stores all the redo log entries.
j) Redo Log Files : Redo log files are set of files that protect altered database data in
memory that has not been written to Data Files. They are basically used for backup when a database crashes.
k) Process : A Process is a 'thread of control' or mechansim in Operating System that
executes series of steps.

5) What are Procedure,functions and Packages
Procedures and functions consist of set of PL/SQL statements that are grouped together as a unit to solve a specific problem or perform set of related tasks.
Procedures do not Return values while Functions return one One Value
Packages Provide a method of encapsulating and storing related procedures, functions, variables and other Package Contents

6) What are Database Triggers and Stored Procedures
Database Triggers :: Database Triggers are Procedures that are automatically executed as a result of insert in, update to, or delete from table. Database triggers have the values old and new to denote the old value in the table before it is deleted and the new indicated the new value that will be used. DT are useful for implementing complex business rules which cannot be enforced using the integrity rules.We can have the trigger as Before trigger or After Trigger and at Statement or Row level.
eg. operations insert,update ,delete 3 before ,after 3*2 A total of 6 combinatons
At statment level(once for the trigger) or row level( for every execution ) 6 * 2 A total of 12. Thus a total of 12 combinations are there and the restriction of usage of 12 triggers has been lifted from Oracle 7.3 Onwards.
Stored Procedures : Stored Procedures are Procedures that are stored in Compiled form in the database.The advantage of using the stored procedures is that many users can use the same procedure in compiled and ready to use format.

7) How many Integrity Rules are there and what are they
There are Three Integrity Rules. They are as follows ::
a) Entity Integrity Rule : The Entity Integrity Rule enforces that the Primary key cannot be Null
b) Foreign Key Integrity Rule : The FKIR denotes that the relationship between the foreign key and the primary key has to be enforced.When there is data in Child Tables the Master tables cannot be deleted.
c) Business Integrity Rules : The Third Intigrity rule is about the complex business processes which cannot be implemented by the above 2 rules.

8) What are the Various Master and Detail Relation ships.
The various Master and Detail Relationship are
a) NonIsolated : The Master cannot be deleted when a child is exisiting
b) Isolated : The Master can be deleted when the child is exisiting
c) Cascading : The child gets deleted when the Master is deleted.

9) What are the Various Block Coordination Properties
The various Block Coordination Properties are
a) Immediate Default Setting. The Detail records are shown when the Master Record are shown.
b) Deffered with Auto Query Oracle Forms defer fetching the detail records until the operator navigates to the detail block.
c) Deffered with No Auto Query The operator must navigate to the detail block and explicitly execute a query

10) What are the Different Optimisation Techniques
The Various Optimisation techniques are
a) Execute Plan : we can see the plan of the query and change it accordingly based on the indexes
b)Optimizer_hint: set_item_property('DeptBlock',OPTIMIZER_HINT,'FIRST_ROWS');
Select /*+ First_Rows */ Deptno,Dname,Loc,Rowid from dept where (Deptno > 25)
c) Optimize_Sql : By setting the Optimize_Sql = No, Oracle Forms assigns a single cursor for all SQL statements.This slow downs the processing because for evertime the SQL must be parsed whenver they are executed.
f45run module = my_firstform userid = scott/tiger optimize_sql = No
d) Optimize_Tp : By setting the Optimize_Tp= No, Oracle Forms assigns seperate cursor only for each query SELECT statement. All other SQL statements reuse the cursor.
f45run module = my_firstform userid = scott/tiger optimize_Tp = No

11) How do u implement the If statement in the Select Statement
We can implement the if statement in the select statement by using the Decode statement.
e.g select DECODE (EMP_CAT,'1','First','2','Second'Null);
Here the Null is the else statement where null is done .

12) How many types of Exceptions are there
There are 2 types of exceptions. They are
a) System Exceptions
e.g. When no_data_found, When too_many_rows
b) User Defined Exceptions
e.g. My_exception exception
When My_exception then

13) What are the inline and the precompiler directives
The inline and precompiler directives detect the values directly

14) How do you use the same lov for 2 columns
We can use the same lov for 2 columns by passing the return values in global values and using the global values in the code

15) How many minimum groups are required for a matrix report
The minimum number of groups in matrix report are 4

16) What is the difference between static and dynamic lov
The static lov contains the predetermined values while the dynamic lov contains values that come at run time

17) What are snap shots and views
Snapshots are mirror or replicas of tables. Views are built using the columns from one or more tables. The Single Table View can be updated but the view with multi table cannot be updated

18) What are the OOPS concepts in Oracle.
Oracle does implement the OOPS concepts. The best example is the Property Classes. We can categorise the properties by setting the visual attributes and then attach the property classes for the objects. OOPS supports the concepts of objects and classes and we can consider the peroperty classes as classes and the items as objects

19) What is the difference between candidate key, unique key and primary key
Candidate keys are the columns in the table that could be the primary keys and the primary key is the key that has been selected to identify the rows. Unique key is also useful for identifying the distinct rows in the table.

20) What is concurrency
Cuncurrency is allowing simultaneous access of same data by different users. Locks useful for accesing the database are
a) Exclusive
The exclusive lock is useful for locking the row when an insert,update or delete is being done.This lock should not be applied when we do only select from the row.
b) Share lock
We can do the table as Share_Lock as many share_locks can be put on the same resource.

21) Previleges and Grants
Previleges are the right to execute a particulare type of SQL statements.
eg. Right to Connect, Right to create, Right to resource
Grants are given to the objects so that the object might be accessed accordingly.The grant has to be given by the owner of the object.

22) Table Space,Data Files,Parameter File, Control Files
Table Space : The table space is useful for storing the data in the database.When a database is created two table spaces are created.
a) System Table space : This data file stores all the tables related to the system and dba tables
b) User Table space : This data file stores all the user related tables
We should have seperate table spaces for storing the tables and indexes so that the access is fast.
Data Files : Every Oracle Data Base has one or more physical data files.They store the data for the database.Every datafile is associated with only one database.Once the Data file is created the size cannot change.To increase the size of the database to store more data we have to add data file.
Parameter Files : Parameter file is needed to start an instance.A parameter file contains the list of instance configuration parameters e.g.::
db_block_buffers = 500
db_name = ORA7
db_domain = u.s.acme lang
Control Files : Control files record the physical structure of the data files and redo log files. They contain the Db name, name and location of dbs, data files ,redo log files and time stamp.

23) Physical Storage of the Data
The finest level of granularity of the data base are the data blocks.
Data Block : One Data Block correspond to specific number of physical database space
Extent : Extent is the number of specific number of contigious data blocks.
Segments : Set of Extents allocated for Extents. There are three types of Segments
a) Data Segment : Non Clustered Table has data segment data of every table is stored in
cluster data segment
b) Index Segment : Each Index has index segment that stores data
c) Roll Back Segment : Temporarily store 'undo' information

24) What are the Pct Free and Pct Used
Pct Free is used to denote the percentage of the free space that is to be left when creating a table. Similarly Pct Used is used to denote the percentage of the used space that is to be used when creating a table
eg. Pctfree 20, Pctused 40

25) What is Row Chaining
The data of a row in a table may not be able to fit the same data block.Data for row is stored in a chain of data blocks .

26) What is a 2 Phase Commit
Two Phase commit is used in distributed data base systems. This is useful to maintain the integrity of the database so that all the users see the same values. It contains DML statements or Remote Procedural calls that reference a remote object. There are basically 2 phases in a 2 phase commit.
a) Prepare Phase : Global coordinator asks participants to prepare
b) Commit Phase : Commit all participants to coordinator to Prepared, Read only
or abort Reply

27) What is the difference between deleting and truncating of tables
Deleting a table will not remove the rows from the table but entry is there in the database dictionary and it can be retrieved But truncating a table deletes it completely and it cannot be retrieved.

28) What are mutating tables
When a table is in state of transition it is said to be mutating. eg :: If a row has been deleted then the table is said to be mutating and no operations can be done on the table except select.

29) What are Codd Rules
Codd Rules describe the ideal nature of a RDBMS. No RDBMS satisfies all the 12 codd rules and Oracle Satisfies 11 of the 12 rules and is the only Rdbms to satisfy the maximum number of rules.

30) What is Normalisation
Normalisation is the process of organising the tables to remove the redundancy.There are mainly 5 Normalisation rules.
a) 1 Normal Form : A table is said to be in 1st Normal Form when the attributes are
atomic
b) 2 Normal Form : A table is said to be in 2nd Normal Form when all the candidate
keys are dependant on the primary key
c) 3rd Normal Form : A table is said to be third Normal form when it is not dependant
transitively

31) What is the Difference between a post query and a pre query
A post query will fire for every row that is fetched but the pre query will fire only once.

32) Deleting the Duplicate rows in the table
We can delete the duplicate rows in the table by using the Rowid

33) Can U disable database trigger? How?
Yes. With respect to table
ALTER TABLE TABLE
[[ DISABLE all_trigger ]]

34) What is pseudo columns ? Name them?
A pseudocolumn behaves like a table column, but is not actually stored in the table. You can select from pseudocolumns, but you cannot insert, update, or delete their values. This section describes these pseudocolumns:
* CURRVAL
* NEXTVAL
* LEVEL
* ROWID
* ROWNUM

35) How many columns can table have?
The number of columns in a table can range from 1 to 254.

36) Is space acquired in blocks or extents ?
In extents .

37) what is clustered index?
In an indexed cluster, rows are stored together based on their cluster key values . Can not applied for HASH.

38) what are the datatypes supported By oracle (INTERNAL)?
Varchar2, Number,Char , MLSLABEL.

39 ) What are attributes of cursor?
%FOUND , %NOTFOUND , %ISOPEN,%ROWCOUNT

40) Can you use select in FROM clause of SQL select ?
Yes.

GUI

1) What is a visual attribute?
Visual attributes are the font, color, and pattern properties that you set for form and menu objects that appear in your application's interface.

2) Diff. between VAT and Property Class? imp
Named visual attributes define only font, color, and pattern attributes; property classes can contain these and any other properties.You can change the appearance of objects at runtime by changing the named visual attribute programmatically; property class assignment cannot be changed programmatically. When an object is inheriting from both a property class and a named visual attribute, the named visual attribute settings take precedence, and any visual attribute properties in the class are ignored.

3 ) Which trigger related to mouse?
* When-Mouse-Click
* When-Mouse-DoubleClick
* When-Mouse-Down
* When-Mouse-Enter
* When-Mouse-Leave
* When-Mouse-Move
* When-Mouse-Up

4) What is Current record attribute property?
Specifies the named visual attribute used when an item is part of the current record.
Current Record Attribute is frequently used at the block level to display the current row in a multi-record If you define an item-level Current Record Attribute, you can display a pre-determined item in a special color when it is part of the current record, but you cannot dynamically highlight the current item, as the input focus changes.

5) Can u change VAT at run time?
Yes. You can programmatically change an object's named visual attribute setting to change the font, color, and pattern of the object at runtime.

6) Can u set default font in forms?
Yes. Change windows registry(regedit). Set form45_font to the desired font.

7) Can u have OLE objects in forms?
Yes.

8) Can u have VBX and OCX controls in forms ?
Yes.

9) What r the types of windows (Window style)?
Specifies whether the window is a Document window or a Dialog window.

10) What is OLE Activation style property?
Specifies the event that will activate the OLE containing item.

11) Can u change the mouse pointer ? How?
Yes. Specifies the mouse cursor style. Use this property to dynamically change the shape of the cursor.


3.0 Data Base Administration

3.1 Introduction to DBA

1. What is a database instance ? Explain

A database instance (server) is a set of memory structures and background processes that access a set of database files.

The process can be shared by all users.

The memory structures that are used to store most queried data from database. This helps us to improve database performance by decreasing the amount of I/O performed against data file.

2. What is parallel server?

Multiple instances accessing the same database (Only in Multi-CPU environments).

3. What is Schema ?

The set of objects owned by user account is called the schema

4. What is an Index ? How it is implemented in Oracle Database ?

An index is a database structure used by the server to have direct access of a row in a table.
An index is automatically created when a unique or primary key constraint clause is specified in create table command (Ver 7.0)

5. What is clustres ?

Group of tables physically stored together because they share common columns and are often used together is called Clusters.

6. What is a cluster key ?

The related columns of the tables are called the cluster key. The cluster key is indexed using a cluster index and its value is stores only once for multiple tables in the cluster.

7. What are the basic element of Base configuration of an oracle Database ?

It consists of
one or more data files
one or more control files
two or more redo log files

The database contains
Multiple users/schemas
one or more rollback segments
one or more tablespaces
Data dictionary tables

User objects (tables,indexes,views etc)

The server that access the database consists of
SGA (Database buffer, Dictionary Cache Buffers, redo log buffers,Shared SQL pool)
SMON
PMON
LGWR
DBWR
ARCH
CKPT
RECO
Dispatcher
User process with associated PGA

8. What is deadlock ? Explain.

Two processes waiting to update the rows of a table which are locked by the other process then deadlock arises.

In a database environment this will often happen because of not issuing proper row lock commands. Poor design of front-end application may cause this situation and the performance of server will reduce drastically.

These locks will be released automatically when a commit/rollback operation performed or any one of this processes being killed externally.

3.2 Memory Management

9. What is SGA ? How it is different from Ver 6 and Ver 7 ?

The System Global Area in a Oracle database is the area in memory to facilitates the transfer of information between users. It holds the most recently requested structural information about the database.

The structure is Database buffers, Dictionary Cache, Redo Log Buffer and Shared SQL pool (Ver 7) area.

10. What is Shared SQL pool ?

The data dictionary cache is stored in an area in SGA called the Shared SQL Pool. This will allow sharing of parsed SQL statements among concurrent users.

11. What is meant by Program Global Area (PGA) ?

It is area in memory that is used by a Single Oracle User process.

12. What is a data segment ?

Data segment are the physical areas within a database block in which the data associated with tables and clusters are stored.

13. What are the factors causing the reparsing of SQL statements in SGA ?

Due to insufficient Shared SQL pool size

Monitor the ratio of the reloads takes place while executing SQL statements. If the ratio is greater that 1 then increase the SHARED_POOL_SIZE.

3.3 Logical & Physical Architecture of Database

14. What is Database Buffers ?

Database buffers are cache in the SGA used to hold the data blocks that are read from the data segments in the database such as tables, indexes and clusters. DB_BLOCK_BUFFERS parameter in INIT.ORA decides the size.

15. What is dictionary cache ?

Dictionary cache is information about the database objects stored in a data dictionary table.

16. What is meant by recursive hits ?

Number of times processes repeatedly query the dictionary table is called recursive hits. It is due to the data dictionary cache is too small. By increasing the SHARED_POOL_SIZE parameter we can optimize the size of Data Dictionary Cache.

17. What is meant by redo log buffer ?

Changes made to entries are written to the on-line redo log files so that they can be used in roll forward operation during database recoveries. Before writing them into the redo log files, they will first brought to redo log buffers in SGA and LGWR will write into files frequently. LOG_BUFFER parameter will decide the size.

18. How will you swap objects into a different table space for an existing database ?

Export the user
Perform import using the command imp system/manager file=export.dp indexfile=newfile.sql. This will create all definitions into newfile.sql.
Drop necessary objects.

Run the script newfile.sql after altering the tablespaces.
Import from the backup for the necessary objects.

19. List the Optimal Flexible Architecture (OFA) of Oracle database ? or
How can we organise the tablespaces in Oracle database to have maximum performance ?

SYSTEM - Data dictionary tables
DATA - Standard operational tables
DATA2 - Static tables used for standard operations
INDEXES - Indexes for Standard operational tables
INDEXES1 - Indexes of static tables used for standard operations
TOOLS - Tool table
TOOLS1 - Indexes for tools table
RBS - Standard Operations Rollback Segments
RBS1,RBS2 - Additional/Special rollback segments
TEMP - Temporary purpose tablespace
TEMP_USER - Temporary tablespace for users
USERS - User tablespaces.

20. How will you force database to use particular rollback segment ?

SET TRANSACTION USE ROLLBACK SEGMENT rbs_name

21. What is meant by free extent ?

A free extent is a collection of continuous free blocks in tablespace. When a segment is dropped its extents are reallocated and are marked as free.

22. How free extents are managed in Ver 6 and Ver 7. ?

Free extents cannot be merged together in Ver 6.0
Free extents are periodically coalesces with the neighboring free extent Ver 7.0.

23. Which parameter in Storage clause will reduce no of rows per block ?

PCTFREE parameter
Row size also reduces no of rows per block.

24. What is significance of having storage clause ?

We can plan the storage for a table as how much initial extents are required, how much can be extended next, how much % should leave free for managing row updations etc.

25. How does space allocation take place within a block ?

Each block contains entries as follows :
Fixed block header
Variable block header

Row header, row date (Multiple rows may exists)
PCTFREE (% of free space for row updation in future)

26. What is the role of PCTFREE parameter is Storage clause ?

This is used to reserve certain amount of space in a block for expansion of rows.

27. What is the OPTIMAL parameter ?

It is used to set the optimal length of rollback segment.

28. What is the functionality of SYSTEM tablespace ?

To manage the database level of transactions such as modifications of the data dictionary table that record information about the free space usage.

29. How will you create multiple rollback segments in a database ?

Create a database which implicitly creates a SYSTEM Rollback Segment in a SYSTEM tablespace.
Create a Second Rollback Segment name R0 in the SYSTEM tablespace.
Make new rollback segment available (After shutdown, modify init.ora file and Start database)
Create other tablespace (RBS) for rollback segments.
Create additional Rollback segment in tablespace (RBS)
Deactivate Rollback Segment R0 and activate the newly created rollback segments.

30. How the space utilisation takes place within rollback segments ?

It will try to fit the transaction in a cyclic fashion to all existing extents. Once it found an extent is in use then it forced to acquire a new extent. (No of extents is based on the OPTIMAL size).

31. Why query fails sometimes ?

Rollback segment dynamically extent to handle larger transactions entry loads.
A single transaction may wipeout all available free space in the Rollback Segment Tablespace. This prevents other user using Rollback segment.

32. How will you monitor the space allocation ?

By querying DBA_SEGMENT table/View

33. How will you monitor rollback segment status ?

Querying the DBA_ROLLBACK_SEGS view

The status available as follows :
IN USE - Rollback Segment is on-line
AVAILABLE - Rollback Segment available bur not on-line
OFF-LINE - Rollback Segment us off-line
INVALID - Rollback Segment dropped
NEEDS RECOVERY - Contains data but need recovery or corrupted
PARTLY AVAILABLE - Contains data from an unresolved transaction involving a distributed database

34. List the sequence of events when a large transaction that exceeds beyond its optimal value when an entry wraps and causes the rollback segment to expand into another extend.

Transaction Begins
An entry is made in the RBS header for new transactions entry
Transaction acquired blocks in an extent of RBS
The entry attempts to wrap into second extent. None is available. So that the RBS must extent.
The RBS checks to see if it is oldest inactive segment
Oldest inactive segment is eliminated
RBS extends
The Data dictionary table for space management are updated
Transaction Completes.

35. How can we plan storage for very large tables ?

Limit the number of extents in the table
Separate the Table from its indexes
Allocate sufficient temporary storage

36. How will you estimate the space required by non-clustered tables ?

Calculate the total block header size
Calculate the available data space per block
Calculate the combined column length of the average row
Calculate the total average row size
Calculate the average number rows that can fit in a block
Calculate the number of blocks and bytes required for the table
After arriving the calculation add the additional space to calculate the initial extent size for working area

37. Is it possible to use raw devices as data file and what is the advantages over file system files ?

Yes.
The advantages over file system files :
I/O will be improved because Oracle is bye-passing the kernal while writing into disk.
Disk Corruption will be very less.

38. What is a control file ?

Database's overall physical architecture is maintained in a file called control file. It will be used to maintain internal consistency and guide recovery operations. Multiple copies of control files are advisable.

39. How to implement the multiple control files for an existing database ?

Shutdown the database
Copy one of the existing control file to new location'
Edit config.ora file by adding new control file name
Restart the database

40. What is meant by Redo Log file mirroring ? How it can be achieved ?

Process of having a copy of redo log files is called mirroring.
This can be achieved by creating group of log files together, so that LGWR will automatically writes them to all the members of the current on-line redo log group. If any one group fails then database automatically switch over to next group.

41. What is advantage of having disk shadowing/Mirroring ?

Shadow set of disks save as a backup in the event of disk failure. In most Operating System if any disk failure occurs it automatically switchover to place of failed disk.
Improved performance because of most OS support volume shadowing can direct file I/O request to use the shadow set of files instead of the main set of files. This reduces I/O load on the main set of disks.

42. What is use of rollback segment in Database ?

They allow the database to maintain read consistency between multiple transactions.

43. What is a Rollback segment entry ?

It is the set of before image data blocks that contain rows that are modified by a transaction.
Each Rollback Segment entry must be completed within one rollback segment.
A single rollback segment can have multiple rollback segment entries.

44. What a hit ratio ?

It is a measure of well the data cache buffer is handling requests for data.
Hit Ratio = (Logical Reads - Physical reads - Hit Misses) / Logical reads.

45. When will be a segment released ?

When Segment is dropped.
When Shrink (RBS only)
When truncated (TRUNCATE used with drop storage option)

46. What are disadvantages of having raw devices ?

We should depend on export/import utility for backup/recovery (fully reliable)
The tar command cannot be used for physical file backup, instead we can use dd command which is less flexible and has limited recoveries.

47. List the factors that can affect the accuracy of the estimations ?

The space used transaction entries and deleted records does not become free immediately after completion due to delayed cleanout.
Trailing nulls and length bytes are not stored.
Inserts of, updates to, and deletes of rows as well as columns larger than a single data block, can cause fragmentation and chained row pieces.

3.4 Database Security & Administration

48. What is user account in Oracle database ?

An user account is not a physical structure in Database but it is having important relationship to the objects in the database and will be having certain privileges.

49. How will you enforce security using stores procedures ?

Don't grant user access directly to tables within application
Instead grant the ability to access the procedures that access the tables
When procedure executed it will execute the privilege of procedures owner. Users cannot access tables except via the procedure.

50. What are the dictionary tables used to monitor a database spaces ?

DBA_FREE_SPACE
DBA_SEGMENTS
DBA_DATA_FILES

51. What are responsibilities of a Database Administrator ?

1. Installing and upgrading the Oracle Server and application tools
2. Allocating system storage and planning future storage requirements for the database system.
3. Managing primary database structures(tablespaces)
4. Managing primary objects (table,views,indexes)
5. Enrolling users and maintaining system security
6. Ensuring compliance with Oracle license agreement
7. Controlling and monitoring user access to the database
8. Monitoring and optimising the performance of the database
9. Planning for backup and recovery of database information
10. Maintain archived data on tape
11. Backing up and restoring the database
12. Contacting Oracle Corporation for technical support

52. What are requirements one should fulfill to connect to ORACLE as internal?

Operating system account has the operating system privileges that allow you to connect
One should be authorised to connect as internal
Database has a password for internal connections, and you know the password must use a dedicated server

53. What are the roles and user accounts created automatically with the database ?

DBA role - Contains all database system privileges

SYS user account - The DBA role will be assigned to this account. All of the base tables and views for the database's dictionary are store in this schema and are manipulated only by ORACLE.

SYSTEM user account - It has all the system privileges for the database and additional tables and views that display administrative information and internal tables and views used by oracle tools are created using the username.

54. What are the database administrators utilities available ?

SQL*DBA - This allows DBA to monitor and control an ORACLE database.

SQL*Loader - It loads data from standard operating system files (Flat files) into ORACLE database tables.

EXPORT(exp) and IMPOER (imp) utilities allow you to move existing data in ORACLE format to and from ORACLE database.

55. What are the minimum parameters should exist in the parameter file (init.ora) ?

DB_NAME - Must set to a text string of not more that 8 characters and it will be stored inside the datafiles, redo log files and control file while database creation.

DB_DOMAIN - It is string that specifies the network domain where the database is created. The global database name is identified by setting these parameters (DB_NAME & DB_DOMAIN)

CONTROL_FILES - List of control filenames of the database. If name is not mentioned then default name will be used.

DB_BLOCK_SIZE - The default data block size and is operating system dependent. It cannot be changed after database creation except by re-creating the database.

DB_BLOCK_BUFFERS - The maximum number of operating system processes that can be connected to ORACLE concurrently. The value should be 5 (background process) and additional 1 for each user.

ROLLBACK_SEGMENTS - List of rollback segments an ORACLE instance acquires at database startup.

Also optionally LICENSE_MAX_SESSIONS,LICENSE_SESSION_WARNING and LICENSE_MAX_USERS.

56. What is a trace file and how it is created ?

Each server and background process can write an associated trace file. When an internal error is detected by a process or user process, it dumps information about the error to its trace. This can be used for tuning the database.

57. What are roles ? How can we implement roles ?

Roles are easiest way to grant and manage common privileges needed by different groups of database users.
Creating roles and assigning privies to roles.
Assign each role to group of users. This will simplify the job of assigning privileges to individual users.

58. What are the steps to switch a database's archiving mode between NOARCHIEVELOG and ARCHIVELOG mode ?

1. Shutdown the database instance
2. Backup the database
3. Perform any operating system specific steps (optional)
4. Start up a new instance and mount but do not open the database
5. Switch the database's archiving mode.

59. How can you enable automatic archiving ?

Shut the database
Backup the database
Modify/Include LOG_ARCHIVE_START = TRUE in init.ora file
Start up the database

60. How can we specify the Archived log file name format and destination ?

By setting the following values in init.ora file
LOG_ARCHIVE_FORMAT = arch%S/s/T/t.arc (%S - Log sequence number and is zero left-paded, %s - Log sequence number not paded, %T - Thread number left-zero-paded and %t - Thread number not paded). The file name created is arch0001.arc %S is used.
LOG_ARCHIEVE_DEST = path

Shut the database and change these parameters in init.ora files.

61. What is the user of ANALYZE command ?

To perform one of these function on an index, table, or cluster :
to collect statistics about object used by the optimizer and store them in the data dictionary.
to delete statistics about the object from the data dictionary
to validate the structure of the object
to identify migrated and chained rows of the table or cluster.

3.5 Managing Distributed Databases

62. How can we reduce the network traffic ?

Replication of data in distributed environment
Using snapshots to replicate data
Using remote procedure calls.

63. What is a snapshot ?

Snapshot is an object used to dynamically replicate data between distributed databases at specified time intervals. In ver 7.0 they are read only.

64. What are the various type of snapshots ?

Simple and Complex.

65. Differentiative simple and complex, snapshots

A simple snapshot is based on a query that does not contains GROUP BY clauses, CONNECT by clauses, JOINs, Subquery or a set of operations.
A complex snapshots contain at least any one of the above.

66. What is dynamic data replication ?

Updating or inserting records in remote database through database triggers. It may fail if remote database is having any problem.

67. How can you enforce referential integrity in snapshots ?

Time the references to occur when master tables are not in use.
Perform the references manually immediately after locking the master tables.
We can join tables in snapshots by creating a complex snapshot that will be based on the master tables.

68. What are the options available to refresh snapshots ?

COMPLETE - Tables are completely regenerated using the snapshot's query and the master tables every time the snapshot referenced.
FAST - If simple snapshot used then a snapshot log can be used to send only the changes to the snapshot tables.
FORCE - The default value. If possible it performs a FAST refresh; Otherwise it will perform a COMPLETE refresh.

69. What is a snapshot tag ?

It is a table that maintains a record of modifications to the master table in a snapshot. It is stored in the same database as master table and is only available for simple snapshots. It should be created before creating snapshots.

70. When will the data in the snapshot log be used ?

The data in the snapshot log is used during fast references of the table's snapshots.

71. What are the pre-requisites to create a snapshot log ?

We must be able to create a after row trigger on table (i.e. it should not be already available)
After giving table previleges.
We cannot specify snapshot log name because oracle uses the name of the master table in the name of the database objects that support its snapshot log.
The master table name should be less than or equal to 23 characters.
(The table name created will be MLOG$_tablename, and trigger name will be TLOG$_tablename)

72. What are the benefits of distributed options in databases ?

Database on other servers can be updated and those transactions can be grouped together with others in a logical unit.
Database uses a two phase commit

73. What is a two-phase commit ?

Database on other servers can be updated and those transactions can be grouped together with others in a logical unit is called two-phase commit. They are

The Preparation Phase : An initiating node called the global coordinator notifies all sites involved in the transaction to be ready either commit or rollback the transaction.

The Commit Phase : If there is no problem with prepare phase, then all sites commit their transactions. If a network or node failure occurs, then all sites rollback their transactions.

3.6 Managing Backup & Recovery

74. What are the different methods of backing up oracle database ?

Logical Backups
Cold Backups
Hot Backups (Archive log)

75. What is a logical backup ?

Logical backup involves reading a set of database records and writing them into a file. Export utility is used for taking backup and Import utility is used to recover from backup.

76. What is cold backup ? What are the elements of it ?

Cold backup is taking backup of all physical files after normal shutdown of database. We need to take
All Data files
All Control files
All on-line redo log files
Then init.ora file (optional)

77. What are the different kind of export backups ?

Full backup - Complete database
Incremental Backup - Only affected tables from last incremental date / Full backup date
Cumulative backup - Only affected table from the last cumulative date / Full backup date

78. What is hot backup and how it can be taken ?

Taking backup of archive log files when database is open. For this the ARCHIVELOG mode should be enabled. The following files need to be backed up :
All data files
All archive log, redo log files
On control file.

79. What is the use of FILE option in EXP command ?

To give the export file name.

80. What is the use of COMPRESS option in EXP command ?

Flag to indicate whether export should compress fragmented segments into single extents.

81. What is the use of GRANT option in EXP command ?

A flag to indicate whether grants on database objects will be exported or not. Values is 'Y' or 'N'.

82. What is the use of INDEXES option in EXP command ?

A flag to indicate whether indexes on tables will be exported.

83. What is use of ROWS option in EXP command ?

Flag to indicate whether table rows should be exported. If 'N' only DDL statements for the database objects will be created.

84. What is the use of CONSTRAINTS option in EXP command ?

A flag to indicate whether constraints on table need to be exported.

85. What is the use of FULL option in EXP command ?

A flag to indicate whether full database export should be performed.

86. What is the use of OWNER option in EXP command ?

List of table accounts should be exported.

87. What is the use of TABLES option in EXP command ?

List of tables should be exported.

88. What is use of RECORD LENGTH option in EXP command ?

Record length in bytes.

89. What is use of INCTYPE option in EXP command ?

Type export should be performed. COMPLETE, CUMULATIVE, INCREMENTAL

90. What is use of RECORD option in EXP command ?

For incremental exports, the flag indicates whether a record will be stored in data dictionary tables recording the export.

91. What is the use of PARFILE option in EXP command ?

Name of the parameter file to passed for export.

92. What is the use of ANALYSE (Ver 7) option in EXP command ?

A flag to indicate whether statistical information about the exported objects should be written to export dump file.

93. What is use of CONSISTENT (Ver 7) option in EXP command ?

A flag to indicate whether a read consistent version of all the exported objects should be maintained.

94. What is the use of Log (Ver 7) option in EXP command ?

The name of file to which log of the export will be written.

95. What is use of FILE option in IMP command ?

The name of file from which import should be performed.

96. What is the use of SHOW option in IMP command ?

A flag to indicate whether file content should be displayed or not.

97. What is the use of IGNORE option in IMP command ?

A flag to indicate whether import should ignore errors encounter when issuing CREATE command.

98. What is the use of GRANT option in IMP command ?

A flag to indicate whether grants on database objects will be imported.

99. What is use of INDEXES option in IMP command ?

A flag to indicate whether import should import index on tables or not.

100. What is use of ROWS option in IMP command ?

A flag to indicate whether rows should be imported. I f this is set to 'N' then only DDL for the database objects will be executed ?

101. What is the use of FULL option in IMP command ?

A flag to indicate whether full import should be done or not.

102. What is the use of FROMUSER option in IMP command ?

A list of database accounts whose objects should be read from the export dump file.

103. What is use of TOUSER option in IMP command ?

A list of database accounts into which objects in the export dump file will be imported

104. What is use of TABLES option in IMP command ?

A list of tables to be imported.

105. What is use of RECORDLENGTH option in IMP command ?

The length of the record in bytes of the export dump file.

106. What is use of INCTYPE option in the IMP command ?

The type of import being performed.

107. What is use of COMMIT option in IMP command ?

A flag to indicate whether import should commit after each array. If 'N' then commit will take place at table level

108. What is use of PARFILE option in IMP command ?

Name of the parameter file to passed for import command.

109. What is use of INDEXFILE option in IMP command ?

If filename is given then all the DDL will be created in the given file.

110. What is use of DESTROY (Ver 7) option in IMP command ?

A flag to indicate whether the create tablespace command found in dump files from full exports will be executed.

111. What is use of LOG option in IMP command ?

Name of the file to which the log of the import will be written.

112. Consider a case below : User is taking the backup in the following fashion :
Type F I I I I C I I I I C I I
Date 1 2 3 4 5 6 7 8 9 10 11 12 13
F - Full Backup
I - Incremental Backup
C - Cumulative Backup
Suppose database crash on 14th morning. How can we retrieve the database ?

Create the database
Import from the Full backup which was taken on 1st
Import from Cumulative backups which was taken on 6th
Import from Cumulative backups which was taken on 1th
Import from the Incremental backups 12,13 respectively.
Now the database will be available to latest status provided there is no transaction taken place after the 13th incremental backup.

113. List the steps to restore the database if data file lost. (Assume we are taking hot backups)

Copy the lost file from the backup to the original location
Start the instance
Mount the database
Recover the database using recover database command
Open the database

114. What are the points to be taken care when we are using SQL*Loader for importing data from flat files ?

Whether table and indexes are properly sized.
Direct option being used or not (Ver 7)
If one time load do not create any index until data has been loaded and table size is verified.

115. What are the advantages of using direct path option in SQL*Loader ?

It bypasses the normal processing of insert statements and instead writes directly to tables data blocks.
When direct option is used index become invalid and once the load complete the new key is merged with all old one and bring the status to valid.
Data should be presorted otherwise it needs the double the size in tablespace.

116. What are areas a DBA can monitor the database using SQLDBA command?

DBA can monitor the following areas to do fine tuning of the database :
Processes
Sessions
Tables(Locks etc)
SQL Area
Library Cache
Latch
Locks
File I/O
System I/O
Rollback Segments
Statistics (System, Sessions)

Apart from this all DBA activities can be performed through SQLDBA command.

DDE ¡V OLE

DDE - Dynamic Data Exchange.
DLL - Dynamic Link Library
OLE - Object Linking and Embedding.
MAPI ¡V Messaging Application Program Interface

What is DDE ?

DDE is method for Inter Process Communication. An inter process communication is a method of passing data between processes and synchronising events.

How does DDE work ?

DDE uses shared memory to exchange data and a protocol to synchronize passing of data.

What does a DLL contain ?

A DLL contains code, data and windows resources.

How does a DLL work ?

A DLL allocates a global memory block to an application and uses this to exchange data with application.

What are the two types of DDE application ?

Message based DDE applications and Dynamic Data Exchange Management Library application.

What are the parts of a DDE application ?

Client application, Server application, Client/Server application and Monitor application.

What is a monitor application in the context of DDE ?

A monitor application can only intercept messages but cannot act on it.

What is the use of a monitor application ?

A monitor application can be used as a debugging tool.

What is the connection between OLE and DDE ?

OLE is a set of DDE executable commands to which DDE protocol is applicable.

What is the difference between an embedded object and a linked object ?

An embedded object is stored in the document itself while the document just stores a reference to the linked object.

If a link object is changed independently of the document, wht happens the linked object in the document ?
1. The reference object is automatically refreshed
2. The reference object is not refreshed
3. The user decides whether the object is to refreshed or if the older version is retained.

Answer is 2

What are the types of OLE applications ?

Client, Server and Object handlers.

What is an object handler ?

An Object handler is a set of DLL that facilitate communication between client application and server application.

What are the advantages of OLE ?

No need to switch between applications. Facilitate the use of specialized applications to create objects which can be embedded.

What is the difference between a stored procedure and a database trigger ?

A trigger is automatically executed when the firing event occurs while stored procedure has to be invoked.

Oracle Forms:

1. How to use single data block to query multiple tables
2. How to see the select statement when we issue execute_query
3. What are the system variables can be changed
4. How do you trap default forms processing ( DML)
5. What is the difference between post-query and post-select
6. What is purpose and order of firing the following triggers
1. on fetch
2. on select
7. What is the number of records buffered and Query array size properties of data block
8. What is the difference between object libraries and object groups
9. What is the difference between pre-query and pre-select triggers
10. What is the difference between pre-text-item and when-new-item-instance triggers
11. What is the order of firing the following triggers
1. when-new-form-instance
2. pre-text-item
(Both are in form-level)
12. What is the validation unit property of form module
13. What is the order of checking for a program unit from form module(local program unit, library, stored procedure)
14. What is the difference between PL/SQL library and object library
15. what is the use of pre text/pre record/pre form
16. types of record groups and usage
17. what is id_null function
18. what is the return data types of id_null, show_alert, show_lov
19. what is the difference between call_form , open_form, new_form
Which is restricted built-in and why?
Which can¡Št issue savepoint
What is session parameter of open_form?

20. which are the triggers will fire in the following situation

I have three text items
1. Text-item1
1.key-next-item
Go_item (¡¥text_item2¡Š);
Go_item (¡¥text_item3¡Š);

2. Text-item2
1. Pre-text-item
2. When-validate-item
3. When-new-item-instance
4. Key-next-item
5. Post-text-item
6. Post-change
3. Text-item3
1. Pre-text-item
2. When-validate-item
3. When-new-item-instance
4. Key-next-item
5. Post-text-item
6. Post-change

If I press tab or enter key at text-item1 what are the triggers will fire and order of firing during the entire navigation.


If I change key-next-item trigger of text-item1

Go_item (¡¥text_item2¡Š);
: Text_item2: = ¡¥Nagendra¡Š;
Go_item (¡¥text_item3¡Š);

Then what are the triggers will fire and order of firing

21. What is synchronous and asynchronous parameters for run_product built-in
22. How do you suppress the logon screen while running the form for the first time
23. What is primary canvas property of window and where it will be useful
24. I have when-button-pressed trigger at form , block and item level
If I want to execute first block, form then item level trigger what changes I have to make.
25. what is data parameter and text parameter
26. Can we re-generate a library that is currently accessing by some other session
27. Can we re-generate and save a library that has been attached with some forms but they are running currently.
28. Can we re-generate a library that has been attached with some forms , will the changes will reflect in the referenced forms
29. What is the use of transactional triggers
30. Can we modify a sub classed object ( from object group and from object libraries)
31. How to set forms default directory
32. What is the return data type of populate_group built-in
33. What is the difference between OLE object created at design time and runtime
34. Will the timer will expire during large query executing
35. What is the built-in package available to manipulate text files( forms)
36. Can we define a relation between two control blocks
37. If we change relation property from non-isolated to cascading what changes will occur
38. What is the coordination property of a relation
39. If we delete on-clear-details trigger in a relation what happens
40. What is the first trigger fires when we run a form
41. What is the use of enforce primary key property of data block
42. Can we put items other than buttons in the toolbars
43. Which object relates content and stacked canvases(window)
44. How to navigate from one form to other form(built-in)
45. How to copy values from list item to record group
46. In a non-isolated relation what is the order of firing the following triggers
1. on-populate-details
2. on-clear-details
3. pre-query
4. pre-select
47. How to find out the previous form id in multi form application(it¡Šs system variable)
48. How to use single LOV for multiple items

Oracle reports:

1. Minimum requirement to make a matrix report
(Queries, Groups and Repeating frames)
2. How to change the font of an field at runtime based on the value
3. What is the anchoring and enclosing object
4. What is anchor object
5. How to rotate a field( data base field in the layout)
6. What is the difference between lexical and bind parameters
7. What is the place holder
8. What is the use of frame(not repeating)
9. What is the use of format triggers
10. SRW package
11. What is flex mode and confine mode
12. what difference between the logical and physical pages and planes
13. what is the use of group filter

SQL and PL/SQL

1. Queries for Nth maximum ,Nth row
2. what is use of the index ( maximum try to cover)
3. Select the departments whose sum of the salary greater than the sum of salaries of any department?
4. What is implicit cursors
5. What is public synonyms and uses
6. When index will be used in the query
7. What is the result of the following queries

1. Select * from emp where Comm in (null);
2. Select * from emp where Comm = null;
3. Select * from emp where Comm = ¡¥¡Š;
4. Select * from emp where Comm is ( select null from dual);

8. Query to display employee name and his managers name
9. Query to find the employees who is having more then one subordinate
10. Query to find the employees whose salary is greater then his department average salary
11. Query to display employees salary as 2000 for department 20 and rest as their salaries
12. Query to display no of employees in the department 10, 20,30 in a single row
Output
Dept10 dept20 dept30
2 5 6
13. Query to find the no of subordinate levels for given manager
14. Query to find the no of employees who is drawing less than 1500 and greater than 2000

Server concepts

1. what are the physical database components
2. what are the logical database components
3. what is row chaining
4. what is the relation between oracle data block ,extents and segments
5. how many types of segments are there
6. what is temporary segments
7. what is redo log
8. what is the difference between rollback segments and redo log files
9. what is the difference between database buffers and redo log buffer of SGA
10.

1) How delete duplicate records in a table
delete from emp where rowid not in (select max(rowid) from emp group by empno);

2) How to make a column into not null column.
Ans: alter table emp
modify (empno not null); ->this can be done only when all the values in empno are non null (i.e not empty)

?h To make a not null column into null column
alter table emp
modify (empno null);
The fallowing are the rules for

i. adding null or not null property
>You may change a column¡Šs null property to not null only when that field does contain null values(i. It can¡Št be empty)
>At any time you may change a column¡Šs not null property to null

ii. adding a colum to a table
>You may add a column at any time if NOT NULL isn¡Št specified (i.e when new column can accept null values )
>You may add a NOT NULL column in three steps.
a. Add the column without NOT NULL specified.
b. Fill every row in that column with data.
c. Modify the column to be NOT NULL.

iii. modifying a column
>You can increase a CHAR column¡¥s width at any time.
>You can increase the number of digits and the number of decimal places in a NUMBER column at any time
>To CHANGE data types or to DECREASE column¡Šs width the column should be null for every row

3)Write queries for the fallowing
ex. select * from emp_self;

EMP_NO EMPN_NAME SAL MGR DEPTID
--------- -------------------- ---------- ---------- ----------
400 jane 20000 110 20
102 Mary 19000 110 20
101 charles 8000 105 50
104 Linda 9000 100 10
110 john 25000 105 20
105 newton 2000 50
100 ALEN 15000 105 50
200 BORIS 3000 110 20
103 DAVID 10000 100 10
300 monica 7000 105 50
i) Query to get the employees who are working under mgr with salary > 10000
select emp_no,mgr from emp_self where mgr in (select emp_no from emp_self where sal > 10000);

ii) Query to get the employees who are getting salaries more than their managers
select a.emp_no from emp_self a,emp_self b where a.mgr =b.emp_no and a.sal > b.sal;
EMP_NO
-------
101
100
110
300
iii) Query to find the nth highest salary
select a.empn_name,a.sal from emp_self a where &n = (select count(*) from emp_self b where a.sal < b.sal);
When n=1 , sal =20000 ->second highest salary ; n=4 , sal =10000 ->fifth highest salary ;
iv) Query to find the second highest salary in different departments.
select a.deptid,min(a. sal) from emp_self a where 1 in (select count(*) from emp_self b
where a.sal < b.sal group by b.deptid) group by a.deptid;

DEPTID MIN(A.SAL)
------- ----------
10 9000
20 20000
50 8000
v) Query to find departments with total salary >25000

select deptid from emp_self having sum(sal) >25000 group by deptid;

DEPTID
------
20
50

4) study the fallowing pl/sql block and find the type of error ->syntax,semantic(logical) or precedence
begin
for i in 1..5 loop
update emp
set sal = 1000 where empno =100 ;
end loop;
end;

5) Difference between (MAX,MIN) and (GREATEST ,LEAST)
The functions max and min compares different rows . Whereas greatest and least work on a group of columns ,either actual or calculated values within a single row.

Ex. select * from emp_self;

EMP_NO EMPN_NAME SAL MGR
------ -------------------- ------- ----------
100 alen 9,000 105
200 boris 10,000 110
101 charles 8,000 105

SQL> select max(sal),min(sal) from emp_self;

MAX(SAL) MIN(SAL)
---------- ----------
10000 8000

SQL> select greatest(sal),least(sal) from emp_self;

GREATEST(SAL) LEAST(SAL)
------------- ----------
9000 9000
10000 10000
8000 8000
6)Different kinds of constraints .
6)Where Procedures,Functions and Triggers are stored ?.
7)What are the improtant differences between Procedures,Functions and Triggers ?.
8)Can we call a Procedure from a Trigger ?.
9)what are packages ?.
9)What are the different kinds of parameters ?.
10)Can we return a OUT parameter from a procedure ?.
11)Differences between ROWNUM and ROWID .
12)How do you handle exceptions ?.
12)How many system defined exceptions are there ?.
13)How do you write user defined message for all the system defined exceptions.
14)Difference between Commit and H(?)ost .
15)Differences between delete ,truncate and drop commands .
16) How do you display messages in the backend procedure ?.
17) why can¡Št you use create/drop while declaring a trigger ?.
18)Advantages of union over joins .
19)Definitions of commit, rollback, save point
20)Difference between truncate and delete (truncate =delete + commit)

1)Name the five global report triggers
i. before report
ii. after report
iii. between pages
iv. before parameter form
v.after parameter form

As a general rule, any processing that will affect the data retrieved by the report should be performed in the Before Parameter Form or After Parameter Form triggers. (These are the two report triggers that fire before anything is parsed or fetched.) Any processing that will not affect the data retrieved by the report can be performed in the other triggers.

Report Builder has five global report triggers. You cannot create new global report triggers. The trigger names indicate at what point the trigger fires:

Before Report Fires before the report is executed but after queries are parsed.
After Report Fires after you exit the Previewer, or after report output is sent to a specified destination, such as a file, a printer, or an Oracle Office userid. This trigger can be used to clean up any initial processing that was done, such as deleting tables. Note, however, that this trigger always fires, whether or not your report completed successfully.
Between Pages Fires before each page of the report is formatted, except the very first page. This trigger can be used for customized page formatting. In the Previewer, this trigger only fires the first time that you go to a page. If you subsequently return to the page, the trigger does not fire again.
Before Parameter Form Fires before the Runtime Parameter Form is displayed. From this trigger, you can access and change the values of parameters, PL/SQL global variables, and report-level columns. If the Runtime Parameter Form is suppressed, this trigger still fires. Consequently, you can use this trigger for validation of command line parameters.
After Parameter Form Fires after the Runtime Parameter Form is displayed. From this trigger, you can access parameters and check their values. This trigger can also be used to change parameter values or, if an error occurs, return to the Runtime Parameter Form. Columns from the data model are not accessible from this trigger. If the Runtime Parameter Form is suppressed, the After Parameter Form trigger still fires. Consequently, you can use this trigger for validation of command line parameters or other data.

2) Name the different types of alerts
note , stop ,caution
3)call_form ( ), new_form ( )
call_form ( ) :-Runs an indicated form while keeping the parent form active. Form Builder runs the called form with the same Runform preferences as the parent form. When the called form is exited Form Builder processing resumes in the calling form at the point from which you initiated the call to CALL_FORM.

PROCEDURE CALL_FORM
(formmodule_name VARCHAR2);

New_form( ) :-
Exits the current form and enters the indicated form. The calling form is terminated as the parent form. If the calling form had been called by a higher form, Form Builder keeps the higher call active and treats it as a call to the new form. Form Builder releases memory (such as database cursors) that the terminated form was using.
Form Builder runs the new form with the same Runform options as the parent form. If the parent form was a called form, Form Builder runs the new form with the same options as the parent form.

PROCEDURE NEW_FORM
(formmodule_name VARCHAR2);

4) system.mode->
SYSTEM.MODE indicates whether the form is in Normal, Enter Query, or Fetch Processing mode. The value is always a character string.

NORMAL Indicates that the form is currently in normal processing mode.
ENTER-QUERY Indicates that the form is currently in Enter Query mode.
QUERY Indicates that the form is currently in fetch processing mode, meaning that a query is currently being processed.

Usage Notes
When using SYSTEM.MODE to check whether the current block is in Enter Query mode, be aware that if testing from a When-Button-Pressed trigger in a control block, Enter Query mode will never be entered, because the control block is not the current block.

4)What are important new(Advanced) features of Forms 6.0.
5)Different types of list boxes.
6)What are record groups ?.
7)In case of a block with multiple records how to display records on the screen without using cursors ?.
8)Can we access a row in the first block from second by referencing block name along with the rowid ?.
9)In case of a block with multiple records how do check where a user entering a duplicate record well before saving it ?.
10)How to take care of concurrency ?.

1. What is the size of Varchar in Oracle 8.0 ?
a. 2000
b. 4000
c. 254
d. none of the above
2. What is the size of Varchar in Oracle 7.0 ?
a. 2000
b. 4000
c. 254
d. none of the above
3. The default value the lpad function takes is
a. a space (¡§ ¡§)
b. an asterisk
c. The default value is not optional
d. None of the above
4. The no. of columns that may be used as composite primary key in oracle 8
a. 8
b. 16
c. 32
d. none of the above
5. which of the following is true about add_months
a. we can pass a numerical value in first parameter
b. we can pass a negative value in second parameter
c. Both a & b
d. None of the above
6. The latest date that can be stored in oracle 8
a. 31st Dec 4012 A.D
b. 31st Dec 4011 A.D
c. Dec 31st ,9999
d. None of the above.
7. What happens when the first date is greater than the second date that is passed to the months_between function in oracle 8.
a. It gives an error
b. It gives a negative value
c. None of the above
8. Regarding the Summary query which of the following is true
a. The order of the base column list in the select statement should be same in the Group by clause.
b. The order of the base column list in the select statement need not be same in the Group by clause.
c. None of the above
9. Regarding the Summary query which of the following is true
a. All the base table columns selected in the select list should be specified in the Group by clause.
b. All the base table columns selected in the select list need not be specified in the Group by clause.
c. None of the above.
10. How do u mask the user from entering irrelevant data ?
a. Synonym
b. View
c. Index
d. sequence
11. What does the length function returns when applied to column of char datatype ?
12. Which of the following is true about the packages ?
a. Package specification should contain return type of a function
b. Package specification need not contain return type of a function
c. Both a & b
d. None of the above
13. If the first parameter is negative, then second parameter
a. need not be negative
b. there is no such restrictions
c. should be positive
d. None of the above.
14. Which of the following is true about procedures
a. The size of the parameter should be mentioned in a procedure.
b. The size of the parameter should not be mentioned in a procedure
c. Both a & b
d. None of the above.
15. ¡§REFERENCING¡š in oracle 8
a. used to mention referential integrity
b. used for creating views
c. there is no such word in oracle 8
d. none of the above
16. If you want to restrict the user, to enter the same values that has been stored in other table then what constraint do u use?
a. Entity integrity
b. Referential Integrity
c. Both a & b
d. None of the above
17. Which of the following is true about NULL?
a. when an arithmetic operation is performed on NULL, u will get the result as NULL
b. NULL is same as 0.
c. NULL is same as blank date.
d. None of the above
18. For a DDL statement, which of the following is true
a. A DDL statement is preceded and followed by commit.
b. All the DML statements gets committed even when u get an error after writing DDL statement.
c. Both a & b
d. None of the above.
19. Which of the following is true for update clause?
a. We can update two base tables simultaneously
b. U can use a subquery in SET clause of the UPDATE statement.
c. Both a & b
d. None of the above
20. Which of the following is true for delete?
a. Delete statement can be given without writing where clause.
b. We can delete two tables simultaneously
c. Both a & b
d. None of the above
21. How do u rename a table ?
a. Using alter command
b. Using RENAME
c. Dropping the table and creating once again
d. None of the above.
22. In oracle 7 which of the following is true about manipulating the view
a. View based on two base tables can be manipulated
b. View having a column which contain operation can be manipulated
c. Both a & b
d. None of the above
23. In oracle 8 which of the following is true about manipulating the view
a. View based on two base tables can be manipulated
b. View having a column which contain operation can be manipulated
c. Both a & b
d. None of the above
24. Which of the following is true about packages
a. We can write a procedure in package body which has not been specified in package specification.
b. We cannot write a procedure in package body which has not been specified in package specification.
c. Both a & b
d. None of the above.
25. Which of the following is true about outer joins
a. The outer join symbol should be present on any one side of the join.
b. The outer join symbol may be present on both the sides of the join
c. The outer join return the rows from the two tables that donot have matching records in other table.
d. None of the above
26. Which of the following is true about procedure and a function
a. Procedure should return a value and a function may not return a value
b. A function has to return a value and a procedure don¡Št have to
c. Both a & b
d. None of the above.
27. What does OFA stands for ?
a. Oracle Flexible Architecture
b. Oracle Financials Applications
c. Optimal Flexible Architecture
d. None of the above

Oracle Questions
?h What is SQL*Plus and where does it come from?
?h How does one use the SQL*Plus utility?
?h What commands can be executed from SQL*Plus?
?h What are the basic SQL*Plus commands?
?h What is AFIEDT.BUF?
?h How does one restore session state in SQL*Plus?
?h What is the difference between @ and @@?
?h What is the difference between & and &&?
?h What is the difference between ! and HOST?
?h What is the difference between ? and HELP?
?h How does one enable the SQL*Plus HELP facility?
?h How can one disable SQL*Plus prompting?
?h How can one trap errors in SQL*Plus?
?h How does one trace SQL statement execution?
?h How can one prevent SQL*Plus connection warning messages?
?h How can uses be prevented from executing devious commands?
?h How can one disable SQL*Plus formatting?
?h Can one send operating system parameters to SQL*Plus?
?h Can one copy tables with LONG columns from one database to another?
?h Where can one get more info about SQL*Plus?
What is SQL*Plus and where does it come from?
SQL*Plus is a command line SQL and PL/SQL language interface and reporting tool that ships with the Oracle Database Client and Server. It can be used interactively or driven from scripts. SQL*Plus is frequently used by DBAs and Developers to interact with the Oracle database.
SQL*Plus's predecessor was called UFI (User Friendly Interface). UFI was included in the first releases of Oracle, its interface was extremely primitive and anything but user friendly.
How does one use the SQL*Plus utility?
Start using SQL*Plus by executing the "sqlplus" command-line utility. Valid options are:
userid/password@db -- Connection details
/nolog -- Do not login to Oracle. You will need to do it yourself.
-s or -silent -- start sqlplus in silent mode. Not recommended for beginners!
@myscript -- Start executing script called "myscript"
Look at this simple example:
sqlplus /nolog
SQL> connect scott/tiger
SQL> select * from tab;
SQL> disconnect
SQL> exit
What commands can be executed from SQL*Plus?
One can enter three kinds of commands from the SQL*Plus command prompt:
1. SQL*Plus commands - SQL*Plus commands are used to set options for SQL*Plus, format reports, edit files, edit the command buffer, and so on. SQL*Plus commands do not interact with the database. These commands do not have to be terminated with a semicolon (;), as is the case with SQL commands. The rest of this page is dedicated to SQL*Plus commands, eg.
SHOW USER
2. SQL commands - for more information see the Oracle SQL FAQ. Eg:
SELECT * FROM TAB;

3. PL/SQL blocks - for more information see the Oracle PLSQL FAQ. Eg:
BEGIN
DBMS_OUTPUT.PUT_LINE('Hello World!');
END;
/
What are the basic SQL*Plus commands?
The following SQL*Plus commands are available:
ACCEPT Get input from the user
DEFINE Declare a variable (short: DEF)
DESCRIBE Lists the attributes of tables and other objects (short: DESC)
EDIT Places you in an editor so you can edit a SQL command (short: ED)
EXIT or QUIT Disconnect from the database and terminate SQL*Plus
GET Retrieves a SQL file and places it into the SQL buffer
HOST Issue an operating system command (short: !)
LIST Displays the last command executed/ command in the SQL buffer (short: L)
PROMPT Display a text string on the screen. Eg prompt Hello World!!!
RUN List and Run the command stored in the SQL buffer (short: /)
SAVE Saves command in the SQL buffer to a file. Eg "save x" will create a script file called x.sql
SET Modify the SQL*Plus environment eg. SET PAGESIZE 23
SHOW Show environment settings (short: SHO). Eg SHOW ALL, SHO PAGESIZE etc.
SPOOL Send output to a file. Eg "spool x" will save STDOUT to a file called x.lst
START Run a SQL script file (short: @)
How does one restore session state in SQL*Plus?
Look at the following example (Oracle8):
SQL> STORE SET filename REPLACE
SQL> (do whatever you like)
SQL> @filename
What is AFIEDT.BUF?
AFIEDT.BUF is the SQL*Plus default edit save file. When you issue the command "ed" or "edit" without arguments, the last SQL or PL/SQL command will be saved to a file called AFIEDT.BUF and opened in the default editor.
In the prehistoric days when SQL*Plus was called UFI, the file name was "ufiedt.buf", short for UFI editing buffer. When new features were added to UFI, it was the initially named Advanced UFI and the filename was changed to "aufiedt.buf" and then to "afiedt.buf". They presumably needed to keep the name short for compatibility with some of the odd operating systems that Oracle supported in those days.
The name "Advanced UFI" was never used officially, as the name was changed to SQL*Plus before this version was released.
You can overwrite the default edit save file name like this:
SET EDITFILE "afiedt.buf"
What is the difference between @ and @@?
The @ (at symbol) is equivalent to the START command and is used to run SQL*Plus command scripts.
A single @ symbol runs the script in your current directory, or one specified with a full or relative path, or one that is found in you SQLPATH or ORACLE_PATH.
@@ will start a sqlplus script that is in the same directory as the script that called it (relative to the directory of the current script). This is normally used for nested command files.

What is the difference between & and &&?
"&" is used to create a temporary substitution variable and will prompt you for a value every time it is referenced.
"&&" is used to create a permanent substitution variable as with the DEFINE command and the OLD_VALUE or NEW_VALUE clauses of a COLUMN statement. Once you have entered a value it will use that value every time the variable is referenced.
Eg: SQL> SELECT * FROM TAB WHERE TNAME LIKE '%&TABLE_NAME.%';
What is the difference between ! and HOST?
Both "!" and "HOST" will execute operating system commands as child processes of SQL*Plus. The difference is that "HOST" will perform variable substitution (& and && symbols), whereas "!" will not. (Note: use "$" under MVS, VMS, and Windows environments, not "!")
What is the difference between ? and HELP?
There is no difference. Both "?" and HELP will read the SYSTEM.HELP table (if available) and shows help text on the screen.
To use the help facility, type HELP followed by the command you need to learn more about. For example, to get help on the SELECT statement, type:
HELP SELECT
How does one enable the SQL*Plus HELP facility?
To enable HELP for SQl*Plus, run the supplied SQL and Loader scritps to create the Help table and to populate it. Look at this Unix example:
cd $ORACLE_HOME/sqlplus/admin/help
sqlplus system/manager @helptbl
sqlplus system/manager @helpindx
sqlldr system/manager control=plushelp.ctl
sqlldr system/manager control=sqlhelp.ctl
sqlldr system/manager control=plshelp.ctl
If the HELP command is not supported on your operating system, you can access the help table with a simple script like this:
HELP.SQL:

select info
from system.help
where upper(topic)=upper('&1')
/
How can one disable SQL*Plus prompting?
If you run a script that contains "&" symbols SQL*Plus thinks that you want to prompt the user for a value. To turn this off:
SET ESCAPE ON
SET ESCAPE ""
SELECT 'You & me' FROM DUAL;
or
SET DEFINE ?
SELECT 'You & me' FROM DUAL;
Note: You can disable substitution variable prompting altogether by issuing the SET DEFINE OFF commmand.

How can one trap errors in SQL*Plus?
Use the "WHENEVER OSERROR ..." to trap operating system errors and the "WHENEVER SQLERROR ..." command to trap SQL and PL/SQL errors. Eg:
SQL> WHENEVER OSERROR EXIT 9
SQL> WHENEVER SQLERROR EXIT SQL.SQLCODE
How does one trace SQL statement execution?
1. Run the PLUSTRCE.SQL script from the SYS database user. This script is located the in $ORACLE_HOME/sqlplus/admin.
2. Create a PLAN_TABLE using the UTLXPLAN.SQL script. This script is in $ORACLE_HOME/rdbms/admin.
3. Use the "SET AUTOTRACE ON" command to trace SQL execution. This will print the result of your query, an explain plan and high level trace information. Look at this example:
SQL> set autotrace on
SQL> select * from dual;

D
-
X

Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 TABLE ACCESS (FULL) OF 'DUAL'

Statistics
----------------------------------------------------------
0 recursive calls
2 db block gets
1 consistent gets
0 physical reads
0 redo size
181 bytes sent via SQL*Net to client
256 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
How can one prevent SQL*Plus connection warning messages?
When I go to SQl*Plus, I get the following errors:

Error accessing PRODUCT_USER_PROFILE
Warning: Product user profile information not loaded!
You may need to run PUPBLD.SQL as SYSTEM
This messages will stop appearing when you create the PRODUCT_USER_PROFILE table in the SYSTEM schema. This is performed by the PUPBLD.SQL script.
Go to the $ORACLE_HOME/sqlplus/admin directory, connect as SYSTEM and run @PUPBLD from the sqlprompt.
How can users be prevented from executing devious commands?
Yes, command authorization is verified against the SYSTEM.PRODUCT_USER_PROFILE table. This table is created by the PUPBLD.SQL script. Note that this table is not used when someone signs on as user SYSTEM.
Eg. to disable all users whose names starts with OPS$ from executing the CONNECT command:
SQL> INSERT INTO SYSTEM.PRODUCT_USER_PROFILE VALUES ('SQL*Plus', 'OPS$%', 'CONNECT', NULL, NULL, 'DISABLED', NULL, NULL);

How can one disable SQL*Plus formatting?
Issue the following SET commands to disable all SQL*Plus formatting:
SET ECHO OFF
SET NEWPAGE 0
SET SPACE 0
SET PAGESIZE 0
SET FEEDBACK OFF
SET HEADING OFF
SET TRIMSPOOL ON
These settings can also be entered on one line, eg.:
SET ECHO OFF NEWPAGE 0 SPACE 0 PAGESIZE 0 FEED OFF HEAD OFF TRIMSPOOL ON
Can one send operating system parameters to SQL*Plus?
One can pass operating system variables to sqlplus using this syntax:
sqlplus username/password @cmdfile.sql var1 var2 var3
Parameter var1 will be mapped to SQL*Plus variable &1, var2 to &2, etc. Look at this example:
sqlplus scott/tiger @x.sql '"test parameter"' dual

Where x.sql consists of:

select '&1' from &2;
exit 5;

Can one copy tables with LONG columns from one database to another?
About the fastest way of copying data between databases and schemas are by using the SQL*Plus COPY statement. Look at this example:
COPY FROM SCOTT/TIGER@LOCAL_DB TO SCOTT/TIGER@REMOTE_DB -
CREATE IMAGE_TABLE USING -
SELECT IMAGE_NO, IMAGE -
FROM IMAGES;


Interview questions:
1.query for self join.
2.deletion of duplicate rows.
3.post query trigger
4.pre query trigger
5.mastere ¡Vdetail relation
6.report triggers
7.report parameters.
8.format triggers in report.
9.order of triggering of when new item instance.
10.



Set 6 : DBA Tasks, Responsibilities and Skills Required

DILBERT'S LAWS OF WORK:
Don't be irreplaceable, if you can't be replaced, you can't be promoted.


Topics
DBA Responsibilities
Required Skills
Qualifications
Typical Interview Questions

--------------------------------------------------------------------------------

DBA Responsibilities:
The job of the DBA seems to be everything that everyone else either doesn't want to do, or doesn't have the ability to do. DBAs get the enviable task of figuring out all of the things no one else can figure out. More seriously though, here is a list of typical DBA responsibilities:

Installation, configuration and upgrading of Oracle server software and related products

Evaluate Oracle features and Oracle related products

Establish and maintain sound backup and recovery policies and procedures

Take care of the Database design and implementation

Implement and maintain database security (create and maintain users and roles, assign privileges)

Perform database tuning and performance monitoring

Perform application tuning and performance monitoring

Setup and maintain documentation and standards

Plan growth and changes (capacity planning)

Work as part of a team and provide 7x24 support when required

Perform general technical trouble shooting and give consultation to development teams

Interface with Oracle Corporation for technical support.

--------------------------------------------------------------------------------

Required Skills:
Good understanding of the Oracle database, related utilities and tools

A good understanding of the underlying operating system

A good knowledge of the physical database design

Ability to perform both Oracle and operating system performance tuning and monitoring

Knowledge of ALL Oracle backup and recovery scenarios

A good knowledge of Oracle security management

A good knowledge of how Oracle acquires and manages resources

A good knowledge Oracle data integrity

Sound knowledge of the implemented application systems

Experience in code migration, database change management and data management through the various stages of the development life cycle

A sound knowledge of both database and system performance tuning

A DBA should have sound communication skills with management, development teams, vendors and systems administrators

Provide a strategic database direction for the organisation

A DBA should have the ability to handle multiple projects and deadlines

A DBA should possess a sound understanding of the business

--------------------------------------------------------------------------------

Qualifications:
Must be certified as an Oracle DBA

Preferably a BS in computer science or related engineering field

Lots and lots of EXPERIENCE

--------------------------------------------------------------------------------

Typical Interview Questions
General Questions
Tell us about yourself/ your background.
What are the three major characteristics that you bring to the job market?
What motivates you to do a good job?
What two or three things are most important to you at work?
What qualities do you think are essential to be successful in this kind of work?
What courses did you attend? What job certifications do you hold?
What subjects/courses did you excel in? Why?
What subjects/courses gave you trouble? Why?
How does your previous work experience prepare you for this position?
How do you define 'success'?
What has been your most significant accomplishment to date?
Describe a challenge you encountered and how you dealt with it.
Describe a failure and how you dealt with it.
Describe the 'ideal' job... the 'ideal' supervisor.
What leadership roles have you held?
What prejudices do you hold?
What do you like to do in your spare time?
What are your career goals (a) 3 years from now; (b) 10 years from now?
How does this position match your career goals?
What have you done in the past year to improve yourself?
In what areas do you feel you need further education and training to be successful?
What do you know about our company?
Why do you want to work for this company. Why should we hire you?
Where do you see yourself fitting in to this organization . . .initially? . . .in 5 years?
Why are you looking for a new job?
How do you feel about re-locating?
Are you willing to travel?
What are your salary requirements?
When would you be available to start if you were selected?
General Oracle Questions

Did you use online or off-line backups?
What version of Oracle were you running?
Haw many databases and what sizes?
If you have to advise a backup strategy for a new application, how would you approach it and what questions will you ask?
If a customer calls you about a hanging database session, what will you do to resolve it?
Compare Oracle to any other database that you know. Why would you prefer to work on one and not on the other?


Oracle interview questions

No answers, but these are useful questions for conducting Oracle interview. The readers are welcome to contribute their answers.

What is an oracle instance?
What is a view?
What is referential integrity?

Name the data dictionary that stores user-defined constraints?
What is a collection of privileges?
What is a snapshot?
What is a synonym?
What is a cursor?
What is a sequence?
What is a trigger?
What is an exception?
What is a partition of table?
What are pseudo-columns in SQL? Provide examples.
What are the Data Control statements?
What is a schema?
What is a type?
What is a data model?
What is a relation?
Advantages of redo log files?
What is an Archiver?
What is a database buffer cache?
What are the background processes in Oracle?
%type and %rowtype are attributes for…?
What are the steps in a two-phase commit?
What is a union, intersect, minus?
What is a join, explain the types of joins?
What is a co-related sub-query?
ODBC stands for…?
Data-type used to work with integers is?
Describe data models?
Describe the Normalization principles?
What are the types of Normalization?
What is de-normalization?
Oracle interview questions

1. What’s the command to see the current user name? Sql> show user;
2. What’s the command to change the SQL prompt name?
SQL> set sqlprompt “database-1 > “
database-1 >
database-1 >
3. How do you switch to DOS prompt from SQL prompt? SQL> host
4. How do I eliminate duplicate rows in an Oracle database?
SQL> delete from table_name where rowid not in (select max(rowid) from table group by duplicate_values_field_name);
or
SQL> delete duplicate_values_field_name dv from table_name ta where rowid < (select min(rowid) from table_name tb where ta.dv=tb.dv);
5. How do I display row number with records? Use the row-num pseudocolumn with query, like
SQL> select rownum, ename from emp;
6. How do you display the records within a given range?
select rownum, empno, ename from emp where rowid in
(select rowid from emp where rownum < =&rangeend
minus
select rowid from emp where rownum<&rangebegin);
7. The NVL function only allows the same data type. But here’s the task: if the commission field is null, then the text “Not Applicable” should be displayed, instead of blank space. How do you write the query?
SQL> select nvl(to_char(comm.),’Not Applicable’) from emp;
8. Explain explicit cursor attributes. There are four cursor attributes used in Oracle: cursor_name%Found, cursor_name%NOTFOUND, cursor_name%ROWCOUNT, cursor_name%ISOPEN
9. Explain implicit cursor attributes. Same as explicit cursor but prefixed by the word SQL: SQL%Found, SQL%NOTFOUND, SQL%ROWCOUNT, SQL%ISOPEN
10.
11. How do you view version information in Oracle?
SQL> select banner from $version;
Oracle DBA interview questions

1. Explain the difference between a hot backup and a cold backup and the benefits associated with each. - A hot backup is basically taking a backup of the database while it is still up and running and it must be in archive log mode. A cold backup is taking a backup of the database while it is shut down and does not require being in archive log mode. The benefit of taking a hot backup is that the database is still available for use while the backup is occurring and you can recover the database to any point in time. The benefit of taking a cold backup is that it is typically easier to administer the backup and recovery process. In addition, since you are taking cold backups the database does not require being in archive log mode and thus there will be a slight performance gain as the database is not cutting archive logs to disk.
2. You have just had to restore from backup and do not have any control files. How would you go about bringing up this database? - I would create a text based backup control file, stipulating where on disk all the data files where and then issue the recover command with the using backup control file clause.
3. How do you switch from an init.ora file to a spfile? - Issue the create spfile from pfile command.
4. Explain the difference between a data block, an extent and a segment. - A data block is the smallest unit of logical storage for a database object. As objects grow they take chunks of additional storage that are composed of contiguous data blocks. These groupings of contiguous data blocks are called extents. All the extents that an object takes when grouped together are considered the segment of the database object.
5. Give two examples of how you might determine the structure of the table DEPT. - Use the describe command or use the dbms_metadata.get_ddl package.
6. Where would you look for errors from the database engine? - In the alert log.
7. Compare and contrast TRUNCATE and DELETE for a table. - Both the truncate and delete command have the desired outcome of getting rid of all the rows in a table. The difference between the two is that the truncate command is a DDL operation and just moves the high water mark and produces a now rollback. The delete command, on the other hand, is a DML operation, which will produce a rollback and thus take longer to complete.
8. Give the reasoning behind using an index. - Faster access to data blocks in a table.
9. Give the two types of tables involved in producing a star schema and the type of data they hold. - Fact tables and dimension tables. A fact table contains measurements while dimension tables will contain data that will help describe the fact tables.
10. What type of index should you use on a fact table? - A Bitmap index.
11. Give two examples of referential integrity constraints. - A primary key and a foreign key.
12. A table is classified as a parent table and you want to drop and re-create it. How would you do this without affecting the children tables? - Disable the foreign key constraint to the parent, drop the table, re-create the table, enable the foreign key constraint.
13. Explain the difference between ARCHIVELOG mode and NOARCHIVELOG mode and the benefits and disadvantages to each. - ARCHIVELOG mode is a mode that you can put the database in for creating a backup of all transactions that have occurred in the database so that you can recover to any point in time. NOARCHIVELOG mode is basically the absence of ARCHIVELOG mode and has the disadvantage of not being able to recover to any point in time. NOARCHIVELOG mode does have the advantage of not having to write transactions to an archive log and thus increases the performance of the database slightly.
14. What command would you use to create a backup control file? - Alter database backup control file to trace.
15. Give the stages of instance startup to a usable state where normal users may access it. - STARTUP NOMOUNT - Instance startup. STARTUP MOUNT - The database is mounted. STARTUP OPEN - The database is opened
16. What column differentiates the V$ views to the GV$ views and how? - The INST_ID column which indicates the instance in a RAC environment the information came from.
17. How would you go about generating an EXPLAIN plan? - Create a plan table with utlxplan.sql. Use the explain plan set statement_id = ‘tst1' into plan_table for a SQL statement. Look at the explain plan with utlxplp.sql or utlxpls.sql
18. How would you go about increasing the buffer cache hit ratio? - Use the buffer cache advisory over a given workload and then query the v$db_cache_advice table. If a change was necessary then I would use the alter system set db_cache_size command.
19. Explain an ORA-01555 - You get this error when you get a snapshot too old within rollback. It can usually be solved by increasing the undo retention or increasing the size of rollbacks. You should also look at the logic involved in the application getting the error message.
20. Explain the difference between $ORACLE_HOME and $ORACLE_BASE. - ORACLE_BASE is the root directory for oracle. ORACLE_HOME located beneath ORACLE_BASE is where the oracle products reside.

1. on UNIX? Basically, set up disks, kernel parameters, and run orainst.
1.
JDBC and JSP interview questions

1. What is the query used to display all tables names in SQL Server (Query analyzer)?
2. select * from information_schema.tables
         
3. How many types of JDBC Drivers are present and what are they?- There are 4 types of JDBC Drivers
o JDBC-ODBC Bridge Driver
o Native API Partly Java Driver
o Network protocol Driver
o JDBC Net pure Java Driver
4. Can we implement an interface in a JSP?- No
5. What is the difference between ServletContext and PageContext?- ServletContext: Gives the information about the container. PageContext: Gives the information about the Request
6. What is the difference in using request.getRequestDispatcher() and context.getRequestDispatcher()?- request.getRequestDispatcher(path): In order to create it we need to give the relative path of the resource, context.getRequestDispatcher(path): In order to create it we need to give the absolute path of the resource.
7. How to pass information from JSP to included JSP?- Using <%jsp:param> tag.
8. What is the difference between directive include and jsp include?- <%@ include>: Used to include static resources during translation time. JSP include: Used to include dynamic content or static content during runtime.
9. What is the difference between RequestDispatcher and sendRedirect?- RequestDispatcher: server-side redirect with request and response objects. sendRedirect : Client-side redirect with new request and response objects.
10. How does JSP handle runtime exceptions?- Using errorPage attribute of page directive and also we need to specify isErrorPage=true if the current page is intended to URL redirecting of a JSP.
11. How do you delete a Cookie within a JSP?
12. Cookie mycook = new Cookie("name","value");
13. response.addCookie(mycook);
14. Cookie killmycook = new Cookie("mycook","value");
15. killmycook.setMaxAge(0);
16. killmycook.setPath("/");
17. killmycook.addCookie(killmycook);
         
18. How do I mix JSP and SSI #include?- If you’re just including raw HTML, use the #include directive as usual inside your .jsp file.
19.
         
But it’s a little trickier if you want the server to evaluate any JSP code that’s inside the included file. If your data.inc file contains jsp code you will have to use
<%@ vinclude="data.inc" %>
         
The <!–#include file="data.inc"–> is used for including non-JSP files.
20. I made my class Cloneable but I still get Can’t access protected method clone. Why?- Some of the Java books imply that all you have to do in order to have your class support clone() is implement the Cloneable interface. Not so. Perhaps that was the intent at some point, but that’s not the way it works currently. As it stands, you have to implement your own public clone() method, even if it doesn’t do anything special and just calls super.clone().
21. Why is XML such an important development?- It removes two constraints which were holding back Web developments: dependence on a single, inflexible document type (HTML) which was being much abused for tasks it was never designed for; the complexity of full SGML, whose syntax allows many powerful but hard-to-program options. XML allows the flexible development of user-defined document types. It provides a robust, non-proprietary, persistent, and verifiable file format for the storage and transmission of text and data both on and off the Web; and it removes the more complex options of SGML, making it easier to program for.
22. What is the fastest type of JDBC driver?- JDBC driver performance will depend on a number of issues:
o the quality of the driver code,
o the size of the driver code,
o the database server and its load,
o network topology,
o the number of times your request is translated to a different API.
In general, all things being equal, you can assume that the more your request and response change hands, the slower it will be. This means that Type 1 and Type 3 drivers will be slower than Type 2 drivers (the database calls are make at least three translations versus two), and Type 4 drivers are the fastest (only one translation).
23. How do I find whether a parameter exists in the request object?
24. boolean hasFoo = !(request.getParameter("foo") == null
25. || request.getParameter("foo").equals(""));
         
or
boolean hasParameter =
request.getParameterMap().contains(theParameter); //(which works in Servlet 2.3+)
         
26. How can I send user authentication information while makingURLConnection?- You’ll want to use HttpURLConnection.setRequestProperty and set all the appropriate headers to HTTP authorization.
Data warehouse interview questions

1. What is source qualifier?
2. Difference between DSS & OLTP?
3. Explain grouped cross tab?
4. Hierarchy of DWH?
5. How many repositories can we create in Informatica?
6. What is surrogate key?
7. What is difference between Mapplet and reusable transformation?
8. What is aggregate awareness?
9. Explain reference cursor?
10. What are parallel querys and query hints?
11. DWH architecture?
12. What are cursors?
13. Advantages of de normalized data?
14. What is operational data source (ODS)?
15. What is meta data and system catalog?
16. What is factless fact schema?
17. What is confirmed dimension?
18. What is the capacity of power cube?
19. Difference between PowerPlay transformer and power play reports?
20. What is IQD file?
21. What is Cognos script editor?
22. What is difference macros and prompts?
23. What is power play plug in?
24. Which kind of index is preferred in DWH?
25. What is hash partition?
26. What is DTM session?
27. How can you define a transformation? What are different types of transformations in Informatica?
28. What is mapplet?
29. What is query panel?
30. What is a look up function? What is default transformation for the look up function?
31. What is difference between a connected look up and unconnected look up?
32. What is staging area?
33. What is data merging, data cleansing and sampling?
34. What is up date strategy and what are th options for update strategy?
35. OLAP architecture?
36. What is subject area?
37. Why do we use DSS database for OLAP tools?
Java database interview questions

1. How do you call a Stored Procedure from JDBC? - The first step is to create a CallableStatement object. As with Statement and PreparedStatement objects, this is done with an open Connection object. A CallableStatement object contains a call to a stored procedure.
2. CallableStatement cs =
3. con.prepareCall("{call SHOW_SUPPLIERS}");
4. ResultSet rs = cs.executeQuery();
         
5. Is the JDBC-ODBC Bridge multi-threaded? - No. The JDBC-ODBC Bridge does not support concurrent access from different threads. The JDBC-ODBC Bridge uses synchronized methods to serialize all of the calls that it makes to ODBC. Multi-threaded Java programs may use the Bridge, but they won’t get the advantages of multi-threading.
6. Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection? - No. You can open only one Statement object per connection when you are using the JDBC-ODBC Bridge.
7. What is cold backup, hot backup, warm backup recovery? - Cold backup (All these files must be backed up at the same time, before the databaseis restarted). Hot backup (official name is ‘online backup’) is a backup taken of each tablespace while the database is running and is being accessed by the users.
8. When we will Denormalize data? - Data denormalization is reverse procedure, carried out purely for reasons of improving performance. It maybe efficient for a high-throughput system to replicate data for certain data.
9. What is the advantage of using PreparedStatement? - If we are using PreparedStatement the execution time will be less. The PreparedStatement object contains not just an SQL statement, but the SQL statement that has been precompiled. This means that when the PreparedStatement is executed,the RDBMS can just run the PreparedStatement’s Sql statement without having to compile it first.
10. What is a “dirty read"? - Quite often in database processing, we come across the situation wherein one transaction can change a value, and a second transaction can read this value before the original change has been committed or rolled back. This is known as a dirty read scenario because there is always the possibility that the first transaction may rollback the change, resulting in the second transaction having read an invalid value. While you can easily command a database to disallow dirty reads, this usually degrades the performance of your application due to the increased locking overhead. Disallowing dirty reads also leads to decreased system concurrency.
11. What is Metadata and why should I use it? - Metadata (’data about data’) is information about one of two things: Database information (java.sql.DatabaseMetaData), or Information about a specific ResultSet (java.sql.ResultSetMetaData). Use DatabaseMetaData to find information about your database, such as its capabilities and structure. Use ResultSetMetaData to find information about the results of an SQL query, such as size and types of columns
12. Different types of Transaction Isolation Levels? - The isolation level describes the degree to which the data being updated is visible to other transactions. This is important when two transactions are trying to read the same row of a table. Imagine two transactions: A and B. Here three types of inconsistencies can occur:
o Dirty-read: A has changed a row, but has not committed the changes. B reads the uncommitted data but his view of the data may be wrong if A rolls back his changes and updates his own changes to the database.
o Non-repeatable read: B performs a read, but A modifies or deletes that data later. If B reads the same row again, he will get different data.
o Phantoms: A does a query on a set of rows to perform an operation. B modifies the table such that a query of A would have given a different result. The table may be inconsistent.
TRANSACTION_READ_UNCOMMITTED : DIRTY READS, NON-REPEATABLE READ AND PHANTOMS CAN OCCUR.
TRANSACTION_READ_COMMITTED : DIRTY READS ARE PREVENTED, NON-REPEATABLE READ AND PHANTOMS CAN OCCUR.
TRANSACTION_REPEATABLE_READ : DIRTY READS , NON-REPEATABLE READ ARE PREVENTED AND PHANTOMS CAN OCCUR.
TRANSACTION_SERIALIZABLE : DIRTY READS, NON-REPEATABLE READ AND PHANTOMS ARE PREVENTED.
13. What is 2 phase commit? - A 2-phase commit is an algorithm used to ensure the integrity of a committing transaction. In Phase 1, the transaction coordinator contacts potential participants in the transaction. The participants all agree to make the results of the transaction permanent but do not do so immediately. The participants log information to disk to ensure they can complete In phase 2 f all the participants agree to commit, the coordinator logs that agreement and the outcome is decided. The recording of this agreement in the log ends in Phase 2, the coordinator informs each participant of the decision, and they permanently update their resources.
14. How do you handle your own transaction ? - Connection Object has a method called setAutocommit(Boolean istrue)
- Default is true. Set the Parameter to false , and begin your transaction
15. What is the normal procedure followed by a java client to access the db.? - The database connection is created in 3 steps:
1. Find a proper database URL
2. Load the database driver
3. Ask the Java DriverManager class to open a connection to your database
In java code, the steps are realized in code as follows:
4. Create a properly formatted JDBR URL for your database. (See FAQ on JDBC URL for more information). A JDBC URL has the form
jdbc:someSubProtocol://myDatabaseServer/theDatabaseName
5. Class.forName("my.database.driver");
6. Connection conn = DriverManager.getConnection("a.JDBC.URL", “databaseLogin","databasePassword");
16. What is a data source? - A DataSource class brings another level of abstraction than directly using a connection object. Data source can be referenced by JNDI. Data Source may point to RDBMS, file System , any DBMS etc.
17. What are collection pools? What are the advantages? - A connection pool is a cache of database connections that is maintained in memory, so that the connections may be reused
18. How do you get Column names only for a table (SQL Server)? Write the Query. -
19. select name from syscolumns
20. where id=(select id from sysobjects where name='user_hdr')
order by colid --user_hdr is the table name

PL/SQL interview questions

1. Which of the following statements is true about implicit cursors?
1. Implicit cursors are used for SQL statements that are not named.
2. Developers should use implicit cursors with great care.
3. Implicit cursors are used in cursor for loops to handle data processing.
4. Implicit cursors are no longer a feature in Oracle.
2. Which of the following is not a feature of a cursor FOR loop?
1. Record type declaration.
2. Opening and parsing of SQL statements.
3. Fetches records from cursor.
4. Requires exit condition to be defined.
3. A developer would like to use referential datatype declaration on a variable. The variable name is EMPLOYEE_LASTNAME, and the corresponding table and column is EMPLOYEE, and LNAME, respectively. How would the developer define this variable using referential datatypes?
1. Use employee.lname%type.
2. Use employee.lname%rowtype.
3. Look up datatype for EMPLOYEE column on LASTNAME table and use that.
4. Declare it to be type LONG.
4. Which three of the following are implicit cursor attributes?
1. %found
2. %too_many_rows
3. %notfound
4. %rowcount
5. %rowtype
5. If left out, which of the following would cause an infinite loop to occur in a simple loop?
1. LOOP
2. END LOOP
3. IF-THEN
4. EXIT
6. Which line in the following statement will produce an error?
1. cursor action_cursor is
2. select name, rate, action
3. into action_record
4. from action_table;
5. There are no errors in this statement.
7. The command used to open a CURSOR FOR loop is
1. open
2. fetch
3. parse
4. None, cursor for loops handle cursor opening implicitly.
8. What happens when rows are found using a FETCH statement
1. It causes the cursor to close
2. It causes the cursor to open
3. It loads the current row values into variables
4. It creates the variables to hold the current row values
9. Read the following code:
10. CREATE OR REPLACE PROCEDURE find_cpt
11. (v_movie_id {Argument Mode} NUMBER, v_cost_per_ticket {argument mode} NUMBER)
12. IS
13. BEGIN
14.  IF v_cost_per_ticket  > 8.5 THEN
15. SELECT  cost_per_ticket
16. INTO            v_cost_per_ticket
17. FROM            gross_receipt
18. WHERE   movie_id = v_movie_id;
19.  END IF;
20. END;
         
Which mode should be used for V_COST_PER_TICKET?
1. IN
2. OUT
3. RETURN
4. IN OUT
21. Read the following code:
22. CREATE OR REPLACE TRIGGER update_show_gross
23.      {trigger information}
24.     BEGIN
25.      {additional code}
26.     END;
         
The trigger code should only execute when the column, COST_PER_TICKET, is greater than $3. Which trigger information will you add?
1. WHEN (new.cost_per_ticket > 3.75)
2. WHEN (:new.cost_per_ticket > 3.75
3. WHERE (new.cost_per_ticket > 3.75)
4. WHERE (:new.cost_per_ticket > 3.75)
27. What is the maximum number of handlers processed before the PL/SQL block is exited when an exception occurs?
1. Only one
2. All that apply
3. All referenced
4. None
28. For which trigger timing can you reference the NEW and OLD qualifiers?
1. Statement and Row
2. Statement only
3. Row only
4. Oracle Forms trigger
29. Read the following code:
30. CREATE OR REPLACE FUNCTION get_budget(v_studio_id IN NUMBER)
RETURN number IS
v_yearly_budget NUMBER;
BEGIN
       SELECT  yearly_budget
       INTO            v_yearly_budget
       FROM            studio
       WHERE   id = v_studio_id;
       RETURN v_yearly_budget;
END;

Which set of statements will successfully invoke this function within SQL*Plus?
1. VARIABLE g_yearly_budget NUMBER
EXECUTE g_yearly_budget := GET_BUDGET(11);
2. VARIABLE g_yearly_budget NUMBER
EXECUTE :g_yearly_budget := GET_BUDGET(11);
3. VARIABLE :g_yearly_budget NUMBER
EXECUTE :g_yearly_budget := GET_BUDGET(11);
4. VARIABLE g_yearly_budget NUMBER
:g_yearly_budget := GET_BUDGET(11);
31. CREATE OR REPLACE PROCEDURE update_theater
32. (v_name IN VARCHAR v_theater_id IN NUMBER) IS
33. BEGIN
34.       UPDATE  theater
35.       SET             name = v_name
36.       WHERE   id = v_theater_id;
37. END update_theater;
38.        
When invoking this procedure, you encounter the error:
ORA-000: Unique constraint(SCOTT.THEATER_NAME_UK) violated.
How should you modify the function to handle this error?
1. An user defined exception must be declared and associated with the error code and handled in the EXCEPTION section.
2. Handle the error in EXCEPTION section by referencing the error code directly.
3. Handle the error in the EXCEPTION section by referencing the UNIQUE_ERROR predefined exception.
4. Check for success by checking the value of SQL%FOUND immediately after the UPDATE statement.
39. Read the following code:
40. CREATE OR REPLACE PROCEDURE calculate_budget IS
41. v_budget        studio.yearly_budget%TYPE;
42. BEGIN
43.       v_budget := get_budget(11);
44.       IF v_budget < 30000
45. THEN
46.               set_budget(11,30000000);
47.       END IF;
48. END;
         
You are about to add an argument to CALCULATE_BUDGET. What effect will this have?
1. The GET_BUDGET function will be marked invalid and must be recompiled before the next execution.
2. The SET_BUDGET function will be marked invalid and must be recompiled before the next execution.
3. Only the CALCULATE_BUDGET procedure needs to be recompiled.
4. All three procedures are marked invalid and must be recompiled.
49. Which procedure can be used to create a customized error message?
1. RAISE_ERROR
2. SQLERRM
3. RAISE_APPLICATION_ERROR
4. RAISE_SERVER_ERROR
50. The CHECK_THEATER trigger of the THEATER table has been disabled. Which command can you issue to enable this trigger?
1. ALTER TRIGGER check_theater ENABLE;
2. ENABLE TRIGGER check_theater;
3. ALTER TABLE check_theater ENABLE check_theater;
4. ENABLE check_theater;
51. Examine this database trigger
52. CREATE OR REPLACE TRIGGER prevent_gross_modification
53. {additional trigger information}
54. BEGIN
55.       IF TO_CHAR(sysdate, DY) = MON
56. THEN
57. RAISE_APPLICATION_ERROR(-20000,Gross receipts cannot be deleted on Monday);
58.       END IF;
59. END;
         
This trigger must fire before each DELETE of the GROSS_RECEIPT table. It should fire only once for the entire DELETE statement. What additional information must you add?
1. BEFORE DELETE ON gross_receipt
2. AFTER DELETE ON gross_receipt
3. BEFORE (gross_receipt DELETE)
4. FOR EACH ROW DELETED FROM gross_receipt
60. Examine this function:
61. CREATE OR REPLACE FUNCTION set_budget
62. (v_studio_id IN NUMBER, v_new_budget IN NUMBER) IS
63. BEGIN
64.       UPDATE  studio
65.       SET             yearly_budget = v_new_budget
       WHERE   id = v_studio_id;


       IF SQL%FOUND THEN
               RETURN TRUEl;
       ELSE
               RETURN FALSE;
       END IF;


       COMMIT;
END;

         
Which code must be added to successfully compile this function?
1. Add RETURN right before the IS keyword.
2. Add RETURN number right before the IS keyword.
3. Add RETURN boolean right after the IS keyword.
4. Add RETURN boolean right before the IS keyword.
66. Under which circumstance must you recompile the package body after recompiling the package specification?
1. Altering the argument list of one of the package constructs
2. Any change made to one of the package constructs
3. Any SQL statement change made to one of the package constructs
4. Removing a local variable from the DECLARE section of one of the package constructs
67. Procedure and Functions are explicitly executed. This is different from a database trigger. When is a database trigger executed?
1. When the transaction is committed
2. During the data manipulation statement
3. When an Oracle supplied package references the trigger
4. During a data manipulation statement and when the transaction is committed
68. Which Oracle supplied package can you use to output values and messages from database triggers, stored procedures and functions within SQL*Plus?
1. DBMS_DISPLAY
2. DBMS_OUTPUT
3. DBMS_LIST
4. DBMS_DESCRIBE
69. What occurs if a procedure or function terminates with failure without being handled?
1. Any DML statements issued by the construct are still pending and can be committed or rolled back.
2. Any DML statements issued by the construct are committed
3. Unless a GOTO statement is used to continue processing within the BEGIN section, the construct terminates.
4. The construct rolls back any DML statements issued and returns the unhandled exception to the calling environment.
70. Examine this code
71. BEGIN
72.       theater_pck.v_total_seats_sold_overall := theater_pck.get_total_for_year;
73. END;
         
For this code to be successful, what must be true?
1. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist only in the body of the THEATER_PCK package.
2. Only the GET_TOTAL_FOR_YEAR variable must exist in the specification of the THEATER_PCK package.
3. Only the V_TOTAL_SEATS_SOLD_OVERALL variable must exist in the specification of the THEATER_PCK package.
4. Both the V_TOTAL_SEATS_SOLD_OVERALL variable and the GET_TOTAL_FOR_YEAR function must exist in the specification of the THEATER_PCK package.
74. A stored function must return a value based on conditions that are determined at runtime. Therefore, the SELECT statement cannot be hard-coded and must be created dynamically when the function is executed. Which Oracle supplied package will enable this feature?
1. DBMS_DDL
2. DBMS_DML
3. DBMS_SYN
4. DBMS_SQL

Database admin interview questions
1. What is a major difference between SQL Server 6.5 and 7.0 platform wise? SQL Server 6.5 runs only on Windows NT Server. SQL Server 7.0 runs on Windows NT Server, workstation and Windows 95/98.

2. Is SQL Server implemented as a service or an application? It is implemented as a service on Windows NT server and workstation and as an application on Windows 95/98.
3. What is the difference in Login Security Modes between v6.5 and 7.0? 7.0 doesn’t have Standard Mode, only Windows NT Integrated mode and Mixed mode that consists of both Windows NT Integrated and SQL Server authentication modes.
4. What is a traditional Network Library for SQL Servers? Named Pipes.
5. What is a default TCP/IP socket assigned for SQL Server? 1433
6. If you encounter this kind of an error message, what you need to look into to solve this problem?
[Microsoft][ODBC SQL Server Driver][Named Pipes]Specified SQL Server not found.
1. Check if MS SQL Server service is running on the computer you are trying to log into
2. Check on Client Configuration utility. Client and Server have to in sync.
7. What is new philosophy for database devises for SQL Server 7.0? There are no devises anymore in SQL Server 7.0. It is file system now.
8. When you create a database how is it stored? It is stored in two separate files: one file contains the data, system tables, other database objects, the other file stores the transaction log.
9. Let’s assume you have data that resides on SQL Server 6.5. You have to move it SQL Server 7.0. How are you going to do it? You have to use transfer command.
10. Do you know how to configure DB2 side of the application? Set up an application ID, create RACF group with tables attached to this group, attach the ID to this RACF group.
11. What kind of LAN types do you know? Ethernet networks and token ring networks.
12. What is the difference between them? With Ethernet, any devices on the network can send data in a packet to any location on the network at any time. With Token Ring, data is transmitted in ‘tokens’ from computer to computer in a ring or star configuration. Token ring speed is 4/16 Mbit/sec , Ethernet - 10/100 Mbit/sec.
13. What protocol both networks use? TCP/IP. Transmission Control Protocol, Internet Protocol.
14. How many bits IP Address consist of?An IP Address is a 32-bit number.
15. How many layers of TCP/IP protocol combined of? Five. (Application, Transport, Internet, Data link, Physical).
16. How do you define testing of network layers? Reviewing with your developers to identify the layers of the Network layered architecture, your Web client and Web server application interact with. Determine the hardware and software configuration dependencies for the application under test.
17. How do you test proper TCP/IP configuration Windows machine? Windows NT: IPCONFIG/ALL, Windows 95: WINIPCFG, Ping or ping ip.add.re.ss
Java on Oracle interview questions
1. What is JServer and what is it used for? Oracle JServer Option is a Java Virtual Machine (Java VM) which runs within the Oracle database server’s address space. Oracle also provides a JServer Accelerator to compile Java code natively. This speeds up the execution of Java code by eliminating interpreter overhead

.
2. How does one install the Oracle JServer Option?Follow these steps to activate the Oracle JServer/ JVM option:
1. Make sure your database is started with large java_pool_size (>20M) and shared_pool_size (>50M) INIT.ORA parameter values.
2. Run the $ORACLE_HOME/javavm/install/initjvm.sql script from SYS AS SYSDBA to install the Oracle JServer Option on a database.
3. Grant JAVAUSERPRIV to users that wants to use Java:
SQL> GRANT JAVAUSERPRIV TO SCOTT;
4. The rmjvm.sql script can be used to deinstall the JServer option from your database.
5. Follow the steps in the Oracle Migrations Guide to upgrade or downgrade the JServer option from one release to
another.
3. ce code into the database? Use the “CREATE OR REPLACE JAVA SOURCE” command or “loadjava” utility. Loaded code can be viewed by selecting from the USER_SOURCE view.
4. Why does one need to publish Java in the database? Publishing Java classes on the database makes it visible on a SQL and PL/SQL level. It is important to publish your code before calling it from SQL statements or PL/SQL code.
5. What is JDBC and what is it used for? JDBC is a set of classes and interfaces written in Java to allow other Java programs to send SQL statements to a relational database management system. Oracle provides three categories of JDBC drivers: (a) JDBC Thin Driver (No local Net8 installation required/ handy
for applets), (b) JDBC OCI for writing stand-alone Java applications, © JDBC KPRB driver (default connection) for Java Stored Procedures and Database JSP’s.
6. How does one connect with the JDBC Thin Driver?
The the JDBC thin driver provides the only way to access Oracle from the Web (applets). It is smaller and faster than the OCI drivers, and doesn’t require a pre-installed version of the JDBC drivers.
7. import java.sql.*;
8. class dbAccess {
9.  public static void main (String args []) throws SQLException
10.  {
        DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());


        Connection conn = DriverManager.getConnection
             ("jdbc:oracle:thin:@hostname:1526:orcl", “scott", “tiger");
                             // @machineName:port:SID,   userid,  password


        Statement stmt = conn.createStatement();
        ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
        while (rset.next())
              System.out.println (rset.getString(1));   // Print col 1
        stmt.close();
  }
}

11. How does one connect with the JDBC OCI Driver? One must have Net8 (SQL*Net) installed and working before attempting to use one of the OCI drivers.
12. import java.sql.*;
13. class dbAccess {
14.  public static void main (String args []) throws SQLException
15.  {
16.        try {
17.              Class.forName ("oracle.jdbc.driver.OracleDriver");
18.        } catch (ClassNotFoundException e) {
19.              e.printStackTrace();
        }


        Connection conn = DriverManager.getConnection
             ("jdbc:oracle:oci8:@hostname_orcl", “scott", “tiger");
                     // or oci7 @TNSNames_Entry,    userid,  password


        Statement stmt = conn.createStatement();
        ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
        while (rset.next())
              System.out.println (rset.getString(1));   // Print col 1
        stmt.close();
  }
}

20. How does one connect with the JDBC KPRB Driver? One can obtain a handle to the default or current connection (KPRB driver) by calling the OracleDriver.defaultConenction() method. Please note that you do not need to specify a database URL, username or password as you are already connected to a database session. Remember not to close the default connection. Closing the default connection might throw an exception in future releases of Oracle.
21. import java.sql.*;
22. class dbAccess {
23.  public static void main (String args []) throws SQLException
24.  {
        Connection conn = (new oracle.jdbc.driver.OracleDriver()).defaultConnection();


        Statement stmt = conn.createStatement();
        ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
        while (rset.next())
              System.out.println (rset.getString(1));   // Print col 1
        stmt.close();
  }
}

25. What is SQLJ and what is it used for? SQLJ is an ANSI standard way of coding SQL access in Java. It provides a Java precompiler that translates SQLJ call to JDBC calls. The idea is similar to that of other Oracle Precompilers.
26. How does one deploy SQLJ programs? Use the sqlj compiler to compile your *.sqlj files to *.java and *.ser files. The *.ser files contain vendor specific database code. Thereafter one invokes the javac compiler to compile the .java files to *.class files. The *.class and *.ser files needs to be deployed.
27. What is JDeveloper and what is it used for? JDeveloper is the Oracle IDE (Integrated Development Environment) for developing SQLJ and JDBC programs, applets, stored procedures, EJB’s, JSP’s etc.
28. What is InfoBus DAC and what is it used for? InfoBus DAC (Data Aware Controls) is a standard Java extension used in JDeveloper to create data aware forms. It replaced the JBCL interface that were used in JDeveloper V1 and V2.
29. What is a JSP and what is it used for? Java Server Pages (JSP) is a platform independent presentation layer technology that comes with SUN’s J2EE platform. JSPs are normal HTML pages with Java code pieces embedded in them. JSP pages are saved to *.jsp files. A JSP compiler is used in the background to generate a Servlet from the JSP page.
30. What is the difference between ASP and JSP? Active Server Pages (ASP) is a Microsoft standard, which is easier to develop than Java Server Pages (JSP). However ASP is a proprietary technology and is less flexible than JSP. For more information about ASP, see the Oracle ASP FAQ.
31. How does one invoke a JSP? A JSP gets invoked when you call a *.jsp file from your Web Server like you would call a normal *.html file. Obviously your web server need to support JSP pages and must be configured properly to handle them.
32. How does a JSP gets executed? The first time you call a JSP, a servlet (*.java) will be created and compiled to a .class file. The class file is then executed on the server. Output produced by the servlet is returned to the web browser. Output will typically be HTML or XML code.
33. What is a Java Stored Procedure/ Trigger? A Java Stored Procedure is a procedure coded in Java (as opposed to PL/SQL) and stored in the Oracle database. Java Stored procedures are executed by the database JVM in database memory space. Java Stored Procedures can be developed in JDBC or SQLJ. Interfacing between PL/SQL and Java are extremely easy. Please note that Java Stored procedures are by default executed with invokers rights. PL/SQL procedures are by default executed with defines rights.
20 Comments on Oracle DBA interview questions

Posted 7/14/2004 at 5:59 pm | Permalink
the answer about difference b/w truncate and delete can have more points. eg.
truncate does not generate undo, unlike delete operation.
delete triggers are not fired for truncate.
truncate releases used space and has implicit commit(ddl opern.)

Posted 8/2/2005 at 11:02 am | Permalink
I saw these questions on a web site. Can I have answers to them?
1. How many memory layers are in the shared pool?
2. How do you find out from the RMAN catalog if a particular archive log has been backed-up?
3. How can you tell how much space is left on a given file system and how much space each of the file system’s subdirectories take-up?
4. Define the SGA and:
How you would configure SGA for a mid-sized OLTP environment?
What is involved in tuning the SGA?
5. What is the cache hit ratio, what impact does it have on performance of an Oracle database and what is involved in tuning it?
6. Other than making use of the statspack utility, what would you check when you are monitoring or running a health check on an Oracle 8i or 9i database?
7. How do you tell what your machine name is and what is its IP address?
8. How would you go about verifying the network name that the local_listener is currently using?
9. You have 4 instances running on the same UNIX box. How can you determine which shared memory and semaphores are associated with which instance?
10. What view(s) do you use to associate a user’s SQLPLUS session with his o/s process?
11. What is the recommended interval at which to run statspack snapshots, and why?
12. What spfile/init.ora file parameter exists to force the CBO to make the execution path of a given statement use an index, even if the index scan may appear to be calculated as more costly?
13. Assuming today is Monday, how would you use the DBMS_JOB package to schedule the execution of a given procedure owned by SCOTT to start Wednesday at 9AM and to run subsequently every other day at
2AM.
14. How would you edit your CRONTAB to schedule the running of /test/test.sh to run every other day at 2PM?
15. What do the 9i dbms_standard.sql_txt() and
dbms_standard.sql_text() procedures do?
16. In which dictionary table or view would you look to determine at which time a snapshot or MVIEW last successfully refreshed?
17. How would you best determine why your MVIEW couldn’t FAST REFRESH?
18. How does propagation differ between Advanced Replication and Snapshot Replication (read-only)?
19. Which dictionary view(s) would you first look at to
understand or get a high-level idea of a given Advanced Replication environment?
20. How would you begin to troubleshoot an ORA-3113 error?
21. Which dictionary tables and/or views would you look at to diagnose a locking issue?
22. An automatic job running via DBMS_JOB has failed. Knowing only that “it’s failed”, how do you approach troubleshooting this issue?
23. How would you extract DDL of a table without using a GUI tool?
24. You’re getting high “busy buffer waits” - how can you find what’s causing it?
25. What query tells you how much space a tablespace named “test” is taking up, and how much space is remaining?
26. Database is hung. Old and new user connections alike hang on impact. What do you do? Your SYS SQLPLUS session IS able to connect.
27. Database crashes. Corruption is found scattered among the file system neither of your doing nor of Oracle’s. What database recovery options are available? Database is in archive log mode.
28. Illustrate how to determine the amount of physical CPUs a Unix Box possesses (LINUX and/or Solaris).
29. How do you increase the OS limitation for open files (LINUX and/or Solaris)?
30. Provide an example of a shell script which logs into SQLPLUS as SYS, determines the current date, changes the date format to include minutes & seconds, issues a drop table command, displays the date again, and finally exits.
31. Explain how you would restore a database using RMAN to Point in Time?
32. How does Oracle guarantee data integrity of data changes?
33. Which environment variables are absolutely critical in order to run the OUI?
34. What SQL query from v$session can you run to show how many sessions are logged in as a particular user account?
35. Why does Oracle not permit the use of PCTUSED with indexes?
36. What would you use to improve performance on an insert statement that places millions of rows into that table?
37. What would you do with an “in-doubt” distributed transaction?
38. What are the commands you’d issue to show the explain plan for “select * from dual”?
39. In what script is “snap$” created? In what script is
the “scott/tiger” schema created?
40. If you’re unsure in which script a sys or system-owned object is created, but you know it’s in a script from a specific directory, what UNIX command from that directory structure can you run to find your answer?
41. How would you configure your networking files to connect to a database by the name of DSS which resides in domain icallinc.com?
42. You create a private database link and upon
connection, fails with: ORA-2085: connects to . What is the problem? How would you go about resolving this error?
43. I have my backup RMAN script called “backup_rman.sh”. I am on the target database. My catalog username/password is rman/rman. My catalog db is called rman. How would you run this shell script from the O/S such that it would run as a background process?
44. Explain the concept of the DUAL table.
45. What are the ways tablespaces can be managed and how do they differ?
46. From the database level, how can you tell under which time zone a database is operating?
47. What’s the benefit of “dbms_stats” over “analyze”?
48. Typically, where is the conventional directory structure chosen for Oracle binaries to reside?
49. You have found corruption in a tablespace that contains static tables that are part of a database that is in NOARCHIVE log mode. How would you restore the tablespace without losing new data in the other tablespaces?
50. How do you recover a datafile that has not been physically been backed up since its creation and has been deleted. Provide syntax example.
Posted 11/17/2005 at 5:58 am | Permalink
Thank you for sending me the answers
Posted 3/30/2006 at 5:20 pm | Permalink
How to calculate the perfomance of Oracle 9i Databases in HPUNIX?
Posted 11/16/2006 at 10:17 am | Permalink
How to defragment in Oracle?
Posted 11/16/2006 at 10:21 am | Permalink
How to Start the database thru Command Prompt when oracle is stoped in service?
Posted 2/17/2007 at 5:56 am | Permalink
1.how to know how many instance are up?
2.when we are taking the hot backup then what is the
background process?
Posted 4/26/2007 at 2:46 am | Permalink
the answer about difference b/w truncate and delete can have more points.
1>In truncate ,we cannot rollback the changes made to the tables
where as in delete we can rollback the changes
2>In truncate,no entry is made in ldf file (log data file)
In Delete,entry is made in ldf file
Posted 6/21/2007 at 9:00 am | Permalink
hi my name is narayana i am working one of the mnc company but i want answeres of these following questions plz help me any one
1.1. Migration of Oracle database from 7.x.x to 8i.x.x. to 9i.x.x to 10g.x.x
Methodologies and steps involved. We do it by 4 ways:
(a) Exp/Imp dump file (b) Data-pump (c) by configuring Standby (d) RMAN
2. Standby database its configuration and concept
3. Database Replication concept
4. Dataguard configuration
Posted 7/1/2007 at 10:23 pm | Permalink
i am just confused with
1. wht is use of UNDO_RETENTION
2. AND use of undo retention policy
3. cache hit ratio
thank you
Harish
Posted 9/17/2007 at 8:42 am | Permalink
The use of undo_retention is that u get information that after how much time the snapshot too old error will be effective, this error depend upon undo_retention.
Yacoob
Posted 10/16/2007 at 6:08 am | Permalink
Hi chandrasekar,
— The following command will give the instance information
select * from v$instance;
— when we are taking the hot backup then what is the
background process?
CKPT background process
Posted 2/25/2008 at 1:54 am | Permalink
Dear Venkat,
for Window or Linux,
sqlplus /nolog
SQL> startup nomount
ORACLE instance started.
–> This command will show the database files details ( Total SGA, Fixed Size, Variable size, Variable size and Redo details…
–> then connect sys with system credentail…
–> check wether the User credentail has locked…
–> if its alter the credentail with unlock….
Thanks,
Mohammed Yacoob
Posted 2/25/2008 at 2:00 am | Permalink
Dear Siva,
There are command line procesures are there to check the oracle 91i performance….
–> Before to test the Oracle 9i find the HPUNIX OS Performance counter …
Thanks,
Mohammed Yacoob
Posted 4/22/2008 at 8:17 am | Permalink
delete:
this can be rollbacked
truncate:’
this cannot be rollbacked
Posted 4/22/2008 at 8:19 am | Permalink
shared pool will have library cache and data dictionary cache
Posted 6/21/2008 at 3:58 am | Permalink
Ans for Question 2:
RMAN> LIST ARCHIVELOG ALL;
the above command list all the archivelog that has been backup.
Naveen
Posted 7/3/2008 at 3:11 am | Permalink
How many memory layers are in the shared pool?
There are three layers in shared pool
i) Library cache
ii) Data dictonary cache
iii) control structures
control structures will consists of locks and latches
Posted 1/27/2009 at 1:01 am | Permalink
Ans for question 44
Dual table is a dummy table maintained by oracle server, you can use it to see current date and time etc.
“select sysdate from dual”
the above command will give you current system date.
Posted 1/29/2009 at 8:13 am | Permalink
how can you perform a baseline backup in oracle dba?

Oracle Technical Interview Questions Answered - Part1
By James Koopmann
The interview process can be quite stressful. Here is the first part of a two part series on helping you answer those tough questions that you might experience in your quest for an Oracle DBA position.
Ever since I wrote the past article on the Oracle Technical Interview, I have been bombarded with e-mails asking for help on getting through the interview questions that I presented. Most of you I have answered, others I was reluctant to post all of the answers so that you could begin your own quest for the answers. Now, however, I have decided to post the answers knowing that we can all benefit from them. If there are any questions here that you still need clarification on, please e-mail me and I will do my best to further explain the answer I have given. Please remember that as you go through the article, it is not enough to know the answer to a particular question, you must try and put yourself in an interview situation and experience answering the question for yourself. Therefore, after you have gone through the questions and answers read the question yourself and then answer it with your own words. As always, good luck, and cheers.
Personal
This part of the interview question is not to be regarded as insignificant. If the interviewer asks you these questions take it as a sign that they are interested in you, your qualities, and how you interact with people throughout the day. Take it as an opportunity to prove that you have been around the block a few times, are willing to work with other people, and enjoy the job you do. Many times people see DBA types as stuffy and pointed, not willing to work with others, and only concerned with the database and its day-to-day operational needs. Put aside the needs of the database and talk about how you work with people and the different departments in the organization and are concerned with providing them with top notch database services.
1.     What DBA activities did you to do today?
Wow, this is a loaded question and almost begs for you to answer it with "What DBA activities do you LIKE to do on a daily basis?." And that is how I would answer this question. Again, do not get caught up in the "typical" day-to-day operational issues of database administration. Sure, you can talk about the index you rebuilt, the monitoring of system and session waits that were occurring, or the space you added to a data file, these are all good and great and you should convey that you understand the day-to-day operational issues. What you should also throw into this answer are the meetings that you attend to provide direction in the database arena, the people that you meet and talk with daily to answer adhoc questions about database use, the modeling of business needs within the database, and the extra time you spend early in the morning or late at night to get the job done. Just because the question stipulates "today" do not take "today" to mean "today." Make sure you wrap up a few good days into "today" and talk about them. This question also begs you to ask the question of "What typical DBA activities are performed day to day within X Corporation?"
2.     What is your typical day like?
If you spend enough time on question 1, this question will never be asked. It is really a continuation of question 1 to try and get you to open up and talk about the type of things you like to do. Personally, I would continue with the theme of question 1 if you are cut short or this question is asked later in the interview process. Just note that this question is not all geared toward the day-to-day operational issues you experience as a DBA. This question also gives you the opportunity to see if they want to know about you as an individual. Since the question did not stipulate "on the job" I would throw in a few items like, I get up at 5:00am to get into work and get some quiet time to read up on new trends or you help coach your son/daughter's soccer team. Just test the waters to what is acceptable. If the interviewer starts to pull you back to "job" related issues, do not go to personal. Also, if you go to the office of the interviewer please notice the surroundings, if there are pictures of his/her family, it is probably a good idea to venture down the personal path. If there is a fly-fishing picture on the wall, do not say you like deep-sea fishing. You get the picture.
3.     What other parts of your organization do you interact with and how?
Again, if you have exhausted question 1 and 2 you may never get to this question. But if you have been apprehensive to opening up and explaining yourself, take note that you may have an issue and the interviewer might also be already getting tired of the interview process. If you get to this question consider yourself in trouble. You really need to forget all your hang-ups and start explaining what it is that you like to do as a DBA, and why you want to work for this particular company. You are going to have to reel this interviewer back into the interview process or you might not get to the true technical question part of the interview.
4.     Do you consider yourself a development DBA or a production DBA and why?
I take this as a trick question and explain it that way. Never in my database carrier have I distinguished between "development" and "production." Just ask your development staff or VP of engineering how much time and money is lost if development systems are down. Explain to the interviewer that both systems are equally important to the operation of the company and both should be considered as production systems because there are people relying on them and money is lost if either one of them is down. Ok you may be saying, and I know you are, that we lose more money if the production system is down. Ok, convey that to the interviewer and you won't get anyone to disagree with you unless your company sells software or there are million dollar deals on the table that are expecting the next release of your product or service.
5.     Are you a nuts-n-bolts DBA or a tools-n-props DBA
This question begs for me to give definition around the terms I basically group DBAs into. These are not good or bad groups but something I like to think about when talking to DBAs. A nuts-n-bolts DBA is the type that likes to figure out every little item about how the database works. He/she is a DBA who typically hates a GUI environment and prefers the command line to execute commands and accomplish tasks. A nuts-n-bolts DBA like to feel in control of the database and only feels comfortable at the command line and vi as an editor. The tools-n-props DBA is mostly the opposite of a nuts-n-bolts DBA, they like the feel of a GUI, the ease at which things can be accomplished without knowing much about the database. They want to get the job done with the least amount of intervention from having to figure out what everything is doing behind the scenes. Now the answer, I would explain myself as a combination of the two. I, having been in this business for over 20 years, have grown up in a command line era where the GUIs never seemed to work. There was high complexity in systems and not much good documentation on how things worked. Thus, I had to learn everything about most aspects of the database environment I was working in and thus became a nuts-n-bolts DBA. I was a true command line and vi bigot. Times have changed and the GUIs are very reliable, understand the environment they are installed on, and can generally get the job done quicker for individuals new to database administration. I too am slowly slipping over to the dark side of GUI administration. If you find yourself as a tools-n-props DBA, try to convey that you are aware of some tasks that require you to be a nuts-n-bolts DBA.
1.     Explain the difference between a hot backup and a cold backup and the benefits associated with each.
A hot backup is basically taking a backup of the database while it is still up and running and it must be in archive log mode. A cold backup is taking a backup of the database while it is shut down and does not require being in archive log mode. The benefit of taking a hot backup is that the database is still available for use while the backup is occurring and you can recover the database to any point in time. The benefit of taking a cold backup is that it is typically easier to administer the backup and recovery process. In addition, since you are taking cold backups the database does not require being in archive log mode and thus there will be a slight performance gain as the database is not cutting archive logs to disk.
2.     You have just had to restore from backup and do not have any control files. How would you go about bringing up this database?
I would create a text based backup control file, stipulating where on disk all the data files where and then issue the recover command with the using backup control file clause.
3.     How do you switch from an init.ora file to a spfile?
Issue the create spfile from pfile command.
4.     Explain the difference between a data block, an extent and a segment.
A data block is the smallest unit of logical storage for a database object. As objects grow they take chunks of additional storage that are composed of contiguous data blocks. These groupings of contiguous data blocks are called extents. All the extents that an object takes when grouped together are considered the segment of the database object.
5.     Give two examples of how you might determine the structure of the table DEPT.
Use the describe command or use the dbms_metadata.get_ddl package.
6.     Where would you look for errors from the database engine?
In the alert log.
7.     Compare and contrast TRUNCATE and DELETE for a table.
Both the truncate and delete command have the desired outcome of getting rid of all the rows in a table. The difference between the two is that the truncate command is a DDL operation and just moves the high water mark and produces a now rollback. The delete command, on the other hand, is a DML operation, which will produce a rollback and thus take longer to complete.
8.     Give the reasoning behind using an index.
Faster access to data blocks in a table.
9.     Give the two types of tables involved in producing a star schema and the type of data they hold.
Fact tables and dimension tables. A fact table contains measurements while dimension tables will contain data that will help describe the fact tables.
10. . What type of index should you use on a fact table?
A Bitmap index.
11. Give two examples of referential integrity constraints.
A primary key and a foreign key.
12. A table is classified as a parent table and you want to drop and re-create it. How would you do this without affecting the children tables?
Disable the foreign key constraint to the parent, drop the table, re-create the table, enable the foreign key constraint.
13. Explain the difference between ARCHIVELOG mode and NOARCHIVELOG mode and the benefits and disadvantages to each.
ARCHIVELOG mode is a mode that you can put the database in for creating a backup of all transactions that have occurred in the database so that you can recover to any point in time. NOARCHIVELOG mode is basically the absence of ARCHIVELOG mode and has the disadvantage of not being able to recover to any point in time. NOARCHIVELOG mode does have the advantage of not having to write transactions to an archive log and thus increases the performance of the database slightly.
14. What command would you use to create a backup control file?
Alter database backup control file to trace.
15. Give the stages of instance startup to a usable state where normal users may access it.
STARTUP NOMOUNT - Instance startup
STARTUP MOUNT - The database is mounted
STARTUP OPEN - The database is opened
16. What column differentiates the V$ views to the GV$ views and how?
The INST_ID column which indicates the instance in a RAC environment the information came from.
17. How would you go about generating an EXPLAIN plan?
Create a plan table with utlxplan.sql.
Use the explain plan set statement_id = 'tst1' into plan_table for a SQL statement
Look at the explain plan with utlxplp.sql or utlxpls.sql
18. How would you go about increasing the buffer cache hit ratio?
Use the buffer cache advisory over a given workload and then query the v$db_cache_advice table. If a change was necessary then I would use the alter system set db_cache_size command.
19. Explain an ORA-01555
You get this error when you get a snapshot too old within rollback. It can usually be solved by increasing the undo retention or increasing the size of rollbacks. You should also look at the logic involved in the application getting the error message.
20. Explain the difference between $ORACLE_HOME and $ORACLE_BASE.
ORACLE_BASE is the root directory for oracle. ORACLE_HOME located beneath ORACLE_BASE is where the oracle products reside.
Well, we have gone through the first 25 questions as I would answer them during an interview. Please feel free to add your personal experiences to the answers as it will always improve the process and add your particular touch. As always remember these are "core" DBA questions and not necessarily related to the Oracle options that you may encounter in some interviews. Take a close look at the requirements for any job and try to come up with questions that the interviewer may ask. Next time we will tackle the rest of the questions. Until then, good luck with the process.
How do you see how many instances are running?

2. How do you automate starting and shutting down of databases in Unix?

3. You have written a script to take backups. How do you make it run automatically every
week?

4. What is OERR utility?

5. How do you see Virtual Memory Statistics in Linux?

6. How do you see how much hard disk space is free in Linux?

7. What is SAR?

8. What is SHMMAX?

9. Swap partition must be how much the size of RAM?

10. What is DISM in Solaris?

11. How do you see how many memory segments are acquired by Oracle Instances?

12. How do you see which segment belongs to which database instances?

13. What is VMSTAT?

14. How do you set Kernel Parameters in Red Hat Linux, AIX and Solaris?

15. How do you remove Memory segments?

16. What is the difference between Soft Link and Hard Link?

17. What is stored in oratab file?

18. How do you see how many processes are running in Unix?

19. How do you kill a process in Unix?

20. Can you change priority of a Process in Unix?



1. What is an Oracle Instance?
2. What information is stored in Control File?
3. When you start an Oracle DB which file is accessed first?
4. What is the Job of SMON, PMON processes?
5. What is Instance Recovery?
6. What is written in Redo Log Files?
7. How do you control number of Datafiles one can have in an Oracle database?
8. How many Maximum Datafiles can there be in an Oracle Database?
9. What is a Tablespace?
10. What is the purpose of  Redo Log files?
11. Which default Database roles are created when you create a Database?
12. What is a Checkpoint?
13. Which Process reads data from Datafiles?
14. Which Process writes data in Datafiles?
15. Can you make a Datafile auto extendible. If yes, how?
16. What is a Shared Pool?
17. What is kept in the Database Buffer Cache?
18. How many maximum Redo Logfiles one can have in a Database?
19. What is difference between PFile and SPFile?
20.  What is PGA_AGGREGRATE_TARGET parameter?
21. Large Pool is used for what?
22. What is PCT Increase setting?
23. What is PCTFREE and PCTUSED Setting?
24. What is Row Migration and Row Chaining?
25. What is 01555 - Snapshot Too Old error and how do you avoid it?
26. What is a Locally Managed Tablespace?
27. Can you audit SELECT statements?
28. What does DBMS_FGA package do?
29. What is Cost Based Optimization?
30. How often you should collect statistics for a table?
31. How do you collect statistics for a table, schema and Database?
32. Can you make collection of Statistics for tables automatic?
33. On which columns you should create Indexes?
34. What type of Indexes are available in Oracle?
35. What is B-Tree Index?
36. A table is having few rows, should you create indexes on this table?
37. A Column is having many repeated values which type of index you should create on this column, if you have to?
38. When should you rebuilt indexes?
39. Can you built indexes online?
40. Can you see Execution Plan of a statement.
41. A table is created with the following setting

      storage (initial 200k
                   next 200k
                   minextents 2
                   maxextents 100
                   pctincrease 40)

     What will be size of 4th extent?

42. What is DB Buffer Cache Advisor?

43. What is STATSPACK tool?

44. Can you change SHARED_POOL_SIZE online?

45. Can you Redefine a table Online?

46. Can you assign Priority to users?

47. You want users to change their passwords every 2 months. How do you enforce this?

48. How do you delete duplicate rows in a table?

49. What is Automatic Management of Segment Space setting?

50. What is the difference between DELETE and TRUNCATE statements?

51. What is COMPRESS and CONSISTENT setting in EXPORT utility?

52. What is the difference between Direct Path and Convention Path loading?

53. Can you disable and enable Primary key?

54. What is an Index Organized Table?

55. What is a Global Index and Local Index?

56. What is the difference between Range Partitioning and Hash Partitioning?

57. What is difference between Multithreaded/Shared Server and Dedicated Server?

58. Can you import objects from Oracle ver. 7.3 to 9i?

59. How do you move tables from one tablespace to another tablespace?

60. How do see how much space is used and free in a tablespace?

How do you see how many instances are running?

2. How do you automate starting and shutting down of databases in Unix?

3. You have written a script to take backups. How do you make it run automatically every
week?

4. What is OERR utility?

5. How do you see Virtual Memory Statistics in Linux?

6. How do you see how much hard disk space is free in Linux?

7. What is SAR?

8. What is SHMMAX?

9. Swap partition must be how much the size of RAM?

10. What is DISM in Solaris?

11. How do you see how many memory segments are acquired by Oracle Instances?

12. How do you see which segment belongs to which database instances?

13. What is VMSTAT?

14. How do you set Kernel Parameters in Red Hat Linux, AIX and Solaris?

15. How do you remove Memory segments?

16. What is the difference between Soft Link and Hard Link?

17. What is stored in oratab file?

18. How do you see how many processes are running in Unix?

19. How do you kill a process in Unix?

20. Can you change priority of a Process in Unix?

Which types of backups you can take in Oracle?

2. A database is running in NOARCHIVELOG mode then which type of backups you can take?

3. Can you take partial backups if the Database is running in NOARCHIVELOG mode?

4. Can you take Online Backups if the the database is running in NOARCHIVELOG mode?

5. How do you bring the database in ARCHIVELOG mode from NOARCHIVELOG mode?

6. You cannot shutdown the database for even some minutes, then in which mode you should run
the database?

7. Where should you place Archive logfiles, in the same disk where DB is or another disk?

8. Can you take online backup of a Control file if yes, how?

9. What is a Logical Backup?

10. Should you take the backup of Logfiles if the database is running in ARCHIVELOG mode?

11. Why do you take tablespaces in Backup mode?

12. What is the advantage of RMAN utility?

13. How RMAN improves backup time?

14. Can you take Offline backups using RMAN?

15. How do you see information about backups in RMAN?

16. What is a Recovery Catalog?

17. Should you place Recovery Catalog in the Same DB?

18. Can you use RMAN without Recovery catalog?

19. Can you take Image Backups using RMAN?

20. Can you use Backupsets created by RMAN with any other utility?
21. Where RMAN keeps information of backups if you are using RMAN without Catalog?

22. You have taken a manual backup of a datafile using o/s. How RMAN will know about it?

23. You want to retain only last 3 backups of datafiles. How do you go for it in RMAN?

24. Which is more efficient Incremental Backups using RMAN or Incremental Export?

25. Can you start and shutdown DB using RMAN?

26. How do you recover from the loss of datafile if the DB is running in NOARCHIVELOG mode?

27. You loss one datafile and it does not contain important objects. The important objects are there in other datafiles which are intact. How do you proceed in this situation?

28. You lost some datafiles and you don't have any full backup and the database was running in NOARCHIVELOG mode. What you can do now?

29. How do you recover from the loss of datafile if the DB is running in ARCHIVELOG mode?

30. You loss one datafile and DB is running in ARCHIVELOG mode. You have full database backup of 1 week old and partial backup of this datafile which is just 1 day old. From which backup should you restore this file?

31. You loss controlfile how do you recover from this?

32. The current logfile gets damaged. What you can do now?

33. What is a Complete Recovery?

34. What is Cancel Based, Time based and Change Based Recovery?

35. Some user has accidentally dropped one table and you realize this after two days. Can you recover this table if the DB is running in ARCHIVELOG mode?

36. Do you have to restore Datafiles manually from backups if you are doing recovery using RMAN?

37. A database is running in ARCHIVELOG mode since last one month. A datafile is added to the database last week. Many objects are created in this datafile. After one week this datafile gets damaged before you can take any backup. Now can you recover this datafile when you don't have any backups?

38. How do you recover from the loss of a controlfile if you have backup of controlfile?

39. Only some blocks are damaged in a datafile. Can you just recover these blocks if you are using RMAN?

40. Some datafiles were there on a secondary disk and that disk has become damaged and it will take some days to get a new disk. How will you recover from this situation?
41. Have you faced any emergency situation. Tell us how you resolved it?
42. At one time you lost parameter file accidentally and you don't have any backup. How you will recreate a new parameter file with the parameters set to previous values.

1. Describe the difference between a procedure, function and anonymous pl/sql block.
Level: Low
Expected answer : Candidate should mention use of DECLARE statement, a function must return a value while a procedure doesn?t have to.
2. What is a mutating table error and how can you get around it?
Level: Intermediate
Expected answer: This happens with triggers. It occurs because the trigger is trying to update a row it is currently using. The usual fix involves either use of views or temporary tables so the database is selecting from one while updating the other.
3. Describe the use of %ROWTYPE and %TYPE in PL/SQL
Level: Low
Expected answer: %ROWTYPE allows you to associate a variable with an entire table row. The %TYPE associates a variable with a single column type.
4. What packages (if any) has Oracle provided for use by developers?
Level: Intermediate to high
Expected answer: Oracle provides the DBMS_ series of packages. There are many which developers should be aware of such as DBMS_SQL, DBMS_PIPE, DBMS_TRANSACTION, DBMS_LOCK, DBMS_ALERT, DBMS_OUTPUT, DBMS_JOB, DBMS_UTILITY, DBMS_DDL, UTL_FILE. If they can mention a few of these and describe how they used them, even better. If they include the SQL routines provided by Oracle, great, but not really what was asked.
5. Describe the use of PL/SQL tables
Level: Intermediate
Expected answer: PL/SQL tables are scalar arrays that can be referenced by a binary integer. They can be used to hold values for use in later queries or calculations. In Oracle 8 they will be able to be of the %ROWTYPE designation, or RECORD.
6. When is a declare statement needed ?
Level: Low
The DECLARE statement is used in PL/SQL anonymous blocks such as with stand alone, non-stored PL/SQL procedures. It must come first in a PL/SQL stand alone file if it is used.
7. In what order should a open/fetch/loop set of commands in a PL/SQL block be implemented if you use the %NOTFOUND cursor variable in the exit when statement? Why?
Level: Intermediate
Expected answer: OPEN then FETCH then LOOP followed by the exit when. If not specified in this order will result in the final return being done twice because of the way the %NOTFOUND is handled by PL/SQL.
8. What are SQLCODE and SQLERRM and why are they important for PL/SQL developers?
Level: Intermediate
Expected answer: SQLCODE returns the value of the error number for the last error encountered. The SQLERRM returns the actual error message for the last error encountered. They can be used in exception handling to report, or, store in an error log table, the error that occurred in the code. These are especially useful for the WHEN OTHERS exception.
9. How can you find within a PL/SQL block, if a cursor is open?
Level: Low
Expected answer: Use the %ISOPEN cursor status variable.
10. How can you generate debugging output from PL/SQL?
Level:Intermediate to high
Expected answer: Use the DBMS_OUTPUT package. Another possible method is to just use the SHOW ERROR command, but this only shows errors. The DBMS_OUTPUT package can be used to show intermediate results from loops and the status of variables as the procedure is executed. The new package UTL_FILE can also be used.
11. What are the types of triggers?
Level:Intermediate to high
Expected Answer: There are 12 types of triggers in PL/SQL that consist of combinations of the BEFORE, AFTER, ROW, TABLE, INSERT, UPDATE, DELETE and ALL key words:
BEFORE ALL ROW INSERT
AFTER ALL ROW INSERT
BEFORE INSERT
AFTER INSERT etc.
DBA:
1. Give one method for transferring a table from one schema to another:
Level:Intermediate
Expected Answer: There are several possible methods, export-import, CREATE TABLE... AS SELECT, or COPY.
2. What is the purpose of the IMPORT option IGNORE? What is it?s default setting?
Level: Low
Expected Answer: The IMPORT IGNORE option tells import to ignore "already exists" errors. If it is not specified the tables that already exist will be skipped. If it is specified, the error is ignored and the tables data will be inserted. The default value is N.
3. You have a rollback segment in a version 7.2 database that has expanded beyond optimal, how can it be restored to optimal?
Level: Low
Expected answer: Use the ALTER TABLESPACE ..... SHRINK command.
4. If the DEFAULT and TEMPORARY tablespace clauses are left out of a CREATE USER command what happens? Is this bad or good? Why?
Level: Low
Expected answer: The user is assigned the SYSTEM tablespace as a default and temporary tablespace. This is bad because it causes user objects and temporary segments to be placed into the SYSTEM tablespace resulting in fragmentation and improper table placement (only data dictionary objects and the system rollback segment should be in SYSTEM).
5. What are some of the Oracle provided packages that DBAs should be aware of?
Level: Intermediate to High
Expected answer: Oracle provides a number of packages in the form of the DBMS_ packages owned by the SYS user. The packages used by DBAs may include: DBMS_SHARED_POOL, DBMS_UTILITY, DBMS_SQL, DBMS_DDL, DBMS_SESSION, DBMS_OUTPUT and DBMS_SNAPSHOT. They may also try to answer with the UTL*.SQL or CAT*.SQL series of SQL procedures. These can be viewed as extra credit but aren?t part of the answer.
6. What happens if the constraint name is left out of a constraint clause?
Level: Low
Expected answer: The Oracle system will use the default name of SYS_Cxxxx where xxxx is a system generated number. This is bad since it makes tracking which table the constraint belongs to or what the constraint does harder.
7. What happens if a tablespace clause is left off of a primary key constraint clause?
Level: Low
Expected answer: This results in the index that is automatically generated being placed in then users default tablespace. Since this will usually be the same tablespace as the table is being created in, this can cause serious performance problems.
8. What is the proper method for disabling and re-enabling a primary key constraint?
Level: Intermediate
Expected answer: You use the ALTER TABLE command for both. However, for the enable clause you must specify the USING INDEX and TABLESPACE clause for primary keys.
9. What happens if a primary key constraint is disabled and then enabled without fully specifying the index clause?
Level: Intermediate
Expected answer: The index is created in the user?s default tablespace and all sizing information is lost. Oracle doesn?t store this information as a part of the constraint definition, but only as part of the index definition, when the constraint was disabled the index was dropped and the information is gone.
10. (On UNIX) When should more than one DB writer process be used? How many should be used?
Level: High
Expected answer: If the UNIX system being used is capable of asynchronous IO then only one is required, if the system is not capable of asynchronous IO then up to twice the number of disks used by Oracle number of DB writers should be specified by use of the db_writers initialization parameter.
11. You are using hot backup without being in archivelog mode, can you recover in the event of a failure? Why or why not?
Level: High
Expected answer: You can?t use hot backup without being in archivelog mode. So no, you couldn?t recover.
12. What causes the "snapshot too old" error? How can this be prevented or mitigated?
Level: Intermediate
Expected answer: This is caused by large or long running transactions that have either wrapped onto their own rollback space or have had another transaction write on part of their rollback space. This can be prevented or mitigated by breaking the transaction into a set of smaller transactions or increasing the size of the rollback segments and their extents.
13. How can you tell if a database object is invalid?
Level: Low
Expected answer: By checking the status column of the DBA_, ALL_ or USER_OBJECTS views, depending upon whether you own or only have permission on the view or are using a DBA account.
14. A user is getting an ORA-00942 error yet you know you have granted them permission on the table, what else should you check?
Level: Low
Expected answer: You need to check that the user has specified the full name of the object (select empid from scott.emp; instead of select empid from emp;) or has a synonym that points to the object (create synonym emp for scott.emp;)
15. A developer is trying to create a view and the database won?t let him. He has the "DEVELOPER" role which has the "CREATE VIEW" system privilege and SELECT grants on the tables he is using, what is the problem?
Level: Intermediate
Expected answer: You need to verify the developer has direct grants on all tables used in the view. You can?t create a stored object with grants given through views.
16. If you have an example table, what is the best way to get sizing data for the production table implementation?
Level: Intermediate
Expected answer: The best way is to analyze the table and then use the data provided in the DBA_TABLES view to get the average row length and other pertinent data for the calculation. The quick and dirty way is to look at the number of blocks the table is actually using and ratio the number of rows in the table to its number of blocks against the number of expected rows.
17. How can you find out how many users are currently logged into the database? How can you find their operating system id?
Level: high
Expected answer: There are several ways. One is to look at the v$session or v$process views. Another way is to check the current_logins parameter in the v$sysstat view. Another if you are on UNIX is to do a "ps -ef|grep oracle|wc -l? command, but this only works against a single instance installation.
18. A user selects from a sequence and gets back two values, his select is:
SELECT pk_seq.nextval FROM dual;
What is the problem?
Level: Intermediate
Expected answer: Somehow two values have been inserted into the dual table. This table is a single row, single column table that should only have one value in it.
19. How can you determine if an index needs to be dropped and rebuilt?
Level: Intermediate
Expected answer: Run the ANALYZE INDEX command on the index to validate its structure and then calculate the ratio of LF_BLK_LEN/LF_BLK_LEN+BR_BLK_LEN and if it isn?t near 1.0 (i.e. greater than 0.7 or so) then the index should be rebuilt. Or if the ratio
BR_BLK_LEN/ LF_BLK_LEN+BR_BLK_LEN is nearing 0.3.
SQL/ SQLPlus
1. How can variables be passed to a SQL routine?
Level: Low
Expected answer: By use of the & symbol. For passing in variables the numbers 1-8 can be used (&1, &2,...,&8) to pass the values after the command into the SQLPLUS session. To be prompted for a specific variable, place the ampersanded variable in the code itself:
"select * from dba_tables where owner=&owner_name;" . Use of double ampersands tells SQLPLUS to resubstitute the value for each subsequent use of the variable, a single ampersand will cause a reprompt for the value unless an ACCEPT statement is used to get the value from the user.
2. You want to include a carriage return/linefeed in your output from a SQL script, how can you do this?
Level: Intermediate to high
Expected answer: The best method is to use the CHR() function (CHR(10) is a return/linefeed) and the concatenation function "||". Another method, although it is hard to document and isn?t always portable is to use the return/linefeed as a part of a quoted string.
3. How can you call a PL/SQL procedure from SQL?
Level: Intermediate
Expected answer: By use of the EXECUTE (short form EXEC) command.
4. How do you execute a host operating system command from within SQL?
Level: Low
Expected answer: By use of the exclamation point "!" (in UNIX and some other OS) or the HOST (HO) command.
5. You want to use SQL to build SQL, what is this called and give an example
Level: Intermediate to high
Expected answer: This is called dynamic SQL. An example would be:
set lines 90 pages 0 termout off feedback off verify off
spool drop_all.sql
select ?drop user ?||username||? cascade;? from dba_users
where username not in ("SYS?,?SYSTEM?);
spool off
Essentially you are looking to see that they know to include a command (in this case DROP USER...CASCADE;) and that you need to concatenate using the ?||? the values selected from the database.
6. What SQLPlus command is used to format output from a select?
Level: low
Expected answer: This is best done with the COLUMN command.
7. You want to group the following set of select returns, what can you group on?
Max(sum_of_cost), min(sum_of_cost), count(item_no), item_no
Level: Intermediate
Expected answer: The only column that can be grouped on is the "item_no" column, the rest have aggregate functions associated with them.
8. What special Oracle feature allows you to specify how the cost based system treats a SQL statement?
Level: Intermediate to high
Expected answer: The COST based system allows the use of HINTs to control the optimizer path selection. If they can give some example hints such as FIRST ROWS, ALL ROWS, USING INDEX, STAR, even better.
9. You want to determine the location of identical rows in a table before attempting to place a unique index on the table, how can this be done?
Level: High
Expected answer: Oracle tables always have one guaranteed unique column, the rowid column. If you use a min/max function against your rowid and then select against the proposed primary key you can squeeze out the rowids of the duplicate rows pretty quick. For example:
select rowid from emp e
where e.rowid > (select min(x.rowid)
from emp x
where x.emp_no = e.emp_no);
In the situation where multiple columns make up the proposed key, they must all be used in the where clause.
10. What is a Cartesian product?
Level: Low
Expected answer: A Cartesian product is the result of an unrestricted join of two or more tables. The result set of a three table Cartesian product will have x * y * z number of rows where x, y, z correspond to the number of rows in each table involved in the join.
11. You are joining a local and a remote table, the network manager complains about the traffic involved, how can you reduce the network traffic?
Level: High
Expected answer: Push the processing of the remote data to the remote instance by using a view to pre-select the information for the join. This will result in only the data required for the join being sent across.
12. What is the default ordering of an ORDER BY clause in a SELECT statement?
Level: Low
Expected answer: Ascending
13. What is tkprof and how is it used?
Level: Intermediate to high
Expected answer: The tkprof tool is a tuning tool used to determine cpu and execution times for SQL statements. You use it by first setting timed_statistics to true in the initialization file and then turning on tracing for either the entire database via the sql_trace parameter or for the session using the ALTER SESSION command. Once the trace file is generated you run the tkprof tool against the trace file and then look at the output from the tkprof tool. This can also be used to generate explain plan output.
14. What is explain plan and how is it used?
Level: Intermediate to high
Expected answer: The EXPLAIN PLAN command is a tool to tune SQL statements. To use it you must have an explain_table generated in the user you are running the explain plan for. This is created using the utlxplan.sql script. Once the explain plan table exists you run the explain plan command giving as its argument the SQL statement to be explained. The explain_plan table is then queried to see the execution plan of the statement. Explain plans can also be run using tkprof.
15. How do you set the number of lines on a page of output? The width?
Level: Low
Expected answer: The SET command in SQLPLUS is used to control the number of lines generated per page and the width of those lines, for example SET PAGESIZE 60 LINESIZE 80 will generate reports that are 60 lines long with a line width of 80 characters. The PAGESIZE and LINESIZE options can be shortened to PAGES and LINES.
16. How do you prevent output from coming to the screen?
Level: Low
Expected answer: The SET option TERMOUT controls output to the screen. Setting TERMOUT OFF turns off screen output. This option can be shortened to TERM.
17. How do you prevent Oracle from giving you informational messages during and after a SQL statement execution?
Level: Low
Expected answer: The SET options FEEDBACK and VERIFY can be set to OFF.
18. How do you generate file output from SQL?
Level: Low
Expected answer: By use of the SPOOL command
Tuning Questions:
1. A tablespace has a table with 30 extents in it. Is this bad? Why or why not.
Level: Intermediate
Expected answer: Multiple extents in and of themselves aren?t bad. However if you also have chained rows this can hurt performance.
2. How do you set up tablespaces during an Oracle installation?
Level: Low
Expected answer: You should always attempt to use the Oracle Flexible Architecture standard or another partitioning scheme to ensure proper separation of SYSTEM, ROLLBACK, REDO LOG, DATA, TEMPORARY and INDEX segments.
3. You see multiple fragments in the SYSTEM tablespace, what should you check first?
Level: Low
Expected answer: Ensure that users don?t have the SYSTEM tablespace as their TEMPORARY or DEFAULT tablespace assignment by checking the DBA_USERS view.
4. What are some indications that you need to increase the SHARED_POOL_SIZE parameter?
Level: Intermediate
Expected answer: Poor data dictionary or library cache hit ratios, getting error ORA-04031. Another indication is steadily decreasing performance with all other tuning parameters the same.
5. What is the general guideline for sizing db_block_size and db_multi_block_read for an application that does many full table scans?
Level: High
Expected answer: Oracle almost always reads in 64k chunks. The two should have a product equal to 64 or a multiple of 64.
6. What is the fastest query method for a table?
Level: Intermediate
Expected answer: Fetch by rowid
7. Explain the use of TKPROF? What initialization parameter should be turned on to get full TKPROF output?
Level: High
Expected answer: The tkprof tool is a tuning tool used to determine cpu and execution times for SQL statements. You use it by first setting timed_statistics to true in the initialization file and then turning on tracing for either the entire database via the sql_trace parameter or for the session using the ALTER SESSION command. Once the trace file is generated you run the tkprof tool against the trace file and then look at the output from the tkprof tool. This can also be used to generate explain plan output.
8. When looking at v$sysstat you see that sorts (disk) is high. Is this bad or good? If bad -How do you correct it?
Level: Intermediate
Expected answer: If you get excessive disk sorts this is bad. This indicates you need to tune the sort area parameters in the initialization files. The major sort are parameter is the SORT_AREA_SIZe parameter.
9. When should you increase copy latches? What parameters control copy latches?
Level: high
Expected answer: When you get excessive contention for the copy latches as shown by the "redo copy" latch hit ratio. You can increase copy latches via the initialization parameter LOG_SIMULTANEOUS_COPIES to twice the number of CPUs on your system.
10. Where can you get a list of all initialization parameters for your instance? How about an indication if they are default settings or have been changed?
Level: Low
Expected answer: You can look in the init .ora file for an indication of manually set parameters. For all parameters, their value and whether or not the current value is the default value, look in the v$parameter view.
11. Describe hit ratio as it pertains to the database buffers. What is the difference between instantaneous and cumulative hit ratio and which should be used for tuning?
Level: Intermediate
Expected answer: The hit ratio is a measure of how many times the database was able to read a value from the buffers verses how many times it had to re-read a data value from the disks. A value greater than 80-90% is good, less could indicate problems. If you simply take the ratio of existing parameters this will be a cumulative value since the database started. If you do a comparison between pairs of readings based on some arbitrary time span, this is the instantaneous ratio for that time span. Generally speaking an instantaneous reading gives more valuable data since it will tell you what your instance is doing for the time it was generated over.
12. Discuss row chaining, how does it happen? How can you reduce it? How do you correct it?
Level: high
Expected answer: Row chaining occurs when a VARCHAR2 value is updated and the length of the new value is longer than the old value and won?t fit in the remaining block space. This results in the row chaining to another block. It can be reduced by setting the storage parameters on the table to appropriate values. It can be corrected by export and import of the effected table.
13. When looking at the estat events report you see that you are getting busy buffer waits. Is this bad? How can you find what is causing it?
Level: high
Expected answer: Buffer busy waits could indicate contention in redo, rollback or data blocks. You need to check the v$waitstat view to see what areas are causing the problem. The value of the "count" column tells where the problem is, the "class" column tells you with what. UNDO is rollback segments, DATA is data base buffers.
14. If you see contention for library caches how can you fix it?
Level: Intermediate
Expected answer: Increase the size of the shared pool.
15. If you see statistics that deal with "undo" what are they really talking about?
Level: Intermediate
Expected answer: Rollback segments and associated structures.
16. If a tablespace has a default pctincrease of zero what will this cause (in relationship to the smon process)?
Level: High
Expected answer: The SMON process won?t automatically coalesce its free space fragments.
17. If a tablespace shows excessive fragmentation what are some methods to defragment the tablespace? (7.1,7.2 and 7.3 only)
Level: High
Expected answer: In Oracle 7.0 to 7.2 The use of the 'alter session set events 'immediate trace name coalesce level ts#';? command is the easiest way to defragment contiguous free space fragmentation. The ts# parameter corresponds to the ts# value found in the ts$ SYS table. In version 7.3 the ?alter tablespace coalesce;? is best. If the free space isn?t contiguous then export, drop and import of the tablespace contents may be the only way to reclaim non-contiguous free space.
18. How can you tell if a tablespace has excessive fragmentation?
Level: Intermediate
If a select against the dba_free_space table shows that the count of a tablespaces extents is greater than the count of its data files, then it is fragmented.
19. You see the following on a status report:
redo log space requests 23
redo log space wait time 0
Is this something to worry about? What if redo log space wait time is high? How can you fix this?
Level: Intermediate
Expected answer: Since the wait time is zero, no. If the wait time was high it might indicate a need for more or larger redo logs.
20. What can cause a high value for recursive calls? How can this be fixed?
Level: High
Expected answer: A high value for recursive calls is cause by improper cursor usage, excessive dynamic space management actions, and or excessive statement re-parses. You need to determine the cause and correct it By either relinking applications to hold cursors, use proper space management techniques (proper storage and sizing) or ensure repeat queries are placed in packages for proper reuse.
21. If you see a pin hit ratio of less than 0.8 in the estat library cache report is this a problem? If so, how do you fix it?
Level: Intermediate
Expected answer: This indicate that the shared pool may be too small. Increase the shared pool size.
22. If you see the value for reloads is high in the estat library cache report is this a matter for concern?
Level: Intermediate
Expected answer: Yes, you should strive for zero reloads if possible. If you see excessive reloads then increase the size of the shared pool.
23. You look at the dba_rollback_segs view and see that there is a large number of shrinks and they are of relatively small size, is this a problem? How can it be fixed if it is a problem?
Level: High
Expected answer: A large number of small shrinks indicates a need to increase the size of the rollback segment extents. Ideally you should have no shrinks or a small number of large shrinks. To fix this just increase the size of the extents and adjust optimal accordingly.
24. You look at the dba_rollback_segs view and see that you have a large number of wraps is this a problem?
Level: High
Expected answer: A large number of wraps indicates that your extent size for your rollback segments are probably too small. Increase the size of your extents to reduce the number of wraps. You can look at the average transaction size in the same view to get the information on transaction size.
25. In a system with an average of 40 concurrent users you get the following from a query on rollback extents:
ROLLBACK CUR EXTENTS
--------------------- --------------------------
R01 11
R02 8
R03 12
R04 9
SYSTEM 4
You have room for each to grow by 20 more extents each. Is there a problem? Should you take any action?
Level: Intermediate
Expected answer: No there is not a problem. You have 40 extents showing and an average of 40 concurrent users. Since there is plenty of room to grow no action is needed.
26. You see multiple extents in the temporary tablespace. Is this a problem?
Level: Intermediate
Expected answer: As long as they are all the same size this isn?t a problem. In fact, it can even improve performance since Oracle won?t have to create a new extent when a user needs one.
Installation/Configuration
1. Define OFA.
Level: Low
Expected answer: OFA stands for Optimal Flexible Architecture. It is a method of placing directories and files in an Oracle system so that you get the maximum flexibility for future tuning and file placement.
2. How do you set up your tablespace on installation?
Level: Low
Expected answer: The answer here should show an understanding of separation of redo and rollback, data and indexes and isolation os SYSTEM tables from other tables. An example would be to specify that at least 7 disks should be used for an Oracle installation so that you can place SYSTEM tablespace on one, redo logs on two (mirrored redo logs) the TEMPORARY tablespace on another, ROLLBACK tablespace on another and still have two for DATA and INDEXES. They should indicate how they will handle archive logs and exports as well. As long as they have a logical plan for combining or further separation more or less disks can be specified.
3. What should be done prior to installing Oracle (for the OS and the disks)?
Level: Low
Expected Answer: adjust kernel parameters or OS tuning parameters in accordance with installation guide. Be sure enough contiguous disk space is available.
4. You have installed Oracle and you are now setting up the actual instance. You have been waiting an hour for the initialization script to finish, what should you check first to determine if there is a problem?
Level: Intermediate to high
Expected Answer: Check to make sure that the archiver isn?t stuck. If archive logging is turned on during install a large number of logs will be created. This can fill up your archive log destination causing Oracle to stop to wait for more space.
5. When configuring SQLNET on the server what files must be set up?
Level: Intermediate
Expected answer: INITIALIZATION file, TNSNAMES.ORA file, SQLNET.ORA file
6. When configuring SQLNET on the client what files need to be set up?
Level: Intermediate
Expected answer: SQLNET.ORA, TNSNAMES.ORA
7. What must be installed with ODBC on the client in order for it to work with Oracle?
Level: Intermediate
Expected answer: SQLNET and PROTOCOL (for example: TCPIP adapter) layers of the transport programs.
8. You have just started a new instance with a large SGA on a busy existing server. Performance is terrible, what should you check for?
Level: Intermediate
Expected answer: The first thing to check with a large SGA is that it isn?t being swapped out.
9. What OS user should be used for the first part of an Oracle installation (on UNIX)?
Level: low
Expected answer: You must use root first.
10. When should the default values for Oracle initialization parameters be used as is?
Level: Low
Expected answer: Never
11. How many control files should you have? Where should they be located?
Level: Low
Expected answer: At least 2 on separate disk spindles. Be sure they say on separate disks, not just file systems.
12. How many redo logs should you have and how should they be configured for maximum recoverability?
Level: Intermediate
Expected answer: You should have at least three groups of two redo logs with the two logs each on a separate disk spindle (mirrored by Oracle). The redo logs should not be on raw devices on UNIX if it can be avoided.
13. You have a simple application with no "hot" tables (i.e. uniform IO and access requirements). How many disks should you have assuming standard layout for SYSTEM, USER, TEMP and ROLLBACK tablespaces?
Expected answer: At least 7, see disk configuration answer above.
Data Modeler:
1. Describe third normal form?
Level: Low
Expected answer: Something like: In third normal form all attributes in an entity are related to the primary key and only to the primary key
2. Is the following statement true or false:
"All relational databases must be in third normal form"
Why or why not?
Level: Intermediate
Expected answer: False. While 3NF is good for logical design most databases, if they have more than just a few tables, will not perform well using full 3NF. Usually some entities will be denormalized in the logical to physical transfer process.
3. What is an ERD?
Level: Low
Expected answer: An ERD is an Entity-Relationship-Diagram. It is used to show the entities and relationships for a database logical model.
4. Why are recursive relationships bad? How do you resolve them?
Level: Intermediate
A recursive relationship (one where a table relates to itself) is bad when it is a hard relationship (i.e. neither side is a "may" both are "must") as this can result in it not being possible to put in a top or perhaps a bottom of the table (for example in the EMPLOYEE table you couldn?t put in the PRESIDENT of the company because he has no boss, or the junior janitor because he has no subordinates). These type of relationships are usually resolved by adding a small intersection entity.
5. What does a hard one-to-one relationship mean (one where the relationship on both ends is "must")?
Level: Low to intermediate
Expected answer: This means the two entities should probably be made into one entity.
6. How should a many-to-many relationship be handled?
Level: Intermediate
Expected answer: By adding an intersection entity table
7. What is an artificial (derived) primary key? When should an artificial (or derived) primary key be used?
Level: Intermediate
Expected answer: A derived key comes from a sequence. Usually it is used when a concatenated key becomes too cumbersome to use as a foreign key.
8. When should you consider denormalization?
Level: Intermediate
Expected answer: Whenever performance analysis indicates it would be beneficial to do so without compromising data integrity.
UNIX:
1. How can you determine the space left in a file system?
Level: Low
Expected answer: There are several commands to do this: du, df, or bdf
2. How can you determine the number of SQLNET users logged in to the UNIX system?
Level: Intermediate
Expected answer: SQLNET users will show up with a process unique name that begins with oracle , if you do a ps -ef|grep oracle |wc -l you can get a count of the number of users.
3. What command is used to type files to the screen?
Level: Low
Expected answer: cat, more, pg
4. What command is used to remove a file?
Level: Low
Expected answer: rm
5. Can you remove an open file under UNIX?
Level: Low
Expected answer: yes
6. How do you create a decision tree in a shell script?
Level: intermediate
Expected answer: depending on shell, usually a case-esac or an if-endif or fi structure
7. What is the purpose of the grep command?
Level: Low
Expected answer: grep is a string search command that parses the specified string from the specified file or files
8. The system has a program that always includes the word nocomp in its name, how can you determine the number of processes that are using this program?
Level: intermediate
Expected answer: ps -ef|grep *nocomp*|wc -l
9. What is an inode?
Level: Intermediate
Expected answer: an inode is a file status indicator. It is stored in both disk and memory and tracts file status. There is one inode for each file on the system.
10. The system administrator tells you that the system hasn?t been rebooted in 6 months, should he be proud of this?
Level: High
Expected answer: Maybe. Some UNIX systems don?t clean up well after themselves. Inode problems and dead user processes can accumulate causing possible performance and corruption problems. Most UNIX systems should have a scheduled periodic reboot so file systems can be checked and cleaned and dead or zombie processes cleared out.
11. What is redirection and how is it used?
Level: Intermediate
Expected answer: redirection is the process by which input or output to or from a process is redirected to another process. This can be done using the pipe symbol "|", the greater than symbol ">" or the "tee" command. This is one of the strengths of UNIX allowing the output from one command to be redirected directly into the input of another command.
12. How can you find dead processes?
Level: Intermediate
Expected answer: ps -ef|grep zombie -- or -- who -d depending on the system.
13. How can you find all the processes on your system?
Level: Low
Expected answer: Use the ps command
14. How can you find your id on a system?
Level: Low
Expected answer: Use the "who am i" command.
15. What is the finger command?
Level: Low
Expected answer: The finger command uses data in the passwd file to give information on system users.
16. What is the easiest method to create a file on UNIX?
Level: Low
Expected answer: Use the touch command
17. What does >> do?
Level: Intermediate
Expected answer: The ">>" redirection symbol appends the output from the command specified into the file specified. The file must already have been created.
18. If you aren?t sure what command does a particular UNIX function what is the best way to determine the command?
Expected answer: The UNIX man -k command will search the man pages for the value specified. Review the results from the command to find the command of interest.
Oracle Troubleshooting:
1. How can you determine if an Oracle instance is up from the operating system level?
Level: Low
Expected answer: There are several base Oracle processes that will be running on multi-user operating systems, these will be smon, pmon, dbwr and lgwr. Any answer that has them using their operating system process showing feature to check for these is acceptable. For example, on UNIX a ps -ef|grep dbwr will show what instances are up.
2. Users from the PC clients are getting messages indicating :
Level: Low
ORA-06114: (Cnct err, can't get err txt. See Servr Msgs & Codes Manual)
What could the problem be?
Expected answer: The instance name is probably incorrect in their connection string.
3. Users from the PC clients are getting the following error stack:
Level: Low
ERROR: ORA-01034: ORACLE not available
ORA-07318: smsget: open error when opening sgadef.dbf file.
HP-UX Error: 2: No such file or directory
What is the probable cause?
Expected answer: The Oracle instance is shutdown that they are trying to access, restart the instance.
4. How can you determine if the SQLNET process is running for SQLNET V1? How about V2?
Level: Low
Expected answer: For SQLNET V1 check for the existence of the orasrv process. You can use the command "tcpctl status" to get a full status of the V1 TCPIP server, other protocols have similar command formats. For SQLNET V2 check for the presence of the LISTENER process(s) or you can issue the command "lsnrctl status".
5. What file will give you Oracle instance status information? Where is it located?
Level: Low
Expected answer: The alert .ora log. It is located in the directory specified by the background_dump_dest parameter in the v$parameter table.
6. Users aren?t being allowed on the system. The following message is received:
Level: Intermediate
ORA-00257 archiver is stuck. Connect internal only, until freed
What is the problem?
Expected answer: The archive destination is probably full, backup the archive logs and remove them and the archiver will re-start.
7. Where would you look to find out if a redo log was corrupted assuming you are using Oracle mirrored redo logs?
Level: Intermediate
Expected answer: There is no message that comes to the SQLDBA or SRVMGR programs during startup in this situation, you must check the alert .log file for this information.
8. You attempt to add a datafile and get:
Level: Intermediate
ORA-01118: cannot add anymore datafiles: limit of 40 exceeded
What is the problem and how can you fix it?
Expected answer: When the database was created the db_files parameter in the initialization file was set to 40. You can shutdown and reset this to a higher value, up to the value of MAX_DATAFILES as specified at database creation. If the MAX_DATAFILES is set to low, you will have to rebuild the control file to increase it before proceeding.
9. You look at your fragmentation report and see that smon hasn?t coalesced any of you tablespaces, even though you know several have large chunks of contiguous free extents. What is the problem?
Level: High
Expected answer: Check the dba_tablespaces view for the value of pct_increase for the tablespaces. If pct_increase is zero, smon will not coalesce their free space.
10. Your users get the following error:
Level: Intermediate
ORA-00055 maximum number of DML locks exceeded
What is the problem and how do you fix it?
Expected answer: The number of DML Locks is set by the initialization parameter DML_LOCKS. If this value is set to low (which it is by default) you will get this error. Increase the value of DML_LOCKS. If you are sure that this is just a temporary problem, you can have them wait and then try again later and the error should clear.
11. You get a call from you backup DBA while you are on vacation. He has corrupted all of the control files while playing with the ALTER DATABASE BACKUP CONTROLFILE command. What do you do?
Level: High
Expected answer: As long as all datafiles are safe and he was successful with the BACKUP controlfile command you can do the following:
CONNECT INTERNAL
STARTUP MOUNT
(Take any read-only tablespaces offline before next step ALTER DATABASE DATAFILE .... OFFLINE;)
RECOVER DATABASE USING BACKUP CONTROLFILE
ALTER DATABASE OPEN RESETLOGS;
(bring read-only tablespaces back online)
Shutdown and backup the system, then restart
If they have a recent output file from the ALTER DATABASE BACKUP CONTROL FILE TO TRACE; command, they can use that to recover as well.
If no backup of the control file is available then the following will be required:
CONNECT INTERNAL
STARTUP NOMOUNT
CREATE CONTROL FILE .....;
However, they will need to know all of the datafiles, logfiles, and settings for MAXLOGFILES, MAXLOGMEMBERS, MAXLOGHISTORY, MAXDATAFILES for the database to use the command.
OTN Ask Tom
Shrinking System
SQL Query
Column order in Index
Oracle 10g upgrade
Difference between Sort Merge and Hash Joins
How to calculate the actual size of a table?
Case and Decode and others
automatically generate a password
more..
OTN Downloads
Analytic Workspace Manager for Oracle OLAP 10g Release 2 (10.2.0.2.0)
Oracle Application Server 10g Release 3 (10.1.3.0.0) for Solaris (SPARC), HP, and AIX5L
more..
Security Alerts
Critical Patch Update - January 2006
more..
Site Statistics
Page Views
597 today
3,278 yesterday
128,515 last month
4,604,418 total
Add a Resource
Home | My Account | Advertise | Link to Us | Contact Us | CodeCompile.com
oracle tutorials plsql tutorials beginning plsql oracle dba tutorial oracle resources oracle scripts oracle reports oracle forms oracle interview questions oracle tutorials plsql tutorials beginning plsql oracle dba tutorial oracle resources oracle scripts oracle reports oracle forms oracle interview questions
DBA Interview Questions
1. Give one method for transferring a table from one schema to another:
Level:Intermediate
Expected Answer: There are several possible methods, export-import, CREATE TABLE... AS SELECT, or COPY.
2. What is the purpose of the IMPORT option IGNORE? What is it?s default setting?
Level: Low
Expected Answer: The IMPORT IGNORE option tells import to ignore "already exists" errors. If it is not specified the tables that already exist will be skipped. If it is specified, the error is ignored and the tables data will be inserted. The default value is N.
3. You have a rollback segment in a version 7.2 database that has expanded beyond optimal, how can it be restored to optimal?
Level: Low
Expected answer: Use the ALTER TABLESPACE ..... SHRINK command.
4. If the DEFAULT and TEMPORARY tablespace clauses are left out of a CREATE USER command what happens? Is this bad or good? Why?
Level: Low
Expected answer: The user is assigned the SYSTEM tablespace as a default and temporary tablespace. This is bad because it causes user objects and temporary segments to be placed into the SYSTEM tablespace resulting in fragmentation and improper table placement (only data dictionary objects and the system rollback segment should be in SYSTEM).
5. What are some of the Oracle provided packages that DBAs should be aware of?
Level: Intermediate to High
Expected answer: Oracle provides a number of packages in the form of the DBMS_ packages owned by the SYS user. The packages used by DBAs may include: DBMS_SHARED_POOL, DBMS_UTILITY, DBMS_SQL, DBMS_DDL, DBMS_SESSION, DBMS_OUTPUT and DBMS_SNAPSHOT. They may also try to answer with the UTL*.SQL or CAT*.SQL series of SQL procedures. These can be viewed as extra credit but aren?t part of the answer.
6. What happens if the constraint name is left out of a constraint clause?
Level: Low
Expected answer: The Oracle system will use the default name of SYS_Cxxxx where xxxx is a system generated number. This is bad since it makes tracking which table the constraint belongs to or what the constraint does harder.
7. What happens if a tablespace clause is left off of a primary key constraint clause?
Level: Low
Expected answer: This results in the index that is automatically generated being placed in then users default tablespace. Since this will usually be the same tablespace as the table is being created in, this can cause serious performance problems.
8. What is the proper method for disabling and re-enabling a primary key constraint?
Level: Intermediate
Expected answer: You use the ALTER TABLE command for both. However, for the enable clause you must specify the USING INDEX and TABLESPACE clause for primary keys.
9. What happens if a primary key constraint is disabled and then enabled without fully specifying the index clause?
Level: Intermediate
Expected answer: The index is created in the user?s default tablespace and all sizing information is lost. Oracle doesn?t store this information as a part of the constraint definition, but only as part of the index definition, when the constraint was disabled the index was dropped and the information is gone.
10. (On UNIX) When should more than one DB writer process be used? How many should be used?
Level: High
Expected answer: If the UNIX system being used is capable of asynchronous IO then only one is required, if the system is not capable of asynchronous IO then up to twice the number of disks used by Oracle number of DB writers should be specified by use of the db_writers initialization parameter.
11. You are using hot backup without being in archivelog mode, can you recover in the event of a failure? Why or why not?
Level: High
Expected answer: You can?t use hot backup without being in archivelog mode. So no, you couldn?t recover.
12. What causes the "snapshot too old" error? How can this be prevented or mitigated?
Level: Intermediate
Expected answer: This is caused by large or long running transactions that have either wrapped onto their own rollback space or have had another transaction write on part of their rollback space. This can be prevented or mitigated by breaking the transaction into a set of smaller transactions or increasing the size of the rollback segments and their extents.
13. How can you tell if a database object is invalid?
Level: Low
Expected answer: By checking the status column of the DBA_, ALL_ or USER_OBJECTS views, depending upon whether you own or only have permission on the view or are using a DBA account.
14. A user is getting an ORA-00942 error yet you know you have granted them permission on the table, what else should you check?
Level: Low
Expected answer: You need to check that the user has specified the full name of the object (select empid from scott.emp; instead of select empid from emp;) or has a synonym that points to the object (create synonym emp for scott.emp;)
15. A developer is trying to create a view and the database won?t let him. He has the "DEVELOPER" role which has the "CREATE VIEW" system privilege and SELECT grants on the tables he is using, what is the problem?
Level: Intermediate
Expected answer: You need to verify the developer has direct grants on all tables used in the view. You can?t create a stored object with grants given through views.
16. If you have an example table, what is the best way to get sizing data for the production table implementation?
Level: Intermediate
Expected answer: The best way is to analyze the table and then use the data provided in the DBA_TABLES view to get the average row length and other pertinent data for the calculation. The quick and dirty way is to look at the number of blocks the table is actually using and ratio the number of rows in the table to its number of blocks against the number of expected rows.
17. How can you find out how many users are currently logged into the database? How can you find their operating system id?
Level: high
Expected answer: There are several ways. One is to look at the v$session or v$process views. Another way is to check the current_logins parameter in the v$sysstat view. Another if you are on UNIX is to do a "ps -ef|grep oracle|wc -l? command, but this only works against a single instance installation.
18. A user selects from a sequence and gets back two values, his select is:
SELECT pk_seq.nextval FROM dual;
What is the problem?
Level: Intermediate
Expected answer: Somehow two values have been inserted into the dual table. This table is a single row, single column table that should only have one value in it.
19. How can you determine if an index needs to be dropped and rebuilt?
Level: Intermediate
Expected answer: Run the ANALYZE INDEX command on the index to validate its structure and then calculate the ratio of LF_BLK_LEN/LF_BLK_LEN+BR_BLK_LEN and if it isn?t near 1.0 (i.e. greater than 0.7 or so) then the index should be rebuilt. Or if the ratio
BR_BLK_LEN/ LF_BLK_LEN+BR_BLK_LEN is nearing 0.3.



Tuning Interview Questions
1. A tablespace has a table with 30 extents in it. Is this bad? Why or why not.
Level: Intermediate
Expected answer: Multiple extents in and of themselves aren?t bad. However if you also have chained rows this can hurt performance.
2. How do you set up tablespaces during an Oracle installation?
Level: Low
Expected answer: You should always attempt to use the Oracle Flexible Architecture standard or another partitioning scheme to ensure proper separation of SYSTEM, ROLLBACK, REDO LOG, DATA, TEMPORARY and INDEX segments.
3. You see multiple fragments in the SYSTEM tablespace, what should you check first?
Level: Low
Expected answer: Ensure that users don?t have the SYSTEM tablespace as their TEMPORARY or DEFAULT tablespace assignment by checking the DBA_USERS view.
4. What are some indications that you need to increase the SHARED_POOL_SIZE parameter?
Level: Intermediate
Expected answer: Poor data dictionary or library cache hit ratios, getting error ORA-04031. Another indication is steadily decreasing performance with all other tuning parameters the same.
5. What is the general guideline for sizing db_block_size and db_multi_block_read for an application that does many full table scans?
Level: High
Expected answer: Oracle almost always reads in 64k chunks. The two should have a product equal to 64 or a multiple of 64.
6. What is the fastest query method for a table?
Level: Intermediate
Expected answer: Fetch by rowid
7. Explain the use of TKPROF? What initialization parameter should be turned on to get full TKPROF output?
Level: High
Expected answer: The tkprof tool is a tuning tool used to determine cpu and execution times for SQL statements. You use it by first setting timed_statistics to true in the initialization file and then turning on tracing for either the entire database via the sql_trace parameter or for the session using the ALTER SESSION command. Once the trace file is generated you run the tkprof tool against the trace file and then look at the output from the tkprof tool. This can also be used to generate explain plan output.
8. When looking at v$sysstat you see that sorts (disk) is high. Is this bad or good? If bad -How do you correct it?
Level: Intermediate
Expected answer: If you get excessive disk sorts this is bad. This indicates you need to tune the sort area parameters in the initialization files. The major sort are parameter is the SORT_AREA_SIZe parameter.
9. When should you increase copy latches? What parameters control copy latches?
Level: high
Expected answer: When you get excessive contention for the copy latches as shown by the "redo copy" latch hit ratio. You can increase copy latches via the initialization parameter LOG_SIMULTANEOUS_COPIES to twice the number of CPUs on your system.
10. Where can you get a list of all initialization parameters for your instance? How about an indication if they are default settings or have been changed?
Level: Low
Expected answer: You can look in the init.ora file for an indication of manually set parameters. For all parameters, their value and whether or not the current value is the default value, look in the v$parameter view.
11. Describe hit ratio as it pertains to the database buffers. What is the difference between instantaneous and cumulative hit ratio and which should be used for tuning?
Level: Intermediate
Expected answer: The hit ratio is a measure of how many times the database was able to read a value from the buffers verses how many times it had to re-read a data value from the disks. A value greater than 80-90% is good, less could indicate problems. If you simply take the ratio of existing parameters this will be a cumulative value since the database started. If you do a comparison between pairs of readings based on some arbitrary time span, this is the instantaneous ratio for that time span. Generally speaking an instantaneous reading gives more valuable data since it will tell you what your instance is doing for the time it was generated over.
12. Discuss row chaining, how does it happen? How can you reduce it? How do you correct it?
Level: high
Expected answer: Row chaining occurs when a VARCHAR2 value is updated and the length of the new value is longer than the old value and won?t fit in the remaining block space. This results in the row chaining to another block. It can be reduced by setting the storage parameters on the table to appropriate values. It can be corrected by export and import of the effected table.
13. When looking at the estat events report you see that you are getting busy buffer waits. Is this bad? How can you find what is causing it? Level: high
Expected answer: Buffer busy waits could indicate contention in redo, rollback or data blocks. You need to check the v$waitstat view to see what areas are causing the problem. The value of the "count" column tells where the problem is, the "class" column tells you with what. UNDO is rollback segments, DATA is data base buffers.
14. If you see contention for library caches how can you fix it?
Level: Intermediate
Expected answer: Increase the size of the shared pool.
15. If you see statistics that deal with "undo" what are they really talking about?
Level: Intermediate
Expected answer: Rollback segments and associated structures.
16. If a tablespace has a default pctincrease of zero what will this cause (in relationship to the smon process)?
Level: High
Expected answer: The SMON process won?t automatically coalesce its free space fragments.
17. If a tablespace shows excessive fragmentation what are some methods to defragment the tablespace? (7.1,7.2 and 7.3 only)
Level: High
Expected answer: In Oracle 7.0 to 7.2 The use of the 'alter session set events 'immediate trace name coalesce level ts#';? command is the easiest way to defragment contiguous free space fragmentation. The ts# parameter corresponds to the ts# value found in the ts$ SYS table. In version 7.3 the ?alter tablespace coalesce;? is best. If the free space isn?t contiguous then export, drop and import of the tablespace contents may be the only way to reclaim non-contiguous free space.
18. How can you tell if a tablespace has excessive fragmentation?
Level: Intermediate
If a select against the dba_free_space table shows that the count of a tablespaces extents is greater than the count of its data files, then it is fragmented.
19. You see the following on a status report:
redo log space requests 23
redo log space wait time 0
Is this something to worry about? What if redo log space wait time is high? How can you fix this?
Level: Intermediate
Expected answer: Since the wait time is zero, no. If the wait time was high it might indicate a need for more or larger redo logs.
20. What can cause a high value for recursive calls? How can this be fixed?
Level: High
Expected answer: A high value for recursive calls is cause by improper cursor usage, excessive dynamic space management actions, and or excessive statement re-parses. You need to determine the cause and correct it By either relinking applications to hold cursors, use proper space management techniques (proper storage and sizing) or ensure repeat queries are placed in packages for proper reuse.
21. If you see a pin hit ratio of less than 0.8 in the estat library cache report is this a problem? If so, how do you fix it?
Level: Intermediate
Expected answer: This indicate that the shared pool may be too small. Increase the shared pool size.
22. If you see the value for reloads is high in the estat library cache report is this a matter for concern?
Level: Intermediate
Expected answer: Yes, you should strive for zero reloads if possible. If you see excessive reloads then increase the size of the shared pool.
23. You look at the dba_rollback_segs view and see that there is a large number of shrinks and they are of relatively small size, is this a problem? How can it be fixed if it is a problem?
Level: High
Expected answer: A large number of small shrinks indicates a need to increase the size of the rollback segment extents. Ideally you should have no shrinks or a small number of large shrinks. To fix this just increase the size of the extents and adjust optimal accordingly.
24. You look at the dba_rollback_segs view and see that you have a large number of wraps is this a problem?
Level: High
Expected answer: A large number of wraps indicates that your extent size for your rollback segments are probably too small. Increase the size of your extents to reduce the number of wraps. You can look at the average transaction size in the same view to get the information on transaction size.
25. In a system with an average of 40 concurrent users you get the following from a query on rollback extents:
ROLLBACK CUR EXTENTS
--------------------- --------------------------
R01 11
R02 8
R03 12
R04 9
SYSTEM 4
You have room for each to grow by 20 more extents each. Is there a problem? Should you take any action?
Level: Intermediate
Expected answer: No there is not a problem. You have 40 extents showing and an average of 40 concurrent users. Since there is plenty of room to grow no action is needed.
26. You see multiple extents in the temporary tablespace. Is this a problem?
Level: Intermediate
Expected answer: As long as they are all the same size this isn?t a problem. In fact, it can even improve performance since Oracle won?t have to create a new extent when a user needs one.
Installation/Configuration Interview Questions
1. Define OFA.
Level: Low
Expected answer: OFA stands for Optimal Flexible Architecture. It is a method of placing directories and files in an Oracle system so that you get the maximum flexibility for future tuning and file placement.
2. How do you set up your tablespace on installation?
Level: Low
Expected answer: The answer here should show an understanding of separation of redo and rollback, data and indexes and isolation os SYSTEM tables from other tables. An example would be to specify that at least 7 disks should be used for an Oracle installation so that you can place SYSTEM tablespace on one, redo logs on two (mirrored redo logs) the TEMPORARY tablespace on another, ROLLBACK tablespace on another and still have two for DATA and INDEXES. They should indicate how they will handle archive logs and exports as well. As long as they have a logical plan for combining or further separation more or less disks can be specified.
3. What should be done prior to installing Oracle (for the OS and the disks)?
Level: Low
Expected Answer: adjust kernel parameters or OS tuning parameters in accordance with installation guide. Be sure enough contiguous disk space is available.
4. You have installed Oracle and you are now setting up the actual instance. You have been waiting an hour for the initialization script to finish, what should you check first to determine if there is a problem?
Level: Intermediate to high
Expected Answer: Check to make sure that the archiver isn?t stuck. If archive logging is turned on during install a large number of logs will be created. This can fill up your archive log destination causing Oracle to stop to wait for more space.
5. When configuring SQLNET on the server what files must be set up?
Level: Intermediate
Expected answer: INITIALIZATION file, TNSNAMES.ORA file, SQLNET.ORA file
6. When configuring SQLNET on the client what files need to be set up?
Level: Intermediate
Expected answer: SQLNET.ORA, TNSNAMES.ORA
7. What must be installed with ODBC on the client in order for it to work with Oracle?
Level: Intermediate
Expected answer: SQLNET and PROTOCOL (for example: TCPIP adapter) layers of the transport programs.
8. You have just started a new instance with a large SGA on a busy existing server. Performance is terrible, what should you check for?
Level: Intermediate
Expected answer: The first thing to check with a large SGA is that it isn?t being swapped out.
9. What OS user should be used for the first part of an Oracle installation (on UNIX)?
Level: low
Expected answer: You must use root first.
10. When should the default values for Oracle initialization parameters be used as is?
Level: Low
Expected answer: Never
11. How many control files should you have? Where should they be located?
Level: Low
Expected answer: At least 2 on separate disk spindles. Be sure they say on separate disks, not just file systems.
12. How many redo logs should you have and how should they be configured for maximum recoverability? Level: Intermediate
Expected answer: You should have at least three groups of two redo logs with the two logs each on a separate disk spindle (mirrored by Oracle). The redo logs should not be on raw devices on UNIX if it can be avoided.
13. You have a simple application with no "hot" tables (i.e. uniform IO and access requirements). How many disks should you have assuming standard layout for SYSTEM, USER, TEMP and ROLLBACK tablespaces?
Expected answer: At least 7, see disk configuration answer above.
Data Modeler Interview Questions
1. Describe third normal form?
Level: Low
Expected answer: Something like: In third normal form all attributes in an entity are related to the primary key and only to the primary key
2. Is the following statement true or false:
"All relational databases must be in third normal form"
Why or why not?
Level: Intermediate
Expected answer: False. While 3NF is good for logical design most databases, if they have more than just a few tables, will not perform well using full 3NF. Usually some entities will be denormalized in the logical to physical transfer process.
3. What is an ERD?
Level: Low
Expected answer: An ERD is an Entity-Relationship-Diagram. It is used to show the entities and relationships for a database logical model.
4. Why are recursive relationships bad? How do you resolve them?
Level: Intermediate
A recursive relationship (one where a table relates to itself) is bad when it is a hard relationship (i.e. neither side is a "may" both are "must") as this can result in it not being possible to put in a top or perhaps a bottom of the table (for example in the EMPLOYEE table you couldn?t put in the PRESIDENT of the company because he has no boss, or the junior janitor because he has no subordinates). These type of relationships are usually resolved by adding a small intersection entity.
5. What does a hard one-to-one relationship mean (one where the relationship on both ends is "must")?
Level: Low to intermediate
Expected answer: This means the two entities should probably be made into one entity.
6. How should a many-to-many relationship be handled?
Level: Intermediate
Expected answer: By adding an intersection entity table
7. What is an artificial (derived) primary key? When should an artificial (or derived) primary key be used? Level: Intermediate
Expected answer: A derived key comes from a sequence. Usually it is used when a concatenated key becomes too cumbersome to use as a foreign key.
8. When should you consider denormalization?
Level: Intermediate
Expected answer: Whenever performance analysis indicates it would be beneficial to do so without compromising data integrity.
UNIX Interview Questions
1. How can you determine the space left in a file system?
Level: Low
Expected answer: There are several commands to do this: du, df, or bdf
2. How can you determine the number of SQLNET users logged in to the UNIX system?
Level: Intermediate
Expected answer: SQLNET users will show up with a process unique name that begins with oracle, if you do a ps -ef|grep oracle|wc -l you can get a count of the number of users.
3. What command is used to type files to the screen?
Level: Low
Expected answer: cat, more, pg
4. What command is used to remove a file?
Level: Low
Expected answer: rm
5. Can you remove an open file under UNIX?
Level: Low
Expected answer: yes
6. How do you create a decision tree in a shell script?
Level: intermediate
Expected answer: depending on shell, usually a case-esac or an if-endif or fi structure
7. What is the purpose of the grep command?
Level: Low
Expected answer: grep is a string search command that parses the specified string from the specified file or files
8. The system has a program that always includes the word nocomp in its name, how can you determine the number of processes that are using this program?
Level: intermediate
Expected answer: ps -ef|grep *nocomp*|wc -l
9. What is an inode?
Level: Intermediate
Expected answer: an inode is a file status indicator. It is stored in both disk and memory and tracts file status. There is one inode for each file on the system.
10. The system administrator tells you that the system hasn?t been rebooted in 6 months, should he be proud of this?
Level: High
Expected answer: Maybe. Some UNIX systems don?t clean up well after themselves. Inode problems and dead user processes can accumulate causing possible performance and corruption problems. Most UNIX systems should have a scheduled periodic reboot so file systems can be checked and cleaned and dead or zombie processes cleared out.
11. What is redirection and how is it used?
Level: Intermediate
Expected answer: redirection is the process by which input or output to or from a process is redirected to another process. This can be done using the pipe symbol "|", the greater than symbol ">" or the "tee" command. This is one of the strengths of UNIX allowing the output from one command to be redirected directly into the input of another command.
12. How can you find dead processes?
Level: Intermediate
Expected answer: ps -ef|grep zombie -- or -- who -d depending on the system.
13. How can you find all the processes on your system?
Level: Low
Expected answer: Use the ps command
14. How can you find your id on a system?
Level: Low
Expected answer: Use the "who am i" command.
15. What is the finger command?
Level: Low
Expected answer: The finger command uses data in the passwd file to give information on system users.
16. What is the easiest method to create a file on UNIX?
Level: Low
Expected answer: Use the touch command
17. What does >> do?
Level: Intermediate
Expected answer: The ">>" redirection symbol appends the output from the command specified into the file specified. The file must already have been created.
18. If you aren?t sure what command does a particular UNIX function what is the best way to determine the command?
Expected answer: The UNIX man -k command will search the man pages for the value specified. Review the results from the command to find the command of interest.
Oracle Troubleshooting Interview Questions
1. How can you determine if an Oracle instance is up from the operating system level?
Level: Low
Expected answer: There are several base Oracle processes that will be running on multi-user operating systems, these will be smon, pmon, dbwr and lgwr. Any answer that has them using their operating system process showing feature to check for these is acceptable. For example, on UNIX a ps -ef|grep dbwr will show what instances are up.
2. Users from the PC clients are getting messages indicating :
Level: Low
ORA-06114: (Cnct err, can't get err txt. See Servr Msgs & Codes Manual)
What could the problem be?
Expected answer: The instance name is probably incorrect in their connection string.
3. Users from the PC clients are getting the following error stack:
Level: Low
ERROR: ORA-01034: ORACLE not available
ORA-07318: smsget: open error when opening sgadef.dbf file.
HP-UX Error: 2: No such file or directory
What is the probable cause?
Expected answer: The Oracle instance is shutdown that they are trying to access, restart the instance.
4. How can you determine if the SQLNET process is running for SQLNET V1? How about V2?
Level: Low
Expected answer: For SQLNET V1 check for the existence of the orasrv process. You can use the command "tcpctl status" to get a full status of the V1 TCPIP server, other protocols have similar command formats. For SQLNET V2 check for the presence of the LISTENER process(s) or you can issue the command "lsnrctl status".
5. What file will give you Oracle instance status information? Where is it located?
Level: Low
Expected answer: The alert.ora log. It is located in the directory specified by the background_dump_dest parameter in the v$parameter table.
6. Users aren?t being allowed on the system. The following message is received:
Level: Intermediate
ORA-00257 archiver is stuck. Connect internal only, until freed
What is the problem?
Expected answer: The archive destination is probably full, backup the archive logs and remove them and the archiver will re-start.
7. Where would you look to find out if a redo log was corrupted assuming you are using Oracle mirrored redo logs?
Level: Intermediate
Expected answer: There is no message that comes to the SQLDBA or SRVMGR programs during startup in this situation, you must check the alert.log file for this information.
8. You attempt to add a datafile and get:
Level: Intermediate
ORA-01118: cannot add anymore datafiles: limit of 40 exceeded
What is the problem and how can you fix it?
Expected answer: When the database was created the db_files parameter in the initialization file was set to 40. You can shutdown and reset this to a higher value, up to the value of MAX_DATAFILES as specified at database creation. If the MAX_DATAFILES is set to low, you will have to rebuild the control file to increase it before proceeding.
9. You look at your fragmentation report and see that smon hasn?t coalesced any of you tablespaces, even though you know several have large chunks of contiguous free extents. What is the problem?
Level: High
Expected answer: Check the dba_tablespaces view for the value of pct_increase for the tablespaces. If pct_increase is zero, smon will not coalesce their free space.
10. Your users get the following error:
Level: Intermediate
ORA-00055 maximum number of DML locks exceeded
What is the problem and how do you fix it?
Expected answer: The number of DML Locks is set by the initialization parameter DML_LOCKS. If this value is set to low (which it is by default) you will get this error. Increase the value of DML_LOCKS. If you are sure that this is just a temporary problem, you can have them wait and then try again later and the error should clear.
11. You get a call from you backup DBA while you are on vacation. He has corrupted all of the control files while playing with the ALTER DATABASE BACKUP CONTROLFILE command. What do you do?
Level: High
Expected answer: As long as all datafiles are safe and he was successful with the BACKUP controlfile command you can do the following:
CONNECT INTERNAL
STARTUP MOUNT
(Take any read-only tablespaces offline before next step ALTER DATABASE DATAFILE .... OFFLINE;)
RECOVER DATABASE USING BACKUP CONTROLFILE
ALTER DATABASE OPEN RESETLOGS;
(bring read-only tablespaces back online)
Shutdown and backup the system, then restart
If they have a recent output file from the ALTER DATABASE BACKUP CONTROL FILE TO TRACE; command, they can use that to recover as well.
If no backup of the control file is available then the following will be required:
CONNECT INTERNAL
STARTUP NOMOUNT
CREATE CONTROL FILE .....;
However, they will need to know all of the datafiles, logfiles, and settings for MAXLOGFILES, MAXLOGMEMBERS, MAXLOGHISTORY, MAXDATAFILES for the database to use the command
hai
this shanthi i am posting some dba interview questions pls post answers for this questions
What are things which play major role in designing the backup strategy?
What are RTO, MTBF, and MTTR?
What are the various tape backup solutions available in the market?
What is RAID? What is RAID0? What is RAID1? What is RAID 10?
What is the difference between physical and logical backups?
What is hot backup and what is cold backup?
When do you recommend hot backup? What are the pre-reqs?
How do you generate the begin backup script?
Give me the steps for recovering the full database from cold backup?
Give me the steps for TIME based recovery from the full database from hot backup. ?
Give me the steps for SCN based recovery from the full database from hot backup. ?
Give me the steps for CANCEL based recovery from the full database from hot backup. ?
Give me the steps for recovery with missing archived redo logs?
Give me the steps for recovery with missing online redo logs?
Give me the steps for recovery of missing data file?
Give me the steps for physical standby database creation?
What is db_recovery_file_dest ? When do you need to set this value ?
Give me the steps to perform the point in time recovery with a backup which is taken before the resetlogs of the db ?
Tell me about the steps required to enable the RMAN backup for a target database ?
What is the difference between obsolete RMAN backups and expired RMAN backups ?
What is recovery catalog ? Why do you need this ?
How do you install the RMAN recovery catalog ?
Can you skip specific tables when using RMAN DUPLICATE feature ?
What is FRA ? When do you use this ?
How do you clone the database using RMAN software ? Give me the brief steps ? when do you use crosscheck command ?
How do you setup the RMAN tape backups ?
How do you identify the expired,active,obsolete backups ? Which RMAN command you use ?
What is channel ? How do you enable the parallel backups with RMAN ?
What is auxiliary channel in RMAN? When do you need this ?
How do you identify what are the all the target databases that are being backed-up with RMAN database ?
Give me some of the RMAN catalog view names which contains the catalog information ?
What is oracle wallet ? Tell me about the encryption options available with RMAN ?
List atleast 6 advantages of RMAN backups compare to traditional hot backups ?
How do you identikit the block corruption in RMAN database ? How do you fix this ?
How do you verify the integrity of the image copy in RMAN environment ?
How do you enable the encryption for RMAN backups ?
What is backup set ?
What is the difference between cumulative incremental and differential incremental backups ?
How do you enable the autobackup for the controlfile using RMAN ?
What is configure command ? When do you use this ?
Give me the steps for setting up the physical stand by database with RMAN ?
Give me the steps for changing the DBID in a cloned environment ?
What is the significance of incarnation and DBID in the RMAN backups ?
What are the steps which needs to be performed in $ORACLE_HOME for enabling the RMAN backups with netbackup or TSM tape library software?

Explain database instance?
A database instance (server) is a set of memory structures and background processes that access a set of database files.  The memory structures are used to store most queried data from database. This helps us to improve database performance by decreasing the amount of I/O performed against data file.  The process can be shared by all users.
2. What is parallel server?
Multiple instances accessing the same database (Only in Multi-CPU environments).
3. What is Schema ?
The set of objects owned by user account is called the schema
4. What is an Index ? How it is implemented in Oracle Database ?
An index is a database structure used by the server to have direct access of a row in a table.An index is automatically created when a unique or primary key constraint clause is specified in create table command
5. What is a clusters? Explain
Group of tables physically stored together because they share common columns and are often used together is called Clusters.
6. What is a cluster key ?
The related columns of the tables are called the cluster key. The cluster key is indexed using a cluster index and its value is stores only once for multiple tables in the cluster.
7. What are the basic elements of an oracle Database?
It consists of one or more data files one or more control files two or more redo log files.  The database contains multiple users/schemas one or more rollback segments one or more tablespaces Data dictionary tables User objects (tables, indexes, views etc)  The server that access the database consists of
SGA (Database buffer, Dictionary Cache Buffers, redo log buffers, Shared SQL pool)
SMON
PMON
LGWR
DBWR
ARCH
CKPT
RECO
Dispatcher
User process with associated PGA
8. What is deadlock ? Explain.
Two processes waiting to update the rows of a table which are locked by the other process then deadlock arises.
In a database environment this will often happen because of not issuing proper row lock commands. Poor design of front-end application may cause this situation and the performance of server will reduce drastically.
These locks will be released automatically when a commit/rollback operation performed or any one of this processes being killed externally.
9. What is SGA ?
The System Global Area in a Oracle database is the area in memory to facilitates the transfer of information between users. It holds the most recently requested structural information about the database.
10. What is Shared SQL pool ?
The data dictionary cache is stored in an area in SGA called the Shared SQL Pool. This will allow sharing of parsed SQL statements among concurrent users.
11. What is meant by Program Global Area (PGA) ?
It is area in memory that is used by a Single Oracle User process.
12. What is a data segment?
Data segment are the physical areas within a database block in which the data associated with tables and clusters are stored.
13. What are the factors causing the reparsing of SQL statements in SGA ?
Due to insufficient Shared SQL pool size
1. How many memory layers are in the shared pool?

1/3 of physical memory, can be 2/4k depending on bit of 32 or 64

2. How do you find out from the RMAN catalog if a particular
archive log has been backed-up?

The database should be in ARCHIVE mode if you are going to use RMAN as
backup method.

3. How can you tell how much space is left on a given file
system and how much space each of the file system's subdirectories
take-up?

4. Define the SGA and:
• How you would configure SGA for a mid-sized OLTP environment?
• What is involved in tuning the SGA?

5. What is the cache hit ratio, what impact does it have on
performance of an Oracle database and what is involved in tuning it?

6. Other than making use of the statspack utility, what would
you check when you are monitoring or running a health check on an
Oracle 8i or 9i database?

7. How do you tell what your machine name is and what is its IP
address?

8. How would you go about verifying the network name that the
local_listener is currently using?

9. You have 4 instances running on the same UNIX box. How can
you determine which shared memory and semaphores are associated with
which instance?

10. What view(s) do you use to associate a user's SQLPLUS session
with his o/s process?

11. What is the recommended interval at which to run statspack
snapshots, and why?

12. What spfile/init.ora file parameter exists to force the CBO
to make the execution path of a given statement use an index, even if
the index scan may appear to be calculated as more costly?

13. Assuming today is Monday, how would you use the DBMS_JOB
package to schedule the execution of a given procedure owned by SCOTT
to start Wednesday at 9AM and to run subsequently every other day at
2AM.

14. How would you edit your CRONTAB to schedule the running
of /test/test.sh to run every other day at 2PM?

15. What do the 9i dbms_standard.sql_txt() and
dbms_standard.sql_text() procedures do?

16. In which dictionary table or view would you look to determine
at which time a snapshot or MVIEW last successfully refreshed?

17. How would you best determine why your MVIEW couldn't FAST
REFRESH?

18. How does propagation differ between Advanced Replication and
Snapshot Replication (read-only)?

19. Which dictionary view(s) would you first look at to
understand or get a high-level idea of a given Advanced Replication
environment?

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

21. Which dictionary tables and/or views would you look at to
diagnose a locking issue?

22. An automatic job running via DBMS_JOB has failed. Knowing
only that "it's failed", how do you approach troubleshooting this
issue?

23. How would you extract DDL of a table without using a GUI tool?

24. You're getting high "busy buffer waits" - how can you find
what's causing it?

25. What query tells you how much space a tablespace named "test"
is taking up, and how much space is remaining?

26. Database is hung. Old and new user connections alike hang on
impact. What do you do? Your SYS SQLPLUS session IS able to connect.

27. Database crashes. Corruption is found scattered among the
file system neither of your doing nor of Oracle's. What database
recovery options are available? Database is in archive log mode.

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

29. How do you increase the OS limitation for open files (LINUX
and/or Solaris)?

30. Provide an example of a shell script which logs into SQLPLUS
as SYS, determines the current date, changes the date format to
include minutes & seconds, issues a drop table command, displays the
date again, and finally exits.

31. Explain how you would restore a database using RMAN to Point
in Time?

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

33. Which environment variables are absolutely critical in order
to run the OUI?

34. What SQL query from v$session can you run to show how many
sessions are logged in as a particular user account?

35. Why does Oracle not permit the use of PCTUSED with indexes?

36. What would you use to improve performance on an insert
statement that places millions of rows into that table?

37. What would you do with an "in-doubt" distributed transaction?

38. What are the commands you'd issue to show the explain plan
for "select * from dual"?

39. In what script is "snap$" created? In what script is
the "scott/tiger" schema created?

40. If you're unsure in which script a sys or system-owned object
is created, but you know it's in a script from a specific directory,
what UNIX command from that directory structure can you run to find
your answer?

41. How would you configure your networking files to connect to a
database by the name of DSS which resides in domain icallinc.com?

42. You create a private database link and upon
connection, fails with: ORA-2085: connects to qualified remote db name>. What is the problem? How would you go
about resolving this error?

43. I have my backup RMAN script called "backup_rman.sh". I am
on the target database. My catalog username/password is rman/rman.
My catalog db is called rman. How would you run this shell script
from the o/s such that it would run as a background process?

44. Explain the concept of the DUAL table.

45. What are the ways tablespaces can be managed and how do they
differ?

46. From the database level, how can you tell under which time
zone a database is operating?

47. What's the benefit of "dbms_stats" over "analyze"?

48. Typically, where is the conventional directory structure
chosen for Oracle binaries to reside?

49. You have found corruption in a tablespace that contains
static tables that are part of a database that is in NOARCHIVE log
mode. How would you restore the tablespace without losing new data
in the other tablespaces?

50. How do you recover a datafile that has not been physically
been backed up since its creation and has been deleted. Provide
syntax example.

51. Draft one mock email requesting your non-technical management
grant you downtime to (provide justification where applicable)
complete the following tasks:

(1) Generate statistics on a large table;
(2) Generate an RDA – if you don't know what an RDA is please say
so.
(3) Rename datafiles.

Which environment variables are absolutely critical in order to run the OUI? 1
Explain what partitioning is and what its benefit is. 2
How would you configure your networking files to connect to a database by the name of DSS which resides in domain icallinc.com? 1
What is blocking and how would you troubleshoot it? 1
How do you add a data file to a tablespace? 1
What is the difference between a TEMPORARY tablespace and a PERMANENT tablespace? 1
What command would you use to create a backup control file? 1
How can you enable a trace for a session? 1
Give two examples of how you might determine the structure of the table DEPT. 2
what is the difference between db2start command and start database manager command? 1
How would you go about generating an EXPLAIN plan? 2
How would you go about increasing the buffer cache hit ratio? 1
How to make a replica of existing oracle server to another server? 1
What would you use to improve performance on an insert statement that places millions of rows into that table? TCS 2
Explian different types of BACKUPs avaialabe in SQL Server? Given a particular scenario, how would you go about choosing a backup plan? 1
What are the different ways of moving data or databases between servers and databases in SQL Server? 2
Should you place Recovery Catalog in the Same DB? . Can you use RMAN without Recovery catalog 4
How to start SQL Server in minimal configuration mode? 1
Give two examples of referential integrity constraints. 1
How can we know the exact updation date of a particular database?

1. What spfile/init.ora file parameter exists to force the CBO to make the execution path of a given statement use an index, even if the index scan may appear to be calculated as more costly?

2. Assuming today is Monday, how would you use the DBMS_JOB package to schedule the execution of a given procedure owned by SCOTT to start Wednesday at 9AM and to run subsequently every other day at 2AM.

3. How would you edit your CRONTAB to schedule the running of /test/test.sh to run every other day at 2PM?

4. What do the 9i dbms_standard.sql_txt() and dbms_standard.sql_text() procedures do?

5. In which dictionary table or view would you look to determine at which time a snapshot or MVIEW last successfully refreshed?

6. How would you best determine why your MVIEW couldn?t FAST REFRESH?

7. How does propagation differ between Advanced Replication and Snapshot Replication (read-only)?

8. Which dictionary view(s) would you first look at to understand or get a high-level idea of a given Advanced Replication environment?

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

10. Which dictionary tables and/or views would you look at to diagnose a locking issue?

11. An automatic job running via DBMS_JOB has failed. Knowing only that ?it?s failed?, how do you approach troubleshooting this issue?

12. How would you extract DDL of a table without using a GUI tool?

13. You?re getting high ?busy buffer waits? - how can you find what?s causing it?

14. What query tells you how much space a tablespace named ?test? is taking up, and how much space is remaining?

15. Database is hung. Old and new user connections alike hang on impact. What do you do? Your SYS SQLPLUS session IS able to connect.

16. Database crashes. Corruption is found scattered among the file system neither of your doing nor of Oracle?s. What database recovery options are available? Database is in archive log mode.

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

18. How do you increase the OS limitation for open files (LINUX and/or Solaris)?

19. Provide an example of a shell script which logs into SQLPLUS as SYS, determines the current date, changes the date format to include minutes & seconds, issues a drop table command, displays the date again, and finally exits.

20. Explain how you would restore a database using RMAN to Point in Time?

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

22. Which environment variables are absolutely critical in order to run the OUI?

23. What SQL query from v$session can you run to show how many sessions are logged in as a particular user account?

24. Why does Oracle not permit the use of PCTUSED with indexes?

25. What would you use to improve performance on an insert statement that places millions of rows into that table?

26. What would you do with an ?in-doubt? distributed transaction?

27. What are the commands you?d issue to show the explain plan for ?select * from dual??

28. In what script is ?snap$? created? In what script is the ?scott/tiger? schema created?

29. If you?re unsure in which script a sys or system-owned object is created, but you know it?s in a script from a specific directory, what UNIX command from that directory structure can you run to find your answer?

30. How would you configure your networking files to connect to a database by the name of DSS which resides in domain icallinc.com?

31. You create a private database link and upon connection, fails with: ORA-2085: connects to . What is the problem? How would you go about resolving this error?

32. I have my backup RMAN script called ?backup_rman.sh?. I am on the target database. My catalog username/password is rman/rman. My catalog db is called rman. How would you run this shell script from the o/s such that it would run as a background process?

33. Explain the concept of the DUAL table.

34. What are the ways tablespaces can be managed and how do they differ?

35. From the database level, how can you tell under which time zone a database is operating?

36. What?s the benefit of ?dbms_stats? over ?analyze??

37. Typically, where is the conventional directory structure chosen for Oracle binaries to reside?

38. You have found corruption in a tablespace that contains static tables that are part of a database that is in NOARCHIVE log mode. How would you restore the tablespace without losing new data in the other tablespaces?

39. How do you recover a datafile that has not been physically been backed up since its creation and has been deleted. Provide syntax example.

40. Draft one mock email requesting your non-technical management grant you downtime to (provide justification where applicable) complete the following tasks:

1. How many memory layers are in the shared pool?

Answer The shared pool portion of the SGA contains three major areas: library cache, dictionary cache, buffers for parallel execution messages, and control structures

2. How do you find out from the RMAN catalogue if a particular archive log has
been backed-up?
Answer :

3. How can you tell how much space is left on a given file system and how
much space each of the file system's subdirectories take-up?
Answer : df -k in Solaris

4. Define the SGA and:
? How you would configure SGA for a mid-sized OLTP environment?
? What is involved in tuning the SGA?
Answer
System Global Area (SGA), which is shared by all server and background
processes and holds the following:
o Database buffer cache
o Redo log buffer
o Shared pool
o Large pool (if configured)
? Program Global Areas (PGA), which is private to each server and background
process; there is one PGA for each process. The PGA holds the following:
o Stack areas
o Data areas
What is involved in tuning the SGA?
Answer :Properly size your database buffers (shared_pool, buffer cache, log buffer, etc) by looking at your buffer hit ratios. Pin large objects into memory to prevent frequent reloads

5. What is the cache hit ratio, what impact it has on performance of
an Oracle database and what is involved in tuning it?
Answer: The cache miss ratio is the the number of cache misses compared to the total number of cache read attempts. This is calculated as follows:
Select sum(getmisses) / sum(gets) "Miss ratio" From v$rowcache;

The miss ratio should be less than 15%. If this is not the case, increase the initialisation parameter SHARED_POOL_SIZE.

6. Other than making use of the stats pack utility, what would you check when
you are monitoring or running a health check on an Oracle 8i or 9i database?
Answer:
UTLBSTAT.SQL and UTLESTAT.SQL - Begin and end stats monitoring or
Oracle Enterprise Manager - Tuning Pack
TKProf

7. How do you tell what your machine name is and what is its IP addresses?
Answer
Windows: ipconfig
UNIX: ifconfig -a
HP-UX : ifconfig 1an0
Linux : ifconfig

8. How would you go about verifying the network name that the local_listener
is currently using?
Answer: With the command: Show parameter LISTENER. After executing this command in SQL, the result that you will get for HOSTNAME is the network name of the local host.

9. You have 4 instances running on the same UNIX box. How can you determine
Which shared memory and semaphores are associated with which instance?
Answer :

10. What view(s) do you use to associate a user's SQLPLUS session with his
o/s process?
Answer : v$session

11. What is the recommended interval at which to run stats pack snapshots,
and why?
Answer :

12. What spfile/init.ora file parameter exists to force the CBO to make the
execution path of a given statement use an index, even if the index scan may
appear to be calculated as more costly?

Answer: optimizer_index_cost_adj

13. Assuming today is Monday, how would you use the DBMS_JOB package to
schedule the execution of a given procedure owned by SCOTT to start
Wednesday at 9AM and to run subsequently every other day at 2AM.
Answer: dbms_job.submit(
:jobno, 'statspack.snap;',
trunc(sysdate)+9/24,
'trunc(SYSDATE+1/24,''HH'')',
TRUE,
:instno);

14. How would you edit your CRONTAB to schedule the running of /test/test.sh
to run every other day at 2PM?
Answer: Use vi to edit Crontab file append a line on the file
00 2 * * * /test/test.sh

15. What do the 9i dbms_standard.sql_txt() and dbms_standard.sql_text() procedures do?
Answer: DBMS_STANDARD package provides language facilities that help your application interact with Oracle.

Function sql_txt (sql_text out ora_name_list_t) return binary_integer;

16. In which dictionary table or view would you look to determine at which
time a snapshot or MVIEW last successfully refreshed?
Answer:

17. How would you best determine why your MVIEW couldn't FAST REFRESH?
Answer: from dba_mview_refresh_times

18. How does propagation differ between Advanced Replication and Snapshot
Replication (read-only)?
Answer:

19. Which dictionary view(s) would you first look at to understand or get a high-level idea of a given Advanced Replication environment?
Answer: dba_repcatlog ; dba_repsites_new ; dba_repextensions

20. How would you begin to troubleshoot an ORA-3113 error?
Answer: End Of File on Communication Channel
The Ora-3113 error is a general error reported by Oracle client tools, which signifies that they cannot communicate with the Oracle shadow process.
Solution
? Increase permanent swap file and test with increasing larger sizes, especially if you are getting 3113 in conjunction with a very large data transfer between client and server.
? (settings -> control panel -> SYSTEM ->performance -> change)
? Sql*Net vs. Database versions mismatch
? Delete unwanted files (like core, .lst, .trc, .log etc) if your executables partition becomes full, especially $ORACLE_HOME
? Set sqlnet.expire_time = 0 in sqlnet.ora file
? If your database is running in archive log mode make sure LOG_ARCHIVE_START = TRUE is set in your init.ora file
? If you have installed Oracle parallel server option but do not have distributed Lock manager installed or running, the 3113 may be encountered
o select * from v$option;
o if you find the two conditions stated above are true, you should de-install the parallel server option. It is recomended to go through Oracle installer to de-install any product, else folow this approach.
o shutdown any Oracle instances
o %script /tmp/relink.out
o %cd $ORACLE_HOME/rdbms/lib
o %rm -f oracle
o %make -f oracle.mk no_parropt ioracle
o %exit
? Try using the SQL*Net V1 driver for local connections:
o setenv TWO_TASK P:
? Your 'Oracle' executable may be corrupt. Relink it
o shutdown any Oracle instances
o %script /tmp/relink.out
o %cd $ORACLE_HOME/rdbms/lib
o %rm -f oracle
o %make -f oracle.mk ioracle
o %exit
? Some unix platform need LD_LIBRARY_PATH to be set correctly to resolve any dynamically linked libraries problems.
? Check the SQL*Net protocol you are using
drivers oracle
if you are using TCP/IP it should list TCP/IP if driver command does not exists on your machine, then try
o %script /tmp/symbols.out
o %cd $ORACLE_HOME/bin
o %nm oracle | grep -i SYMBOL # where symbol can be osnptt, osnasy, osnttt, osntlitcp, osntlispx, osndnt
o %exit

21. Which dictionary tables and/or views would you look at to diagnose a
locking issue?

Answers: sys.v_$lock, sys.v_$session sys.obj$ , sys.user$ ,
sys.v_$process

22. An automatic job running via DBMS_JOB has failed. Knowing only that
"it's failed", how do you approach troubleshooting this issue?
Answers:

23. How would you extract DDL of a table without using a GUI tool?
Answers:

24. You're getting high "busy buffer waits" - how can you find what's
causing it?
Answers:

25. What query tells you how much space a tablespace named "test" is taking
up, and how much space is remaining?
Answers:

26. Database is hung. Old and new user connections alike hang on impact.
What do you do? Your SYS SQLPLUS session IS able to connect.
Answers:

27. Database crashes. Corruption is found scattered among the file system
neither of your doing nor of Oracle's. What database recovery options are
available? Database is in archive log mode.
Answers:

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

29. How do you increase the OS limitation for open files (LINUX and/or
Solaris)?
Answers:

30. Provide an example of a shell script which logs into SQLPLUS as SYS,
determines the current date, changes the date format to include minutes &
seconds, issues a drop table command, displays the date again, and finally
exits.
Answers: Create a file.sh using vi then type the following line
sqlplus -s sys/*******@service_name
select sysdate from dual;
ALTER SESSION SET NLS_DATE_FORMAT='YYYY/MM/DD MI:SS'
drop table xx;
select sysdate from dual;
exit;

31. Explain how you would restore a database using RMAN to Point in Time?
Answer: Rman page no 4 ? 26 --- 29
32. How does Oracle guarantee data integrity of data changes?

33. Which environment variables are absolutely critical in order to run the
OUI?
Answer: On UNIX: Oracle_Home , Path , ORA_NLS33 AND LD_LIBRARY_PATH

34. What SQL query from v$session can you run to show how many sessions are
Logged in as a particular user account?

Answer: Select count (*) from v$session where username=?User_account_name?

35. Why does Oracle not permit the use of PCTUSED with indexes?

36. What would you use to improve performance on an insert statement that
Places millions of rows into that table?

37. What would you do with an "in-doubt" distributed transaction?

38. What are the commands you'd issue to show the explain plan for "select *
from dual"?

39. In what script is "snap$" created? In what script is the "scott/tiger" schema created?
Answer :

40. If you're unsure in which script a sys or system-owned object is
created, but you know it's in a script from a specific directory, what UNIX
command from that directory structure can you run to find your answer?
Answer :

41. How would you configure your networking files to connect to a database
by the name of DSS which resides in domain icallinc.com?
Answer : In tnsnames use host=DSS.icallinc.com

42. You create a private database link and upon
connection, fails with: ORA-2085: connects to remote db name>. What is the problem? How would you go about resolving this
error?
Answer : This happens after the DB_NAME of the database was changed (as in note# 15390.1 ie re-create controfile with set database option etc ...).After This, the NAME column value is the new DB_NAME in V$DATABASE. The problem comes from the PROPS$ where GLOBAL_DB_NAME is still the old database name. So the WA is to execute the ALTER DATABASE RENAME GLOBAL_NAME (global_name=false is not a WA if global_naming is required).


43. I have my backup RMAN script called "backup_rman.sh". I am on the target
database. My catalog username/password is rman/rman. My catalog db is called
rman. How would you run this shell script from the O/S such that it would
run as a background process?
Answer : backup_rman.sh >&1&

44. Explain the concept of the DUAL table.
Answer : Dual is a table which is created by oracle along with the data dictionary.
It consists of exactly one column whose name is dummy and one record.
The value of that record is X.

sql> desc dual
Name Null? Type
--------
DUMMY VARCHAR2(1)

sql> select * from dual;

D
-
X

The owner of dual is SYS but dual can be accessed by every user.
As dual contains exactly one row (unless someone fiddled with it),
it is guaranteed to return exactly one row in select statements if a
constant expression selected against dual, such as in:

select sysdate from dual

Although it is possible to delete the one record, or insert additional records,
one really should not do that!.

45. What are the ways tablespaces can be managed and how do they differ?
Answer : 2 ways Locally Managed or Managed in the dictionary
Locally-managed tablespaces have the following advantages over dictionary-managed tablespaces:
Local management of extents avoids recursive space management operations, which can occur in dictionary-managed tablespaces if consuming or releasing space in an extent results in another operation that consumes or releases space in a rollback segment or data dictionary table.

Local management of extents automatically tracks adjacent free space, eliminating the need to coalesce free extents.

46. From the database level, how can you tell under which time zone a
Database is operating?
Answer : select DBTIMEZONE from dual;

47. What's the benefit of "dbms_stats" over "analyze"?
Answer : Starting with the introduction of the dbms_stats package, Oracle provides a simple way for the Oracle professional to collect statistics for the CBO. The old-fashioned analyze table and dbms_utility methods for generating CBO statistics are obsolete and somewhat dangerous to SQL performance because they don't always capture high-quality information about tables and indexes. The CBO uses object statistics to choose the best execution plan for all SQL statements.

The dbms_stats utility does a far better job in estimating statistics, especially for large partitioned tables, and the better stats result in faster SQL execution plans.

48. Typically, where is the conventional directory structure chosen for
Oracle binaries to reside?
Answer : \oracle\ora91\bin ( windows
$Oracle_Home\

49. You have found corruption in a tablespace that contains static tables
That is part of a database that is in NOARCHIVE log mode. How would you
Restore the table space without losing new data in the other table spaces?
Answer:

=====================================================================================================

Oracle golden-gate interview questions:
==============================================

1)

What type of Topology does Goldengate support?
GoldenGate supports the following topologies. More details can be found here.

Unidirectional
Bidirectional
Peer-to-peer
Broadcast
Consolidation
Cascasding

================================================================================================================================================
2)
What are the main components of the Goldengate replication?
The replication configuration consists of the following processes.

Manager
Extract
Pump
Replicate


================================================================================================================================================

3)

What transaction types does Goldengate support for Replication?
Goldengate supports both DML and DDL Replication from the source to target.


================================================================================================================================================
4)

What are the supplemental logging pre-requisites?
The following supplemental logging is required.

Database supplemental logging
Object level logging

================================================================================================================================================
5)

Why is Supplemental logging required for Replication?
When a transaction is committed on the source database, only new data is written to the Redo log.
However for Oracle to apply these transactions on the destination database, the before image key values are required to identify the effected rows.
This data is also placed in the trail file and used to identify the rows on the destination, using the key value the transactions are executed against them.

================================================================================================================================================

6)

List important considerations for bi-directional replication?
The customer should consider the following points in an active-active replication environment.

Primary Key: Helps to identify conflicts and Resolve them.
Sequences: Are not supported. The work around is use to use odd/even, range or concatenate sequences.
Triggers: These should be disabled or suppressed to avoid using uniqueness issue
Data Looping: This can easy avoided using OGG itself
LAG: This should be minimized. If a customer says that there will not be any LAG due to network or huge load, then we don’t need to deploy CRDs.
But this is not the case always as there would be some LAG and these can cause Conflicts.
CDR (Conflict Detection & Resolution): OGG has built in CDRs for all kind of DMLs that can be used to detect and resolve them.
Packaged Application: These are not supported as it may contain data types which are not support by OGG or it might not allow the application modification to work with OGG.

======================================================================================================================================================================================================================================================

7)

Are OGG binaries supported on ASM Cluster File System (ACFS)?
Yes, you can install and configure OGG on ACFS.

======================================================================================================================================================================================================================================================

8)

Are OGG binaries supported on the Database File System (DBFS)? What files can be stored in DBFS?
No, OGG binaries are not supported on DBFS. You can however store parameter files, data files (trail files), and checkpoint files on DBFS.


======================================================================================================================================================================================================================================================

9)

What is the default location of the GLOBALS file?
A GLOBALS file is located under Oracle GoldenGate installation directory (OGG HOME)

======================================================================================================================================================================================================================================================

10)

Where can filtering of data for a column be configured?
Filtering of the columns of a table can be set at the Extract, Pump or Replicat level.

======================================================================================================================================================================================================================================================

11)

Is it a requirement to configure a PUMP extract process in OGG replication?
A PUMP extract is an option, but it is highly recommended to use this to safe guard against network failures.
Normally it is configured when you are setting up OGG replication across the network.


======================================================================================================================================================================================================================================================

12)

What are the differences between the Classic and integrated Capture?
Classic Capture:

The Classic Capture mode is the traditional Extract process that accesses the database redo logs (optionally archive logs) to capture the DML changes occurring on the objects
specified in the parameter files.
At the OS level, the GoldenGate user must be a part of the same database group which owns the database redo logs.
This capture mode is available for other RDBMS as well.
There are some data types that are not supported in Classic Capture mode.
Classic capture can’t read data from the compressed tables/tablespaces.
Integrated Capture (IC):

In the Integrated Capture mode, GoldenGate works directly with the database log mining server to receive the data changes in the form of logical change records (LCRs).
IC mode does not require any special setup for the databases using ASM, transparent data encryption, or Oracle RAC.
This feature is only available for oracle databases in Version 11.2.0.3 or higher.
 It also supports various object types which were previously not supported by Classic Capture.
This Capture mode supports extracting data from source databases using compression.
Integrated Capture can be configured in an online or downstream mode.


======================================================================================================================================================================================================================================================

13)

List the minimum parameters that can be used to create the extract process?
The following are the minimium required parameters which must be defined in the extract parameter file.

EXTRACT NAME
USERID
EXTTRAIL
TABLE

======================================================================================================================================================================================================================================================

14)

I want to configure multiple extracts to write to the same exttrail file? Is this possible?
Only one Extract process can write to one exttrail at a time. So you can’t configure multiple extracts to write to the same exttrail.


======================================================================================================================================================================================================================================================

15)

What type of Encryption is supported in Goldengate?
Oracle Goldengate provides 3 types of Encryption.

Data Encryption using Blow fish.
Password Encryption.
Network Encryption.

======================================================================================================================================================================================================================================================

16)

What are the different password encrytion options available with OGG?
You can encrypt a password in OGG using

Blowfish algorithm and
Advance Encryption Standard (AES) algorithm





======================================================================================================================================================================================================================================================


17)

What are the different encryption levels in AES?
You can encrypt the password/data using the AES in three different keys

a) 128 bit
b) 192 bit and
c) 256 bit

======================================================================================================================================================================================================================================================

18)


How is Golden Gate different than streams?
Oracle GoldenGate uses trail files to transfer data to the target while Streams uses a dblink to transfer data to the destination.

======================================================================================================================================================================================================================================================
19)

What are the area’s to monitor in Golden Gate?
The lag and checkpoint latency for the Extract, pump and replicat are normally monitored.



======================================================================================================================================================================================================================================================

20)

How do you look at the data which is extracted?
The Golden Gate logdump utility has to be used to look at the RBA and the data at that point.

======================================================================================================================================================================================================================================================

21)

What are common possible reasons that the Extract process will slow down?
Some of the common possible reasons are:
- Long running batch transactions in the database
- Insufficient memory set for on running transactions causing writing of the uncommitted transaction to the temporary area.


======================================================================================================================================================================================================================================================

22)

What are common possible reasons that the Replicat process will slow down?
Some of the common possible reasons are:
- If using DBFS, writing and reading of trail files may be slow if the SGA parameter are not tuned.
- For slow replicat’s latency may be due to missing indexes on target.
- Replicat having to process Update, delete of rows in very large tables.


======================================================================================================================================================================================================================================================

23)

What steps would you use to add a new table to the destination replicat?
The steps would be along the following:
- Include the new table to the extract and pump process.
- Obtain starting database SCN and Copy the source table data to the target database
- Start replicat on target at the source SCN database point.


======================================================================================================================================================================================================================================================

24)

FAQ: Most Common Goldengate Errors and Issues (Doc ID 1354649.1)


Oracle GoldenGate Logdump Complete Reference FAQ (Doc ID 1446672.1)
Master Note - Oracle GoldenGate (Doc ID 1298817.1)
Main Note - Oracle GoldenGate - Troubleshooting (Doc ID 1306476.1)
======================================================================================================================================================================================================================================================

25)

======================================================================================================================================================================================================================================================


1.       how can u tell a particular parameter is static or dynamic

Ans: select name,ISSES_MODIFIABLE,ISSYS_MODIFIABLE from v$parameter;

2.       which background process collects stats for awr

ANS: MMON

3.       benefits of datapump export and import as compared to conventional export or import

ANS:

links: http://dbasanthosh.wordpress.com/2011/08/02/differences-between-traditional-expimp-and-datapump/
http://www.acehints.com/2012/02/datapump-vs-expimp-difference-or.html

Here are some advantages of Datapump :

Data Pump Export and Import operations are processed in the database as a Data Pump job,
which is much more efficient that the client-side execution of original Export and Import.

Data Pump operations can take advantage of the server’s parallel processes to read or
write multiple data streams simultaneously.

Data Pump differs from original Export and Import in that all jobs run primarily on the server
using server processes. These server processes access files for the Data Pump jobs using
directory objects that identify the location of the files. The directory objects enforce a security
model that can be used by DBAs to control access to these files.

Datapump has a very powerful interactive command-line mode which allows the user to
monitor and control Data Pump Export and Import operations.Datapump allows you to disconnect
and reconnect to the session

Because Data Pump jobs run entirely on the server, you can start an
export or import job, detach from it, and later reconnect to the job to monitor its progress.

Data Pump gives you the ability to pass data between two databases over a network (via a
database link), without creating a dump file on disk.

Datapump uses the Direct Path data access method (which permits the server to bypass SQL and go right to
the data blocks on disk) has been rewritten to be much more efficient and now supports Data
Pump Import and Export.

Original Export is being deprecated with the Oracle Database 11g


4.       why is datapump faster than conventional is there any other factor.

ANS: http://neeraj-dba.blogspot.in/2011/04/question-about-data-pump.html

Using  the  Direct  Path  method  of  unloading, a single  stream  of data  unload is about 2 times faster than
original  Export  because  the Direct  Path API  has been  modified to be  even  more efficient.
Depending on the level of parallelism, the level of improvement can be much more.

A  single  stream  of data load is 15-45 times  faster  Original  Import.
The reason it  is  so much faster  is that Conventional  Import uses only  conventional mode  inserts,
 whereas  Data Pump Import uses the Direct Path  method  of  loading. As  with Export, the  job can be parallelized for even more improvement.


5.       suppose datapump job is running in serial how will u force it to run in parallel

6.       what is ASMM in 10g automatic shared memory management

ANS:

The Oracle Automatic Shared Memory Management is a feature that automatically readjusts the sizes of the main pools (db_cache_size, shared_pool_size, large_pool_size, java_pool_size) based on existing workloads. Oracle Automatic Shared Memory Management is enabled by setting:

You must use an spfile for the init.ora values

sga_target parameter is set to a non-zero value

statistics_level parameter set to to TYPICAL (the default) or ALL

shared_pool_size must be set to a non-zero value

7.       why sql loader direct path is so fast

ANS: http://docs.oracle.com/cd/B28359_01/server.111/b28319/ldr_modes.htm

8.       breakable parse lock

ANS: http://docs.oracle.com/cd/E11882_01/server.112/e26088/ap_locks002.htm
http://www.dba-village.com/village/dvp_forum.OpenThread?ThreadIdA=34895


Breakable parse locks are library cache locks (of enqueue types L[A-P])
which are held briefly during the compilation time/parsing time of SQL
or PL/SQL codes. They are released at the end of the
compilation/parsing. They are known as breakable parse locks as they
are not released, and only can be broken when the object is un-pinned.

TM locks are held on tables during DDLs (like partition addition, Index
Rebuilds, View creation on that table, PDML and Analyze) to protect
(lock!) the definition of the table.

In short breakable parse locks are library cache locks and TM locks
protect the definition of the table during DDLs.

Breakable Parse Locks

A parse lock is held by a SQL statement or PL/SQL program unit for each schema object that it references.
Parse locks are acquired so that the associated shared SQL area can be invalidated if a referenced object is altered or dropped.
A parse lock is called a breakable parse lock because it does not disallow any DDL operation and can be broken to allow conflicting DDL operations.
A parse lock is acquired in the shared pool during the parse phase of SQL statement execution.
The lock is held as long as the shared SQL area for that statement remains in the shared pool.

9.       difference between correlated subquery and nested subquery

ANS:

Subquery:-If a sql statement contains another sql statement then the sql statement which is inside another sql statement is called Subquery.
It is also known as nested query. The Sql Statement which contains the other sql statement is called Parent Statement.
Nested Subquery:-If a Subquery contains another subquery, then the subquery inside another subquery is called nested subquery.
Correlated Subquery:-If the outcome of a subquery is depends on the value of a column of its parent query table then the Sub query is called Correlated Subquery.

10.   what is hash cluster

ANS: http://www.relationaldbdesign.com/extended-database-features/module3/oracle-hash-cluster.php
A row is stored in a hash cluster based on the result of applying a hash function to the row's cluster key value.
All rows with the same hash key value are stores together on disk. - See more at: http://www.geekinterview.com/question_details/3965#sthash.TGicvFu5.dpuf


11.   character set scan

ANS: http://docs.oracle.com/cd/B10501_01/server.920/a96529/ch11.htm
http://docs.oracle.com/cd/B19306_01/server.102/b14225/ch12scanner.htm

The Character Set Scanner provides an assessment of the feasibility and potential issues in migrating an Oracle database to a new database character set.
The Character Set Scanner checks all character data in the database and tests for the effects and problems of changing the character set encoding.
At the end of the scan, it generates a summary report of the database scan.
This report shows the scope work required to convert the database to a new character set.

12.   what is a fractured block

ANS:

A block in which the header and footer are not consistent at a given SCN.
In a user-managed backup, an operating system utility can back up a datafile at the same time that DBWR is updating the file.
It is possible for the operating system utility to read a block in a half-updated state,
so that the block that is copied to the backup media is updated in its first half,
while the second half contains older data. In this case, the block is fractured.

For non-RMAN backups, the ALTER TABLESPACE ... BEGIN BACKUP or ALTER DATABASE BEGIN BACKUP command is the solution for the fractured block problem.
When a tablespace is in backup mode, and a change is made to a data block,
the database logs a copy of the entire block image before the change so that the database can reconstruct this block if media recovery finds that this block was fractured.

Because the database continues writing to the file during an online backup,
there is the possibility of backing up inconsistent data within a block. For example,
assume that either RMAN or an operating system utility reads the block while database writer is in the middle of updating the block.
In this case, RMAN or the copy utility could read the old data in the top half of the block and the new data in the bottom top half of the block.
The block is a fractured block, meaning that the data in this block is not consistent.

When performing a user-managed backup of an online tablespace or database,
an operating system utility can back up a datafile at the same time that database writer is updating the file.
It is possible for the utility to read a block in a half-updated state,
so that the block that is copied to the backup media is updated in its first half,
while the second half contains older data. This type of logical corruption is known as a fractured block, that is,
a block that is not consistent with respect to an SCN.
If this backup needs to be restored later, and if the block requires recovery,
then recovery will fail because the block is not usable.


13. why is the datafile put in begin backup mode in hot backup


ANS: What Happens When A Tablespace/Database Is Kept In Begin Backup Mode [ID 469950.1]

14.   how it manages begin backup which was in hot backup and how rman works internally architecture of rman,

ANS: http://docs.oracle.com/cd/B28359_01/backup.111/b28270/rcmcncpt.htm

When performing a user-managed backup of an online tablespace or database,
an operating system utility can back up a datafile at the same time that database writer is updating the file.
It is possible for the utility to read a block in a half-updated state,
so that the block that is copied to the backup media is updated in its first half,
while the second half contains older data. This type of logical corruption is known as a fractured block, that is,
a block that is not consistent with respect to an SCN.
If this backup needs to be restored later, and if the block requires recovery,
then recovery will fail because the block is not usable.


When performing a user-managed online backup, you must place your datafiles into backup mode with the ALTER DATABASE or ALTER TABLESPACE statement with the BEGIN BACKUP clause.
When a tablespace is in backup mode, the database writes the before image for an entire block to the redo stream before modifying a block.
The database also records changes to the block in the online redo log. Backup mode also freezes the datafile checkpoint until the file is removed from backup mode.
Oracle Database performs this safeguard because it cannot guarantee that a third-party backup tool will copy the file header before copying the data blocks.

Unlike user-managed tools, RMAN does not require extra logging or backup mode because it knows the format of data blocks.
RMAN is guaranteed not to back up fractured blocks. During an RMAN backup,
a database server session reads each data block and checks whether it is fractured by comparing the block header and footer.
If a block is fractured,then the session rereads the block. If the same fracture is found, then the block is considered permanently corrupt.
Also, RMAN does not need to freeze the datafile header checkpoint because it knows the order in which the blocks will be read,
which enables it to capture a known good checkpoint for the file.

15.how to find out unused indexes

ANS:

ou can use Monitoring feature of Oracle to find which indexes are unused. You can run the following query to enable monitoring on an index:
ALTER INDEX index_name MONITORING USAGE;
After you enable indexing, you should wait for a while (for example 1-2 days if you think that this index should be used daily),
and then you can query v$object_view to see if index is used:


ALTER INDEX

Index monitoring is started and stopped using the ALTER INDEX syntax shown below.

ALTER INDEX my_index_i MONITORING USAGE;
ALTER INDEX my_index_i NOMONITORING USAGE;
Information about the index usage can be displayed using the V$OBJECT_USAGE view.

SELECT index_name,
       table_name,
       monitoring,
       used,
       start_monitoring,
       end_monitoring
FROM   v$object_usage
WHERE  index_name = 'MY_INDEX_I'
ORDER BY index_name;



16.   command in rman to ignore the missing archive logs and make backup successfull

ANS:https://blogs.oracle.com/sysdba/entry/rman_backup_error_what_to_do_i

I always encounters the problem while my seminars that what DBA should do if some archivelog is missing during RMAN backup.
I think apart from crossing the fingers, one can at least make successful backup. backup should not be missed even if you miss some of the files. Nothing is important than successful backup. All future recovery depends upon the presence of backups.

RMAN> crosscheck archivelog all;

and then follwoing to delete expired archivelog.

RMAN> delete expired archive log;

Also refer to the skip inaccessible clause of the backup command. for example...

RMAN> backup archivelog all skip inaccessible delete input;
RMAN> change archivelog all validate;

17.   steps to convert dmt to lmt


ANS:
Oracle does include procedure in a supplied package to help you convert a DMT to a LMT. The DBMS_SPACE_ADMIN.TABLESPACE_MIGRATE_TO_LOCAL will convert a DMT to a LMT.
Similarly, the DBMS_SPACE_ADMIN.TABLESPACE_MIGRATE_FROM_LOCAL will convert a tablespace from a LMT to a DMT.


18.   dead lock, who manages, where is the trace file generated

ANS: http://docs.oracle.com/cd/E17076_02/html/gsg_txn/C/blocking_deadlocks.html


LMDx - The Global Enqueue Service Daemon (LMD) is the lock agent process that manages enqueue manager service requests for Global Cache Service enqueues
to control access to global enqueues and resources.
The LMD process also handles deadlock detection and remote enqueue requests.
Remote resource requests are the requests originating from another instance.

racle will dump a trace file to the user_dump_dest. You need to look at that trace file.

In summary, the steps necessary to identify and rectify code causing deadlocks are:

Locate the error messages in the alert log.
Locate the relevant trace file(s).
Identify the SQL statements in both the current session and the waiting session(s).
Use these SQL statements to identify the particular piece of code that is having problems.
Alter the application code to prevent deadlocks by always locking rows in the tables in the same order.


19.   new feature of 11g compression

ANS: http://www.dba-oracle.com/oracle11g/sf_Oracle_11g_Data_Compression_Tips_for_the_DBA.html

20.   new features of 10g rman

ANS: http://www.oracle-base.com/articles/10g/rman-enhancements-10g.php

21.   have u ever setup resource manager


22.   background process which works when bct is enabled -- ctwr

ANS: ctwr

23.   where is backup info first inserted in rman repository.. target control file or recovery catalog

ANS:


24.   how will u inform rman about the user managed backup...  (i didn't understand this question)

ANS:


25.   diagonositic_dest diag

ANS: http://docs.oracle.com/cd/B28359_01/server.111/b28320/initparams071.htm


26.   query was fast yesterday but today it is slow... how will u diagnose

ANS:


27.   uses of log transport services

ANS:
http://docs.oracle.com/cd/A97630_01/server.920/a96653/stdbylts.htm
http://docs.oracle.com/cd/B10500_01/server.920/a96653/log_transport.htm
http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10823/log_transport.htm


The log transport services component of the Data Guard environment is responsible for automatic archiving of primary database online redo logs.
Once archived, these logs are known as archived redo logs.
Log transport services provide for the management of archived redo log permissions, destinations, transmission, reception, and transmission failure resolution.
In a Data Guard environment, the log transport services component coordinates its activities with log apply services
and role management services for switchover and failover operations.

28.   instance recovery  vs crash recovery

ANS:

29.   difference between rman differential and cumulative backups

ANS: http://www.dba-oracle.com/t_incr_differential_incr_cumulative_backups.htm

30.   db file recovery dest size modifying and parameters for it

ANS: db_recovery_file_dest_size

31.   steps for migration from single to rac

ANS: http://www.oracle.com/technetwork/articles/chan-sing2rac-install-086874.html
https://docs.google.com/document/edit?id=1--dTvk0Ign9qD0NovlgXHQ19jutVQb7TX3L0GKZNqYo&hl=en
http://docs.oracle.com/cd/B19306_01/server.102/b25159/migrate.htm
http://www.youtube.com/watch?v=TI2nADjokfc

32.   what are the new features in 11g standby dataguard
ANS: http://viragsharma.blogspot.in/2007/09/oracle-11g-data-guard-enhancements-new.html
http://dbaregistry.blogspot.in/2010/01/oracle-database-11g-new-features-in_26.html
http://www.databasejournal.com/features/oracle/article.php/3929131/Top-10-New-Features-for-Oracle-11g-Data-Guard---Part-One.htm


33. how oracle manages uncommitted changes during instance crash

ANS – reference article for new oracle dba :

http://itcareershift.com/blog1/2011/09/23/how-oracle-manages-uncommitted-changes-during-instance-crash-reference-article-for-new-oracle-dba/


Related Questions

1)What is an Oracle database Full Backup?

ANS: A full backup is an operating system backup of all data files, on-line redo log files and control file that constitute ORACLE database and the parameter.

2) What is an Oracle database Partial Backup?

ANS: A Partial Backup is any operating system backup short of a full backup, taken while the database is open or shut down.

3)What are the advantages of operating a database in ARCHIVE LOG mode over operating it in NO ARCHIVE LOG mode ?

ANS: Complete database recovery from disk failure is possible only in ARCHIVE LOG mode.
Online database backup is possible only in ARCHIVE LOG mode.
Archive log mode that you can put database in for creating a backup of all tranaction that have been occured in a data base so you can recover at any point in time
Non Archive log mode is a basically absence of archive log mode and it is not recover at any point

4) What is the steps for recovery of missing data file? and the steps for physical stand by database creation?
ANS:
f it is non system datafile
steps
1 offline of datafile
2 Restore the datafile
3 Recover the datafile
4 Online the datafile
If it is system or active undo datafile
1 Mount the database
2 restore the datafile
3 recover the datafile
4 open the database

If any data file is missing, make datafile offline with the commond 'alter tablespace tablespace_name offline;
And Restore the relivent datafile from the backup, recover the datafile 'recover datafile path of datafile or datafile no# online;
it will apply all archive logs and redo logs and it will recover and open for normal use.


5) What is the steps for recovery with missing online redo logs?

6) What are the steps involved in Database Startup ?

7) What are the steps involved in Database Shutdown ?

8) What is Restricted Mode of Instance Startup ?

9)What are the different modes of mounting a Database with the Parallel Server ?

10) What is Full Backup ?

11) Can Full Backup be performed when the database is open ?

12)What is Partial Backup ?

13) What is On-line Redo Log?

14) What is Mirrored on-line Redo Log ?

15) What is Archived Redo Log ?

16) What are the advantages of operating a database in ARCHIVELOG mode over operating it in NO ARCHIVELOG mode ?

17) What is Log Switch ?

18) What are the steps involved in Instance Recovery ?

ALTER DATABASE BACKUP CONTROLFILE TO '/opt/app/oracle/admin/amxdcmp1/controlfile_backup/amxdcm_bkp_control.ctl' ;

alter tablespace UNDOTBS3 add datafile '+DG1_TMO_DATA' size 8g AUTOEXTEND ON MAXSIZE 25G;


Master Note: Locks, Enqueues and Deadlocks [ID 1392319.1]


==============================================================================================
FREQUENTLY ASKED QUESTIONS
--------------------------


CONTENTS
--------
1. What is a Partitioned View?
2. What is a Partitioned Table?
3. What are the advantages of Partitioned Tables?
4. What is a Partitioned Index?
5. What is a Local Prefixed/Non-Prefixed index?
6. What is a Global Index?
7. How to Create a partitioned Table?
8. What are the restrictions for Partitioned tables?
9. How to manipulate partitions?
10. What are the restrictions on partition-extended table names?
11. What is the difference between Table-Level and
    Partition-Level Export and Import?
12. How to convert a partitioned table or view into non-partitioned table?
13. How to Partition a non-partitioned table?
14. How to Merge table partitions?
15. How to split a table Partition?
16. Can you update a partition key column(s) if the update causes rows to be
    moved from one partition to another?
17. Are there restrictions on importing into partitions or with NLS
    character sets?
18. What are the effects of exchange on local and global indexes?

QUESTIONS and ANSWERS


1. What is a  Partitioned View?

Answer
------
Introduced in Oracle Version 7.3 still available in Oracle8 for backwards
compatibility.  VLDB's (very large databases) can achieve better performance with partitioned
Tables/Indexes because Partitioned tables can be easily striped across more
than one datafile. This datafaile can reside on different physical devices under different IO
controllers. Also, the optimizer will use execution plans that eliminate
certain partitions based on the partition keys.

References
----------
Oracle8 Server Concepts
Note: 43194.1 Partition views in 7.3

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

2. What is a Partitioned Table?

Answer
------
In Oracle8, a table can be divided into partitions based on a range of key
values. Each partition can be operated on independently.  For example, a table
partition can be recovered, undergo DML (insert, update, delete) transactions,
be analyzed, etc.  without affecting the other partitions.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

3. What are advantages of Partitioned Tables?

Answer
------
The primary benefit of the partitioning option is ease of maintenance on
very large tables and improved reliability. This is important for both OLTP
and data warehousing environments. Partitioning also provides performance
improvements via partition elimination.

References
----------
Oracle8 Server Concepts

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


4. What is a Partitioned Index?

Answer
------

The primary benefit of partitioning an index is better query access plans
and improved reliability.

There are three types of partitioned indexes:

a) Global Prefixed
b) Local Prefixed
c) Local Non-prefixed


References
----------
Oracle8 Server Concepts

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


5. What is a Local Prefixed/Non-Prefixed index?

Answer
------
Local indexes are indexes on partitioned tables where the index contains
ROWID pointers that refer to rows in only one partition. Local index partitions
usually use the same partition keys as the partitioned table; this is called
equi-partitioning.

Prefixed index: means that the partition key is based on the left most columns
                in the index.

Non-Prefixed index: means that the partition key is based on something else than
                    the left most columns in the index.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

6. What is a Global index?

Answer
------
Global Indexes are partitioned either on the same key than the underlying table
but different ranges either on a different key.

**Oracle only supports prefixed global partitioned indexes.

An index is global prefixed if it is partitioned on the left prefix of the
index columns.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

7. How to Create a partitioned Table?

Answer
------
Use the new enhanced create table syntax to specify the partition key(s)
and range of values for each partition.  The partition name is optional;
if omitted, Oracle generates automatically the partition names.

For example:
Create a table emp partition on the EMPNO column (partition key)

 CREATE TABLE emp
                     (EMPNO NUMBER(5),
                     ...)
                   PARTITION BY RANGE(EMPNO)
                  PARTITION emp_p1 VALUES LESS THAN (2000),
                  PARTITION emp_p2 VALUES LESS THAN (4000),
                  PARTITION emp_p3 VALUES LESS THAN (MAXVALUE);

Please refer to the Oracle8 Server SQL Reference for complete syntax.

References
----------
Oracle8 Server SQL Reference.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

8. What are the restrictions for Partitioned tables?

Answer
------
a) Datatype Restrictions
   Partitioned tables cannot have any columns with LONG or LONG RAW datatypes,
   LOB datatypes (BLOB, CLOB, NCLOB, or BFILE), or object types. We expect to
   support partitioning of tables that contain LOBs in 8.1.

b) Clusters cannot be partitioned

c) Bitmap Restrictions
   The only restriction is that bitmap indexes must be local to the
   partitioned table-they cannot be global indexes (See "Index Partitioning"
   on page Oracle8 8-19 for information about local indexes.)

d) Optimizer Restrictions
    Oracle8 COST BASED Optimizer supports partitions. Rule Base Optimizer is
    not "partition aware" and  will not support partition elimination. So any
    application still using RBO will not gain any performance benefits from
    using partitioned tables or indexes; they can, however, make use of
    ease of administration and availability features of partitioned tables.

c) Physical Restrictions
   Partitioned tables cannot span multiple databases, they must be within one
   instance.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


9. How to manipulate partitions?

Answer
------
Use Partition-Extended Table Names.

The table specification syntax for the following DML statements may contain an
optional partition specification for non-remote partitioned tables.

Partition-Extended Table Name:

  "schema.table PARTITION (part_name)"

where schema is the schema owner, table is the base table name,
PARTITION is an optional keyword, and partition_name is the name
of the partition if the PARTITION keyword was specified.

The partition-extented table name can be used in the following DML statements:
     INSERT
     UPDATE
     DELETE
     LOCK TABLE
     SELECT

Q) How can I insert data into a particular partition?
   SQL> insert into sales partition (p8) values (7000, 'bcd', 10, 30);

Q) How can I delete data from a particular partition?
   SQL> delete from sales partition (p8);

Q) How can I update a particular partition?
   SQL> update sales partition (p8) set sales_amount = 20;

Q) How can I select from a particular partition?
   SQL> select * from sales PARTITION (Q4);

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

10. What are the restrictions on partition-extended table names?

Answer
------
The use of partition-extended table names has the following restrictions:

   A. A partition-extended table name cannot refer to a remote schema object.

      A partition-extended table name cannot contain a dblink or a
      synonym, which translates to a table with a dblink.
      If you need to use remote partitions, you can create a view at the
      remote site, which uses the partition-extended table name syntax
      and refer to that remote view.

   B. The partition-extended table name syntax is not supported by PL/SQL.

      A SQL statement using the partition-extended table name syntax cannot
      be used in a PL/SQL block, though it can be used through dynamic SQL
      via the DBMS_SQL package. Again, if you need to refer to a partition
      within a PL/SQL block you can instead use views which in turn use the
      partition-extended table name syntax.

   C. Only base tables are allowed.

      A partition extension must be specified with a base table.
      No synonyms, views, or any other schema objects are allowed.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

11. What is the difference between Table-Level and Partition-Level Export/Import?

Answer
------
Understanding Table-Level and Partition-Level Export (Server Utilities)

In table-level Export, an entire partitioned or non-partitioned table, along
with its indexes and other table-dependent objects, is exported. All the
partitions of a partitioned table are exported. (This applies to both direct
path Export and conventional path Export.) All Export modes (full, user, table)
support table-level Export.

In partition-level Export, the user can export one or more specified partitions
of a table. Full database and user mode Export do not support partition-level
Export; only table mode Export does. Because incremental Exports (incremental,
cumulative, and complete) can be done only in full database mode, partition-
level Export cannot be specified for incremental exports.

Partition-level Import cannot import a non-partitioned exported table. However,
a partitioned table can be imported from a non-partitioned exported table using
table-level Import. Partition-level Import is legal only if the source table
(that is, the table called table-name at export time) was partitioned and
exists in the Export file.

 If the partition-name is not a valid partition in the export file, Import
generates a warning.

In all modes, partitioned data is exported in a format such that partitions can
be imported selectively.

For information on how to specify a partition-level Export, see "TABLES" on
page 1-20.

TABLES=
     schema_name: schema owner of the table/to be exported
     tables_name: table to be exported/imported
     partition-name: indicates that the export is a partition-level Export.

Partition-level Export lets you export one or more specified partitions within
a table.

If you use table-name:partition-name, the specified table must be partitioned,
and partition-name must be the name of one of its partitions.

The presence of a table-name:partition-name with the TABLES parameter results
in reading from the Export file only data rows from the specified source
partition. If you do not specify the partition-name, the entire table is used
as source. Import issues a warning if the specified partition is not in the
list of partitions in the exported table.

Data exported from one or more partitions can be imported into one or more
partitions. Import inserts rows into partitions based on the partitioning
criteria in the import database.

The following line shows an example of a partition-level Export:

exp system/manager FILE = export.dmp TABLES = (scott.b:px, scott.b:py, mary.c,
d:qb)

In this example, scott.b must be a partitioned table, and px and py must be two
of its partitions. The table denoted by mary.c can be a partitioned or
non-partitioned table. Table d, however, must be a partitioned table, and qb
must be one of its partitions.

If the table-name or partition-name for the same table is used redundantly in
the command line, Export aborts with an error. For example, the following
partition-level Export command line with a redundant specification for table sc
and partition px of table sc causes Export to abort with an error:

exp system/manager FILE = export.dmp TABLES = (sc, sc:px, sc)

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

12. How to convert a partitioned table or view into non-partitioned table?

Answer
------
Use the alter  table EXCHANGE PARTITION syntax to accomplish this. This
operation is very fast as it only updates the data dictionary to indicate
that the swap has taken place. SPLIT PARTITION may also be useful when you are
dealing with very large partitions or partition Views.

create dummy partitioned tables to receive (or be exchanged with) the table or
view data

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

13. How to Partition an non-partitioned table?

Answer
------
 SQL:
   1. Create table dummy_t as select with the required partitions
   2. Alter table EXCHANGE partition T with dummy_T
   3. Drop table T

exp/imp:    
Perform the following steps to partition an non-partitioned table:
   1.Export the table to save the data.
   2.Drop the table from the database.
   3.Create the table again with partitions.
   4.Import the table data.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

14. How to Merge table partitions?

Answer
------
Export/Import:
Partition-level Export and Import provide a way to merge partitions in the same
table, even though SQL does not explicitly support merging partitions. A DBA
can use partition-level Import to merge a table partition into the next highest
partition on the same system. See "Example 2: Merging Partitions of a Table" on
page 2-36 for an example of merging partitions.

CTAS:
  1. Create a temporary table to hold the partition data
  2. Drop the partition to be merged
  3. Insert into Table (select * from temporary table)
  4. Drop temp.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

15. How to split a table Partition?

Answer
------
Partition-level Export and Import do not provide for splitting a partition.
For information on how to split a partition, refer to the Oracle8 Server
Administrator's Guide.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


16. Can you update a partition key column(s) if the update causes rows to be
    moved from one partition to another?

Answer
------
With 8.0, No. If you try to update a partition key that would cause the row
to move from one partition to another, you will see error message
ORA-14402; Updating partition key column would cause a partition
change.

With 8.1, you can update the value of a partition key column

    sql>alter table enable row movement;

See Note:73474.1 Update Partition Keys for example.
Row Movement is disabled by default on all tables. You may check the
status of ROW_MOVEMENT on dba and user_tables.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
       
17. Are there restrictions on importing into partitions or with NLS
    character sets?

Answer
------
Yes.



Importing partitioned tables into a database
with a different  character set will fail.

E.g. Export from US7ASCII, import to WE8ISO8859P1. Import will fail with:
     ORA-14037: partition bound of partition "P_2" is too high
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

18. What are the effects of exchange on local and global indexes?

Answer
------

A global index will require rebuilding after an exchange partition.
If the INCLUDING INDEXES clause is used in the exchange, local indexes on the
will be exchanged with the corresponding regular indexes. If the EXCLUDING
INDEXES clause is used, all the local index partitions corresponding to the
partition and all the regular indexes on the exchanged table are marked as
unusable and will have to be rebuilt.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

19) How to check whether partitioning is being used in a database?

Starting from 10g you can query the DBA_FEATURE_USAGE_STATISTICS view to get this information.

select name, version, last_usage_date,currently_used from DBA_FEATURE_USAGE_STATISTICS where upper(name) like '%PARTITION%';


------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
20)

How do I know if an object is partitioned or not?

A simple query against the data dictionary will show if a given table or index is partitioned or not:
SELECT * FROM dba_part_tables;
SELECT * FROM dba_part_indexes;


------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
21) How does one list the partitions of a partitioned object?

One can list the partitions of a table with:
SELECT * FROM dba_tab_partitions WHERE table_name = '';

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
22) What partitioning types does Oracle support?

Oracle support the following partitioning methods:
Range partitioning - data is mapped to partitions based on a range of column values (usually a date column)
Hash partitioning - data is mapped to partitions based on a hashing algorithm, evenly distributing data between the partitions.
List partitioning - data is mapped to partitions based on a list of discrete values.
Interval partitioning - data is mapped to partitions based on an interval
Composite partitioning - combinations of the above methods
Range-Hash partitioning - data is partitioned by range, then hashed to sub-partitions.
Range-List partitioning - data is partitioned by range, then to sub-partitions based on a value list.
Range-range partitioning
List-range partitioning
List-hash partitioning
List-list partitioning
Interval partitioning, an extension of range partitioning. New partitions are automatically added.
System partitioning, application controlled partitioning.
Reference partitioning, partitioned like a parent table (referenced in a referential constraint).


Partitioning types

Available partitioning types:
Range partitioning (introduced in Oracle 8)
Hash partitioning (introduced in Oracle 8i)
Composite partitioning (introduced in Oracle 8i)
List partitioning (introduced in Oracle 9i)
Interval partitioning (introduced in Oracle 11g)
System partitioning (introduced in Oracle 11g)
Reference partitioning (introduced in Oracle 11g)


------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
====================================================================================

Comments

  1. No matter what database platform you’re running, dbaDIRECT is your answer for 24×7 monitoring and expert skill, at a lower cost than what’s possible with internal administration. We offer each of our core remote management services for all major database platforms, including Oracle, Sybase, MySQL, SQLServer, and IBM DB2. Our team of DBAs is here ’round the clock for your database needs, capable of servicing any size organization at any time of the day. Period.
    Remote dba services support 24x7 of below mentioned applications - more… Online Training- Corporate Training- IT Support U Can Reach Us On +917386622889 - +919000444287
    http://www.21cssindia.com/support.html

    ReplyDelete
  2. Great collection of question and answers thank you for sharing. Follow the link if you want Oracle DBA Online Training

    ReplyDelete
  3. useful information , we want more like this type of question and answersoracle courses

    ReplyDelete
  4. Continuously Facing “Connect to Oracle” Error? Contact to Cognegic’s Remote DBA Services
    Most of the users trying to connect to Oracle using SSMA i.e. “SQL Server Migration Assistance” but they got an error message. If you are the same guy who facing these technical hiccups then first let me tell you ODAC (Oracle Data Access Components) are required for applications to connect to Database. Make sure this is very long process so you have to get in touch with most talented and professional expert who resolves this issue and that team is Oracle Database System or Database Administration for Oracle. Here we provide Online Oracle DB Support so that you do not have to face the same issue.
    For More Info: https://cognegicsystems.com/
    Contact Number: 1-800-450-8670
    Email Address- info@cognegicsystems.com
    Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801

    ReplyDelete
  5. Howdy Mate,

    So bloody thorough! Ah! So happy and blissed out! I feel redeemed by reading out Oracle DBA Information at one place . Keep up the good work!

    I read in articles Linux and BSD are increasingly filling the market needs traditionally served by proprietary Unix operating systems, as well as expanding into new markets such as the consumer desktop and mobile and embedded devices. Is it killing the Windows device market?

    Anyways great write up, your efforts are much appreciated.

    ,Merci
    Irene Hynes

    ReplyDelete
  6. How to fathom Oracle 11g Decimal Issue? Contact to Remote DBA Services
    Prophet decimal issue is a standout amongst the most widely recognized issue which typically looked by the Oracle client. In any case, with some fundamental abilities and information you can without much of a stretch handle this issue however in the event that not then you can choose Database Administration for Oracle or Online Oracle DB Support for fast Oracle decimal issue. Our exceptionally experienced specialized specialists give you cost-sparing administrations which drive better consistency all through the Oracle condition.
    For More Info: https://cognegicsystems.com/
    Contact Number: 1-800-450-8670
    Email Address- info@cognegicsystems.com
    Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801

    ReplyDelete
  7. Do you want to pass 1Z0-447 exam in 1st try? Pass your OPN Certified Specialist 1Z0-447 easily by the help of latest 1Z0-447 dumps questions & answers. Your Oracle GoldenGate 12c Implementation Essentials success is guaranteed with our 100% money back guarantee. Braindumps4IT provide real 1Z0-447 exam questions and latest 1Z0-447 exam braindumps.

    ReplyDelete
  8. Step by step instructions to Solve Oracle Import Error through Remote DBA Services
    At whatever point you will do import into your Oracle 10g server from a similar fare document then you will get a blunder message which imply that "Mistake 1400" and you additionally not ready to embed NULL into section. For this issue in the event that you are searching for help then I recommend you to connect with Cognegic's Online Oracle DB Support or Database Administration for Oracle. We truly take every one of the issues and offering gigantic help in regards to your Oracle Database. Cash doesn't make a difference for us in light of the fact that our principle witticism is to investigate your issue under your financial plan.
    For More Info: https://cognegicsystems.com/
    Contact Number: 1-800-450-8670
    Email Address- info@cognegicsystems.com
    Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801

    ReplyDelete
  9. Thanks for providing the information . The articles in your blog helped me a lot for improving the knowledge on the subject. Also check my small collection on this at Java online course blog

    ReplyDelete
  10. A universal message I suppose, not giving up is the formula for success I think. Some things take longer than others to accomplish, so people must understand that they should have their eyes on the goal, and that should keep them motivated to see it out til the end.
    Data Science course in rajaji nagar
    Data Science with Python course in chenni
    Data Science course in electronic city
    Data Science course in USA
    Data science course in pune | Data Science Training institute in Pune

    ReplyDelete
  11. I would really like to read some personal experiences like the way, you've explained through the above article. I'm glad for your achievements and would probably like to see much more in the near future. Thanks for share.
    python training in chennai
    python course institute in chennai

    ReplyDelete
  12. This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.

    rpa training in chennai
    rpa training in bangalore | best rpa training in bangalore | rpa course in bangalore | rpa training institute in bangalore | rpa training in bangalore | rpa online training

    ReplyDelete
  13. Hmm, it seems like your site ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well as an aspiring blog writer, but I’m still new to the whole thing. Do you have any recommendations for newbie blog writers? I’d appreciate it.
    Top 250+AWS Interviews Questions and Answers 2018 [updated]
    Learn Amazon Web Services Tutorials 2018 | AWS Tutorial For Beginners
    Best AWS Interview questions and answers 2018 | Top 110+AWS Interview Question and Answers 2018
    AWS Training in Pune | Best Amazon Web Services Training in Pune
    AWS Online Training 2018 | Best Online AWS Certification Course 2018
    Best Amazon Web Services Training in Pune | AWS Training in Pune

    ReplyDelete
  14. I appreciate your efforts because it conveys the message of what you are trying to say. It's a great skill to make even the person who doesn't know about the subject could able to understand the subject . Your blogs are understandable and also elaborately described. I hope to read more and more interesting articles from your blog. All the best.
    Java training in Bangalore | Java training in Btm layout

    Java training in Bangalore |Java training in Rajaji nagar

    Java training in Bangalore | Java training in Kalyan nagar

    Java training in Bangalore | Java training in Kalyan nagar

    Java training in Bangalore | Java training in Jaya nagar

    ReplyDelete
  15. Excellant post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
    Best Devops Training in pune

    ReplyDelete
  16. This comment has been removed by the author.

    ReplyDelete
  17. nice post
    https://docs.google.com/document/d/1KTIne8qts5OBAajsi8WxA3OCc5i61uiBQEKUealuL18/edit?ts=5f046b0c

    ReplyDelete
  18. You added such an extraordinary piece to recover, giving totally part of portion of circumstance edification for us to benefit assessment. gratitude for sharing such recommend when us due to which my few standards were cleared. X Force Keygen Free Download

    ReplyDelete
  19. I could following to appreciation for the undertakings you have made recorded as a printed copy this leaflet. I'm trusting the thesame fine take diversion doings from you inside the thinking of as capably. thankful to you...
    Bitdefender Activate

    ReplyDelete
  20. I have a melody in my heart. You’re the reason I sing the song that I do. And it’s all because you’re a year older today. Baby, happy birthday to you. Your future will shine so bright than you ever imagined.
    Boyfriend Birthday Card Message

    ReplyDelete
  21. great, valuable post , i have learned many intresting thing about sql from your blog, thanks . keep posting and checking out my blog if your intresting in python course in satara

    ReplyDelete
  22. Very well explained.Keep up with your good work.
    SQL Classes in Pune

    ReplyDelete

Post a Comment

Oracle DBA Information