Oracle Interview Questions

Top most important Oracle interview questions and answers by Experts:

Here is a list of Top most important Oracle interview questions and answers by Experts.If you want to download Oracle interview questions pdf free ,you can register with RVH techguru. Our experts prepared these Oracle interview questions to accommodate freshers level to most experienced level technical interviews.

If you want to become an expert in Oracle ,Register for Oracle online training here.

1) What are cursor attributes?
-%ROWCOUNT

-%NOTFOUND
-%FOUND
-%ISOPEN

There is a % sign in one field of a column. What will be the query to find it?
” Should be used before ‘%’.

2) What is ON DELETE CASCADE ?
When ON DELETE CASCADE is specified ORACLE maintains referential integrity by automatically removing dependent foreign key values if a referenced primary or unique key value is removed.

3) What is the fastest way of accessing a row in a table ?
Using ROWID.CONSTRAINTS

4) What is difference between TRUNCATE & DELETE ?
TRUNCATE commits after deleting entire table i.e., can not be rolled back. Database triggers do not fire on TRUNCATEDELETE allows the filtered deletion. Deleted records can be rolled back or committed. Database triggers fire on DELETE.

5) What is a transaction ?
Transaction is logical unit between two commits and commit and rollback.

6) What are the advantages of VIEW ?
To protect some of the columns of a table from other users.To hide complexity of a query.To hide complexity of calculations.

7) How will you a activate/deactivate integrity constraints ?
The integrity constraints can be enabled or disabled by ALTER TABLE ENABLE constraint/DISABLE constraint.

8) Where the integrity constraints are stored in Data Dictionary ?
The integrity constraints are stored in USER_CONSTRAINTS.

9) What is the Subquery ?
Sub query is a query whose return values are used in filtering conditions of the main query.

10) How to access the current value and next value from a sequence ? Is it possible to access the current value in a session before accessing next value ?
Sequence name CURRVAL, Sequence name NEXTVAL.It is not possible. Only if you access next value in the session, current value can be accessed.

11) What are the usage of SAVEPOINTS ?value in a session before accessing next value ?
SAVEPOINTS are used to subdivide a transaction into smaller parts. It enables rolling back part of a transaction. Maximum of five save points are allowed.

12) What is ROWID ?in a session before accessing next value ?
ROWID is a pseudo column attached to each row of a table. It is 18 character long, blockno, rownumber are the components of ROWID.

13) Explain Connect by Prior ?in a session before accessing next value ?
Retrieves rows in hierarchical order.e.g. select empno, ename from emp where.

14) How many LONG columns are allowed in a table ? Is it possible to use LONG columns in WHERE clause or ORDER BY ?
Only one LONG columns is allowed. It is not possible to use LONG column in WHERE or ORDER BY clause.

15) What is Referential Integrity ?
Maintaining data integrity through a set of rules that restrict the values of one or more columns of the tables based on the values of primary key or unique key of the referenced table.

16) What is a join ? Explain the different types of joins ?
Join is a query which retrieves related columns or rows from multiple tables.Self Join – Joining the table with itself.Equi Join – Joining two tables by equating two common columns.Non-Equi Join – Joining two tables by equating two common columns.Outer Join – Joining two tables in such a way that query can also retrieve rows that do not have corresponding join value in the other table.

17) If an unique key constraint on DATE column is created, will it validate the rows that are inserted with SYSDATE ?
It won’t, Because SYSDATE format contains time attached with it.

18) What are Procedure, functions and Packages ?
Procedures and functions consist of set of PL/SQL statements that are grouped together as a unit to solve a specific problem or perform set of related tasks.

Procedures do not Return values while Functions return one One Value Packages :: Packages Provide a method of encapsulating and storing related procedures, functions, variables and other Package Contents

19) What are Database Triggers and Stored Procedures
Database Triggers :: Database Triggers are Procedures that are automatically executed as a result of insert in, update to, or delete from table.
Database triggers have the values old and new to denote the old value in the table before it is deleted and the new indicated the new value that will be used. DT are useful for implementing complex business rules which cannot be enforced using the integrity rules.We can have the trigger as Before trigger or After Trigger and at Statement or Row level. e.g:: operations insert,update ,delete 3 before ,after 3*2 A total of 6 combinatons
At statment level(once for the trigger) or row level( for every execution ) 6 * 2 A total of 12. Thus a total of 12 combinations are there and the restriction of usage of 12 triggers has been lifted from Oracle 7.3 Onwards.
Stored Procedures :: Stored Procedures are Procedures that are stored in Compiled form in the database.The advantage of using the stored procedures is that many users can use the same procedure in compiled and ready to use format.

