Professional Documents
Culture Documents
com
2. What is TNS?
Answer: Most people prefer to edit the SQL*Net configuration files by hand.The
only "officially supported" configuration method, however, is via the Oracle Network
Manager utility.
Answer: Create/edit your SQLNET.ORA file.You will find the SQLNET.ORA file in
one of the following locations (SQL*Net V2 searches for it in this order):
trace_level_client=16
trace_unique_client=yes
Answer: Set the dedicated server option in your database connects string.ie.
SQLPLUS SCOTT/TIGER@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
(PORT=1521)
(NODE=yourServerName)) (CONNECT_DATA=(SID=yourSid)
(SERVER=DEDICATED)))
http://sparshme5.googlepages.com
1
First Job…. Dream Job…. Sparshme5.googlepages.com
Answer: SQL*Net V1 cannot talk with SQL*Net V2, and vice versa.The only way to
overcome this problem is to run SQL*Net V1 and V2 simultaneously on the same
database server.You can then install SQL*Net V2 on your clients as time
permits.SQL*Net V1 and V2 can coexist on the same server, or on the same client.
You can also list V1 connect strings in your TNSNAMES.ORA file.
Eg:
ORA1_NET1 = T:machine_name/port:database_name
Answer: Dead database connections can be detected and killed by SQL*Net if you
specify the SQLNET.EXPIRE_TIME=n parameter in your SQLNET.ORA file.This
parameter will instruct SQL*Net to send a probe through the network to the client
every n minutes, if the client doesn't respond, it will be killed.
Answer: These are the main SQL*Net protocol adapters supported by Oracle:
VTAM
IBM's
DEC Net
IBM's LU 6.2
Named Pipes
TCP/IP
Novell's IPX/SPX
IBM MVS Cross Memory
NetBEUI
9. Can one get connected to a database regardless of machine failure?
Answer: With SQL*Net V2 you can connect to a database, even if some kind of
physical failover occurred.Look at the following example:
oradb1 = (DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(COMMUNITY = TCP_COMM)
(PROTOCOL = TCP)
(HOST = Machine01))
http://sparshme5.googlepages.com
2
First Job…. Dream Job…. Sparshme5.googlepages.com
(ADDRESS =
(COMMUNITY = TCP_COMM)
(PROTOCOL = TCP)
(HOST = Machine02)))
{CONNECT_DATA=(
(SID=oradb1))))
Suppose Machine01 is down, then every new SQL*NET connection using service
oradb1 will automatically login to Machine02.However, there is one restriction, the
SID must be the same on both machines.This feature can provide guaranteed login
for application servers and the Oracle Parallel Server.
What is SQL?
Answer: The SELECT statement lets you select a set of values from a table in a database.The
values selected from the database table would depend on the various conditions that are
specified in the SQL query.
How can you compare a part of the name rather than the entire name?
Answer: The INSERT statement lets you insert information into a database.
Answer: Use the DELETE statement to remove records or any particular column values from
a database.
http://sparshme5.googlepages.com
3
First Job…. Dream Job…. Sparshme5.googlepages.com
Answer: The SELECT statement in conjunction with DISTINCT lets you select a set of
distinct values from a table in a database.The values selected from the database table would
of course depend on the various conditions that are specified in the SQL
query.ExampleSELECT DISTINCT empname FROM emptable
Answer: You can sort the results and return the sorted results to your program by using
ORDER BY keyword thus saving you the pain of carrying out the sorting yourself.The
ORDER BY keyword is used for sorting.SELECT empname, age, city FROM emptable
ORDER BY empname
Answer: You could use the COUNT keyword , exampleSELECT COUNT(*) FROM emp
WHERE age>40
Answer: The GROUP BY keywords have been added to SQL because aggregate functions
(like SUM) return the aggregate of all column values every time they are called.Without the
GROUP BY functionality, finding the sum for each individual group of column values was
not possible.
What is the difference among "dropping a table", "truncating a table" and "deleting
all records" from a table.
Answer: Dropping : (Table structure + Data are deleted), Invalidates the dependent objects
,Drops the indexes Truncating: (Data alone deleted), Performs an automatic commit, Faster
than deleteDelete : (Data alone deleted), Doesn't perform automatic commit
Answer: Having clause is used only with group functions whereas Where is not used with.
Answer: Both primary key and unique enforce uniqueness of the column on which they are
defined.But by default primary key creates a clustered index on the column, where are unique
creates a nonclustered index by default.Another major difference is that, primary key doesn't
allow NULLs, but unique key allows one NULL only.
What are cursors? Explain different types of cursors.What are the disadvantages of
cursors? How can you avoid cursors?
http://sparshme5.googlepages.com
4
First Job…. Dream Job…. Sparshme5.googlepages.com
Answer: Triggers are special kind of stored procedures that get executed automatically when an
INSERT, UPDATE or DELETE operation takes place on a table.Triggers can't be invoked on
demand.They get triggered only when an associated action (INSERT, UPDATE, DELETE)
happens on the table on which they are defined.Triggers are generally used to implement
business rules, auditing.Triggers can also be used to extend the referential integrity checks,
but wherever possible, use constraints for this purpose, instead of triggers, as constraints are
much faster.
Answer: Joins are used in queries to explain how different tables are related.Joins also let you
select data from a table depending upon data from another table.Types of joins: INNER JOINs,
OUTER JOINs, CROSS JOINs.OUTER JOINs are further classified as LEFT OUTER
JOINS, RIGHT OUTER JOINS and FULL OUTER JOINS.
Answer: Self join is just like any other join, except that two instances of the same table will
be joined in the query.
Answer: SQL> DELETE FROM table_name A WHERE ROWID > (SELECT min(rowid)
FROM table_name B WHERE A.key_values = B.key_values);
FROM tab1
DUMP(COL1)
http://sparshme5.googlepages.com
5
First Job…. Dream Job…. Sparshme5.googlepages.com
For this example the type is 96, indicating CHAR, and the last byte in the column is 32,
which is the ASCII code for a space.This tells us that this column is blank-padded.
http://sparshme5.googlepages.com
6
First Job…. Dream Job…. Sparshme5.googlepages.com
Explain IN operator.
Answer: The IN operator may be used if you know the exact value you want to return for at
least one of the columns.
Explain BETWEEN...AND
What is PL/SQL?
Answer: PL/SQL V2.2, available with Oracle7.2, implements a binary wrapper for PL/SQL
programs to protect the source code.
This is done via a standalone utility that transforms the PL/SQL source code into portable
binary object code (somewhat larger than the original).This way you can distribute software
without having to worry about exposing your proprietary algorithms and methods.SQL*Plus
and SQL*DBA will still understand and know how to execute such scripts.Just be careful,
there is no "decode" command available.
http://sparshme5.googlepages.com
7
First Job…. Dream Job…. Sparshme5.googlepages.com
Answer: Included in Oracle 7.3 is a UTL_FILE package that can read and write files.The
directory you intend writing to has to be in your INIT.ORA file.
Before Oracle 7.3 the only means of writing a file was to use DBMS_OUTPUT with the
SQL*Plus SPOOL command.
DECLARE
fileHandler UTL_FILE.FILE_TYPE;
BEGIN
UTL_FILE.FCLOSE(fileHandler);
END;
Answer: From PL/SQL V2.1 one can use the DBMS_SQL package to execute dynamic SQL
statements.
Eg:
cur integer;
rc integer;
BEGIN
cur := DBMS_SQL.OPEN_CURSOR;
rc := DBMS_SQL.EXECUTE(cur);
DBMS_SQL.CLOSE_CURSOR(cur);
END;
How does one get the value of a sequence into a PL/SQL variable?
http://sparshme5.googlepages.com
8
First Job…. Dream Job…. Sparshme5.googlepages.com
Answer: No.All your PL/SQL are send directly to the database engine for execution.
Answer: Currently, the maximum parsed/compiled size of a PL/SQL block is 64K and the
maximum code size is 100K.You can run the following select statement to query the size of
an existing package or procedure.
What is SQL*Plus?
Answer: SQL*Plus is a command line SQL and PL/SQL language interface and reporting
tool that ship with the Oracle Database Server.It can be used interactively or driven from
scripts.
Although SQL*Plus's predecessor was called UFI (User Friendly Interface), its interface is
quite primitive.
Answer: You can enter three kinds of commands from the SQL*Plus command prompt:
SQL*Plus commands
SQL commands
PL/SQL blocks
Answer:
http://sparshme5.googlepages.com
9
First Job…. Dream Job…. Sparshme5.googlepages.com
SPOOL Send output to a file.Eg "spool x" will save STDOUT to a file called x.lst
START Run a SQL script file (short: @)
What is AFIEDT.BUF?
AFIEDT.BUF is the SQL*Plus default edit save file.When you issue the command "ed" or
"edit" without arguments, the last SQL or PL/SQL command will be saved to a file called
AFIEDT.BUF and opened in the default editor.
Answer: The @ (at symbol) is equivalent to the START command and is used to run
SQL*Plus command scripts.
A single @ symbol runs the script relative to the current directory, the double at (@@) runs a
command file relative to the directory of the current script
Answer: "&" is used to create a temporary substitution variable and will prompt you for a
value every time it is referenced.
"&&" is used to create a permanent substitution variable as with the DEFINE command and
the OLD_VALUE or NEW_VALUE clauses of a COLUMN statement.
Answer: Both "!" and "HOST" will execute operating system commands as child processes of
SQL*Plus.
The difference is that "HOST" will perform variable substitution (& and && symbols),
whereas "!" will not.
Answer: Use the "WHENEVER OSERROR..." to trap operating system errors and the
"WHENEVER SQLERROR..." command to trap SQL and PL/SQL errors.
Eg:
Note that this table is not used when someone signs on as user SYSTEM.
http://sparshme5.googlepages.com
10
First Job…. Dream Job…. Sparshme5.googlepages.com
Eg.to disable all users whose names starts with OPS$ from executing the CONNECT
command:
Answer: The Delete command will log the data changes in the log file where as the truncate
will simply remove the data without it.Hence Data removed by Delete command can be
rolled back but not the data removed by TRUNCATE.Truncate is a DDL statement whereas
DELETE is a DML statement.
What is the maximum buffer size that can be specified using the
DBMS_OUTPUT.ENABLE function?
Answer: 1000000
Answer: Yes, if you are using autonomous transactions in the Database triggers.
What is an UTL_FILE? What are different procedures and functions associated with
it?
Answer: 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.
http://sparshme5.googlepages.com
11
First Job…. Dream Job…. Sparshme5.googlepages.com
Answer: Database triggers are fired whenever any database action like INSERT, UPATE,
DELETE, LOGON LOGOFF etc occurs.Form triggers on the other hand are fired in response
to any event that takes place while working with the forms, say like navigating from one field
to another or one block to another and so on.
Answer: OCI is Oracle Call Interface.When applications developers demand the most powerful
interface to the Oracle Database Server, they call upon the Oracle Call Interface (OCI).OCI
provides the most comprehensive access to all of the Oracle Database functionality.The
newest performance, scalability, and security features appear first in the OCI API.If you write
applications for the Oracle Database, you likely already depend on OCI.Some types of
applications that depend upon OCI are:
Answer: A precompiler is a tool that allows programmers to embed SQL statements in high-
level source programs like C, C++, COBOL, etc.The precompiler accepts the source program
as input, translates the embedded SQL statements into standard Oracle runtime library calls,
and generates a modified source program that one can compile, link, and execute in the usual
way.Examples are the Pro*C Precompiler for C, Pro*Cobol for Cobol, SQLJ for Java etc.
Answer: Drop Procedure/Function ; yes, if they are standalone procedures or functions.If they
are a part of a package then one have to remove it from the package definition and body and
recompile the package.
Answer: Yes.In such case you don't need to specify any value and the actual parameter will
take the default value provided in the function definition.
http://sparshme5.googlepages.com
12
First Job…. Dream Job…. Sparshme5.googlepages.com
Answer: The formal parameters are the names that are declared in the parameter list of the
header of a module.The actual parameters are the values or expressions placed in the
parameter list of the actual call to the module.
IN- The IN parameter allows you to pass values in to the module, but will not pass
anything out of the module and back to the calling PL/SQL block.In other words, for
the purposes of the program, its IN parameters function like constants.Just like
constants, the value of the formal IN parameter cannot be changed within the
program.You cannot assign values to the IN parameter or in any other way modify its
value.
IN is the default mode for parameters.IN parameters can be given default values in
the program header.
OUT - An OUT parameter is the opposite of the IN parameter.Use the OUT
parameter to pass a value back from the program to the calling PL/SQL block.An
OUT parameter is like the return value for a function, but it appears in the parameter
list and you can, of course, have as many OUT parameters as you like.
Inside the program, an OUT parameter acts like a variable that has not been
initialised.In fact, the OUT parameter has no value at all until the program terminates
successfully (without raising an exception, that is).During the execution of the
program, any assignments to an OUT parameter are actually made to an internal copy
of the OUT parameter.When the program terminates successfully and returns control
to the calling block, the value in that local copy is then transferred to the actual OUT
parameter.That value is then available in the calling PL/SQL block.
IN OUT - With an IN OUT parameter, you can pass values into the program and
return a value back to the calling program (either the original, unchanged value or a
new value set within the program).The IN OUT parameter shares two restrictions
with the OUT parameter: An IN OUT parameter cannot have a default value. An IN
OUT actual parameter or argument must be a variable.It cannot be a constant, literal,
or expression, since these formats do not provide a receptacle in which PL/SQL can
place the outgoing value.
Answer: A function always returns a value, while a procedure does not.When you call a
function you must always assign its value to a variable.
Can cursor variables be stored in PL/SQL tables.If yes how.If not why?
Answer: Yes.Create a cursor type - REF CURSOR and declare a cursor variable of that type.
DECLARE
http://sparshme5.googlepages.com
13
First Job…. Dream Job…. Sparshme5.googlepages.com
CLOSE company_curvar;
END;
Answer: Using OPEN cursor_name and CLOSE cursor_name commands.The cursor must be
opened before using it in order to fetch the result set of the query it is associated with.The
cursor needs to be closed so as to release resources earlier than end of transaction, or to free
up the cursor variable to be opened again.
What should be the return type for a cursor variable.Can we use a scalar data type as
return type?
Answer: Cursor variable is used to mark a work area where Oracle stores a multi-row query
output for processing.It is like a pointer in C or Pascal.Because it is a TYPE, it is defined as
TYPE REF CURSOR RETURN ;
Answer: The Where Current Of statement allows you to update or delete the record that was
last fetched by the cursor.
Answer: NO DATA FOUND is an exception which is raised when either an implicit query
returns no data, or you attempt to reference a row in the PL/SQL table which is not yet
defined.SQL%NOTFOUND, is a BOOLEAN attribute indicating whether the recent SQL
statement does not match to any row.
http://sparshme5.googlepages.com
14
First Job…. Dream Job…. Sparshme5.googlepages.com
Answer: A cursor FOR loop is a loop that is associated with (actually defined by) an explicit
cursor or a SELECT statement incorporated directly within the loop boundary.Use the cursor
FOR loop whenever (and only if) you need to fetch and process each and every record from a
cursor, which is a high percentage of the time with cursors.
Answer: Cursor attributes are used to get the information about the current status of your
cursor.Both explicit and implicit cursors have four attributes, as shown:
Name Description
Answer: The implicit cursor is used by Oracle server to test and parse the SQL statements and the
explicit cursors are declared by the programmers.
What is a cursor?
Answer: A cursor is a mechanism by which you can assign a name to a "select statement" and
manipulate the information within that SQL statement.
Answer: A cluster provides an optional method of storing table data.A cluster is comprised of
a group of tables that share the same data blocks, which are grouped together because they
share common columns and are often used together.For example, the EMP and DEPT table
share the DEPTNO column.When you cluster the EMP and DEPT, Oracle physically stores all
rows for each department from both the EMP and DEPT tables in the same data blocks.You
should not use clusters for tables that are frequently accessed individually.
Answer: select count(*) from table, or from NUM_ROWS column of user_tables if the table
statistics has been collected.
Answer: Information such as row numbers and row descriptions are automatically stored by
Oracle and is directly accessible, ie.not through tables.This information is contained within
http://sparshme5.googlepages.com
15
First Job…. Dream Job…. Sparshme5.googlepages.com
pseudo columns.These pseudo columns can be retrieved in queries.These pseudo columns can
be included in queries which select data from tables. Available Pseudo Columns
Answer: By changing the order of the columns that are used in the index, in the Where
condition, or by concatenating the columns with some constant values.
Answer: An OUTER JOIN returns all rows that satisfy the join condition and also returns
some or all of those rows from one table for which no rows from the other satisfy the join
condition.
http://sparshme5.googlepages.com
16
First Job…. Dream Job…. Sparshme5.googlepages.com
When do you use WHERE clause and when do you use HAVING clause?
Answer: The WHERE condition lets you restrict the rows selected to those that satisfy one or
more conditions.Use the HAVING clause to restrict the groups of returned rows to those
groups for which the specified condition is TRUE.
There is a % sign in one field of a column.What will be the query to find it?
Answer: INSTR function search string for sub-string and returns an integer indicating the
position of the character in string that is the first character of this occurrence.SUBSTR function
return a portion of string, beginning at character position, substring_length characters
long.SUBSTR calculates lengths using characters as defined by the input character set.
Answer: SQL is the query language to manipulate the data from the database.SQL*PLUS is
the tool that lets to use SQL to fetch and display the data.
Answer: An UNIQUE key can have NULL whereas PRIMARY key is always not NOT
NULL.Both bears unique values.
Answer: Rename is actually changing the name of an object whereas Alias is giving another
name (additional name) to an existing object.
Answer: 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.
http://sparshme5.googlepages.com
17
First Job…. Dream Job…. Sparshme5.googlepages.com
Give two examples of how you might determine the structure of the table DEPT.
Explain the difference between a hot backup and a cold backup and the benefits
associated with each.
Answer: A hot backup is basically taking a backup of the database while it is still up and
running and it must be in archive log mode.A cold backup is taking a backup of the database
while it is shut down and does not require being in archive log mode.The benefit of taking a
hot backup is that the database is still available for use while the backup is occurring and you
can recover the database to any point in time.The benefit of taking a cold backup is that it is
typically easier to administer the backup and recovery process.In addition, since you are
taking cold backups the database does not require being in archive log mode and thus there
will be a slight performance gain as the database is not cutting archive logs to disk.
A table is classified as a parent table and you want to drop and re-create it.How
would you do this without affecting the children tables?
Answer: Disable the foreign key constraint to the parent, drop the table, re-create the table,
enable the foreign key constraint.
Answer: ARCHIVELOG mode is a mode that you can put the database in for creating a
backup of all transactions that have occurred in the database so that you can recover to any
point in time.NOARCHIVELOG mode is basically the absence of ARCHIVELOG mode and
has the disadvantage of not being able to recover to any point in time.NOARCHIVELOG
mode does have the advantage of not having to write transactions to an archive log and thus
increases the performance of the database slightly.
Give the stages of instance startup to a usable state where normal users may access it.
What column differentiates the V$ views to the GV$ views and how?
http://sparshme5.googlepages.com
18
First Job…. Dream Job…. Sparshme5.googlepages.com
Answer: The INST_ID column which indicates the instance in a RAC environment
Use the explain plan set statement_id = 'tst1' into plan_table for a SQL statement
How would you go about increasing the buffer cache hit ratio?
Answer: 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.
Explain an ORA-01555
Answer: You get this error when you get a snapshot too old within rollback.It can usually be
solved by increasing the undo retention or increasing the size of rollbacks.You should also
look at the logic involved in the application getting the error message.
Where would you look for errors from the database engine?
Answer: Both the truncate and delete command have the desired outcome of getting rid of all
the rows in a table.The difference between the two is that the truncate command is a DDL
operation and just moves the high water mark and produces a now rollback.The delete
command, on the other hand, is a DML operation, which will produce a rollback and thus
take longer to complete.
Give the two types of tables involved in producing a star schema and the type of data
they hold.
Answer: Fact tables and dimension tables.A fact table contains measurements while
dimension tables will contain data that will help describe the fact tables.
http://sparshme5.googlepages.com
19
First Job…. Dream Job…. Sparshme5.googlepages.com
Normal Queries
Sub Queries
Co-related queries
Nested queries
Compound queries
2. What is a transaction ?
Answer: A transaction is a set of SQL statements between any two COMMIT and
ROLLBACK statements.
4. Which of the following is not a schema object : Indexes, tables, public synonyms,
triggers and packages ?
5. What is PL/SQL?
Answer: No.Unlike Oracle Forms, SQL*Plus does not have a PL/SQL engine.Thus,
all your PL/SQL are send directly to the database engine for execution.This makes it
much more efficient as SQL statements are not stripped off and send to the database
individually.
Answer: Included in Oracle 7.3 is a UTL_FILE package that can read and write
files.The directory you intend writing to has to be in your INIT.ORA file (see
http://sparshme5.googlepages.com
21
First Job…. Dream Job…. Sparshme5.googlepages.com
Answer: PL/SQL V2.2, available with Oracle7.2, implements a binary wrapper for
PL/SQL programs to protect the source code.This is done via a standalone utility that
transforms the PL/SQL source code into portable binary object code (somewhat larger
than the original).This way you can distribute software without having to worry about
exposing your proprietary algorithms and methods.SQL*Plus and SQL*DBA will
still understand and know how to execute such scripts.Just be careful, there is no
"decode" command available. The syntax is: wrap iname=myscript.sql
oname=xxxx.yyy
10. Can one use dynamic SQL within PL/SQL? OR Can you use a DDL in a
procedure ? How ?
Answer: From PL/SQL V2.1 one can use the DBMS_SQL package to execute
dynamic SQL statements.
Eg: CREATE OR REPLACE PROCEDURE DYNSQL AS
cur integer;
rc integer;
BEGIN
cur := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(cur,'CREATE TABLE X (Y DATE)', DBMS_SQL.NATIVE);
rc := DBMS_SQL.EXECUTE(cur);
DBMS_SQL.CLOSE_CURSOR(cur);
END;
Normal Queries
Sub Queries
Co-related queries
Nested queries
Compound queries
What is a transaction ?
Answer: A transaction is a set of SQL statements between any two COMMIT and
ROLLBACK statements.
http://sparshme5.googlepages.com
22
First Job…. Dream Job…. Sparshme5.googlepages.com
Which of the following is not a schema object : Indexes, tables, public synonyms,
triggers and packages ?
What is PL/SQL?
Answer: No.Unlike Oracle Forms, SQL*Plus does not have a PL/SQL engine.Thus, all your
PL/SQL are send directly to the database engine for execution.This makes it much more
efficient as SQL statements are not stripped off and send to the database individually.
Answer: Currently, the maximum parsed/compiled size of a PL/SQL block is 64K and the
maximum code size is 100K.You can run the following select statement to query the size of
an existing package or procedure. SQL> select * from dba_object_size where name =
'procedure_name'
Answer: Included in Oracle 7.3 is a UTL_FILE package that can read and write files.The
directory you intend writing to has to be in your INIT.ORA file (see
UTL_FILE_DIR=...parameter).Before Oracle 7.3 the only means of writing a file was to use
DBMS_OUTPUT with the SQL*Plus SPOOL command.
DECLARE
fileHandler UTL_FILE.FILE_TYPE;
BEGIN
fileHandler := UTL_FILE.FOPEN('/home/oracle/tmp', 'myoutput','W');
UTL_FILE.PUTF(fileHandler, 'Value of func1 is %sn', func1(1));
UTL_FILE.FCLOSE(fileHandler);
END;
Answer: PL/SQL V2.2, available with Oracle7.2, implements a binary wrapper for PL/SQL
programs to protect the source code.This is done via a standalone utility that transforms the
PL/SQL source code into portable binary object code (somewhat larger than the
http://sparshme5.googlepages.com
23
First Job…. Dream Job…. Sparshme5.googlepages.com
original).This way you can distribute software without having to worry about exposing your
proprietary algorithms and methods.SQL*Plus and SQL*DBA will still understand and know
how to execute such scripts.Just be careful, there is no "decode" command available. The
syntax is: wrap iname=myscript.sql oname=xxxx.yyy
Can one use dynamic SQL within PL/SQL? OR Can you use a DDL in a procedure ?
How ?
Answer: From PL/SQL V2.1 one can use the DBMS_SQL package to execute dynamic SQL
statements.
Eg: CREATE OR REPLACE PROCEDURE DYNSQL AS
cur integer;
rc integer;
BEGIN
cur := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(cur,'CREATE TABLE X (Y DATE)', DBMS_SQL.NATIVE);
rc := DBMS_SQL.EXECUTE(cur);
DBMS_SQL.CLOSE_CURSOR(cur);
END;
Answer: No.
Answer: Functions return a single variable by value whereas procedures do not return any
variable by value.Rather they return multiple variables by passing variables by reference
through their OUT parameter.
Can you have two functions with the same name in a PL/SQL block ?
Answer: Yes.
Can you have two stored functions with the same name ?
Answer: Yes.
Answer: No.
http://sparshme5.googlepages.com
24
First Job…. Dream Job…. Sparshme5.googlepages.com
Answer: OverLoading means an object performing different functions depending upon the
no.of parameters or the data type of the parameters passed to it.
Answer: Yes.
Can 2 functions have same name & input parameters but differ only by return
datatype
Answer: No.
http://sparshme5.googlepages.com
25
First Job…. Dream Job…. Sparshme5.googlepages.com
Answer: We have control over the firing of a stored procedure but we have no control over
the firing of a trigger.
What is the maximum no.of statements that can be specified in a trigger statement ?
Answer: One.
Answer: No
Answer: When a statement in a trigger body causes another trigger to be fired, the triggers are
said to be cascading.Max = 32.
Answer: A trigger giving a SELECT on the table on which the trigger is written.
Answer:
http://sparshme5.googlepages.com
26
First Job…. Dream Job…. Sparshme5.googlepages.com
Answer: Contains pointers to locations of various data files, redo log files, etc.
Answer: It Used by Oracle to store information about various physical and logical Oracle
structures e.g.Tables, Tablespaces, datafiles, etc
Answer: No.
Answer: Yes.
Answer: Yes.In the CHECK condition for a column of a table, we can reference some other
column of the same table and thus enforce self referential integrity.
Answer: Two
What are the states of a rollback segment ? What is the difference between partly
available and needs recovery ?
ONLINE
OFFLINE
PARTLY AVAILABLE
NEEDS RECOVERY
INVALID.
http://sparshme5.googlepages.com
27
First Job…. Dream Job…. Sparshme5.googlepages.com
Answer: No.
Answer: Yes.
Answer: Yes.
Answer: 254.
Answer: The & operator means that the PL SQL block requires user input for a variable.
The && operator means that the value of this variable should be the same as inputted by the
user previously for this same variable
Answer: Explicit cursors can take parameters, as the example below shows.A cursor
parameter can appear in a query wherever a constant can appear.
Answer: Yes
http://sparshme5.googlepages.com
28
First Job…. Dream Job…. Sparshme5.googlepages.com
Answer: Yes
Answer: Yes
Answer: Yes
Answer: 9 rows
Answer: No rows
Which symbol preceeds the path to the table in the remote database ?
Answer: @
Answer: Yes
Answer: No
If all the values from a cursor have been fetched and another fetch is issued, the
output will be : error, last record or first record ?
A table has the following data : [[5, Null, 10]].What will the average function return ?
Answer: 7.5
http://sparshme5.googlepages.com
29
First Job…. Dream Job…. Sparshme5.googlepages.com
Answer: 3
Answer: A Relational Database is a database where all data visible to the user is organized
strictly as tables of data values and where all database operations work on these tables.
Answer: In a Single Threaded Architecture (or a dedicated server configuration) the database
manager creates a separate process for each database user.But in MTA the database manager
can assign multiple users (multiple user processes) to a single dispatcher (server process), a
controlling process that queues request for work thus reducing the databases memory
requirement and resources.
Answer:
RDBMS - R system
Hierarchical - IMS
N/W - DBTG
Answer:
ORACLE 7 ORACLE 6
Cost based optimizer Rule based optimizer
Shared SQL Area SQL area allocated for each user
Multi Threaded Server Single Threaded Server
Hash Clusters Only B-Tree indexing
Roll back Size Adjustment No provision
Truncate command No provision
Distributed Database Distributed Query
Table replication & snapshots No provision
Client/Server Tech No provision
What is Functional Dependency
http://sparshme5.googlepages.com
30
First Job…. Dream Job…. Sparshme5.googlepages.com
What is Auditing ?
Answer: The database has the ability to audit all actions that take place within it. a) Login
attempts, b) Object Accesss, c) Database Action Result of Greatest(1,NULL) or
Least(1,NULL) NULL
Answer: To be created when table is queried for less than 2% or 4% to 25% of the table rows.
Answer: Error
Can database trigger written on synonym of a table and if it can be then what would
be the effect if original table is accessed.
http://sparshme5.googlepages.com
31
First Job…. Dream Job…. Sparshme5.googlepages.com
Answer: No
Answer: No.
Answer: Synonym is just a second name of table used for multiple link of database.View can
be created with many tables, and with virtual columns and with conditions.But synonym can
be on view.
Answer: Foreign key is the key i.e.attribute which refers to another table primary key.
Reference key is the primary key of table referred by another table.
Answer: Yes
Answer: Yes
If any other table same as dual is created would it act similar to dual?
Answer: Yes
.Assume that there are multiple databases running on one machine.How can you
switch from one to another ?
Answer: Portability : Oracle is ported to more platforms than any of its competitors, running
on more than 100 hardware platforms and 20 networking protocols. Market Presence : Oracle
is by far the largest RDBMS vendor and spends more on R & D than most of its competitors
earn in total revenue.This market clout means that you are unlikely to be left in the lurch by
http://sparshme5.googlepages.com
32
First Job…. Dream Job…. Sparshme5.googlepages.com
Oracle and there are always lots of third party interfaces available. Backup and Recovery :
Oracle provides industrial strength support for on-line backup and recovery and good
software fault tolerence to disk failure.You can also do point-in-time recovery. Performance :
Speed of a 'tuned' Oracle Database and application is quite good, even with large
databases.Oracle can manage > 100GB databases. Multiple database support : Oracle has a
superior ability to manage multiple databases within the same transaction using a two-phase
commit protocol.
Answer: PL/SQL requires that you declare an identifier before using it.Therefore, you must
declare a subprogram before calling it.This declaration at the start of a subprogram is called
forward declaration.A forward declaration consists of a subprogram specification terminated
by a semicolon.
What all important parameters of the init.ora are supposed to be increased if you
want to increase the SGA size ?
Answer: In our case, db_block_buffers was changed from 60 to 1000 (std values are 60, 550
& 3500) shared_pool_size was changed from 3.5MB to 9MB (std values are 3.5, 5 & 9MB)
open_cursors was changed from 200 to 300 (std values are 200 & 300) db_block_size was
changed from 2048 (2K) to 4096 (4K) {at the time of database creation}. The initial SGA
was around 4MB when the server RAM was 32MB and The new SGA was around 13MB
when the server RAM was increased to 128MB.
.If I have an execute privilege on a procedure in another users schema, can I execute
his procedure even though I do not have privileges on the tables within the procedure ?
Answer: Yes
http://sparshme5.googlepages.com
33
First Job…. Dream Job…. Sparshme5.googlepages.com
Equijoins
Non-equijoins
self join
outer join
Answer: A package cursor is a cursor which you declare in the package specification without
an SQL statement.The SQL statement for the cursor is attached dynamically at runtime from
calling procedures.
If you insert a row in a table, then create another table and then say Rollback.In this
case will the row be inserted ?
http://sparshme5.googlepages.com
34