Beruflich Dokumente
Kultur Dokumente
You have taken import of a table in a database. You have got the Integrity constraint violation error.
How you are going to resolve it.
If u wants to import the table just says constraints=n the movement table got imported then u create
constraint on that tables.
What is the most important action a DBA must perform after changing the database from
NOARCHIVELOG TO ARCHIVELOG?
First of all take an offline backup of whole database (including the (datafile controlfile and redolog files). It is
obvious that archive log process should be started by:
SQL>alter system Archivelog start;
Otherwise the database halts if unable to rotate redo logs
Show one instance when you encountered an error in alert log and you overcome that error. What
actions you took to overcome that error.
Oracle writes error in alert log file. Depending upon the error corrective action needs to be taken.
1) Deadlock Error: Take the trace file in user dump destination and analysis it for the error.
2) ORA-01555 Snapshot error: Check the query try to fine tune and check the undo size.
3) Unable to extent segment: Check the tablespace size and if require add space in the tablespace by
'alter database datafile .... resize' or alter tablespace add datafile command.
What is Ora-1555 Snapshot too Old error? Explain in detail?
Oracle Rollback Segments (Undo more recently) hold a copy of data before it was modified and they work in
a round-robin fashion. Writing and then eventually overwriting the entries as soon as the changes are
committed.
They are needed to provide read consistency (a consistent set of data at a point in time) or to allow a
process to abandon or rollback the changes or for database recovery.
Heres a typical scenario:User A opens a query to fetch every row from a billion row table. If User B updates and commits the last row
of the billion row table a Rollback entry will be created so User A can see the data as it was before the
update.
Other users are busily updating rows in the database and this in turn generates rollback which may
eventually cause the entry needed for User A to be overwritten (after all User B did commit the change so
its OK to overwrite the rollback segment). Maybe 15 minutes later the query is still running and User A finally
fetches the last row of the billion row table but the rollback entry is gone. He gets ORA-01555: Snapshot
too old rollback segment too small
I have applied the following commands: Now what will happen, will the database will give an error / it
will work?
Shutdown abort;
Startup;
Definitely database will be start without error but all uncommitted data will be lost such as killed all
sessions, killed all transactions, and didn't write from the buffers because shutdown abort directly
shutdown instance without committing.
There is four modes to shutdown the database:
1) Shutdown immediate, 2) Shutdown normal, 3) Shutdown transactional, 4) Shutdown aborts
When the database is shutdown by first 3 methods checkpoint takes place but when is shutdown by abort
option it doesn't enforces checkpoints, it simply shutdowns without waiting any users to disconnect.
What is mutated trigger? In single user mode we got mutated error, as a DBA how you will resolve it?
Mutated error will occur when same table access more than once in one state. If you are using before in
trigger block then replace it with after.
Explain Dual table. Is any data internally stored in dual Table. of users is accessing select sysdate
from dual and they getting some millisecond differences. If we execute SELECT SYSDATE FROM
This query will returns NULL in the value column if you are using pfile and not spfile
3) SELECT COUNT(*) FROM v$spparameter WHERE value IS NOT NULL;
If the count is non-zero then the instance is using a spfile, and if the count is zero then it is using a pfile:
SQL> SELECT DECODE(value, NULL, 'PFILE', 'SPFILE') "Init File Type"
FROM sys.v_$parameter WHERE name = 'spfile';
What is full backup?
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. If you are using the Rman for backup
then in Rman full backup means Incremental backup on 0 level.
While taking hot backup (begin end backup) what will happens back end?
When we r taking hot backup (begin backup - end backup) the datafile header associated with the datafiles
in the corresponding Tablespace is frozen. So Oracle will stop updating the datafile header but will continue
to write data into datafiles. In hot backup oracle will generate more redos this is because oracle will write out
complete changed blocks to the redo log files.
Which is the best option used to move database from one server to another serve on same network
and Why?
Import Export, Backup-Restore, Detach-Attach
Import-Export is the best option used to move database from one server to another serve on same network.
It reduces the network traffic.Import/Export works well if youre dealing with very small databases. If we have
few million rows its takes minutes to copy when compared to seconds using backup and restore.
What is Different Type of RMAN Backup?
Full backup: During a Full backup (Level 0) all of the block ever used in datafile are backed up. The only
difference between a level 0 incremental backup and a full backup is that a full backup is never included in
an incremental strategy.
Comulative Backup: During a cumulative (Level 0) the entire block used since last full backup are backed
up.
RMAN> BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE; # blocks changed since level 0
Differential Backup: During incremental backup only those blocks that have changed since last cumulative
(Level 1) or full backup (Level 0) are backed up. Incremental backup are differential by default.
RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE
Give one method for transferring a table from one schema to another:
There are several possible methods: Export-Import, CREATE TABLE... AS SELECT or COPY.
What is the purpose of the IMPORT option IGNORE? What is its default setting?
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.
What happens when the DEFAULT and TEMP tablespace clauses are left out from CREATE USER
statements?
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).
What happens if the constraint name is left out of a constraint clause?
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.
What happens if a Tablespace clause is left off of a primary key constraint clause?
This result 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.
What happens if a primary key constraint is disabled and then enabled without fully specifying the
index clause?
The index is created in the users default tablespace and all sizing information is lost. Oracle doesnt 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.
Using hot backup without being in archive log mode, can you recover in the event of a failure? Why
or why not?
You can't recover the data because in archive log mode it take the backup of redo log files if it in Active
mode, If it in inactive mode then it is not possible to take the backup of redolog files once the size is full, so in
that case it is impossible to take hot backup
What causes the "snapshot too old" error? How can this be prevented or mitigated?
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.
How can you tell if a database object is invalid?
select STATUS from user_objects where object_type='TABLE' AND
OBJECT_NAME='LOGMNRT_TABPART$';
A user is getting an ORA-00942 error yet you know you have granted them permission on the table,
what else should you check?
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 that object (CREATE SYNONYM
emp FOR scott.emp;)
A developer is trying to create a view and the database wont 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?
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 a role.
If you have an example table, what is the best way to get sizing data for the production table
implementation?
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.
How can you find out how many users are currently logged into the database? How can you find
their operating system id?
To look at the v$session or v$process views and check the current_logins parameter in the v$sysstat view. 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.
How can you determine if an index needs to be dropped and rebuilt?
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 isnt 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. It is not so easy
to decide so I personally suggest contact to the expert before going to rebuild.
What is tkprof and how is it used?
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.
What is Explain plan and how is it used?
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.
How do you prevent output from coming to the screen?
The SET option TERMOUT controls output to the screen. Setting TERMOUT OFF turns off screen output.
This option can be shortened to TERM.
How do you prevent Oracle from giving you informational messages during and after a SQL
statement execution?
The SET options FEEDBACK and VERIFY can be set to OFF.
How do you generate file output from SQL?
By use of the SPOOL command
A tablespace has a table with 30 extents in it. Is this bad? Why or why not.
Multiple extents in and of themselves arent bad. However if you also have chained rows this can hurt
performance.
The SMON process would not automatically coalesce its free space fragments.
If a tablespace shows excessive fragmentation what are some methods to defragment the
tablespace? (7.1,7.2 and 7.3 only)
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 is not contiguous then export, drop and import of the tablespace contents may be the only
way to reclaim non-contiguous free space.
How can you tell if a tablespace has excessive fragmentation?
If a select against the dba_free_space table shows that the count of tablespaces extents is greater than the
count of its data files, then it is fragmented.
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?
Since the wait time is zero, no problem. If the wait time was high it might indicate a need for more or larger
redo logs.
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?
This indicates that the shared pool may be too small. Increase the shared pool size.
If you see the value for reloads is high in the estat library cache report is this a matter for concern?
Yes, you should strive for zero reloads if possible. If you see excessive reloads then increase the size of the
shared pool.
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?
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.
You look at the dba_rollback_segs view and see that you have a large number of wraps is this a
problem?
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.
You see multiple extents in the Temporary Tablespace. Is this a problem?
As long as they are all the same size this is not a problem. In fact, it can even improve performance since
Oracle would not have to create a new extent when a user needs one.
How do you set up your Tablespace on installation Level: Low?
The answer here should show an understanding of separation of redo and rollback, data and indexes and
isolation of SYSTEM tables from other tables. An example would be to specify that at least 7 disks should be
used for an Oracle installation.
Disk Configuration:
SYSTEM tablespace on 1, Redo logs on 2 (mirrored redo logs), TEMPORARY tablespace on 3, ROLLBACK
tablespace on 4, DATA and INDEXES 5,6
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.
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?
Check to make sure that the archiver is not 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.
When configuring SQLNET on the server what files must be set up?
INITIALIZATION file, TNSNAMES.ORA file, SQLNET.ORA file
When configuring SQLNET on the client what files need to be set up?
SQLNET.ORA, TNSNAMES.ORA
You have just started a new instance with a large SGA on a busy existing server. Performance is
terrible, what should you check for?
The first thing to check with a large SGA is that it is not being swapped out.
What OS user should be used for the first part of an Oracle installation (on UNIX)?
You must use root first.
When should the default values for Oracle initialization parameters be used as is?
Never
How many control files should you have? Where should they be located?
At least 2 on separate disk spindles (Mirrored by Oracle).
How many redo logs should you have and how should they be configured for maximum
recoverability?
You should have at least 3 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.
Why are recursive relationships bad? How do you resolve them?
A recursive relationship defines when or where a table relates to itself. It is considered as 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 could not 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.
What does a hard one-to-one relationship mean (one where the relationship on both ends is "must")?
This means the two entities should probably be made into one entity.
How should a many-to-many relationship be handled?
By adding an intersection entity table
What is an artificial (derived) primary key? When should an artificial (or derived) primary key be
used?
A derived key comes from a sequence. Usually it is used when a concatenated key becomes too
cumbersome to use as a foreign key.
When should you consider de-normalization?
Whenever performance analysis indicates it would be beneficial to do so without compromising data integrity.
-UNIXHow can you determine the space left in a file system?
There are several commands to do this: du, df, or bdf
How can you determine the number of SQLNET users logged in to the UNIX system?
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.
What command is used to type files to the screen?
cat, more, pg
Can you remove an open file under UNIX?
Yes
What is the purpose of the grep command?
grep is a string search command that parses the specified string from the specified file or files
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?
ps -ef|grep *nocomp*|wc -l
The system administrator tells you that the system has not been rebooted in 6 months, should he be
proud of this?
Most UNIX systems should have a scheduled periodic reboot so file systems can be checked and cleaned
and dead or zombie processes cleared out. May be, Some UNIX systems do not clean up well after
themselves. Inode problems and dead user processes can accumulate causing possible performance and
corruption problems.
How can you find dead processes?
ps -ef|grep zombie -- or -- who -d depending on the system.
How can you find all the processes on your system?
Use the ps command
How can you find your id on a system?
Use the "who am i" command.
What is the finger command?
The finger command uses data in the passwd file to give information on system users.
What is the easiest method to create a file on UNIX?
Use the touch command
What does >> do?
The ">>" redirection symbol appends the output from the command specified into the file specified. The file
must already have been created.
If you are not sure what command does a particular UNIX function what is the best way to determine
the command?
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.
How can you determine if an Oracle instance is up from the operating system level?
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 ps -ef|grep pmon will show what instances are up.
Users from the PC clients are getting messages indicating : ORA-06114: NETTCP: SID lookup failure.
What could the problem be?
The instance name is probably incorrect in their connection string.
Users from the PC clients are getting the following error stack:
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?
The Oracle instance is shutdown that they are trying to access, restart the instance.
How can you determine if the SQLNET process is running for SQLNET V1? How about V2?
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".
What file will give you Oracle instance status information? Where is it located?
The alert.ora log. It is located in the directory specified by the background_dump_dest parameter in the
v$parameter table.
Users are not being allowed on the system. The following message is received: ORA-00257 archiver
is stuck. Connect internal only, until freed. What is the problem?
The archive destination is probably full, backup the archivelogs and remove them and the archiver will restart.
Where would you look to find out if a redo log was corrupted assuming you are using Oracle
mirrored redo logs?
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.
You attempt to add a datafile and get: ORA-01118: cannot add anymore datafiles: limit of 40
exceeded. What is the problem and how can you fix it?
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.
You look at your fragmentation report and see that smon has not coalesced any of you tablespaces,
even though you know several have large chunks of contiguous free extents. What is the problem?
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.
Your users get the following error: ORA-00055 maximum number of DML locks exceeded? What is
the problem and how do you fix it?
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.
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?
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.
You have taken a manual backup of a datafile using OS. How RMAN will know about it?
Whenever we take any backup through RMAN in the repository information of the backup is recorded. The
RMAN repository can be either controlfile or recovery catalog. However if you take a backup through OS
command then RMAN does not aware of that and hence recorded are not reflected in the repository. This is
also true whenever we create a new controlfile or a backup taken by RMAN is transferred to another place
using OS command then controlfile/recovery catalog does not know about the prior backups of the database.
So in order to restore database with a new created controlfile we need to inform RMAN about the backups
taken before so that it can pick one to restore.
This task can be done by catalog command in RMAN.
Add information of backup pieces and image copies in the repository that are on disk.
The above query will displays for each sort segment in the database the tablespace the segment resides in,
the size of the tablespace, the amount of space within the sort segment that is currently in use, and the
amount of space available.
What is the frequency of log Updated..?
Whenever commit, checkpoint or redolog buffer is 1/3rd full, Time out occurs (3 sec.), 1 MB of redo log buffer
What are the Possibilities of Logical Backup (Export/Import)
- We can export from one user and import into another within the same database.
- We can export from one database and import into another database (but both source and destination
databases
should be are ORACLE databases)
- When migrating from one platform to another like from windows to sun Solaris then export is the only
method
to transfer the data.
What is stored in Oratab file
"oratab" is a file created by Oracle in the /etc or /var/opt/oracle directory when installing database software.
Originally ORATAB was used for SQL*Net V1, but lately it is being used to list the databases and software
versions installed on a server.
database_sid:oracle_home_dir:Y|N
The Y|N flags indicate if the instance should automatically start at boot time (Y=yes, N=no).
Besides acting as a registry for what databases and software versions are installed on the server, ORATAB
is also used for the following purposes:
Oracle's "dbstart" and "dbshut" scripts use this file to figure out which instances are to be start up or
shut down (using the third field, Y or N).
The "oraenv" utility uses ORATAB to set the correct environment variables.
One can also write Unix shell scripts that cycle through multiple instances using the information in the
oratab file.
In your database some blocks of particular datafile are corrupted. What statement will you issue
to know how many blocks are corrupted?
You can check the " Select * from V$DATABASE_BLOCK_CORRUPTION; " view to determine the
corrupted blocks.
What is a flash back query? This feature is also available in 9i. What are the difference between 9i
and 10g (related to flash back query).
Oracle 9i flashback 10g enhancement
Flashback query:
Flashback version query
Flashback_Transactional_query view
10g new Features:
Flashback Table
Flashback database
Setup for new feature:
AUM
Flash Recovery Area
Describe the use of %ROWTYPE and %TYPE in PL/SQL
%ROWTYPE allows you to associate a variable with an entire table row. The %TYPE associates a variable
with a single column type.
How can the problem be resolved if a SYSDBA, forgets his password for logging into enterprise
manager?
There are two ways to do that:
1. Login as SYSTEM and change the SYS password by using ALTER USER.
2. Recreate the password file using orapwd and set remote_password_file exclusive and then restart the
instance.
3. Also you can enter as / as sysdba and then after change the password Alter user sys identified by xxx;
How many maximum number of columns can be part of primary key in a table in 9i and 10g.
You can set primary key in a single table up to 16 columns of table in oracle 9i and 10g.
What is RAC?
RAC stands for Real Application Cluster. In previous versions, it is known as PARALLEL SERVER. RAC is a
mechanism that allows multiple instances (on different hosts/nodes) to access the same database. The
benefits: It provides more memory resources, since more hosts are being used; If one host gets down, then
other host assumes it's work load.
What is Data Pumping?
Data Pumping is a data movement utility. This is a replacement to imp/exp utilities. The earlier imp/exp
utilities are also data movement utilities, but they work within the local servers only. Where as, impdp/expdp
(Data pumping) are very fast and perform data movements from one database to another database on same
as well as different host. In other words, it provides secure transports.
What is Data Migration?
Data migration is actually the translation of data from one format to another format or from one storage
device to another storage device. Data migration is necessary when a company upgrades its database
or system software, either from one version to another or from one program to an entirely different program.
What is difference between spfile and init.ora file
init.ora or spfile both are contains Database parameters information. Both are supported by oracle. Every
database instance required either any one. If both are present first choice is given
to spfile only. init.ora saved in the format of ASCII where as SPFILE saved in the format of
binary. init.ora information is read by oracle engine at the time of database instance started only that means
any modification made in this those are applicable in the next startup only. But in spfile modifications
(through alter system..... command) can applicable without restarting oracle database (restarting instance).
What is SCN? Where the SCN does resides?
SCN - System Change Number - is always getting incremented by Oracle server and will be used to make
sure the consistency across the database. The system change number (SCN) is an ever-increasing value
that uniquely identifies a committed version of the database. Every time a user commits a transaction. Oracle
records a new SCN. You can obtain SCNs in a number of ways for example from the alert log. You can then
use the SCN as an identifier for purposes of recovery. For example you can perform an incomplete recovery
of a database up to SCN 1030. Oracle uses SCNs in control files datafile headers and redo records. Every
redo log file has both a log sequence number and low and high SCN. SCN number will be updated in almost
all places of the database.
CONTROLFILE, DATAFILE HEADERS, REDOLOG FILES (and hence ARCHIVE LOG FILES), DATA
BLOCK HEADERS but not in ALERT LOG file as it is not part of database.
How to know which query is taking long time?
By testing with the help of these tools tkprof or using explain plan. tkprof is available to DBA Only where as
explain plan can run programmer as well as DBA also. As well as tkprof generates complexilty after
sucessful execution only where as explain plan can show Oracle internal plan & other details. Even though
they are not alternatives for one to another. But both are designed for one purpose only. They are two
different tools they are engaged in different useful situations also you can use STATSPACK to take Snaps
while running those queries and get the report with details of SQL taking more time to
respond otherwise, you can search Top ten sql with the following views:
SQL>SELECT * FROM V$SQL;
SQL>SELECT * FROM V$SQLAREA;
SQL>SELECT * FROM (SELECT rownum Substr(a.sql_text 1 200) sql_text
Trunc(a.disk_reads/Decode(a.executions 0 1 a.executions)) reads_per_execution a.buffer_gets a.disk_reads
a.executions a.sorts a.address FROM v$sqlarea a ORDER BY 3 DESC)WHERE rownum < 10;
How can you check which user has which Role.
Sql>Select * from DBA_ROLE_PRIVS order by grantee;
What are clusters
Groups of tables physically stored together because they share common columns and are often used
together is called clusters.
Name (init.ora) parameters which affects system performance.
These are the Parameters for init.ora which affect system performance
DB_BLOCK_BUFFERS; SHARED_POOL_SIZE; SORT_AREA_SIZE; DBWR_IO_SLAVES;
ROLLBACK_SEGMENTS; SORT_AREA_RETAINED_SIZE; B_BLOCK_LRU_EXTENDED_STATISTICS
SHARED_POOL_RESERVE_SIZE
How do you rename a database?
Prior to the introduction of the DBNEWID (NID) utility alteration of the internal DBID of an instance was
impossible and alteration of the DBNAME required the creation of a new controlfile. The DBNEWID utility
allows the DBID to be altered for the first time and makes changing the DBNAME simpler.
Steps: Change DBNAME only
1.Mount the database after clean shutdown.
2.Invoke the DBNEWID utility (NID) from the command line using sys user.
nid TARGET=sys/password@TSH2 DBNAME=TSH3 SETNAME=YES
Assuming the validation is successful the utility prompts for confirmation before performing the actions.
Note: The SETNAME parameter tells the DBNEWID utility to only alter the database name.
3.clean shutdown the database
SQL>SHUTDOWN IMMEDIATE
Set the DB_NAME initialization parameter in the initialization parameter file (PFILE) to the new database
name.
Note:The DBNEWID utility does not change the server parameter file (SPFILE). Therefore, if you use
SPFILE to start your Oracle database, you must re-create the initialization parameter file from the server
parameter file, remove the server parameter file, change the DB_NAME in the initialization parameter file,
and then re-create the server parameter file. Because you have changed only the database name, and not
thedatabase ID, it is not necessary to use the RESETLOGS option when you open the database. This
means that all previous backups are still usable.
4.Create a new password file.
orapwd file=c:\oracle\920\database\pwdTSH2.ora password=password entries=10
5.Open the database without Reset logs option
SQL>Startup;
Steps: change DBID only
Repeat the same above procedure
nid TARGET=sys/password@TSH3
Shutdown and open the database with RESETLOGS option
What is the view name where we can get the space for tables or views?
DBA_Segments;
SELECT SEGMENT_NAME, SUM(BYTES) FROM DBA_SEGMENTS
WHERE SEGMENT_NAME='TABLE_NAME' AND OWNER='OWNER OF THE TABLE GROUP BY
SEGMENT_NAME;
We cannot get the space of view because view does not have its own space it depend on base table.
What background process refreshes materialized views?
Job Queue processes
What view would you use to determine free space in a tablespace?
It is dba_free_space
SQL>SELECT TABLESPACE_NAME , BYTES FROM sm$ts_free;
SQL>SELECT TABLESPACE_NAME,SUM(BYTES/1024/1024) FROM
DBA_FREE_SPACE GROUP BY TABLESPACE_NAME;
If CPU is very slow, what can u do to speed?
Use VMSTAT to check the CPU enqueues or use also TOP and SAR commands for CPU load.
What would you use to improve performance on an insert statement that places millions of rows into that table?
Drop the indexes and recreate after insert.
DML Triggers to be DISABLED and then ENABLED once the insert completed.
DISABLE the Clustered Index and then ENABLED once the insert completed.
If Monday take full backup and Tuesday it was cumulative backup and Wednesday we taken incremental
backup, Thursday some disaster happen then what type of recovery and how it will take?
Restore the Monday full backup + Tuesday cumulative backup + Wednesday Incremental backup. Becausecumulative
and incremental clears the archives every backup
What is the difference between local managed Tablespace & dictionary managed Tablespace ?
The basic diff between a locally managed tablespace and a dictionary managed tablespace is that in the
dictionary managed tablespace every time a extent is allocated or deallocated data dictionary is updated
which increases the load on data dictionary while in case of locally managed tablespace the space
information is kept inside the datafile in the form of bitmaps every time a extent is allocated or deallocated
only the bitmap is updated which removes burden from data dictionary. The Tablespaces that record extent
allocation/deallocation in the dictionary are called dictionary managed tablespaces and tablespaces that
record extent allocation in the tablespace header are called locally managed tablespaces.
While installing the Oracle 9i ( 9.2) version, automatically system takes the space of approximately 4
GB. That is fine.... Now, if my database is growing up and it is reaching the 4GB of my database
space...Now, I would like to extend my Database space to 20 GB or 25 GB... what are the things i have
to do?
Optimizer statistics are a collection of data that describes more details about the database and the objects in
the database. The optimizer statistics are stored in the data dictionary. They can be viewed using data
dictionary views similar to the following:
SELECT * FROM DBA_SCHEDULER_JOBS WHERE JOB_NAME 'GATHER_STATS_JOB';
Because the objects in a database can constantly change statistics must be regularly updated so that they
accurately describe these database objects. Statistics are maintained automatically by Oracle Database or
you can maintain the optimizer statistics manually using the DBMS_STATS package.
Analyzing an Execution Plan
General guidelines for using the EXPLAIN PLAN statement are:
To use the SQL script UTLXPLAN.SQL to create a sample output table called PLAN_TABLE in your schema.
To include the EXPLAIN PLAN FOR clause prior to the SQL statement.
After issuing the EXPLAIN PLAN statement to use one of the scripts or packages provided by Oracle
Database to display the most recent plan table output.
The execution order in EXPLAIN PLAN output begins with the line that is indented farthest to the right. If two
lines are indented equally then the top line is normally executed first.
To analyze EXPLAIN PLAN output:
EXPLAIN PLAN FOR (YOUR QUERY);
EXPLAIN PLAN FOR SELECT p.prod_name c.channel_desc SUM(s.amount_sold) revenue
FROM products p channels c sales s
WHERE s.prod_id p.prod_id
AND s.channel_id c.channel_id
AND s.time_id BETWEEN '01-12-2001' AND '31-12-2001'GROUP BY p.prod_name c.channel_desc;
SELECT * FROM TABLE (DBMS_XPLAN.DISPLAY);
Using Advisors how to Verify SQL Performance?
Using the SQL Tuning Advisor and SQL Access Advisor you can invoke the query optimizer in advisory mode
to examine a given SQL statement or set of SQL statements and provide recommendations to improve their
efficiency. The SQL Tuning Advisor and SQL Access Advisor can make various types of recommendations
such as creating SQL profiles restructuring SQL statements creating additional indexes or materialized views
and refreshing optimizer statistics. Additionally Oracle Enterprise Manager enables you to accept and
implement many of these recommendations in very few steps
Difference between Rman Recovery Catalog or nocatalog Option?
The recovery catalog is an optional feature of RMAN though Oracle, recommends that you use it, it isnt
required. One major benefit of the recovery catalog is that it stores metadata about backups in a database
that can be reported or queried. Catalog means you have a recovery catalog database, nocatalog means
that you are using the controlfile as rman repository. Of course catalog option can only be used when
recovery catalog is present (which is not mandatory). From functional point of view there is no difference
either taking backup in catalog or nocatlaog mode.
What is Oracle Net?
Oracle Net is responsible for handling client-to-server and server to- server communications in an
Oracle environment. It manages the flow of information in the Oracle network infrastructure. Oracle Net is
used to establish the initial connection to the Oracle server and then it acts as the messenger, which passes
requests from the client back to the server or between two Oracle servers.
Difference of Backup Sets and Backup Pieces?
RMAN can store backup data in a logical structure called a backup set, which is the smallest unit of an
RMAN backup. A backup set contains the data from one or more datafiles, archived redo logs, or control files
or server parameter file. Backup sets, which are only created and accessed through RMAN, are the only
form in which RMAN can write backups to media managers such as tape drives and tape libraries.
A backup set contains one or more binary files in an RMAN-specific format. This file is known as a backup
piece. A backup set can contain multiple datafiles. For example, you can back up ten datafiles into a single
backup set consisting of a single backup piece. In this case, RMAN creates one backup piece as output. The
backup set contains only this backup piece.
What is an UTL_FILE? What are different procedures and functions associated with it?
The UTL_FILE package lets your PL/SQL programs read and write operating system (OS) text files. It
provides a restricted version of standard OS stream file input/output (I/O).
Subprogram -Description
FOPEN function-Opens a file for input or output with the default line size.
IS_OPEN function -Determines if a file handle refers to an open file.
FCLOSE procedure -Closes a file.
FCLOSE_ALL procedure -Closes all open file handles.
GET_LINE procedure -Reads a line of text from an open file.
PUT procedure-Writes a line to a file. This does not append a line terminator.
NEW_LINE procedure-Writes one or more OS-specific line terminators to a file.
PUT_LINE procedure -Writes a line to a file. This appends an OS-specific line terminator.
PUTF procedure -A PUT procedure with formatting.
FFLUSH procedure-Physically writes all pending output to a file.
FOPEN function -Opens a file with the maximum line size specified.
Differentiate between TRUNCATE and DELETE?
The Delete commands 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.
What is an Oracle Instance?
Instance is a combination of memory structure and process structure. Memory structure is SGA (System or
Shared Global Area) and Process structure is background processes.
Components of SGA:
Database Buffer Cache: It is further divided into Library Cache and Data Dictionary Cache or Row Cache,
Shared Pool/large pool/stream pool/java pool
Redo log Buffer,
Background Process:
Mandatory Processes (SMON, PMON, DBWR, LGWR, CKPT, RECO)
Optional Process (ARCN, RBAC, MMAN, MMON, MMNL)
When Oracle starts an instance, it reads the initialization parameter file to determine the values of
initialization parameters. Then, it allocates an SGA, which is a shared area of memory used for database
information, and creates background processes. At this point, no database is associated with these memory
structures and processes.
What information is stored in Control File?
The database name, The timestamp of database creation, The names and locations of associated datafiles
and redo log files, Tablespace information, Datafile offline ranges, The log history, Archived log
information, Backup set and backup piece information, Backup datafile and redo log information, Datafile
copy information, The current log sequence number
When you start an Oracle DB which file is accessed first?
To Start an instance, oracle server need a parameter file which contains information about the instance,
oracle server searches file in following sequence:
1) SPFILE ------ if finds instance started .. Exit
2) Default SPFILE -- if it is spfile is not found
3) PFILE -------- if default spfile not find, instance started using pfile.
4) Default PFILE -- is used to start the instance.
DB_8K_CACHE_SIZE=256
How many maximum Redo Logfiles one can have in a Database?
Maximum number of log files a database can accommodate depends on the parameter
"MAXLOGMEMBERS" specified during database creation. In a database we can create 255 maximum redo
log files. It depends on what you specified for MAXLOGFILES during database creation (manually) or what
you specified for "Maximum no. of redo log files" with DBCA.
What is PGA_AGGREGRATE_TARGET parameter?
PGA_AGGREGATE_TARGET is an Oracle server parameter that specifies the target aggregate PGA
memory available to all server processes attached to the instance. Some of the properties of the
PGA_AGGREGATE_TARGET parameter are given below:
Parameter type: Big integer
Syntax: PGA_AGGREGATE_TARGET = integer [K M G]Default value: 20% of SGA size or 10MB,
whichever is greater or modifiable by ALTER SYSTEM
Large Pool is used for what?
Large Pool is an optional memory structure used for the following purposes: (1) Session information for shared server
(2) I/O server processes
(3) Parallel queries
(4) Backup and recovery if using through RMAN.
The role of Large Pool is important because otherwise memory would be allocated from the Shared pool.
Hence Large pool also reduces overhead of Shared pool.
What is PCT Increase setting?
PCTINCREASE refers to the percentage by which each next extent (beginning with the third extend) will
grow. The size of each subsequent extent is equal to the size of the previous extent plus this percentage
increase.
What is PCTFREE and PCTUSED Setting?
PCTFREE is a block storage parameter used to specify how much space should be left in a database block
for future updates. For example, for PCTFREE=10, Oracle will keep on adding new rows to a block until it is
90% full. This leaves 10% for future updates (row expansion).
When using Oracle Advanced Compression, Oracle will trigger block compression when the PCTFREE is
reached. This eliminates holes created by row deletions and maximizes contiguous free space in blocks.
PCTUSED is a block storage parameter used to specify when Oracle should consider a database block to be
empty enough to be added to the freelist. Oracle will only insert new rows in blocks that is enqueued on the
freelist. For example, if PCTUSED=40, Oracle will not add new rows to the block unless sufficient rows are
deleted from the block so that it falls below 40% empty.
SQL> SELECT Pct_free FROM user_tables WHERE table_name = EMP;
The dbms_fga Package is the central mechanism for the FGA is implemented in the package dbms_fga,
where all the APIs are defined. Typically, a user other than SYS is given the responsibility of maintaining
these policies. With the convention followed earlier, we will go with the user SECUSER, who is entrusted with
much of the security features. The following statement grants the user SECUSER enough authority to create
and maintain the auditing facility.
Grant execute on dbms_fga to secuser;
The biggest problem with this package is that the polices are not like regular objects with owners. While a
user with execute permission on this package can create policies, he or she can drop policies created by
another user, too. This makes it extremely important to secure this package and limit the use to only a few
users who are called to define the policies, such as SECUSER, a special user used in examples.
What is Cost Based Optimization?
The CBO is used to design an execution plan for SQL statement. The CBO takes an SQL statement and tries
to weigh different ways (plan) to execute it. It assigns a cost to each plan and chooses the plan with smallest
cost.
The cost for smallest is calculated: Physical IO + Logical IO / 1000 + net IO.
How often you should collect statistics for a table?
CBO needs some statistics in order to assess the cost of the different access plans. These statistics
includes:
Size of tables, Size of indexes, number of rows in the tables, number of distinct keys in an index, number of
levels in a B* index, average number of blocks for a value, average number of leaf blocks in an index
These statistics can be gathered with dbms_stats and the monitoring feature.
How do you collect statistics for a table, schema and Database?
Statistics are gathered using the DBMS_STATS package. The DBMS_STATS package can gather statistics
on table and indexes, and well as individual columns and partitions of tables. When you generate statistics
for a table, column, or index, if the data dictionary already contains statistics for the object, then Oracle
updates the existing statistics. The older statistics are saved and can be restored later if necessary. When
statistics are updated for a database object, Oracle invalidates any currently parsed SQL statements that
access the object. The next time such a statement executes, the statement is re-parsed and the optimizer
automatically chooses a new execution plan based on the new statistics.
Collect Statistics on Table Level
sqlplus scott/tiger
exec dbms_stats.gather_table_stats ( ownname
=> 'SCOTT', tabname
=> 'EMP', estimate_percent => dbms_stats.auto_sample_size, method_opt
=> 'for all columns size auto', cascade
=> true, degree
=> 5 - )
/
Collect Statistics on Schema Level
sqlplus scott/tiger
exec dbms_stats.gather_schema_stats ( ownname
=> 'SCOTT', options
=> 'GATHER', estimate_percent => dbms_stats.auto_sample_size, method_opt
=> 'for all columns size auto', cascade
=> true, degree
=> 5 - )
You should create indexes on columns that are used frequently in WHERE clauses.
You should create indexes on columns that are used frequently to join tables.
You should create indexes on columns that are used frequently in ORDER BY clauses.
You should create indexes on columns that have few of the same values or unique values in the table.
You should not create indexes on small tables (tables that use only a few blocks) because a full table
scan may be faster than an indexed query.
If possible, choose a primary key that orders the rows in the most appropriate order.
If only one column of the concatenated index is used frequently in WHERE clauses, place that column first
in the CREATE INDEX statement.
If more than one column in a concatenated index is used frequently in WHERE clauses, place the most
selective column first in the CREATE INDEX statement.
What type of Indexes is available in Oracle?
It provides a mechanism to make table structure modification without significantly affecting the table
availability of the table. When a table is redefining online it is accessible to both queries and DML during the
redefinition process.
Purpose for Table Redefinition
Add, remove, or rename columns from a table
Converting a non-partitioned table to a partitioned table and vice versa
Switching a heap table to an index organized and vice versa
Modifying storage parameters
Adding or removing parallel support
Reorganize (defragmenting) a table
Transform data in a table
Restrictions for Table Redefinition:
One cannot redefine Materialized Views (MViews) and tables with MViews or MView Logs defined on
them.
One cannot redefine Temporary and Clustered Tables
One cannot redefine tables with BFILE, LONG or LONG RAW columns
One cannot redefine tables belonging to SYS or SYSTEM
One cannot redefine Object tables
Table redefinition cannot be done in NOLOGGING mode (watch out for heavy archiving)
Cannot be used to add or remove rows from a table
Can you assign Priority to users?
Yes, we can do this through resource manager. The Database Resource Manager gives a database
administrators more control over resource management decisions, so that resource allocation can be aligned
with an enterprise's business objectives.
With Oracle database Resource Manager an administrator can:
Guarantee certain users a minimum amount of processing resources regardless of the load on the system
and the number of users
Distribute available processing resources by allocating percentages of CPU time to different users and
applications.
Limit the degree of parallelism of any operation performed by members of a group of users
Create an active session pool. This pool consists of a specified maximum number of user sessions
allowed to be concurrently active within a group of users. Additional sessions beyond the maximum are
queued for execution, but you can specify a timeout period, after which queued jobs terminate.
Allow automatic switching of users from one group to another group based on administrator-defined
criteria. If a member of a particular group of users creates a session that runs for longer than a specified
amount of time, that session can be automatically switched to another group of users with different resource
requirements.
Prevent the execution of operations that are estimated to run for a longer time than a predefined limit
Create an undo pool. This pool consists of the amount of undo space that can be consumed in by a group
of users.
Configure an instance to use a particular method of allocating resources. You can dynamically change the
method, for example, from a daytime setup to a nighttime setup, without having to shut down and restart the
instance.
space. A bitmap, in this case, is a map that describes the status of each data block within a segment with
respect to the amount of space in the block available for inserting rows. As more or less space becomes
available in a data block, its new state is reflected in the bitmap.
CREATE TABLESPACE myts DATAFILE '/oradata/mysid/myts01.dbf' SIZE 100M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 2M
SEGMENT SPACE MANAGEMENT AUTO;
What is COMPRESS and CONSISTENT setting in EXPORT utility?
If COMPRESS=Y, the INITIAL storage parameter is set to the total size of all extents allocated for the object.
The change takes effect only when the object is imported.
Setting CONSISTENT=Y exports all tables and references in a consistent state. This slows the export, as
rollback space is used. If CONSISTENT=N and a record is modified during the export, the data will become
inconsistent.
What is the difference between Direct Path and Convention Path loading?
When you use SQL loader by default it use conventional path to load data. This method competes equally
with all other oracle processes for buffer resources. This can slow the load. A direct path load eliminates
much of the Oracle database overhead by formatting Oracle data blocks and writing the data blocks directly
to the database files. If load speed is most important to you, you should use direct path load because it is
faster.
What is an Index Organized Table?
An index-organized table (IOT) is a type of table that stores data in a B*Tree index structure. Normal
relational tables, called heap-organized tables, store rows in any order (unsorted).
CREATE TABLE my_iot (id INTEGER PRIMARY KEY, value VARCHAR2 (50)) ORGANIZATION INDEX;
What are a Global Index and Local Index?
When you create a partitioned table, you should create an index on the table. The index may be partitioned
according to the same range values that were used to partition the table. Local keyword in the index partition
tells oracle to create a separate index for each partition of the table. The Global clause in create index
command allows you to create a non-partitioned index or to specify ranges for the index values that are
different from the ranges for the table partitions. Local indexes may be easier to manage than global indexes
however, global indexes may perform uniqueness checks faster than local (portioned) indexes perform them.
What is difference between Multithreaded/Shared Server and Dedicated Server?
Oracle Database creates server processes to handle the requests of user processes connected to an
instance.
restoration, and cluster techniques to provide a high level of data protection and data availability.
What is Standby Databases
A standby database is a transitionally consistent copy of the primary database. Using a backup copy of the
primary database, you can create up to 9 standby databases and incorporate them in a Data Guard
configuration. Once created, Data Guard automatically maintains each standby database by
transmitting redo data from the primary database and then applying the redo to the standby database.
Similar to a primary database, a standby database can be either a single-instance Oracle database or an
Oracle Real Application Clusters database. A standby database can be either a physical standby database
or a logical standby database:
Difference between Physical standby Logical standby databases
Provides a physically identical copy of the primary database on a block-for-block basis. The database
schema, including indexes, is the same. A physical standby database is kept synchronized with the primary
database, though Redo Apply, which recovers the redo data, received from the primary database and
applies the redo to the physical standby database.
Logical Standby database contains the same logical information as the production database, although the
physical organization and structure of the data can be different. The logical standby database is kept
synchronized with the primary database though SQL Apply, which transforms the data in the redo received
from the primary database into SQL statements and then executing the SQL statements on the standby
database.
If you are going to setup standby database what will be your Choice Logical or Physical?
We need to keep the physical standby database in recovery mode in order to apply the received archive
logs from the primary database. We can open physical stand by database to read only and make it
available to the applications users (Only select is allowed during this period). Once the database is opened in
Read only mode then we can not apply redo logs received from primary database.
We do not see such issues with logical standby database. We can open up the database in normal mode
and make it available to the users. At the same time, we can apply archived logs received from primary
database.
If the primary database needed to support pretty large user community for the OLTP system and pretty large
Reporting Group then better to use logical standby as primary database instead of physical database.
What are the requirements needed before preparing standby database?
OS Architecture of primary database secondary database should be same.
The version of secondary database must be the same as primary database.
The Primary database must run in Archivelog mode.
Require the same hardware architecture on the primary and all standby site.
Does not require the same OS version and release on the primary and secondary site.
Each Primary and secondary database must have its own database.
What are Failover and Switchover in case of dataguard?
Failover is the operation of bringing one of the standby databases online as the new primary database when
failure occurs on the primary database and there is no possibility of recover primary database in a timely
manner. The switchover is a situation to handle planned maintenance on the primary database. The main
difference between switchover operation and failover operation is that switchover is performed when primary
database is still available or it does not require a flash back or re-installation of the original primary database.
This allows the original primary database to the role of standby database almost immediately. As a result
schedule maintenance can performed more easily and frequently.
When you use WHERE clause and when you use HAVING clause?
HAVING clause is used when you want to specify a condition for a group function and it is written after
GROUP BY clause The WHERE clause is used when you want to specify a condition for columns, single row
functions except group functions and it is written before GROUP BY clause if it is used.
---------1
691421794
The resulting key and id can then be used to unregister the database:
SQL> EXECUTE dbms_rcvcat.unregisterdatabase(1, 691421794);
PL/SQL procedure successfully completed.
overwritten in the control file before RMAN is able to add them to the catalog. As we know that
The CONTROL_FILE_RECORD_KEEP_TIME initialization parameter determines the minimum
number of days that records are retained in the control file before they are candidates for
being overwritten.
How to find the last refresh of your database (when the recovery with resetlogs
performed)?
If the cloned database has been opened with RESETLOGS option, you can try checking out
V$DATABASE.RESETLOGS_TIME. if the V$DATABASE.CREATED is not equal to
V$DATABASE.RESETLOGS_TIME...there is a possibility that it might be opened with resetlogs
option. I don't have the required set up to check and confirm this myself....but this is
something you can get it a shot.
Command to find files created a day before
find . -type f -mtime 1 -exec ls -lth {} \;
Initially Flashback Database was enabled but noticed Flashback was disabled
automatically long time ago. What is the Issue?
Reason:
It could be because the flashback area 100% Once Flashback Area become 100% full then
oracle will log in Alert that Flashback will be disabled and it will automatically turn off Flash
Back without user intervention.
How can I check if there is anything rolling back?
It depends on how you killed the process. If you did and alter system kill session you should be
able to look at the used_ublk block in v$transaciton to get an estimate for the rollback being
done. If you killed to server process in the OS and pmon is recovering the transaction you can
look at V$FAST_START_TRANSACTIONS view to get the estimate
How do you see how many instances are running?
In Linux, Unix the command: ps -ef|grep pmon
In Windows: services.msc
Which is more efficient Incremental Backups using RMAN or Incremental Export?
Rman
The current logfile gets damaged. What you can do now?
Once current redolog file is damaged, instance is aborted and it needs recovery upto
undamaged part. Only undamaged part can be recovered. Here DBA must apply time based
recovery, means it can be a point in time or specified by SCN. It leads to incomplete recovery
Where should the tuning effort be directed?
Consider the following areas for tuning in order to increase performance of DB
Application Tuning:
Experience showed that approximately 80% of all Oracle system performance problems are
resolved by coding optimal SQL. Also consider proper scheduling of batch tasks after peak
working hours.
Memory Tuning:
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.
Disk I/O Tuning:
Database files needs to be properly sized and placed to provide maximum disk subsystem
throughput. Also look for frequent disk sorts, full table scans, missing indexes, row chaining,
Connected.
OK, we're in. Let's quickly change the password back before anybody notices.
SQL> ALTER USER scott IDENTIFIED BY VALUES 'F894844C34402B67';
User altered.
While applying the CPU Patch why we need to update the Oracle Inventory?
Because when you apply the CPU it updates the oracle binaries.
purge it outright)?
Use "ALTER SYSTEM RESET ..." (For database versions 9i and up)
Syntax:
ALTER SYSTEM RESET PARAMETER SID='SID|*'
ALTER SYSTEM RESET "_TRACE_FILES_PUBLIC" SCOPE=SPFILE SID='*';
NOTE: The "SID='SID|*'" argument is REQUIRED!
Can you use RMAN to recover RMAN?
Yes, you can!
Which situation Exist condition is better than IN
If the resultant of sub query is small then IN is typically more appropriate where as resultant
of sub query is big/large/long then EXIST is more appropriate. The Exist always results full
scan of table where as first query can make use of index on Table.
Is Oracle really quicker on Windows than Solaris?
I found in my experience that Yes, windows perform better on comparable hardware just about
any UNIX box. I am working on Windows but once I installed Solaris trying to test. I found the
windows installations always outperformed the Solaris ones both on initial loading the pool
cache and subsequent runs. The test package is rather large (5000+ lines), which is used in a
form to display customer details. On Solaris I was typically getting an initial return time of 5
seconds and on windows, typically, 1 second. Even subsequent runs (i.e. cached) the windows
outperformed Solaris. The parameter sizes for the SGA were approx. the same and the file
systems are the conventional method. In both cases the disk configuration is local.
What is Difference between DBname and instance_name?
A database is a set of files (data, redo, ctl and so on) where as An instance is a set of
processes (SMON, PMON, DBWR, etc) and a shared memory segment (SGA).
A database may be mounted and opened by many INSTANCES (Parallel Server) concurrently.
An instance may mount and open ANY database -- however it may only open a single database
at any time. There for you need unique (for the set of files).
Does DBCA create instance while creating database?
DBCA does not create instance. It create database (set of files). The instance is only feelings
do a shutdown and goodbye instance and on windows it registers the necessary services that
can be used to start an instance when you want.
Is there any way to create database without DBCA?
Yes, you can used oradim directly
What's the difference between connections, sessions and processes?
A connection is a physical circuit between you and the database. A connection might be one of
many types -- most popular begin DEDICATED server and SHARED server. Zero, one or more
sessions may be established over a given connection to the database as show above with
sqlplus. A process will be used by a session to execute statements. Sometimes there is a one
to one relationship between CONNECTION->SESSION->PROCESS (eg: a normal dedicated
server connection). Sometimes there is a one to many from connection to sessions (eg: like
autotrace, one connection, two sessions, one process). A process does not have to be
dedicated to a specific connection or session however, for example when using shared server
(MTS), your SESSION will grab a process from a pool of processes in order to execute a
statement. When the call is over, that process is released back to the pool of processes.
SQL>select username from v$session where username is not null;
you can see one session, me
SQL>select username, program from v$process;
you can see all of the backgrounds and my dedicated server...
Autotrace for statistics uses ANOTHER session so it can query up the stats for your
CURRENT session without impacting the STATS for that session!
SQL>select username from v$session where username is not null;
now you can see two session but...
SQL>select username, program from v$process;
Same 14 processes...
What about Fragmentation situation (LMT) in oracle 8i and up?
Fragmentation is that if you have many small holes (regions of contiguous free space) that
are too small to be the next extent of any object. These holes of free space resulted from
dropping some object (or truncating them) and the resulting free space cannot be used by any
other object in that tablespace. This is a direct result of using pctincrease that is not zero and
having many weird sized extents (every extents is unique size and shape). In oracle 8i and
above we all are using locally managed tablespace. These would use either uniform sizing or
our automatic allocation scheme. In either case it is almost impossible to get into a situation
where you have unusable free space.
To see if you suffer from fragmentation you can query from DBA_FREE_SPACE (best to do an
alter tablespace to ensure all contiguous made into 1 big free region). You would look any free
space that is smaller then the smallest next extent size for any object in that tablespace.
Check with below query:
Select * from dba_free_space
where tablespace_name = 'T' and bytes <= ( select min(next_extent)
from dba_segments where tablespace_name = 'T') order by block_id
Is there a way we can flush out a known data set from the database buffer cache?
No you dont, in real life; the cache would never be empty. It is true that 10g introduce an
alter system flush buffer_cache, but it is not really worthwhile. Having empty buffer cache is
fake, if no more so than what you are currently doing.
What would be the best approach to benchmark the response time for a particular
query?
run query q1 over and over (with many different inputs)
run query q2 over and over (with many different inputs)
discard first couple of observations, and last couple
use the observations in the middle
What is difference between Char and Varchar2 and which is better approach?
A CHAR datatype and VARCHAR2 datatype are stored identically (eg: the word 'WORD' stored
in a CHAR(4) and a varchar2(4) consume exactly the same amount of space on disk, both
have leading byte counts).
The difference between a CHAR and a VARCHAR is that a CHAR(n) will ALWAYS be N bytes
long, it will be blank padded upon insert to ensure this. A varchar2(n) on the other hand will
be 1 to N bytes long, it will NOT be blank padded. Using a CHAR on a varying width field can
be a pain due to the search semantics of CHAR.
Consider the following examples:
SQL> create table t ( x char(10) );
Table created.
SQL> insert into t values ( 'Hello' );
1 row created.
SQL> select * from t where x = 'Hello';
X
---------Hello
SQL> variable y varchar2(25)
SQL> exec :y := 'Hello'
PL/SQL procedure successfully completed.
SQL> select * from t where x = :y;
no rows selected
SQL> select * from t where x = rpad(:y,10);
X
---------Hello
Notice how when doing the search with a varchar2 variable (almost every tool in the world
uses this type), we have to rpad() it to get a hit. If the field is in fact ALWAYS 10 bytes long,
using a CHAR will not hurt -- HOWEVER, it will not help either.
Rman always shows date in DD-MON-YY format. How to set date format to
M/DD/YYYY HH24:MI:SS in rman ?
You can just set the NLS_DATE_FORMAT before going into RMAN:
In Rman list backup how do i get time column that shows me date and time including
seconds as generally it is showing only date.
Before connecting the rman target set the date format on command prompt:
export NLS_DATE_FORMAT=dd-mon-yyyy hh24:mi:ss - Linux
Set NLS_DATE_FORMAT=dd-mon-yyyy hh24:mi:ss - windows
then try to connect rman target
rman target sys/oralce@orcl3 catalog rman/rman@shaan
rman> list backupset 10453
etc on new_table
drop table old_table
rename new_table to old_table;
You can do that using parallel query, with nologging on most operations generating very
little redo and no undo at all in a fraction of the time it would take to update the
data.
SQL>create table new_emp as select empno, LOWER(ename) ename, JOB,
MGR, HIREDATE, SAL, COMM, DEPTNO from emp;
SQL>drop table emp;
SQL>rename new_emp to emp;
How to convert database server sysdate to GMT date?
Select sysdate, sysdate+
(substr(tz_offset(dbtimezone),1,1)||1)*to_dsinterval(0
What is the difference between to back up the current control file and to backup up
control file copy?
If you backup current control file you backup control file which is currently open by an
instance where as If you backup controlfile file copy" you backup the copy of control file which
is created either with SVRMGRL command "alter system backup controlfile to .." or with RMAN
command "copy current controlfile to ...". In the other words, the control file copy is not
current controlfile backup current controlfile creates a BACKUPSET containing controlfile. You
don't have to give the FILENAME where as backup controlfile copy <filename> creates a
BACKUPSET from a copy of controlfile. You
have to give the FILENAME.
How much of overhead in running BACKUP VALIDATE DATABASE and RESTORE
VALIDATE DATABASE commands to check for block corruptions using RMAN? Can I
run these commands anytime?
Backup validate works against the backups not against the live database so no impact on the
live database, same for restore validate they do not impact the real thing (it is reading the files
there only).
Is there a way to force rman to use these obsolete backups or once it is marked
obsolete?
As per my understanding it is just a report, they are still there until you delete them.
Can I use the same snapshot controlfile to backup multiple databases(one after
another) running on the same server?
This file is only use temporarily like a scratch file. Only one rman session can access the
snapshot controlfile at any time so this would tend to serialize your backups if you do that.
Why does not oracle keep RMAN info after recreating the controlfile?
Creating the new controlfile from scratch how do you expect the create controlfile to "make up"
the missing data? that would be like saying similarly we have drop and recreated my table and
now it is empty similarly here recreating from the scratch means the contents there will be
naturally will be gone. Use the rman catalog to deal this situation. It is just a suggestion.
What is the advantage of using PIPE in rman backups? In what circumstances one
would use PIPE to backup and restore?
It lets 3rd parties (anyone really) build an alternative interface to RMAN as it permits anyone
that can connect to an Oracle instance to control RMAN programmatically.
How To turn Debug Feature on in rman?
run {
allocate channel c1 type disk;
debug on;
}
rman>list backup of database;
now you will see a output
You can always turn debug off by issuing
rman>debug off;
Report obsolete backup are reported unusable according to the users retention policy where as
Report obsolete orphan report the backup that are unusable because they belong to
incarnation of the database that are not direct ancestor of the current incarnation.
How to Increase Size of Redo Log
1. Add new log files (groups) with new size
ALTER DATABASE ADD LOGFILE GROUP
2. Switch with alter system switch log file until a new log file group is in state current
3. Now you can delete the old log file
ALTER DATABASE DROP LOGFILE MEMBER
What is the difference between alter database recover and sql*plus recover
command?
ALTER DATABASE recover is useful when you as a user want to control the recovery where as
SQL*PLUS recover command is useful when we prefer automated recovery.
Difference of two view V$Backup_Set and Rc_Backup_Set in respect of Rman
The V$Backup_Set is used to check the backup details when we are not managing Rman
catalog that is the backup information is stored in controlfile where as Rc_Backup_Set is
used when we are using catalog as a central repository to list the backup information.
Can I cancel a script from inside the script? How I cancil a select on Windows client?
Use ctl-c
How to Find the Number of Oracle Instances Running on Windows Machine
C:\>net start |find OracleService
How to create an init.ora from the spfile when the database is down?
Follow the same way as you are using
SQL> connect sys/oracle as sysdba
SQL> shutdown;
SQL> create pfile from spfile;
SQL> create spfile from pfile;
When you shutdown the database, how does oracle maintain the user session i.e.of
sysdba?
You still have your dedicated server
!ps -auxww | grep ora920
sys@ORA920> !ps -auxww | grep ora920
sys@ORA920> shutdown
sys@ORA920> !ps -auxww | grep ora920
You can see you still have your dedicated server. When you connect as sysdba, you fire up
dedicated server that is where it is.
What is ORA-002004 error? What you will do in that case?
A disk I/O failure was detected on reading the control file. Basically you have to check whether
the control file is available, permissions are right on the control file, spfile/init.ora right to the
right location, if all checks were done still you are getting the error, then from the multiplexed
block image before the change so that the database can reconstruct this block if media
recovery finds that this block was fractured.
The block that the operating system reads can be split, that is, the top of the block is written
at one point in time while the bottom of the block is written at another point in time. If you
restore a file containing a fractured block and Oracle reads the block, then the block is
considered a corrupt.
You recreated the control file by using backup control file to trace and using alter
database backup controlfile to location command what have you lost in that case?
You lost all of the backup information as using backup controlfile to trace where as using other
ALTER DATABASE BACKUP CONTROLFILE to D:\Backup\control01.ctl. All backup information is
retained when you take binary control file backup.
If a backup is issued after shutdown abort command what kind of backup
is that?
It is an inconsistent backup. If you are in noarchivelog mode ensure that you issue the
shutdown immediate command or startup force is another option that you can issue: startup
force->shutdown abort; followed by shutdown immediate;
Yes you have to use both in application , for application patches you will use ADPATCH UTILITY
and for applying database patch in application you will use opatch UTILITY.
Do you have idea how to trace a running process on Linux?
Using strace you can trace the system calls being executed by a running process
$ strace -p 1435
Process 1435 attached interrupt to quit
Pressed <control-C> - press control-C to stop the strace
$ strace -cfo smon_strace.log -p 1435
Process 1435 attached interrupt to quit
Process 1435 detached
What are database link? Differenciate the use of each of them?
A database link is a named object that describes a "path" from one database to another. There
are different types of database link such as: Private database link, public database link &
network database link.
Private database link is created on behalf of a specific user. A private database link can be used
only when the owner of the link specifies a global object name in a SQL statement or in the
definition of the owner's views or procedures.
Public database link is created for the special user group PUBLIC. A public database link can be
used when any user in the associated database specifies a global object name in a SQL
statement or object definition.
Network database link is created and managed by a network domain service. A network
database link can be used when any user of any database in the network specifies a global
object name in a SQL statement or object definition.
How to know which version of database you are working?
select * from v$version;
In Reference to Rman point in time Recovery which scenario is better for you (Until
time or until sequence)?
I am practicing various scenarios for backup and recovery using RMAN. I find until SCN better
than until time, with log_seq in the middle. Until time is still going to use (ultimately) an SCN
to recover, so if you know the SCN it would be preferred if not then time is fine.
If you have forgotten the root password on CentOS then what you will do?
If you are on CentOS then follow these steps:
- At the splash screen during boot time, press any key which will take you an interactive menu.
- Then select a Linux version you wish to boot and press a to append option to the line this
will bring you to a line with the boot command
- Next at the end of that line type single as an option/parameter and then Press Enter to
exit and execute the boot this will start the OS with single user mode which allow you to reset
the root password by typing passwd and you can set new password for root.
How to determine whether the datafiles are synchronized or not?
select status, checkpoint_change#, to_char(checkpoint_time, 'DD-MON-YYYY HH24:MI:SS') as
checkpoint_time, count(*)
from v$datafile_header
group by status, checkpoint_change#, checkpoint_time
order by status, checkpoint_change#, checkpoint_time;
Check the results of the above query if it returns one and only one row for the online datafiles,
means they are already synchronized in terms of their SCN. Otherwise the datafiles are still not
synchronized yet.
You have just restored from backup and do not have any control files. How would
you go about bringing up this database?
If you do not have a control file, you can create one from scratch in SQL*Plus as follows:
1. sqlplus /nolog
2. connect / as sysdba
3. Startup nomount;
4. the either create controlfile or restore it from the backup (if you have)
5. alter dataase mount;
6. Recover database using backup controlfile;
7. Alter database open;
From more details follow my blog post "Disaster Recovery from the
scratch": http://shahiddba.blogspot.com/2012/05/rman-disaster-recovery-from-scratch.html
Is there any way to find the last record from the table?
select * from employees where rowid in(select max(rowid) from employees);
select * from employees minus select * from employees where rownum < (select count(*) from
employees);
How you will find Oracle timestamp from current SCN?
select dbms_flashback.get_system_change_number scn from dual; -- Oracle Ver. 9i
SCN
-----------8843525
SQL> Select to_char(CURRENT_SCN) from v$database; -- oracle Ver. 10g or above
SQL>
select current_scn, dbms_flashback.get_system_change_number from v$database;
--standby case
SQL> select scn_to_timestamp(8843525) from dual;
How to suspend/resume a process using oradebug?
SQL> oradebug setorapid 14
Unix process pid: 14962, image: oracle@localhost.localdomain (TNS V1-V3)
SQL> oradebug suspend
Statement processed.
SQL> oradebug resume
Statement processed.
--cr
free
xcur
-- flush buffer cache for 10g and upwards
SQL> alter system flush buffer_cache;
System altered.
-- flush buffer cache for 9i and upwards
SQL> alter session set events immediate trace name flush_cache;
Session altered.
-- Shows buffer cache was freed after flushing buffer cache
SQL> select distinct status from v$bh;
STATUS
Free
How to suspend all jobs from executing in dba_jobs?
By setting the value of 0 to the parameter job_queue_processes you can suspend all jobs
from executing in DBA_JOBS. The value of this parameter can be changed without instance
restart.
SQL> show parameter job_queue_processes;
NAME TYPE VALUE
job_queue_processes integer 400
Now set the value of the parameter in memory, which will suspend jobs from starting
SQL> alter system set job_queue_processes=0 scope=memory;
System altered.
How to see the jobs currently being executed?
By using dba_jobs_running to can see all the job currently executing
SQL> select djr.sid, djr.job, djr.failures, djr.this_date, djr.this_sec, dj.what from
dba_jobs_running djr, dba_jobs dj where djr.job = dj.job;
What is GSM in Oracle application E-Business Suite?
GSM stands for Generic Service Management Framework. Oracle E-Business Suite consist of
various compoennts like Forms, Reports, Web Server, Workflow, Concurrent Manager. Earlier
each service used to start at their own but managing these services (given that) they can be
on various machines distributed across network. So Generic Service Management is extension
of Concurrent Processing which manages all your services , provide fault tolerance (If some
service is down ICM through FNDSM and other processes will try to start it even on remote
server) With GSM all services are centrally managed via this Framework.
How can you license a product after installation?
You can use ad utility adlicmgr to licence product in Oracle application.
In a situation when you want to know which was the last query fired by the user.
How to check?
Select S.USERNAME||'('||s.sid||')-'||s.osuser UNAME
,s.sid||'/'||s.serial# sid,s.status "Status",p.spid,sql_text sqltext
from v$sqltext_with_newlines t,V$SESSION s , v$process p
where t.address =s.sql_address and p.addr=s.paddr(+) and t.hash_value = s.sql_hash_value
order by s.sid,t.piece;
Can one copy Oracle software from one machine to another?
Yes, one can copy or FTP the Oracle Software between similar machines. Look at the following
example:
# use tar to copy files and directorys with permissions and ownership
tar cf $ORACLE_HOME | rsh cd $ORACLE_HOME; tar xf
To copy the Oracle software to a different directory on the same server:
cd /new/oracle/dir/
(cd $ORACLE_HOME; tar cf . ) | tar xvf NOTE: Remember to relink the Intelligent Agent on the new machine to prevent messages like
Encryption key supplied is not the one used to encrypt file:
cd /new/oracle/dir/
cd network/lib
make -f ins_agent.mk install
A single transaction can have multiple deletes and a single SCN number identifying
all of these deletes. What if I want to flash back only a single individual delete?
You would flash back to the SYSTEM (not your transactions) SCN at that point in time. The
SYSTEM has an SCN, your transaction has an SCN. You care about the SYSTEM SCN with
flashback, not your transactions SCN.
Are flash back queries useful for the developer or the DBA both? How can I as a
developer and DBA get to know the SCN number of a transaction?
Oracle Flashback is a tool is useful for both either DBA and Developer. If you deleted data
accidently then either DBA or Developer both can flashback, recover and fix this problem. As a
developer you can use "dbms_flashback.get_system_change_number" to returns the current
system SCN and as DBA you can use Log Miner utility to to look back in time at various events
to find SCN's as well.
After Performing DML operation you are using flashback query to retun back your
committed data can you use flashback concept after Truncating any data?
In version 9i, Flashback is limited to Data Manipulation Language (DML) commands such as
SELECT,INSERT, UPDATE, and DELETE. Truncate doesn't generate any undo for the table
truncate just cuts it all loses where as delete puts the deleted data into undo. Flashback query
works on undo.
What is SID and what is it used for? Where can I find out the SID of my database?
The SID is a site identifier. It plus the Oracle_home are hashed together in Unix to create a
unique key name for attaching an SGA. If your Oracle_sid or Oracle_home is not set correctly,
you will get "oracle not available". you can get instance name with the following command:
select instance from v$thread;
select instance_name from v$instance;
If you are buying a new server that will be a mirror image of the current Production
Server what would be the step for that?
In same environment and directory structure setup server, install oracle, use oradim to setup
the registry (register the instance) and restore from backup.
I am cloning database A as database B, both exactly identical, running in
NOARCHIVELOG mode. Database A will be shutdown before copying files. I am using
the CREATE CONTROLFILE statement to clone.
a) Do I need to copy redo log files from A to B if I need to open B with RESETLOGS
option?
b) Do I need to copy control files from A to B since I will be creating controlfile for B?
a) You do not need to, but you would avoid having to open resetlogs if that makes you feel
better.
b) Not if you are doing the create controlfile trick. You could just copy EVERYTHING, startup
mount, and issue a series of alter database rename file 'old name' to 'new names'; and then
alter database open (assuming logs are in the same place, else you'll drop and create them).
Note: My understanding is that if you use RESETLOGS option in CREATE CONTROLFILE, the
redo log files will be created by Oracle as per the specifications given in the create controlfile
statement.
I have a new server. What is the best way I can have the same oracle setup that is
there on a prodn db? Either we need to restore the file systems and relink oracle
without doing any installation?
My suggestion is install the same software on another server then then apply restore and
recover procedure on the same environment or directory structure.
No idea about "relink oracle without doing any installation", see the admin guide for your OS
for details on things like this.
There is any difference between Oracle TCL and DCL command?
DCL stands for Data Control Language. These command are used to configure and control
database objects such as GRANT, REVOKE where as TCL stands for Transaction Control
language. It is used to manage the changes made by DML statements. It allows statements to
be grouped together into logical transactions such as
COMMIT - save work done
SAVEPOINT - identify a point in a transaction to which you can later roll back
ROLLBACK - restore database to original since the last COMMIT
SET TRANSACTION - Change transaction options like isolation level and what rollback segment
to use
What happens when the lock is disabling on the table?
When you disabling the lock on table then you are not able to perform DDL operation on that
table but you still to manage DML operation easily
For Example:
Create Table s1 (Eno number(2), ename varchar2(15), salary number(5,2));
insert into s1 values (1, 'shahid', 400);
insert into s1 values (1, 'javed', 200);
insert into s1 values (2, 'karim', 100);
--disable lock on table
Alter table s1 disable table lock;
-- cannot drop/truncate table as table lock is disable
drop table s1;
truncate table s1;
--you cannot able to add/modify/drop column
Alter table s1 add comm number(5,2);
Alter table s1 modify s1 salary number (10,4);
Alter table s1 drop column salary;
-- But still you are able to perform DML
update s1 set salary= 800 where eno=2;
select * from s1;
delete from s1 where eno=2;
insert into s1 values (2, 'mohan', 250);
What is the importance of clock time in case of database cloning?
My personal experience sometimes just cloning a database is not enough if moving it to
another machine you also have to ensure:
1. The environment on the new machine is setup, to match the cloned system this would
include memory & disc allocation space.
2. The "new" machine time is the same or greater than the machine you were cloning from
How much space does it take to clone a database?
The clone needs the same space.
In which case %LIKE (before or after use) operator performance increases?
LIKE% works the fastest because it uses the index to search on the column provided an index
is specified on the column. Using % after LIKE, results in faster results.
Do you have idea about Fuzz testing or fuzzing?
Fuzz testing or fuzzing is a software testing technique that provides random data ("fuzz") to
the inputs of a program. If the program fails (for example, by crashing, or by failing built-in
code assertions), the defects can be noted. The great advantage of fuzz testing is that the test
design is extremely simple, and free of preconceptions about system behavior.
Using the expdp/impdp (Data Pump in 10g), can export and import data from one
CURRENT_UTILIZATION MAX_UTILIZATION
---------------------
------------------- ---------------
processes
14
18
sessions
12
17
Update of a partition key that causes a row to move, that moves rows and would change
rowids.
If I fire two inserts in a table, whether the rowid of the 2nd record will be greater
than
rowid of the 1st record?
The answer is NO see the example below
if you insert A
then
insert B
later
insert C
delete A
insert D
It is quite possible in above example that D will be "first" in the table as it took over A's place.
If rowids always "grew", than space would never be reused (that would be an implication of
rowids growing always. We would never be able to reuse old space as the rowid is just a
file.block.slot-on-block - a physical address).
Difference between Stored Procedure and Macro?
Stored Procedure:
It does not return rows to the user.
It has to use cursors to fetch multiple rows
It used Inout/out to send values to user
It is stored in DATABASE or USER PERM
A stored procedure also provides output/Input capabilities
Macros:
It returns set of rows to the user.
It is stored in DBC PERM space
A macro that allows only input values
If the port 1521 is default port for the TNSLinstener. I have a database server on
port 1527 how can I make the clients connect on this port or can I have one listener
service connect to listen for 2 servers?
If you are using "Host naming" convention (this is a method that does not require the client to
have a tnsnames.ora file at all. You must be using TCP or you must only have one default
database per host. The client only needs to know the hostname of the server to connect) then
yes, 1521 is the default and only port.
If you are using tnsnames.ora, the Oracle nameserver, or any other method to connect then
no, 1521 is not a default port. In this case, 1521 is simply the port used by "convention". The
clients would, typically in their tnsnames.ora, connect to the listener on some specified port
number. 1521 is the convention used by many people; it is neither mandatory nor necessary.
What is an IPC protocol and where and how it is used? I have experience only in
TCP/IP protocol. Is there any advantage in using IPC over TCP?
IPC is interposes communication you have messages, pipes, socket pairs and so on it is alot
like just using sockets with TCP/IP. IPC is generally limited to "a machine", not over a network.
IPC used to be a tad faster than TCP but recent tests have shown this to be less and less true.
In your absence any body has done any alteration then how did you notice or How to
know last DDL fired from the particular schema and particular table?
To find the last ddl performed check out the last_ddl_time from all_objects, dba_objects,
user_objects view because each time and object changes the last_ddl_time is updated from
these view.
Select CREATED, TIMESTAMP, last_ddl_time from all_objects
WHERE OWNER='HRMS' AND OBJECT_TYPE='TABLE' AND OBJECT_NAME='PAYROLL_MAIN_FIL
E';
In the above query HRMS is the schema name and payroll_main_file is the table name.
How to find tables that have a specific column name?
SELECT owner, table_name, column_name
FROM dba_tab_columns
WHERE column_name like 'AMOUNT'
ORDER by table_name;
Differentiate Row level and statement level Trigger?
Row Level Trigger is fired each time row is affected by Insert, Update or Delete command. If
statement doesnt affect any row then no trigger action happens where as Statement level
trigger fires when a SQL statement affects the rows of the table. The trigger activates and
performs its activity irrespective of number of rows affected due to SQL statement. They get
fired once for each triggering statement.
I exported one table with a name of user, how to import that table with another name of user?
EXPDP user1/pwd TABLES=test DUMPFILE=test.DMP DIRECTORY=abc;
IMPDP user2/pwd REMAP_SCHEMA=user1:user2 DUMPFILE=test.DMP DIRECTORY=abc ;
-orIMPDP user2/pwd directory=directory_name tables=table_name
dumpfile=dump_name.dmp;
SQL>Grant read, write on directory directory_name to public;
SQL>Grant read, write on directory <dir_name> to <user>;
Just careful to give grant to public if it is production Environment
I have two server of same configuration having single database of 10GB and 20 GB size respectively,
I want to merge into single server what are the prerequisites and steps to follow in this case.
In my view Export/Import is the best solution to merge the database. You can export the schemas from one
database and import it into other database.
Can one monitor how fast a table is imported?
If you need to monitor how fast rows are imported from a running import job, try one of the following
methods:
Method 1:
select substr(sql_text,instr(sql_text,'INTO "'),30) table_name,
rows_processed,
round((sysdate-to_date(first_load_time,'yyyy-mm-dd hh24:mi:ss'))*24*60,1)
minutes,
trunc(rows_processed/((sysdate-to_date(first_load_time,'yyyy-mm-dd
hh24:mi:ss'))*24*60)) rows_per_min
from sys.v_$sqlarea
where sql_text like 'INSERT %INTO "%'
and command_type = 2
and open_versions > 0;
If the import has more than one table, this statement will only show information about the current table being
imported.
Method 2:
Use the FEEDBACK=n import parameter. This command will tell IMP to display a dot for every N rows
imported.
How we will increase performance on particular table? Here I am inserting 2GB data in table, its takes
more time to insert in a table. Is there any way to increase performance on a particular table?
Index on huge table while doing insert will not only solution to improve performance. Get your table
partitioned that will make table insertion faster and also easy to manage the archive data. Alternatively do
one thing first disable constraints as well as index then perform insertion then again enable.
You can use high-speed solid-state disk (RAM-SAN) to make Oracle inserts run up to 300x faster than platter
disk.
How to reduce alert log Size?
If you move or delete your Alert log file, it is recreated automatically in next startup, alternatively you can put
a script at OS level to move the archives and use new one. So the best way to reduce the size of log is just
move your aler.log to some other place. Oracle will recreate it in next startup.
How you will know the instance is Primary or Standby?
By querying v$database one can tell if the host is primary or standby
On the primary database:
SQL> select database_role from v$database;
DATABASE_ROLE
-----------------PRIMARY
OR check the value of controlfile_type in V$database i.e is CURRENT for primary and "STANDBY" for
standby
SQL> SELECT controlfile_type FROM V$database;
CONTROL
------------CURRENT
On the Standby database:
SQL> select database_role from v$database;
DATABASE_ROLE
------------------PHYSICAL STANDBY
SQL> SELECT controlfile_type FROM V$database;
CONTROL
------------STANDBY
Note: You may need to connect to as sys if the instance is in mount state
How would you determine what sessions are connected and what resources they are waiting for?
Use of V$SESSION and V$SESSION_WAIT
Give two methods you could use to determine what DDL changes have been made.
You could use Logminer or Streams
How would you determine who has added a row to a table?
Turn on fine grain auditing for the table.
Explain the differences between PFILE and SPFILE
A PFILE is a Static, text file that initializes the database parameter in the moment that its started. If you want
to modify parameters in PFILE, you have to restart the database.
A SPFILE is a dynamic, binary file that allows you to overwrite parameters while the database is already
started (with some exceptions).
Name some clients that can connect with Oracle?
There are several such as SQL Developer, SQL-Plus, TOAD, dbvisualizer, PL/SQL Developer.
In which view can you find information about every view and table of oracle dictionary?
Disable the foreign key constraint to the parent, drop the table, re-create the table, enable the foreign key
constraint.
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.
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.
How would you determine the time zone under which a database was operating?
select DBTIMEZONE from dual;
Explain the use of setting GLOBAL_NAMES equal to TRUE.
Setting GLOBAL_NAMES indicates 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.
What background process refreshes materialized views?
The Job Queue Processes.
When a user process fails, what background process cleans up after it?
PMON
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 this
username.
What are the minimum parameters should exist in the parameter file (init.ora) ?
DB NAME - Must set to a text string of no more than 8 characters and it will be stored inside the datafiles,
redo log files and control 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) CONTORL FILES - List of control filenames of the database. If name is not
mentioned then default name will be used.
DB_BLOCK_BUFFERS - To determine the no of buffers in the buffer cache in SGA.
PROCESSES - To determine 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.
What is the difference between NAME_IN and COPY ?
Copy is package procedure and writes values into a field.
Name in is a package function and returns the contents of the variable to which you apply.
How do you 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 .
How many rows will the following SQL return?
Select * from emp Where rownum = 10;
No rows
Can dual table be deleted, dropped or altered or updated or inserted?
Yes
Advanced replication allows the simultaneous transfer of data between two or more Master Sites. There are
considerations to keep in mind when using multi-master replication. The important ones are sequences
(which cannot be replicated), triggers (which can turn recursive if you're not careful) and conflict resolution.
What is the basic difference between Cloning and Standby databases?
The clone database is a copy of the database which can be opened in read write mode. It is treated as a
separate copy of the database that is functionally completely separate. The standby database is a copy of
the production database used for disaster protection. In order to update the standby database; archived redo
logs from the production database can be used. If the primary database is destroyed or its data becomes
corrupted, one can perform a failover to the standby database, in which case the standby database becomes
the new primary database.
Why we are using materialized view instead of a table?
Materialized views are basically used to increase query performance since it contains results of a query.
They should be used for reporting instead of a table for a faster execution.
Which BG process refreshes the materialized view?
Job Queue Process
What is the importance of transportable Tablespace in oracle?
The transportable tablespace enable us to transport data objects across different platform. Moving data
using transportable can be much faster than performing either export/import or unload or load of the same
because transporting a tablespace only requires the copying of datafiles & integrating the tablespace
structure information.
Can we reduce the size of TEMP datafile?
Yes, we can reduce the space of the TEMP datafile. Prior to oracle 11g, you had to recreate the datafile but
in oracle 11g you reduce space of TEMP datfile by shrinking the TEMP tablespace. It is a new feature to 11g.
The dynamic performance view DBA_temp_files can be very useful in determining which table space to
shrink.
SELECT TABLESPACE_NAME, ROUND(BYTES/1048576/1024, 2) "IN
GB", FILE_ID, FILE_NAME FROM DBA_TEMP_FILES;
ALTER TABLESPACE TEMP SHRINK TEMPFILE D:\ORACLE\ORADATA\SADHAN\TEMP02.DBF KEEP
5G;
It is generated only if the value of SQL_TRACE parameter is set to true for a session.
If it set at instance level, trace file will be created for all connected sessions.
If it is set at session level, trace file will be generated only for specified session.
The location of user process trace file is specified in the USER_DUMP_DEST parameter.
How can you use automatic PGA memory management with oracle 9i or above?
Set the WORK_AREA_SIZE_POLICY parameter to AUTO and set PGA_AGGREGATE_TARGET
When a user comes to you and asks that a particular SQL query is taking more time. How will you
solve this?
If you find the particular query is taking time to execute, then take a SQLTRACE with explain plan, it will
show how the SQL query will be executed by oracle, depending upon the report you will tune your database.
Then determine the table size and check the user requirement is % of data from query table. If it is less then
For example: one table has 10000 records, but you want to fetch only 5 rows, but in that query oracle does
the full table scan. Only for 5 rows full table scan is not a good, so create an index on that particular column.
If the user requirement is more than 80% of data from query table then in that case if we create index, again
user will get poor performance because oracle will get contention on db buffer cache since first of all index
block need to be picked up as well as almost all block from that table will be pull out. Hence it will increase
the I/O, also other user request may get slow performance since existing data in cache will be flush out and
reloaded.
Additionally we need to check system level performance, either any problem with dbwn either dbwn writing
slow any modified data which is in buffer to datafile and either user server process is waiting for space in
buffer cache?
Check alert log file too.
Check if user query needed join or sorting?
Check either there is not enough space in temporary tablespace?
If user again user again facing issue then we need drill down to check either any issue with table block level
either table needs defragments if watermark reached high.
{
allocate auxiliary channel aux1 device type disk;
set until SCN 42612597059;
duplicate target database to "TEST"
pfile='/u01/app/xxxx/product/10.2.0/db_1/dbs/initTEST.ora' NOFILENAMECHECK;
}
EOF
\
How will we know the IP address of our system in Linux environment?
Either use ipconfig command or ip addr show
It will give you all IP address and if you have oracle 9i you can query from SQL prompt.
SELECT UTL_INADDR.GET_HOST_ADDRESS "Host Address", UTL_INADDR.GET_HOST_NAME
"Host Name" FROM DUAL;
Can we create Bigfile Tablespace for all databases?
Infact your question do we create bigfile tablespace for every database is not clear for me. If you are asking
can we create bigfile for every database?
Yes you can but it is not ideal for every datafile if your work is suitable for small file then why you create
bigfile but if your mean is impact of bigfile that depends on your requirements and storage.
A bigfile tablespace is having single very big datafile which can store 4GB to 128 TB.
Creating single large datafile reducing the requirement of SGA and also it will allow you modification at
tablespace level. In fact it is ideal for ASM, logical device supporting stripping.
Avoid using bigfile tablespace where there is limited space availability. For more details impact, advantage,
disadvantage of bigfile on my blog.
Can you gice more explanation on logfile states?
CURRENT state means that redo records are currently being written to that group. It will be until a log
switch occurs. At a time there can be only one redo group current.
If a redo group containing redos of a dirty buffer that redo group is said to be ACTIVE state. As we know log
file keep changes made to the data blocks then data blocks are modified in buffer cache (dirty blocks). These
dirty blocks must be written to the disk (RAM to permanent media).
And when a redolog group contains no redo records belonging to a dirty buffer it is in an "INACTIVE" state.
These inactive redolog can be overwritten.
One more state UNUSED initially when you create new redo log group its log file is empty on that time it is
unused. Later it can be any of the above mentioned state.
What is difference between oracle SID and Oracle service name?
Oracle SID is the unique name that uniquely identifies your instance/database where as the service name is
the TNS alias can be same or different as SID.
How to find session for Remote users?
-- To return session id on remote session:
SELECT distinct sid FROM v$mystat;
-- Return session id of you in remote Environment:
echo %bytesfree%
endlocal && set bytesfree=%bytesfree%
You can create a schedular to run the above free.bat, free_space.txt inside the oracle directory.
Differentiate between Tuning Advisor and Access Advisor?
The tuning Advisor:
other applications, you can install both 32 bit and 64 bit client on a single machine and just tell the toad to
use the 32 bit client.
What are the differences between Physical/Logical standby databases? How would you decide which
one is best suited for your environment?
Physical standby DB:
As the name, it is physically (datafiles, schema, other physical identity) same copy of the primary
database.
It synchronized with the primary database with Apply Redo to the standby DB.
As the name logical information is the same as the production database, it may be physical structure
can be different.
It synchronized with primary database though SQL Apply, Redo received from the primary database
into SQL statements and then executing these SQL statements on the standby DB.
We can open physical stand by DB to read only and make it available to the applications users
(Only select is allowed during this period). we can not apply redo logs received from primary database at this
time.
We do not see such issues with logical standby database. We can open the database in normal mode
and make it available to the users. At the same time, we can apply archived logs received from primary
database.
For OLTP large transaction database it is better to choose logical standby database.
A latch is a serialization mechanism. It is used to gain access to shared data structure in order to latches the
structure that will prevent others from modifying it while you are modifying it.
Why it is not necessary to take UNDO backup?
In fact it is not necessary to take UNDO tablespace backup either with COLD or HOT backup scripts but
many of DBA include UNDO tablespace in their backup script.
You know when you do some transactions; redo entries will be generated and accepted! Just like that other
tablespace whenever any change happens to UNDO tablespace or UNDO segments oracle will generate
redo entries. So even you not backed up the UNDO tablespace, you have the redo entries through which you
can recover or rollback the transactions.
What should be effect on DB performance if virtual memory used to store SGA parameter?
For optimal performance in most systems, the entire SGA should fit in real memory. If it does not, and if
virtual memory is used to store parts of it, then overall database system performance can decrease
dramatically. The reason for this is that portions of the SGA are paged (written to and read from disk) by the
operating system.
What is the role of lock_sga parameter?
The LOCK_SGA parameter, when set to TRUE, locks the entire SGA into physical memory. This parameter
cannot be used with automatic memory management or automatic shared memory management.
What is CSSCAN?
CSSCAN (Database Character Set Scanner) is a SCAN tool that allows us to see the impact of a database
character set change or assist us to correct an incorrect database nls_characterset setup. This helps us to
determine the best approach for converting the database characterset.
Differentiate between co-related sub-query and nested query?
Co-related sub query is one in which inner query is evaluated only once and from that result your outer query
is evaluated where as Nested query is one in which Inner query is evaluated for multiple times for getting one
row of that outer query.
Example: Query used with IN() clause is Co-related query.
SELECT EMPLOYEE_NUMBER, LOAN_CODE, DOCUMENT_NUMBER, LOAN_AMOUNT
FROM PAY_LOAN_TRANS
WHERE EMPLOYEE_NUMBER IN (SELECT EMPLOYEE_NUMBER
FROM PAY_EMPLOYEE_PERSONAL_INFO
WHERE EMPLOYEE_NUMBER BETWEEN 1 AND 100);
Example: Query used with = operator is Nested query
SELECT * FROM PARTIAL_PAYMENT_SEQUENCE
WHERE SEQCOD = (SELECT MAX(SEQCOD) FROM PARTIAL_PAYMENT_SEQUENCE);
One after noon suddenly you get a call from your application user and complaining the database is
slow then what will be your first step to solve this issue?
High performance is common expectation for end user, in fact the database is never slow or fast in most of
the case session connected to the database slow down when they receives unexpected hit. Thus to solve
this issue you need to find those unexpected hit. To know exactly what the second session is doing join your
query with v$session_wait.
Reduce the number of blocks retrieved by the SQL statement. Examine the SQL statement to see if it
is doing a full-table scan when it should be using an index, if it is using a wrong index, or if it can be rewritten
to reduce the amount of data it retrieves.
Place the tables used in the SQL statement on a faster part of the disk.
Consider increasing the buffer cache to see if the expanded size will accommodate the additional
b) Manage the process of resolving any gaps in the archived redo log files due to a network failure.
c) Automatically detect missing or corrupted archived redo log files on a standby system and automatically
retrieve replacement archived redo log files from the
primary database or another standby database.
Is Opatch (utility) is also another type of patch?
OPatch is utility from oracle corp. (Java based utility) that helps you in applying interim patches to Oracle's
software and rolling back interim patches from Oracle's software. Opatch also able to Report already
installed interim patch and can detect conflict when already interim patch has been applied. This program
requires Java to be available on your system and requires installation of OUI. Thus from the above
discussion coming to your question it is not ideal to say OPATCH is another patch.
When we applying single Patch, can you use opatch utility?
Yes, you can use Opatch incase of single patch. The only type of patch that cannot be used with OPatch is a
patchset
When you applying Patchsets, You can use OUI.
Yes, Patcheset uses OUI. A patch set contains a large number of merged patches, to change the version of
the product or introduce new functionality. Patch sets are cumulative bug fixes that fix all bugs and consume
all patches since the last base release. Patch sets and the Patch Set Assistant are usually applied through
OUI-based product specific installers.
Can you Apply OPATCH without downtime?
As you know for apply patch your database and listener must be down. When you apply OPTACH it will
update your current ORACLE_HOME. Thus coming to your question to the point in fact it is not possible
without or zero downtime in case of single instance but in RAC you can Apply Opatch without downtime as
there will be more separate ORACLE_HOME and more separate instances (running once instance on each
ORACLE_HOME).
You have collection of patch (nearly 100 patches) or patchset. How can you apply only one patch
from it?
With Napply itself (by providing patch location and specific patch id) you can apply only one patch from a
collection of extracted patch. For more information check the opatch util NApply help. It will give you
clear picture.
For Example:
opatch util napply <patch_location> -id 9 -skip_subset -skip_duplicate
This will apply only the patch id 9 from the patch location and will skip duplicate and subset of patch installed
in your ORACLE_HOME.
If both CPU and PSU are available for given version which one, you will prefer to apply?
From the above discussion it is clear once you apply the PSU then the recommended way is to
apply the next PSU only. In fact, no need to apply CPU on the top of PSU as PSU contain CPU (If
you apply CPU over PSU will considered you are trying to rollback the PSU and will require more
effort in fact). So if you have not decided or applied any of the patches then, I will suggest you to go
to use PSU patches. For more details refer: Oracle Products [ID 1430923.1], ID 1446582.1
PSU is superset of CPU then why someone choose to apply a CPU rather than a PSU?
CPUs are smaller and more focused than PSU and mostly deal with security issues. It seems to be
theoretically more consecutive approach and can cause less trouble than PSU as it has less code changing
in it. Thus any one who is concerned only with security fixes and not functionality fixes, CPU may be good
approach.
Will Patch Application affect System Performance?
Sometimes applying certain patch could affect Application performance of SQL statements. Thus it is
recommended to collect a set of performance statistics that can serve as a baseline before we make any
major changes like applying a patch to the system.
What is your day to day activity as an Apps DBA?
As an Apps DBA we monitor the system for different alerts (Entreprise Manager or third party tools used for
configuring the Alerts) Tablespace Issues, CPU consumption, Database blocking sessions etc., Regular
maintenance activities like cloning, patching, custom code migrations (provided by developers) and Working
with user issues.
How often do you use patch in your organization?
Usually for non-production the patching request comes around weekly 4-6 and the same patches will be
applied to Production in the outage or maintenance window.
Production has weekly maintenance window (eg. Sat 6PM to 9PM) where all the changes (patches) will
applied on production.
How often do you use cloning in your organization?
Cloning happens weekly or monthly depending on the organization requirement. Generally when we need to
perform major task such as oracle financial annual closing etc.
the full backup without level 0 can not be considered as a parent backup from which you can take level 1
backup.
How can you change or rename the database name?
SQL> ALTER DATABASE BACKUP CONTROLFILE TO TRACE;
The above command will create a text control file in user_dump_dest directory and change name of the
database in above file and also in init.orafile.
Now startup your database in nomount phase using the modified pfile and then run the modified controlfile
script.
SQL> STARTUP NOMOUNT;
SQL> @D:\Backup\controlfile.txt
SQL> ALTER DATABASE OPEN RESETLOGS;
You can use DBNEWID utility NID for this purpose. For more information: DBNEWID, Changing DBNAME
Temp Tablespace is 100% FULL and there is no space available to add datafiles to increase temp
tablespace. What can you do in that case to free up TEMP tablespace?
Try to close some of the idle sessions connected to the database will help you to free some TEMP space.
Otherwise you can also use Alter Tablespace PCTINCREASE 1 followed by Alter Tablespace
PCTINCREASE 0
What is the use of setting GLOBAL_NAMES equal to true?
Setting GLOBAL_NAMES indicates how you might connect to the database. This variable is either true or
false. If it is set to true enforces database link to have same link as the remote database to which they
are linking.
What is the purpose of fact and dimension table? What type of index is used with fact table?
Fact and dimension tables are involved in producing a star schema. A fact table contains measurements
while dimension table will contain data that will help to describe the fact table. A Bitmap index is used with
fact table.
If you got complain application is running very slow from your application user. Where do you start
looking first?
Below are some of very important step to identify the root cause of slowness in Application database.
Run TOP command in Linux to check CPU usage.
Run VMSTAT, SAR, PRSTAT command to get more information on CPU, memory usage and possible
blocking.
Run STATSPACK report to identify TOP 5 Events and Resource Intensive SQL statement.
If found poor written statements then run EXPLAIN PLAN on these statements and see whether new
or Take the database OFFLINE, and then bring back online with a new BLOCK SIZE specification.
You need to restore from backup and do not have any control files. What will be your step to recover
the database?
Create a text based control files, saved on the disk same location where all the datafiles are located then
issue the recover command by using backup control file clause.
Shutdown abort;
-- if db still open
Startup nomount;
create controlfile
database <name>
logfile '<online redo log groups>'
noresetlogs|resetlogs
maxlogfiles 10
maxlogmembers <your value>
datafile '<names of all data files>'
maxdatafiles 254
archivelog;
Use alter database open if you created the control file with NORESETLOGS and have
performed no recovery or a full recovery (without until cancel).
Use alter database open noresetlogs if you created the control file with NORESETLOGS and performed a
full recovery despite the use of the until cancel option.
Use alter database open resetlogs if you created the control file with RESETLOGS or when you performed
a partial recovery.
In below list which SQL phrase is NOT supported by oracle?
A.ON DELETE CASCADE
B.ON UPDATE CASCADE
C.CREATE SEQUENCE [SequenceName]
D.DROP SEQUENCE [SequenceName]
Answer: B
What is the effect on working with Report when flex/confine mode are ON?
When flex mode is ON, reports automatically resize the parent when the child is resized.
When the confine mode is ON, the object cannot be moved outside its parent in layout.
How will you enforce security using stored procedure?
Dont grant user access directly to tables within the application. Instead grant the ability to access the
procedure that accesses the tables. When procedure execute it will execute the privilege of procedures
owner. Users cannot access except via the procedure.
What is RAC? What is the benefit of RAC over single instance database?
In Real Application Clusters environments, all nodes concurrently execute transactions against the same
database. Real Application Clusters coordinates each node's access to the shared data to provide
consistency and integrity.
Benefits:
Can you configure primary server and standby server on different OS?
NO, Standby database must be on same version of database and same version of OS.
If you want users will change their passwords after every 60 days then how you will enforce this?
Oracle password security is implemented through oracle PROFILES which are assigned to
users. PASSWORD_LIFE_TIME parameter limits the number of days the same password can be used for
authentication.
You have to first create database PROFILE and then assign each user to this profile or if you have already
having PROFILE then you need to just alter the above parameter.
create profile Sadhan_users
limit
PASSWORD_LIFE_TIME 60
PASSWORD_GRACE_TIME 10
PASSWORD_REUSE_TIME UNLIMITED
PASSWORD_REUSE_MAX 0
FAILED_LOGIN_ATTEMPTS 3
PASSWORD_LOCK_TIME UNLIMITED;
Then create user or already created user assigned to this profile.
SQL> Create user HRMS identified by oracle profile sadhan_users;
If you have already assigned profile then you can directly modify the profile parameter:
SQL> Alter profile sadhan_users set PASSWORD_LIFE_TIME = 90;
What happens actually in case of instance Recovery?
While Oracle instance fails, Oracle performs an Instance Recovery when the associated database is being
re-started. Instance recovery occurs in two steps:
Cache recovery: Changes being made to a database are recorded in the database buffer cache as well as
redo log files simultaneously. When there are enough data in the database buffer cache, they are written to
data files. If an Oracle instance fails before these data are written to data files, Oracle uses online redo log
files to recover the lost data when the associated database is re-started. This process is called cache
recovery.
Transaction recovery: When a transaction modifies data in a database (the before image of the modified
data is stored in an undo segment which is used to restore the original values in case the transaction is rolled
back). At the time of an instance failure, the database may have uncommitted transactions. It is possible that
changes made by these uncommitted transactions have gotten saved in data files. To maintain read
consistency, Oracle rolls back all uncommitted transactions when the associated database is re-started.
Oracle uses the undo data stored in undo segments to accomplish this. This process is called transaction
recovery.
What is the main purpose of CHECKPOINT in oracle database?
A checkpoint is a database event, which synchronize the database blocks in memory with the datafiles on
disk. It has two main purposes: To establish a data consistency and enable faster database Recovery. For
more information: Discussion on Checkpoint and SCN
Can you change the Characterset of database?
No, you can not change the character set of database, you will need to re-create the database with
appropriate characterset.
What is Cascading standby database?
A CASCADING STANDBY is a standby database that receives its REDO information from another standby
database (not from primary database).
What the use of ANALYZE command?
To collect statistics about object used by the optimizer and store them in the data dictionary, delete statistics
about the object, validate the structure of the object and identify migrated and chained rows of the table or
cluster.
How will you check active shared memory segment?
ipcs -a
How will you check paging swapping in Linux?
vmstat s
prstat s
swap l
sar p
How do you check number of CPU installed on Linux server?
psrinfot v
When you moved oracle binary files from one ORACLE_HOME server to another server then which
oracle utility will be used to make this new ORACLE_HOME usable?
Relink all
In which months oracle release CPU patches?
JAN, APR, JUL, OCT
Oracle version 9.2.0.4.0 what does each number refers to?
Oracle version number refers:
9 Major database release number
2 Database Maintenance release number
0 Application server release number
4 Component Specific release number
0 Platform specific release number
What does database do during the mounting process?
While mounting the database oracle reads the data from controlfile which is used for verifying physical
database files during sanity check. Background processes are started before mounting the database only.
When having multiple oracle homes on a single server or client what is the parameter that points all
Oracle installs at one TNSNAMES.ORA file.
TNS_ADMIN
How to implement the multiple controlfile for existing database?
1.
2.
Shutdown immediate
3.
Copy controlfile to multiple locations & confirm from init.ora contolfiles parameter
4.
5.
Why we look for CHUNKS_FREE space while tracking fragmentation details query?
The CHUNK_FREE return the number of chunks of contiguous free space based on dba_free_space table.
The motive is to find the largest size chunks of free space within a tableapce. This is because as we know
oracle server allocates space for segments in unit of one extent. When the existing extent of segment is full,
the server allocates another extent for the segment.
In order to do oracle searches free space in the tablespace (contiguous set of data block sufficient to meet
the required extent). If sufficient space not found then an error is returned by the oracle server.
What is the impact of NLS/Characterset in database?
NLS is a National language support and encompasses how to display currency, whenever we use a comma
or a dot to separate numbers, how the name of the day is spelled etc.
Charactersets are how we store data.
For Example: US7ASCII is a 7bit characterset and WE8ISO8859P1 8 bit character set. It can store 2 times
as many characters as the 7bit characterset. If you try to export from 8 bit characterset database and import
into 7bit database then there is chance to loose data in 7bit characterset that have the high bit set and if you
try from 7bit to 8bit would not encounter any issues since the 7bit characterset is a subset of the 8bit
characterset and can hold more types of characters and can support many countries.
Can we perform RMAN level 1 backup without level 0?
If no level 0 is available, then the behavior depends upon the compatibility mode setting (oracle version). If
the compatibility mode less than 10.0.0, RMAN generates a level 0 backup of files contents at the time of
backup. If compatibility is greater than 10.0.0 RMAN copies all block changes since the file was created, and
stores the results as level 1 backup.
What will happen if ARCHIVE process cannot copy an archive redolog to a mandatory archive log
destination?
Oracle will continue with cycle to the other online redolog groups until it return to the group that the ARCH
process is trying to copy to the mandatory archive log destination. If the mandatory archive log destination
copy has not occurred, the database operation will suspend until the copy is successful or the DBA has
intervened to perform force log switching.
Can you differentiate between HOTBACKUP and RMAN backup?
For hotbackup we have to put database in begin backup mode, then take backup where as RMAN would not
put database in begin backup mode. In fact RMAN has a number of advantages over general backup. For
more information please check: Benefit of RMAN Backup
How to put Manual/User managed backup in RMAN?
In case of recovery catalog, you can put by using catalog command:
RMAN> CATALOG START WITH /oraback/backup.ctl;
When you put any SQL statement how oracle responds them internally?
First it will check the syntax and semantics in library cache, after that it will created execution plan. If already
data in buffer cache (in case of identical query) it will directly return to the client. If not it write the fetch to the
database buffer cache after that it will send server and finally server send to the client.
Can we use Same target database as Catalog?
No, the recovery catalog should not reside in the target database (database to be backed up) because the
Export the table, drop the table, create definition of table in new tablespace and then import the data
Create new table in new tablespace then drop the original table and rename temporary table with
How would you decide your backup strategy and timing for backup?
In fact backup strategy is purely depends upon your organization business need. If no downtime then
database must be run on archivelog mode and you have to take frequently or daily backup. If sufficient
downtime is there and loss of data would not affect your business then you can run your database in
archivelog mode and backup can be taken in-frequently or weekly or monthly.
In most of the case in an organization when no downtime then frequent inconsistent backup needed (daily
backup), multiplex online redo log files (multiple copies), different location for redo log files, database must
run in archivelog mode and dataguard can be implemented for extra bit of protection (to make less downtime
during recovery).
What is Jinitiator and what its purpose?
It is a java virtual machine provided for running web based oracle forms applications inside a client web
browser. It is implemented as a plug-in or ActiveX object, allows you to specify the use of oracle certified
JVM instead of relying on default JVM provided by browser. It is automatically downloaded to a client
machine from the application. Its installation and update is performed by standard plug-in mechanism
provided by the browser.
What is the use of large pool, which case you need to set the large pool?
You need to set large pool if you are using: MTS (Multi thread server) and RMAN Backups. Large pool
prevents RMAN & MTS from competing with other sub system for the same memory. RMAN uses the large
pool for backup & restore when you set the DBWR_IO_SLAVES or BACKUP_TAPE_IO_SLAVES
parameters to simulate asynchronous I/O. If neither of these parameters is enabled, then Oracle allocates
backup buffers from local process memory rather than shared memory. Then there is no use of large pool.
How can you audit system operations?
Sys connection can be audited by setting init.ora parameter AUDIT_SYS_OPERATIONS=TRUE
How can you implement Encryption in database?
Data with database can be encrypted and decrypted using package: DBMS_OBFUSCATION_TOOLKIT
How do you list the folder files with hidden file in Linux
s ltra
How to execute Linux command in Background?
Use the "&" at the end of command or use nohup command
What Linux command will control the default permission when file are created?
Umask
Give the command to display space usage on the LINUX file system?
df lk
What is the use of iostat/vmstat/netstat command in Linux?
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.
What are the steps to install oracle on Linux system. List two kernel parameter that effect oracle
installation?
Initially set up disks and kernel parameters, then create oracle user and DBA group, and finally run installer
to start the installation process. The SHMMAX & SHMMNI two kernel parameter required to set before
installation process.
__________ Parameter change will decrease Paging/Swapping?
Answer: Decrease_Shared_Pool_size
_______ Command is used to see the contents of SQL* Plus buffer
Answer: LIST
Transaction per rollback segment is derived from ________
Answer: Processes
LGWR process writes information into ___________
Answer: Redo log files.
A database over all structure is maintained in a file __________
Answer: Control files
What is the use of NVL function?
The NVL function is used to replace NULL values with another or given value.
For Example: NVL (Value, replace value);
What is WITH CHECK OPTION?
The WITH CHECK option clause specifies check level to be done in DML statements. It is used to prevent
changes to a view that would produce results that are not included in the sub query.
The concepts are different than previous concept in fact. In that case you can access the some of the
concept in your mind to achieve the target.
How can you track the password change for a user in oracle?
Oracle only tracks the date that the password will expire based on when it was latest changed. Thus listing
the view DBA_USERS.EXPIRY_DATE and subtracting PASSWORD_LIFE_TIME you can determine when
password was last changed. You can also check the last password change time directly from the PTIME
column in USER$ table (on which DBA_USERS view is based). But If you
have PASSWORD_REUSE_TIME and/orPASSWORD_REUSE_MAX set in a profile assigned to a user account
then you can reference dictionary table USER_HISTORY$ for when the password was changed for this
account.
SELECT user$.NAME, user$.PASSWORD, user$.ptime, user_history$.password_date
FROM SYS.user_history$, SYS.user$
WHERE user_history$.user# = user$.user#;
What is the difference between a data block/extent/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.
What is the difference between SQL*loader and Import utilities?
Both these utilities are used for loading the data into the database. The difference is that the import utility
relies on the data being produced by another oracle utility Export while SQL*Loader is a high speed data
loading mechanism allows data to be loaded that has been produced by other utilities from different data
source. Import is mainly used reading and writing operating system files.
Can you list the Step how to create Standby database?
1.Take a full hot backup of Primary database
2.Create standby control file
7.(Alternatively, RMAN DUPLICATE DATABASE FOR STANDBY DO RECOVERY can be also used)
8.Setup FAL_CLIENT and FAL_SERVER parameters on both sides
9.Put Standby database in Managed Recover mode
How would you activate Physical Standby database in oracle 9i?
Perform below on primary database if available to transfer all pending archive logs to standby:
SQL> ALTER SYSTEM SWITCH LOGFILE;
SQL> ALTER SYSTEM SWITCH LOGFILE;
Now perform below on STANDBY database:
SQL> ALTER DATABASE ACTIVATE STANDBY DATABASE;
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP;
Note: Once you start the Standby DB, your relation between primary databases to standby database has
been lost and at this time your standby database becomes primary database.
How to Switch from Primary to Physical Standby database?
Perform below step on Primary Database:
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION
SHUTDOWN;
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP NOMOUNT;
SQL> ALTER DATABASE
DATABASE;
database object. It is created for reasons of Security and Convenience. Two levels of security
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.
What are Sequences?
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.
What is the difference between view and synonym in oracle?
A view is a stored query you can access as a (read-only) table. It is often used as an interface
to other modules/programs. The view stays the same (name, columns, etc.) but the underlying
query and/or tables can change without affecting the calling module.
A synonym is just that another name for an existing object (table, view, stored procedure) in
oracle. You usually create public synonyms to access objects in another schema without
referencing the schema.
How do you implement one-to-one, one-to-many and many-to-many relationships
while designing tables?
One-to-One relationship can be implemented as a single table and rarely as two tables with
primary and foreign key relationships. One-to-Many relationships are implemented by splitting
the data into two tables with primary key and foreign key relationships. Many-to-Many
relationships are implemented using a junction table with the keys from both the tables
forming the composite primary key of the junction table.
Define candidate key, alternate key and Composite key?
A candidate key is one that can identify each row of a table uniquely. Generally a candidate key
becomes the primary key of the table. If the table has more than one candidate key, one of
them will become the primary key, and the rest are called alternate keys. A key formed by
combining at least two or more columns is called composite key.
Explain different isolation levels?
An isolation level determines the degree of isolation of data between concurrent transactions.
The default SQL Server isolation level is Read Committed. Here are the other isolation levels
(in the ascending order of isolation): Read Uncommitted, Read Committed, Repeatable Read,
and Serializable.
What is an index? What are the types of indexes? How many clustered indexes can
be created on a table? I create a separate index on each column of a table. What are
the advantages and disadvantages of this approach?
Index in oracle helps to trace the information faster just like and index in book. It is a pointer
to the location of data purpose to make SQL queries run faster. There is several type of index
in oracle such as: b*tree indexes, b*tree cluster indexes, hash cluster indexes, reverse key
indexes, bitmap indexes, partitioned indexes, function-based indexes
What is blocking and how would you troubleshoot it?
Blocking happens when one connection from an application holds a lock and a second
connection requires a conflicting lock type. This forces the second connection to wait, blocked
on the first. How to find whose lock is blocking in oracle
link:http://shahiddba.blogspot.com/2012/04/find-whose-lock-is-blocking.html
Import the table using INDEXFILE parameter (the import is not done, but a file which contains the
indexes creation is generated)
Modify this script to create the indexes in the tablespace we want
Import the table using IGNORE=y option (because the table exists)
Recreate the indexes
In which cases imp/exp is used?
Eliminate database fragmentation
Schema refresh (move the schema from one database to another)
Detect database corruption. Ensure that all the data can be read (if the data can be read that means
there is no block corruption)
Transporting tablespaces between databases
Backup database objects
How we can improve the EXP Performance?
Set the BUFFER parameter to a high value (e.g. 2M)
If you run multiple export sessions, ensure they write to different physical disks.
How we can improve the IMP performance?
Import the table using INDEXFILE parameter (the import is not done, but a file which contains the
indexes creation is generated), import the data and recreate the indexes
Store the dump file to be imported on a separate physical disk from the oracle data files
If there are any constraints on the target table, the constraints should be disabled during the
import and enabled after import
Set the BUFFER parameter to a high value (ex. BUFFER=30000000 (~30MB) ) and COMMIT =y or
set COMMIT=n (is the default behavior: import commits after each table is loaded, however, this use a
lot of the rollback segments or undo space for huge tables.)
Use the direct path to import the data (DIRECT=y)
(if possible) Increase DB_CACHE_SIZE (DB_BLOCK_BUFFERS prior to 9i) considerably in the
init<SID>.ora file
(if possible) Set the LOG_BUFFER to a big value and restart oracle.
Which are the common IMP/EXP problems?
ORA-00001: Unique constraint ... violated - Perhaps you are importing duplicate rows. Use IGNORE=N to
skip tables that already exist (imp will give an error if the object is re-created) or the table could be dropped/
truncated and re-imported if we need to do a table refresh..
IMP-00015: Statement failed ... object already exists... - Use the IGNORE=Y import parameter to ignore
these errors, but be careful as you might end up with duplicate rows.
ORA-01555: Snapshot too old - Ask your users to STOP working while you are exporting or use parameter
CONSISTENT=NO (However this option could create possible referential problems, because the tables are
not exported from one snapshot in time).
ORA-01562: Failed to extend rollback segment - Create bigger rollback segments or set parameter
COMMIT=Y (with an appropriate BUFFER parameter) while importing.
Import/Export Related Post:
Order by scn_to_timestamp(SCN);
What if the transaction is rolled-back? Does the SCN again increase?
Yes it is, check out this Example
SQL> CREATE TABLE S1 (ENO NUMBER(4), ENAME VARCHAR2(20));
Table created.
SQL> Select dbms_flashback.get_system_change_number scn from dual;
SCN
---------8806085
SQL> begin
for i in 1 .. 1000
loop
insert into S1 values ( 1, 'SHAAN' );
rollback;
end loop;
end;
/
PL/SQL procedure successfully completed.
SQL> select scn, scn-8806085 from (
select dbms_flashback.get_system_change_number scn from dual
);
SCN SCN-8806085
---------- ------------8806085
2014
SCN SCN-8806085
---------- ------------155317184
20180
1959
);
SCN SCN-8830447
---------- ------------8842825
12378
Is there any difference between select CURRENT_SCN from v$database and select
dbms_flashback.get_system_change_number scn from dual?
For a "normal" database (not standby) they are for all intents and purposes the same. They
could be a LITTLE different if you do something like:
SQL>select current_scn, dbms_flashback.get_system_change_number from v$database; since
they would be evaluated at two slightly different points in time, but consider them "the same"
What is the difference or similarity between SCN and ORA_ROWSCN? Where does
oracle store SCN?
The SCN is like a clock - it is always advancing (use the command
dbms_flashback.get_system_change_number and wait for few seconds, print it again, it will
have advanced). So, just think of the SCN like a ticker, like time - every time a transaction
ends - another unit of time is added, like adding seconds to time where as ora_rowscn is an
observed point in time. The ora_rowscn is a value associated to a block or a row on a block
that represents the time the block/row was last modified.
When alter system checkpoint command is used?
When we have few dirty buffers of one table in the buffer cache and we issue the command
The checkpoint SCN of the data block is updated and ITL is also updated as:
Itl
Xid
Uba
Flag
Lck
Scn/Fsc
0x01
0x0005.020.00002b46
0x00c00235.0d0f.15
--U-
fsc 0x0000.00ddffee
0x02
0x0001.012.00002088
0x00c0021d.0b70.07
--U-
fsc 0x0000.00df1407
But the header block (after we dump and see) of the file still contains the same SCN as before
irrespective of the change in the data block
Where the SCN number resides? Does archive and redo logs also contain SCN
numbers?
SCN doe not really reside anywhere, it is like time itself. A value of the SCN, taken at various
times, representing the time something happened is stored in many places, sort of like a
timestamp would be. Datafiles have SCNs associated with them (times of various operations)
control files have them (times of various operations) log files have them (to record times of
various operations) undo segments have them (......) they are littered all over the place, they
are like timestamps.
Overview DATA DICTIONARY: CHECKPOINT
V$INSTANCE_RECOVERY, V$LOG, V$LOG_HISTORY
V$INSTANCE_RECOVERY: lowest value in last four columns controls checkpoints
redo log file size, log_checkpoint_timeout, log_checkpoint_interval, fast_start_io_target
init parameter: log_checkpoint_interval, log_checkpoint_timeout, log_checkpoints_to_alert
log_checkpoint_interval
redo log blocks (OS blocks not DB blocks) written before a checkpoint
If set greater than redo log file size, checkpoints occur at log switches
Ignored if set to zero.
log_checkpoint_timeout
set log_checkpoint_interval larger than the size of the online redo logs
eliminate time-based checkpoints by setting log_checkpoint_timeout = 0
increase size of online redo logs
Note: checkpoints DO NOT cause log switches, but log switches cause checkpoints. For Manual
check point use alter system checkpoint.
SQL>oradebug hanganalyze 3
Open a separate SQL session and immediately generate a system state dump.
SQL>alter session set events 'immediate trace name SYSTEMSTATE level 10';
How to Check why shutdown immediate taking longer time to shutdown?
Ref. 1076161.6: Shutdown immediate or shutdown hangs. SMON disabling TX recovery
Ref. Note 375935.1: What to do and not to do when shutdown immediate hangs.
Ref. Note 428688.1: Shutdown immediate very slow to close database.
When shutdown immediate taking longer time as compare to the normal time usually it is taking. You must
perform following task before performing actual shutdown immediate.
1. All active session.
2. Temporary Tablespace Recover.
3. Long Running Query in Database.
4. Large Transaction.
5. Progress of the Transaction that oracle is recovering.
6. Parallel Transaction Recovery.
SQL> Select sid, serial#, username, status, schemaname, logon_time from
v$session where status='ACTIVE' and username is not null;
If Active session is exist then, try to find out what is doing in the database by this session. Active session
makeshutdown slower
SQL> Select f.R "Recovered", u.nr "Need Recovered" from (select
count(block#) R , 1 ch from sys.fet$ ) f,(selectcount(block#) NR, 1 ch from
sys.uet$) u where f.ch=u.ch;
Check to see any long query is running into the database while you are trying to shutdown the database.
SQL> Select * from v$session_longops where time_remaining>0 order by username;
Check to ensure large transaction is not going on while you are trying to shutdown the database.
SQL>Select sum(used_ublk) from v$transaction;
Check the progress of the transaction that oracle is recovering.
SQL>Select * from v$fast_start_transactions;
Check to ensure that any parallel transaction recovery is going on before performing shutdown immediate.
SQL>Select * from v$fast_start_servers;
Finally if you do not understand the reason why the shutdown is hanging or taking longer time to shutdown
then try to shutdown your database with abort option and startup with restrict option and try shutdown with
immediate option.
Check the alert.log, if you find any error related Thread 1 cannot allocate new log, sequence
then you need to enable your archival process. Your archival is disable due to any reason.
Process:
1. In command prompt set the oracle_sid first
C:\SET ORACLE_SID = your db_name
2. Now start the SQL*plus:
C:\sqlplus /nolog
SQL>connect sys/***@instance_name
SQL>Select instance_name from v$instance;
3. Try to checkpoint before shutdown abort
SQL>alter system checkpoint;
SQL> shutdown abort;
4. Start the database with restrict option so that no other user is able to connect you in the mean time.
SQL>startup restrict;
SQL>select logins from v$instance;
RESTRICTED
SQL>shutdown immediate;
5. Mount the database and ensure archive process is enabling by using archive log list command. If it is
disabling then enable it.
SQL>startup mount;
SQL> archive log list; --if disable then enable it
SQL>Alter database archivelog;
SQL> Alter system archive log start;
Note: If your archivelog destination and format is already set no need to set again. After setting check with
the archive log list command archival is enable or not.
SQL> alter database open;
Now check if your database is still in restricted mode then remove the restriction.
SQL>select logins from v$instance;
SQL>alter system disable restricted session;
Note: Now try to generate archivelog with any command
SQL>alter system archivelog current;
SQL>alter system switch logfile;
Now try to check or perform normal shutdown and startup with the database.