20) How many Integrity Rules are there and what are they
There are Three Integrity Rules. They are as follows ::

a) Entity Integrity Rule :: The Entity Integrity Rule enforces that the Primary key cannot be Null
b) Foreign Key Integrity Rule :: The FKIR denotes that the relationship between the foreign key and the primary key has to be enforced.When there is data in Child Tables the Master tables cannot be deleted.
c) Business Integrity Rules :: The Third Intigrity rule is about the complex business processes which cannot be implemented by the above 2 rules.

21) What are the Various Master and Detail Relation ships.
The various Master and Detail Relationship are
a) NonIsolated :: The Master cannot be deleted when a child is existing
b) Isolated :: The Master can be deleted when the child is existing
c) Cascading :: The child gets deleted when the Master is deleted.

22) What are the Various Block Coordination Properties
The various Block Coordination Properties are
a) Immediate Default Setting. The Detail records are shown when the Master Record are shown.
b) Differed with Auto Query Oracle Forms defer fetching the detail records until the operator navigates to the detail block.
c) Differed with No Auto Query The operator must navigate to the detail block and explicitly execute a query

23) What are the Different Optimization Techniques
The Various Optimisation techniques are

a) Execute Plan :: we can see the plan of the query and change it accordingly based on the indexes
b) Optimizer_hint ::
set_item_property(‘DeptBlock’,OPTIMIZER_HINT,’FIRST_ROWS’);
Select /*+ First_Rows */ Deptno,Dname,Loc,Rowid from dept
where (Deptno > 25)
c) Optimize_Sql ::
By setting the Optimize_Sql = No, Oracle Forms assigns a single cursor for all SQL statements.This slow downs the processing because for evertime the SQL must be parsed whenver they are executed.
f45run module = my_firstform userid = scott/tiger optimize_sql = No
d) Optimize_Tp ::
By setting the Optimize_Tp= No, Oracle Forms assigns seperate cursor only for each query SELECT statement. All other SQL statements reuse the cursor.
f45run module = my_firstform userid = scott/tiger optimize_Tp = No

24) How does one change an Oracle user’s password?(for DBA)
Issue the following SQL command:
ALTER USER <username> IDENTIFIED BY <new_password>;

From Oracle8 you can just type “password” from SQL*Plus, or if you need to change another user’s password, type “password user_name”. Look at this example:
SQL> password
Changing password for SCOTT
Old password:
New password:
Retype new password:

25) How does one create and drop database users?
Look at these examples:
CREATE USER scott
IDENTIFIED BY tiger — Assign password
DEFAULT TABLESACE tools — Assign space for table and index segments
TEMPORARY TABLESPACE temp; — Assign sort space
DROP USER scott CASCADE; — Remove user
After creating a new user, assign the required privileges:
GRANT CONNECT, RESOURCE TO scott;
GRANT DBA TO scott; — Make user a DB Administrator
Remember to give the user some space quota on its tablespaces:
ALTER USER scott QUOTA UNLIMITED ON tools;

26) How does one enforce strict password control? (for DBA)
By default Oracle’s security is not extremely good. For example, Oracle will allow users to choose single character passwords and passwords that match their names and userids. Also, passwords don’t ever expire. This means that one can hack an account for years without ever locking the user.

From Oracle8 one can manage passwords through profiles. Some of the things that one can restrict:
. FAILED_LOGIN_ATTEMPTS – failed login attempts before the account is locked
. PASSWORD_LIFE_TIME – limits the number of days the same password can be used for authentication
. PASSWORD_REUSE_TIME – number of days before a password can be reused
. PASSWORD_REUSE_MAX – number of password changes required before the current password can be reused
. PASSWORD_LOCK_TIME – number of days an account will be locked after maximum failed login attempts
. PASSWORD_GRACE_TIME – number of days after the grace period begins during which a warning is issued and login is allowed
. PASSWORD_VERIFY_FUNCTION – password complexity verification script
Look at this simple example:
CREATE PROFILE my_profile LIMIT
PASSWORD_LIFE_TIME 30;
ALTER USER scott PROFILE my_profile;

27) How does one switch to another user in Oracle? (for DBA)
Users normally use the “connect” statement to connect from one database user to another. However, DBAs can switch from one user to another without a password. Of course it is not advisable to bridge Oracle’s security, but look at this example: SQL> select password from dba_users where username=’SCOTT’;

PASSWORD
F894844C34402B67
SQL> alter user scott identified by lion;
User altered.

SQL> connect scott/lion
Connected.

REM Do whatever you like…
SQL> connect system/manager
Connected.

SQL> alter user scott identified by values ‘F894844C34402B67’;
User altered.
SQL> connect scott/tiger
Connected.
Note: Also see the su.sql script in the Useful Scripts and Sample Programs Page.

28) What are snap shots and views
Snapshots are mirror or replicas of tables. Views are built using the columns from one or more tables. The Single Table View can be updated but the view with multi table cannot be updated

29) What are the OOPS concepts in Oracle.
Oracle does implement the OOPS concepts. The best example is the Property Classes. We can categorize the properties by setting the visual attributes and then attach the property classes for the objects. OOPS supports the concepts of objects and classes and we can consider the property classes as classes and the items as objects

30) What is the difference between candidate key, unique key and primary key
Candidate keys are the columns in the table that could be the primary keys and the primary key is the key that has been selected to identify the rows. Unique key is also useful for identifying the distinct rows in the table.)

31) What is concurrency
Concurrency is allowing simultaneous access of same data by different users. Locks useful for accesing the database are

a) Exclusive
The exclusive lock is useful for locking the row when an insert,update or delete is being done.This lock should not be applied when we do only select from the row.
b) Share lock
We can do the table as Share_Lock as many share_locks can be put on the same resource.

Previleges and Grants
Previleges are the right to execute a particulare type of SQL statements. e.g :: Right to Connect, Right to create, Right to resource Grants are given to the objects so that the object might be accessed accordingly.The grant has to be given by the owner of the object

Table Space,Data Files,Parameter File, Control Files
Table Space :: The table space is useful for storing the data in the database.When a database is created two table spaces are created.
a) System Table space :: This data file stores all the tables related to the system and dba tables
b) User Table space :: This data file stores all the user related tables
We should have seperate table spaces for storing the tables and indexes so that the access is fast.
Data Files :: Every Oracle Data Base has one or more physical data files.They store the data for the database.Every datafile is associated with only one database.Once the Data file is created the size cannot change.To increase the size of the database to store more data we have to add data file.
Parameter Files :: Parameter file is needed to start an instance.A parameter file contains the list of instance configuration parameters e.g.::
db_block_buffers = 500
db_name = ORA7
db_domain = u.s.acme lang
Control Files :: Control files record the physical structure of the data files and redo log files
They contain the Db name, name and location of dbs, data files ,redo log files and time stamp.

Physical Storage of the Data
The finest level of granularity of the data base are the data blocks.
Data Block :: One Data Block correspond to specific number of physical database space
Extent :: Extent is the number of specific number of contigious data blocks.
Segments :: Set of Extents allocated for Extents. There are three types of Segments
a) Data Segment :: Non Clustered Table has data segment data of every table is stored in cluster data segment
b) Index Segment :: Each Index has index segment that stores data
c) Roll Back Segment :: Temporarily store ‘undo’ information

32) What are the Pct Free and Pct Used
Pct Free is used to denote the percentage of the free space that is to be left when creating a table. Similarly Pct Used is used to denote the percentage of the used space that is to be used when creating a table

eg.:: Pctfree 20, Pctused 40

33) What is Row Chaining
The data of a row in a table may not be able to fit the same data block.Data for row is stored in a chain of data blocks .

34) What is a 2 Phase Commit
Two Phase commit is used in distributed data base systems. This is useful to maintain the integrity of the database so that all the users see the same values. It contains DML statements or Remote Procedural calls that reference a remote object. There are basically 2 phases in a 2 phase commit.
a) Prepare Phase :: Global coordinator asks participants to prepare
b) Commit Phase :: Commit all participants to coordinator to Prepared, Read only or abort Reply

35) What is the difference between deleting and truncating of tables
Deleting a table will not remove the rows from the table but entry is there in the database dictionary and it can be retrieved But truncating a table deletes it completely and it cannot be retrieved.

36) What are mutating tables
When a table is in state of transition it is said to be mutating. eg :: If a row has been deleted then the table is said to be mutating and no operations can be done on the table except select.

37) What are Codd Rules
Codd Rules describe the ideal nature of a RDBMS. No RDBMS satisfies all the 12 codd rules and Oracle Satisfies 11 of the 12 rules and is the only Rdbms to satisfy the maximum number of rules.

38) What is Normalisation
Normalisation is the process of organising the tables to remove the redundancy.There are mainly 5 Normalisation rules.

a) 1 Normal Form :: A table is said to be in 1st Normal Form when the attributes are atomic
b) 2 Normal Form :: A table is said to be in 2nd Normal Form when all the candidate keys are dependant on the primary key
c) 3rd Normal Form :: A table is said to be third Normal form when it is not dependant transitively

39) What are the different types of PL/SQL program units that can be defined and stored in ORACLE database ?
Procedures and Functions,Packages and Database Triggers.

40) What are the advantages of having a Package ?
Increased functionality (for example,global package variables can be declared and used by any proecdure in the package) and performance (for example all objects of the package are parsed compiled, and loaded into memory once)

41) What are the uses of Database Trigger ?
Database triggers can be used to automatic data generation, audit data modifications, enforce complex Integrity constraints, and customize complex security authorizations.

42) What is a Procedure ?
A Procedure consist of a set of SQL and PL/SQL statements that are grouped together as a unit to solve a specific problem or perform a set of related tasks.

43) What is a Package ?
A Package is a collection of related procedures, functions, variables and other package constructs together as a unit in the database.

44) What is difference between Procedures and Functions ?
A Function returns a value to the caller where as a Procedure does not.

45) What is Database Trigger ?
A Database Trigger is procedure (set of SQL and PL/SQL statements) that is automatically executed as a result of an insert in, update to, or delete from a table.

46) Can the default values be assigned to actual parameters?
Yes

 
47) Can a primary key contain more than one columns?
Yes

48) What is an UTL_FILE.What are different procedures and functions associated with it?
UTL_FILE is a package that adds the ability to read and write to operating system files. Procedures associated with it are FCLOSE, FCLOSE_ALL and 5 procedures to output data to a file PUT, PUT_LINE, NEW_LINE, PUTF, FFLUSH.PUT, FFLUSH.PUT_LINE,FFLUSH.NEW_LINE. Functions associated with it are FOPEN, ISOPEN.

49) What are ORACLE PRECOMPILERS?
Using ORACLE PRECOMPILERS, SQL statements and PL/SQL blocks can be contained inside 3GL programs written in C,C++,COBOL,PASCAL, FORTRAN,PL/1 AND ADA. The Precompilers are known as Pro*C,Pro*Cobol,… This form of PL/SQL is known as embedded pl/sql,the language in which pl/sql is embedded is known as the host language. The prcompiler translates the embedded SQL and pl/sql statements into calls to the precompiler runtime library. The output must be compiled and linked with this library to creator an executable.

50) Differentiate between TRUNCATE and DELETE?
TRUNCATE deletes much faster than DELETE
TRUNCATE
DELETE
It is a DDL statement
It is a DML statement
It is a one way trip, cannot ROLLBACK
One can Rollback
Doesn’t have selective features (where clause)
Has
Doesn’t fire database triggers
Does
It requires disabling of referential constraints.

51) What is difference between a formal and an actual parameter?
The variables declared in the procedure and which are passed, as arguments are called actual, the parameters in the procedure declaration. Actual parameters contain the values that are passed to a procedure and receive results. Formal parameters are the placeholders for the values of actual parameters

52) What should be the return type for a cursor variable. Can we use a scalar data type as return type?
The return type for a cursor must be a record type.It can be declared explicitly as a user-defined or %ROWTYPE can be used. eg TYPE t_studentsref IS REF CURSOR RETURN students%ROWTYPE

53) What are different Oracle database objects?
-TABLES
-VIEWS
-INDEXES
-SYNONYMS
-SEQUENCES
-TABLESPACES etc
 
54) What is difference between SUBSTR and INSTR?
SUBSTR returns a specified portion of a string eg SUBSTR(‘BCDEF’,4) output BCDE INSTR provides character position in which a pattern is found in a string. eg INSTR(‘ABC-DC-F’,’-‘,2) output 7 (2nd occurence of ‘-‘)

55) Display the number value in Words?
SQL> select sal, (to_char(to_date(sal,’j’), ‘jsp’))
from emp;
the output like,
SAL (TO_CHAR(TO_DATE(SAL,’J’),’JSP’))
——— —————————————-
800 eight hundred
1600 one thousand six hundred
1250 one thousand two hundred fifty
If you want to add some text like, Rs. Three Thousand only.
SQL> select sal “Salary “,
(‘ Rs. ‘|| (to_char(to_date(sal,’j’), ‘Jsp’))|| ‘ only.’))
“Sal in Words” from emp
/
Salary Sal in Words
——- ———————————————–
800 Rs. Eight Hundred only.
1600 Rs. One Thousand Six Hundred only.
1250 Rs. One Thousand Two Hundred Fifty only.

56) What is difference between SQL and SQL*PLUS?
SQL*PLUS is a command line tool where as SQL and PL/SQL language interface and reporting tool. Its a command line tool that allows user to type SQL commands to be executed directly against an Oracle database. SQL is a language used to query the relational database(DML,DCL,DDL). SQL*PLUS commands are used to format query result, Set options, Edit SQL commands and PL/SQL.

57) What are various joins used while writing SUBQUERIES?
Self join-Its a join foreign key of a table references the same table. Outer Join–Its a join condition used where One can query all the rows of one of the tables in the join condition even though they don’t satisfy the join condition.

Equi-join–Its a join condition that retrieves rows from one or more tables in which one or more columns in one table are equal to one or more columns in the second table.

58) What a SELECT FOR UPDATE cursor represent.?
SELECT……FROM……FOR……UPDATE[OF column-reference][NOWAIT]

The processing done in a fetch loop modifies the rows that have been retrieved by the cursor. A convenient way of modifying the rows is done by a method with two parts: the FOR UPDATE clause in the cursor declaration, WHERE CURRENT OF CLAUSE in an UPDATE or declaration statement.

59) What are various privileges that a user can grant to another user?
-SELECT
-CONNECT
-RESOURCES

60) Display the records between two range?
select rownum, empno, ename from emp where rowid in (select rowid from emp where rownum <=&upto minus select rowid from emp where rownum<&Start);

minvalue.sql Select the Nth lowest value from a table?
select level, min(‘col_name’) from my_table where level = ‘&n’ connect by prior (‘col_name’) < ‘col_name’)
group by level;
Example:
Given a table called emp with the following columns:
— id number
— name varchar2(20)
— sal number

— For the second lowest salary:
— select level, min(sal) from emp
— where level=2
— connect by prior sal < sal
— group by level

61) What is difference between Rename and Alias?
Rename is a permanent name given to a table or column whereas Alias is a temporary name given to a table or column which do not exist once the SQL statement is executed.

62) Difference between an implicit & an explicit cursor.?
only one row. However,queries that return more than one row you must declare an explicit cursor or use a cursor FOR loop. Explicit cursor is a cursor in which the cursor name is explicitly assigned to a SELECT statement via the CURSOR…IS statement. An implicit cursor is used for all SQL statements Declare, Open, Fetch, Close. An explicit cursors are used to process multirow SELECT statements An implicit cursor is used to process INSERT, UPDATE, DELETE and single row SELECT. .INTO statements.

63) What is a OUTER JOIN?
Outer Join–Its a join condition used where you can query all the rows of one of the tables in the join condition even though they don?t satisfy the join condition.

64) What is a cursor?
Oracle uses work area to execute SQL statements and store processing information PL/SQL construct called a cursor lets you name a work area and access its stored information A cursor is a mechanism used to fetch more than one row in a Pl/SQl block.

65) What is the purpose of a cluster?
Oracle does not allow a user to specifically locate tables, since that is a part of the function of the RDBMS. However, for the purpose of increasing performance, oracle allows a developer to create a CLUSTER. A CLUSTER provides a means for storing data from different tables together for faster retrieval than if the table placement were left to the RDBMS.

 
66) What is OCI. What are its uses?
Oracle Call Interface is a method of accesing database from a 3GL program. Uses–No precompiler is required,PL/SQL blocks are executed like other DML statements.

The OCI library provides
–functions to parse SQL statemets
–bind input variables
–bind output variables
–execute statements
–fetch the results

67) How you open and close a cursor variable. Why it is required?
OPEN cursor variable FOR SELECT…Statement

CLOSE cursor variable In order to associate a cursor variable with a particular SELECT statement OPEN syntax is used. In order to free the resources used for the query CLOSE statement is used.
 
68) Display Odd/ Even number of records?
Odd number of records:

select * from emp where (rowid,1) in (select rowid, mod(rownum,2) from emp);
Output:-
1
3
5
Even number of records:
select * from emp where (rowid,0) in (select rowid, mod(rownum,2) from emp)
Output:-
2
4
6

69) What are various constraints used in SQL?
-NULL

-NOT NULL
-CHECK
-DEFAULT

70) Can cursor variables be stored in PL/SQL tables. If yes how. If not why?
No, a cursor variable points a row which cannot be stored in a two-dimensional PL/SQL table.

71) Difference between NO DATA FOUND and %NOTFOUND?
NO DATA FOUND is an exception raised only for the SELECT….INTO statements when the where clause of the querydoes not match any rows. When the where clause of the explicit cursor does not match any rows the %NOTFOUND attribute is set to TRUE instead.

72) Can you use a commit statement within a database trigger?
No

73) What WHERE CURRENT OF clause does in a cursor?
LOOP

SELECT num_credits INTO v_numcredits FROM classes
WHERE dept=123 and course=101;
UPDATE students
FHKO;;;;;;;;;SET current_credits=current_credits+v_numcredits
WHERE CURRENT OF X;

74) There is a string 120000 12 0 .125 , how you will find the position of the decimal place?
INSTR(‘120000 12 0 .125′,1,’.’)

output 13

75) What are different modes of parameters used in functions and procedures?
-IN -OUT -INOUT

76) How you were passing cursor variables in PL/SQL 2.2?
In PL/SQL 2.2 cursor variables cannot be declared in a package.This is because the storage for a cursor variable has to be allocated using Pro*C or OCI with version 2.2, the only means of passing a cursor variable to a PL/SQL block is via bind variable or a procedure parameter.

77) When do you use WHERE clause and when do 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.

78) Difference between procedure and function.?
Functions are named PL/SQL blocks that return a value and can be called with arguments procedure a named block that can be called with parameter. A procedure all is a PL/SQL statement by itself, while a Function call is called as part of an expression.

79) Which is more faster – IN or EXISTS?
EXISTS is more faster than IN because EXISTS returns a Boolean value whereas IN returns a value.

80) What is syntax for dropping a procedure and a function .Are these operations possible?
Drop Procedure procedure_name

Drop Function function_name

81) How will you delete duplicating rows from a base table?
delete from table_name where rowid not in (select max(rowid) from table group by duplicate_values_field_name); or delete duplicate_values_field_name dv from table_name ta where rowid <(select min(rowid) from table_name tb where ta.dv=tb.dv);

82) Difference between database triggers and form triggers?
-Data base trigger(DBT) fires when a DML operation is performed on a data base table. Form trigger(FT) Fires when user presses a key or navigates between fields on the screen
-Can be row level or statement level No distinction between row level and statement level.
-Can manipulate data stored in Oracle tables via SQL Can manipulate data in Oracle tables as well as variables in forms.
-Can be fired from any session executing the triggering DML statements. Can be fired only from the form that define the trigger.
-Can cause other database triggers to fire. Can cause other database triggers to fire, but not other form triggers.

83) What is a cursor for loop?
Cursor For Loop is a loop where oracle implicitly declares a loop variable, the loop index that of the same record type as the cursor’s record.

84) How you will avoid duplicating records in a query?
By using DISTINCT

85) What is a view ?
A view is stored procedure based on one or more tables, it?s a virtual table.

86) What is difference between UNIQUE and PRIMARY KEY constraints?
A table can have only one PRIMARY KEY whereas there can be any number of UNIQUE keys. The columns that compose PK are automatically define NOT NULL, whereas a column that compose a UNIQUE is not automatically defined to be mandatory must also specify the column is NOT NULL.

87) What is use of a cursor variable? How it is defined?
A cursor variable is associated with different statements at run time, which can hold different values at run time. Static cursors can only be associated with one run time query. A cursor variable is reference type (like a pointer in C).
Declaring a cursor variable:
TYPE type_name IS REF CURSOR RETURN return_type type_name is the name of the reference type,return_type is a record type indicating the types of the select list that will eventually be returned by the cursor variable.

88) How do you find the numbert of rows in a Table ?
A bad answer is count them (SELECT COUNT(*) FROM table_name)
A good answer is :-
‘By generating SQL to ANALYZE TABLE table_name COUNT STATISTICS by querying Oracle System Catalogues (e.g. USER_TABLES or ALL_TABLES).
The best answer is to refer to the utility which Oracle released which makes it unnecessary to do ANALYZE TABLE for each Table individually.
 

89) What is the maximum buffer size that can be specified using the DBMS_OUTPUT.ENABLE function?
1,000,00

 

 

Oracle DBA Interview Questions

Top most important Oracle DBA interview questions and answers by Experts:

Here is a list of Top most important Oracle DBA interview questions and answers by Experts.If you want to download Oracle DBA interview questions pdf free ,you can register with RVH techguru. Our experts prepared these Oracle DBA interview questions to accommodate freshers level to most experienced level technical interviews.

If you want to become an expert in Oracle DBA ,Register for Oracle DBA online training here.

 

 

1) How would you determine the time zone under which a database was operating?
select DBTIMEZONE from dual;
2) Explain the use of setting GLOBAL_NAMES equal to TRUE.
Setting GLOBAL_NAMES dictates how you might connect to a database. This variable is either TRUE or FALSE and if it is set to TRUE it enforces database links to have the same name as the remote database to which they are linking.
3) What command would you use to encrypt a PL/SQL application?
WRAP
4) Explain the difference between a FUNCTION, PROCEDURE and PACKAGE.
A function and procedure are the same in that they are intended to be a collection of PL/SQL code that carries a single task. While a procedure does not have to return any values to the calling application, a function will return a single value. A package on the other hand is a collection of functions and procedures that are grouped together based on their commonality to a business function or application.
5) Explain the use of table functions.
Table functions are designed to return a set of rows through PL/SQL logic but are intended to be used as a normal table or view in a SQL statement. They are also used to pipeline information in an ETL process.
6) Name three advisory statistics you can collect.
Buffer Cache Advice, Segment Level Statistics, & Timed Statistics
7) Where in the Oracle directory tree structure are audit traces placed?
In unix $ORACLE_HOME/rdbms/audit, in Windows the event viewer
8) Explain materialized views and how they are used.
Materialized views are objects that are reduced sets of information that have been summarized, grouped, or aggregated from base tables. They are typically used in data warehouse or decision support systems.
9)When a user process fails, what background process cleans up after it?
PMON
10) What background process refreshes materialized views?
The Job Queue Processes.
11) How would you determine what sessions are connected and what resources they are waiting for?
Use of V$SESSION and V$SESSION_WAIT
12) Describe what redo logs are.
Redo logs are logical and physical structures that are designed to hold all the changes made to a database and are intended to aid in the recovery of a database.
13) How would you force a log switch?
ALTER SYSTEM SWITCH LOGFILE;
14) Give two methods you could use to determine what DDL changes have been made.
You could use Logminer or Streams
15) What does coalescing a tablespace do?
Coalescing is only valid for dictionary-managed tablespaces and de-fragments space by combining neighboring free extents into large single extents.
16) What is the difference between a TEMPORARY tablespace and a PERMANENT tablespace?
A temporary tablespace is used for temporary objects such as sort structures while permanent tablespaces are used to store those objects meant to be used as the true objects of the database.
17) Name a tablespace automatically created when you create a database.
The SYSTEM tablespace.
18) When creating a user, what permissions must you grant to allow them to connect to the database?
Grant the CONNECT to the user.
19) How do you add a data file to a tablespace?
ALTER TABLESPACE <tablespace_name> ADD DATAFILE <datafile_name> SIZE <size>
20) How do you resize a data file?
ALTER DATABASE DATAFILE <datafile_name> RESIZE <new_size>;
21) What view would you use to look at the size of a data file?
DBA_DATA_FILES
22)  What view would you use to determine free space in a tablespace?
DBA_FREE_SPACE
23) How would you determine who has added a row to a table?
Turn on fine grain auditing for the table.
24) How can you rebuild an index?
ALTER INDEX <index_name> REBUILD;
25) Explain what partitioning is and what its benefit is.
Partitioning is a method of taking large tables and indexes and splitting them into smaller, more manageable pieces.
26) You have just compiled a PL/SQL package but got errors, how would you view the errors?
SHOW ERRORS
27)  How can you gather statistics on a table?
The ANALYZE command.
28) How can you enable a trace for a session?
Use the DBMS_SESSION.SET_SQL_TRACE or
Use ALTER SESSION SET SQL_TRACE = TRUE;
29) What is the difference between the SQL*Loader and IMPORT utilities?
These two Oracle utilities are used for loading data into the database. The difference is that the import utility relies on the data being produced by another Oracle utility EXPORT while the SQL*Loader utility allows data to be loaded that has been produced by other utilities from different data sources just so long as it conforms to ASCII formatted or delimited files.
30) Name two files used for network connection to a database.
TNSNAMES.ORA and SQLNET.ORA
Technical – UNIX
Every DBA should know something about the operating system that the database will be running on. The questions here are related to UNIX but you should equally be able to answer questions related to common Windows environments.
31) How do you list the files in an UNIX directory while also showing hidden files?
ls -ltra
32) How do you execute a UNIX command in the background?
Use the “&”
33) What UNIX command will control the default file permissions when files are created?
Umask
34) Explain the read, write, and execute permissions on a UNIX directory.
Read allows you to see and list the directory contents.
Write allows you to create, edit and delete files and subdirectories in the directory.
Execute gives you the previous read/write permissions plus allows you to change into the directory and execute programs or shells from the directory.
35) The difference between a soft link and a hard link?
A symbolic (soft) linked file and the targeted file can be located on the same or different file system while for a hard link they must be located on the same file system.
36) Give the command to display space usage on the UNIX file system.
df -lk
37) Explain iostat, vmstat and netstat.
Iostat reports on terminal, disk and tape I/O activity.
Vmstat reports on virtual memory statistics for processes, disk, tape and CPU activity.
Netstat reports on the contents of network data structures.
38) How would you change all occurrences of a value using VI?
Use :%s/<old>/<new>/g
39) Give two UNIX kernel parameters that effect an Oracle install
SHMMAX & SHMMNI
40) Briefly, how do you install Oracle software on UNIX.
Basically, set up disks, kernel parameters, and run orainst.

41) What is Secure External password Store (SEPS)?

Through the use of SEPS you can store password credentials for connecting to database by using a client side oracle wallet, this wallet stores signing credentials. This feature introduced since oracle 10g. Thus the application code, scheduled job, scripts no longer needed embedded username and passwords. This reduces risk because the passwords are no longer exposed and password management policies are more easily enforced without changing application code whenever username and password change.

42) Differentiate DB file sequential read wait/DB File Scattered Read?

Sequential read associated with index read where as scattered read has to do with full table scan. The sequential read, reads block into contiguous memory and DB scattered read gets from multiple block and scattered them into buffer cache. 

43) I install oracle 10g on windows 7 successfully. I found every thing working fine except the toad is giving “cannot load oci.dll” error. Is this compatibility issue?

Read the toad user guide. You will get important information related to compatibility issue. In fact toad works with both 32 bit and 64 bit oracle server where as toad only work with 32 bit client. If you need 64 bit client for 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.

44) How to re-organize schema?

We can use dbms_redefinition package for online re-organization of schema objects. Otherwise using import/export and data pump utility you can recreate or re-organize your schema

45) How can you control number of datafiles in oracle database?

The db_files parameter is a “soft limit ” parameter that controls the maximum number of physical OS files that can map to an Oracle instance. The maxdatafiles parameter is a different – “hard limit” parameter. When issuing a “create database” command, the value specified for maxdatafiles is stored in Oracle control files and default value is 32. The maximum number of database files can be set with the init parameter db_files.

Regardless of the setting of this parameter, maximum per database: 65533 (May be less on some operating systems), Maximum number of datafiles per tablespace: OS dependent = usually 1022

You can also by Limited size of database blocks and by the DB_FILES initialization parameter for a particular instance. Bigfile tablespaces can contain only one file, but that file can have up to 4G blocks.

46) What is Latches and why they are used in oracle?

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.

47) 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.

48) 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

49) 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.

50) 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.