Академический Документы
Профессиональный Документы
Культура Документы
1) What are the Back ground processes in Oracle and what are they?
This is one of the most frequently asked questions. There are basically 9 Processes
but in
a general system we need to mention the first five background processes. They do
the
house keeping activities for the Oracle and are common in any system.
Data Base Writer (DBWR): Data Base Writer Writes Modified blocks from Database
buffer cache to Data Files. This is required since the data is not written whenever a
transaction is committed.
Log Writer (LGWR): Log writer writes the redo log entries to disk. Redo Log data is
generated in redo log buffer of SGA. As transaction commits and logs buffer fills,
LGWR writes log entries into an online redo log file.
System Monitor (SMON): The System Monitor performs instance recovery at
instance startup. This is useful for recovery from system failure
Process Monitor (PMON): The Process Monitor performs process recovery when
user Process fails. PMON Clears and Frees resources that process was using.
Check Point (CKPT): At Specified times, all modified database buffers in SGA are
written to data files by DBWR at Checkpoints and Updating all data files and control
files of database to indicate the most recent checkpoint
Achieves (ARCH): The Archiver copies online redo log files to archival storal when
they are busy.
Recover or (RECO): The Recovered is used to resolve the distributed transaction in
network
Dispatcher (Dnnn): The Dispatcher is useful in Multi Threaded Architecture
Lckn: We can have up to 10 lock processes for interred instance locking in parallel
SQL.
Data Definition Language (DDL): The DDL statements define and maintain
objects and drop objects.
Data Manipulation Language (DML): The DML statements manipulate database
data.
Transaction Control Statements: Manage change by DML
Session Control: Used to control the properties of current session enabling and
disabling roles and changing. E.g. Alter Statements, Set Role
System Control Statements: Change Properties of Oracle Instance. E.g.: Alter
1
System
Embedded SQL: Incorporate DDL, DML and T.C.S in Programming Language.
E.g. Using the SQL Statements in languages such as 'C', Open, Fetch, execute and
close
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. Database
Triggers 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, and delete 3
Before, after 3*2 A total of 6 combinations
At statement 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.
2
8) How many Integrity Rules are there and what are they?
There are Three Integrity Rules. They are as follows:
Entity Integrity Rule: The Entity Integrity Rule enforces that the Primary key cannot
be Null
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.
Business Integrity Rules: The Third Integrity rule is about the complex business
processes
which cannot be implemented by the above 2 rules.
3
15) How do you use the same lov for 2 columns
We can use the same lov for 2 columns by passing the return values in global
values and using the global values in the code
16) How many minimum groups are required for a matrix report
The minimum number of groups in matrix report are 4
20) 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.
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 separate 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 data file 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.
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.
32) What is the Difference between a post query and a pre query?
A post query will fire for every row that is fetched but the pre query will fire only
once.
41) Can you use select in FROM clause of SQL select? Yes.
42) what is the significance of SQLCODE & SQLERRM in pl/SQL exception
handler?
For internal exceptions, SQLCODE returns the number of the Oracle error. The
number that SQLCODE returns is negative unless the Oracle error is no data
6
found, in which case SQLCODE returns +100.
SQLERRM: returns the corresponding error message. The message begins with the
Oracle error code. For user-defined exceptions, SQLCODE returns +1 and SQLERRM
returns the message
User-Defined Exception: If no exception has been raised, SQLCODE returns zero and
SQLERRM returns the message
Tab1 will be the name of the table and lower_value will be the Lower bound and
upper_bound will be the Upper bound value
Another view can be used to find the object dependencies called as DEPTREE and
IDEPTREE for indirect dependencies.
48) What DBMS package should I use to manipulate the long column in Oracle 7
You cannot use PL/SQL. You have to use OCI calls to do this and Oracle has a great
tech note on this. It is located in our PL/SQL development section at
53) Can you have two functions with the same name in a PL/SQL block?
Yes.
54) Can you have two stored functions with the same name?
Yes.
/* If there are enough employees then make him or her the manager */
IF empCount >= 1 THEN
UPDATE dept d
SET manager_num = :n.empno
WHERE d.deptno = :n.deptno;
END IF;
END;
/
58) How can I get the source code for a function or a procedure or a package from the
database?
Query the view ALL_SOURCE. It has a field called TYPE, which says whether the
object is a FUNCTION or a PACKAGE or a PACKAGE BODY or a PROCEDURE.
The field TEXT gives the actual source code for that object.
Example: SELECT TEXT FROM ALL_SOURCE WHERE NAME='FUNCTION_NAME';
61) Can 2 functions have same name & input parameters but differ only by Return data
type
No.
63) Why create or Replace and not drop and recreate procedures?
So that Grants are not dropped.
67) What is the maximum no. of statements that can be specified in a trigger
statement ?
One.
69) What are the values of :new and :old in Insert/Delete/Update Triggers ?
INSERT: new = new value, old = NULL
DELETE: new = NULL, old = old value
UPDATE: new = new value, old = old value
70) What are cascading triggers? What is the maximum no of cascading triggers at a
time?
When a statement in a trigger body causes another trigger to be fired, the triggers
are said to be cascading. Max = 32.
82) Can Check constraint be used for self referential integrity? How?
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.
84) What are the states of a rollback segment? What is the difference between partly
available and needs recovery?
The various states of a rollback segment are:
ONLINE, OFFLINE, PARTLY AVAILABLE, NEEDS RECOVERY and INVALID.
85) What is the difference between unique key and primary key?
Unique key can be null; Primary key cannot be null.
89) What is the maximum no. of columns a table can have ? 1000.
If a transaction is very large, and the rollback segment is not able to hold the
rollback information, then will the transaction span across different rollback
segments or will it terminate? It will terminate (Please check).
98) Which symbol preceeds the path to the table in the remote database?
@
99) Are views automatically updated when base tables are updated? Yes
101) 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 ?
Last Record
102) A table has the following data : [5, Null, 10]. What will the average function
return?
7.5
110) While designing in client/server what are the 2 imp. Things to be considered?
Network Overhead (traffic), Speed and Load of client server
115) Can database trigger written on synonym of a table and if it can be then what
would be the effect if original table were accessed.
Yes, database trigger would fire.
120) What is the effect of synonym and table name used in same Select statement?
14
Valid
122) What is the difference between foreign key and reference key?
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.
123) Can dual table be deleted, dropped or altered or updated or inserted? Yes
124) If content of dual is updated to some value computation takes place or not? Yes
125) If any other tables same as dual were created would it act similar to dual? Yes
126) For which relational operators in where clause, index is not used?
, like '% ...' is NOT functions, field +constant, field || ''
127) Assume that there are multiple databases running on one machine. How can
you
switch from one to another?
Changing the ORACLE_SID
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 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.
132) What all important parameters of the init.ora are supposed to be increased if
you
want to increase the SGA size?
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}.
139) Which of the following is not a schema object: Indexes, tables, public synonyms,
triggers and packages? Public synonyms
144) What are the advantage and disadvantages of using a select for update in a
cursor
Using the "for update clause" and then using useing "update... for current
cursor" is a good way to make sure that no one else is changing the rows you are
working with.
If you use this then you cannot issue a commit within the loop. A commit will
release all locks and invalidate your cursor.
145) What constraints will cause oracle to create default indexes
When a table is created, an index associated to the primary key of the table is
also created to enforce uniqueness and faster data selection that uses the
primary key in the where clause of the select statement.
146) How can I get the difference between two date columns?
select floor((date1-date2)*24*60*60)/3600)
|| ' HOURS ' ||
floor((((date1-date2)*24*60*60) -
floor(((date1-date2)*24*60*60)/3600)*3600)/60)
|| ' MINUTES ' ||
round((((date1-date2)*24*60*60) -
floor(((date1-date2)*24*60*60)/3600)*3600 -
(floor((((date1-date2)*24*60*60) -
floor(((date1-date2)*24*60*60)/3600)*3600)/60)*60)))
|| ' SECS ' time_difference
from table a
148) Why should I not commit after every record when updating a large table
Committing after every record does not hurt but its much efficient to commit
after a batch of records like 5000 - 7000. I would suggest that you set this range
based on the size of your rollback segment.
17
149) I want to use a view to update a table. Is it possible?
Yes and No. A table can be updated through a view only if it matches certain
criteria.
1. Simple Sub Set of Data
2. All Not Null Columns are included
3. Based on a single table
So, you can update a view that is like this
create view v_emp as select * from emp;
152) How can I retrieve a specified number of highest- or lowest-value columns with a
single query
oracle refers to this as an "TOP-N Query".
Think of this as a two-step process. In the first step, you create a view with an
ORDER BY clause that orders records in ascending or descending values of a
specified column. You then select the top required number of records from this
view using ROWNUM.
You could combine both of these steps in a single query by selecting the
specified number of records from an in-line view whose records are ordered in
ascending or descending order of the required column.
Thus, to retrieve the three employees in the EMP table with the highest salaries,
you could write the following query:
158) Why is the query not fetching the records for the date I wanted?
For example, if your query is
SELECT EMP_NAME, SSN FROM EMP WHERE HIER_DATE = TO_DATE('03-NOV-
1999','DD-MON-YYYY');
Oracle assumes the hours, minutes and seconds to 12:00:00, So it tries to fetch
the records matched on that date at 1200 hours 00 minutes and 00 seconds.
If the record is inserted at 11:02:34 hours, it will not be fetched.
If you need all the records for a particular date, use the date conversion
functions, like
SELECT EMP_NAME, SSN FROM EMP WHERE TO_CHAR(HIER_DATE,'DD-MON-
YYYY') = '03-NOV-1999';
Remember that if you have an Index on the date field the query optimizer may
not use it;
How do I drop an unused column ? Any restrictions if so what are they?
As of Oracle 8i, it is possible to drop a column or UNUSED Column from a Table.
This feature drops the column from a table and releases any space back to the
segment. It will also drop any columns that were previously marked as being
unused. This clause also causes any indexes, constraints and statistics on this
19
column to be dropped.
Restrictions. Oracle does not permit combination drop and set unused clauses in
the same statement. Also an error will occur if drop column is attempted from an
object type table or a nested table or a partitioning key column or a parent key
column. Another good restriction is that a column cannot be dropped from any of
the tables owned by SYS.
160) Can one use dynamic SQL within PL/SQL? OR Can you use a DDL in a procedure?
How?
From PL/SQL V2.1 one can use the DBMS_SQL package to execute dynamic SQL
statements.
Ex: 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;
I want to use sub selects give me an example of what is a good case for sub
selects
Use subselects when you want to get detailed information based on group
values.
confusing... look at the example where I want to display all employees with
salary more than the average salary...
163) How can I see what tables I have access to and what tables I own
Oracle Data Dictionary provides 3 levels of views user,all and dba views. These
views provide information based on your privileges in the database.
User_tables, User_indexes.. etc., provide information about the objects you own.
All_Tables, All_indexes... etc., provide information about the objects you have
access to.
Dba_tables, dba_indexes.. etc., provide information about all the objects in the
database but are only available to dba's.
Example :
To see what tables I own...
select table_name from user_tables;
To see what tables I have access to and who the owner is...select owner,
table_name from user_tables;
164) How can I use a large rollback segment ( rblarge )to avoid the snapshot too old
error
You can use the following command
set transaction use rollback segment rblarge;
This has to be the first statement of the transaction and you need to reissue this
statement whenever you end the transaction, i.e, most of us forget to re issue
the command after a commit or rollback.
165) which of the following is better to find the number of rows in a table
1. count(1)
2. count(*)
3. count(rowid)
the answer is
1. and 3.
The function count() executes faster when given a criteria/value which is quicker
to resolve in the sql processing mechanism.Thus, an integer or rowid are faster
to resolve than an '*'which is a wild card symbol for all the colums in a table and
hence it is more time consuming.
21
Oracle(SQL) Interview Questions and Answers : SQL
or
Example.
Table Emp
Empno Ename
101 Scott
102 Jiyo
103 Millor
104 Jiyo
105 Smith
delete ename from emp a
where rowid < ( select min(rowid) from emp b
where a.ename = b.ename);
The output like,
Empno Ename
101 Scott
102 Millor
103 Jiyo
104 Smith
7. I know the nvl function only allows the same data type (i.e. number or char
or date nvl(comm, 0)), if commission is null then the text “Not Applicable” want
to display, instead of blank space. How do I write the query?
SQL> select nvl (to_char (comm.),'NA') from EMP;
Output:
NVL (TO_CHAR (COMM),'NA')
-----------------------
NA
300
500
NA
1400
NA
NA
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.
24
15. Which date function returns number value?
months_between
18. Other way to replace query result null value with a text
SQL> Set NULL ‘N/A’
to reset SQL> Set NULL ‘’
21. What is the maximum number of triggers, can apply to a single table?
12 triggers.
22. How would you determine the time zone under which a database was operating?
select DBTIMEZONE from dual;
28. Where in the Oracle directory tree structure are audit traces placed?
In unix $ORACLE_HOME/rdbms/audit, in Windows the event viewer
25
29. 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.
30. When a user process fails, what background process cleans up after it?
PMON
32. How would you determine what sessions are connected and what resources they
are waiting for?
Use of V$SESSION and V$SESSION_WAIT
35. Give two methods you could use to determine what DDL changes have been
made. You could use Logminer or Streams
39. When creating a user, what permissions must you grant to allow them to connect to
the database?
Grant the CONNECT to the user.
42. What view would you use to look at the size of a data file?
DBA_DATA_FILES
43. What view would you use to determine free space in a tablespace?
DBA_FREE_SPACE
44. How would you determine who has added a row to a table?
26
Turn on fine grain auditing for the table.
47. You have just compiled a PL/SQL package but got errors, how would you view the
errors?
SHOW ERRORS
50. 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.
102. One or more RETURN statements must appear in the executable part of function.
(True)
103. The return statement immediately completes the execution of a subprogram and
returns control to the caller. (True)
104. A recursive subprogram is one that calls itself. (True)
105. A stored subprogram cannot call another stored subprogram. (False)
106. To recompile a standalone subprogram we have to use the COMPILE keyword.
(True)
107. Like subprograms, packages can be called, passed parameters or nested. (False)
108. The body of a package can be changed without having to recompile calling
programs. (True)
109. A database trigger has to be invoked explicitly. (False)
110. Database triggers fire with the privileges of the owner not the current user. (True)
111. By default a database trigger fires once per table.
30
112. Oracle guarantees the data integrity of BFILE files stored outside the database.
(False).
113. When you delete an external LOB(BFILE), then only the locator value is deleted.
(True).
114. An index-only table allows you to store the entire table’s data in an index. (True)
115. As of Oracle 8, passwords can expire and accounts may be locked due to repeated
failed attempts to connect. (True)
116. If the instead of clause is used the triggers code will be executed instead of the
event that caused the trigger to be executed. (True)
117. Abstract datatypes can be nested. (True)
118. For each record within the main table, the nested table may contain multiple rows.
(True)
119. For each record within the main table, the nested table may contain multiple rows.
(True).
120. You can also query the varying array directly to determine its maximum number of
entries per row called its COUNT. (false)
121. The data for a nested table is not stored “in-line” with the rest of the table’s data.
(True)
122. Referenced objects are not physically separate from the objects that refer to them.
(false)
123. The rows of an object table can’t be referenced by other objects within the
database. (false)
124. OID values are not reused. (True)
125. The REF operator takes a row object as the argument and returns a reference
value.
(True).
126. You need to know the name of the object table in order to DEREF its value. (False)
127. Object views are a means for defining objects used by existing relational tables.
(True)
1. Data Integrity means that the data contained in the database is both accurate and
consistent
2. The CODD rule that says that an application program must remain unimpaired
when any change is mode in storage representation Physical independence rule
3. The rule that states that all vies that are theoretically updatable must be
updatable by the system view updation rule
4. For any DBMS to be considered as on RDBMS it has to satisfy a minimum of 6
CODD rules
5. The rule which states that all information in a relational database must be stored
in the form of table only Information rule
6. Logical data Independence rule states that users and user programmes should be
independent of the logical structure of the database.
7. The principles of the relational model of database were first laid down by Dr E F
CODD
8. RDBMS stands for Relational Database Management system
9. Partitioning is the ability to break tables and indexes into smaller, more
manageable pieces
31
10. Personal Oracle is the Oracle database product for stand alone workstations.
11. SQL is a Non Procedural language and data access language
12. Oracle has precompilers that allow database access within which of the language
C, Cobol, ADA
13. SQL & Pl/SQL are used in which of the following products SQL*plus, Oracle Forms
and Oracle reports
14. The tools that allows direct and interactive use of the SQL language to access the
Oracle server is Oracle reports, Oracle forms and SQL * Plus.
15. The relations operator that displays certain columns form the relation and is
therefore often called a vertical subset is projection
16. With a non-procedural language you only specify what to do? And not how to do?
17. The database option from oracle corporation, which provides very high security
features, is Trusted Oracle
18. The distributed option supports transactions which update data across more than
one database in a distributed database network
19. Oracle’s procedural language for writing application logic and for manipulating
data outside the database is PL/SQL
20. The closely integrated set of the main application development tools are called
the co-operative development.
21. Array and nested tables are new features of Oracle 8
22. Objects are software representations of real world entities
23. Encapsulation means that each object within the database has a well defined
interface with district borders
24. Extensibility is the ability of an object oriented database to add new objects and
their associated behavior without affecting the other objects and application
25. Partitioning is the ability to break tables and indexes into smaller more
manageable pieces Partitioning
26. Inheritance is the ability to create new classes of objects as specialization of
existing classes
27. Polymorphism is the ability of objects to differently to an identical message
28. Classes are templates for objects
29. Oracle loader is the oracle tool to use when you need to move data into your data
warehouse
30. The organization which implement the standards on a language are ANSI &ISO
31. If you insert a value that is shorter than column length for a column of ‘CHAR’
data type then Oracle Blank Pads the value to column length
32. The data type, which enables storage of variable length character strings
containing up to 2GB is Long
33. 7,2 and 10,-2 is a valid precision and scale value
34. The commands, which compose DCL are Grant & Revoke
35. The data types used for storing byte oriented or binary such as graphics images
or digital sound RAW
36. A collection of logical structures of data or schema objects is called Schema
37. The schemas which are used to enhance performance are Indexes and clusters
38. SQL stands for structure query language
39. The default date format is specified by the initialization parameter
NLS_DATE_Format
40. One Primary key can a table have
41. The option that prevents nulls from occurring if a row is inserted without a value
for the column default
42. The definitive key through which rows in the table are individually identified is
Primary Key
43. To define a composite key(Primary & unique) you must use Table constraint
syntax
44. Oracle generates a name of the form sys-cn where ‘n’ is an integer for each
unnamed constraint ‘n’ in the above case is unique
45. Rows that violate the constraint can be placed into another existing table using
32
the Exceptions into option
46. The clause that allows deletion of reference key values in the parent table that
have dependent rows in the child table and causes Oracle to automatically delete
dependent rows from the child table is ON-DELETE-CASCADE.
47. The table containing the foreign key is called the child or detail table and the
table containing the referenced key is called master table
48. Constraints, which reference one or more columns and are defined separately
from the definition of the columns in the table are called table constraint
49. Foreign keys provide referential integrity rules either with in a table or between
tables.
50. The Only type of integrity constraint that you can add to an existing column using
the MODIFY clause is not null
51. In an insert statement if you omit any columns from the column list, oracle
assigns them default value only
52. To end your current transaction and make permanent all changes performed in
the transaction you use commit command
53. You identify the point in a transaction to which you can later roll_back using a
save_point
54. Rollback your entire current transaction, Rollback your current transaction to a
save point and Roll back the entire session will be done by roll back command.
55. The add clause in an alter command is used to ad a column or integrity constraint
56. You can change a column data type or declare a column’s size only if the column
contains a Null in all rows
57. Using the ADD clause of an alter command the types of integrity constraints which
can be added are Unique, Primary Key, Referential Integrity and CHECK constraint
58. To drop all referential integrity constraints that refer to primary key and unique
keys in the dropped table we use the cascade constraint option
59. All DDL commands are auto committed.
60. The Order of the following clauses in a select statement is WHERE clause, GROUP
BY clause, ORDER BY clause and HAVING clause.
61. Using an (*) in the SELECT clause of a SELECT statement having only the SELECT
and FROM clause would retrieve all the data.
62. If ‘a’ is 10 then the condition a IS NOT NULL evaluates to true
63. To lock the selected rows in a SELECT command we can use the following options
FOR UPDATE
64. In which of the following clauses in a SELECT command we can use a condition
WHERE, START WITH, CONNECT BY and HAVING
65. To return only one of each set of duplicate rows selected we use the distinct
parameter
66. The conditions used in the WHERE and HAVING clauses should evaluate to a
Boolean
67. To retrieve data from schema of another user the table name has to be prefixed
by Scheme Name
68. To test for nulls only use the comparison operators IS NULL and IS NOT NULL
69. The list of expressions that appear after the SELECT keyword and before the
FROM clause is called the select list.
70. An expression(s), Column partition(s), table name and column name(s) can be
used by an ORDER BY clause.
71. The default order in which records are retrieved when an ORDER BY clause is used
is ascending
72. The logical operator that returns true if both component conditions are true,
otherwise return false is AND
73. When using the BETWEEN x AND Y in a condition the values of x and y are
inclusive
74. The operator precedence between AND & OR is AND over OR
75. The omission where clause, returns all rows from the tables, views or snapshots in
the FROM clause
33
76. LOGICAL operators are used to combine the results of two component conditions
to produce a single result based on them or to invert the result of a single
condition
77. To check for the column value in a set of values we use the IN operator
78. The IN operator is equivalent to ANY
79. To check for a range of values we use the between operator.
80. In a hierarchical query the children are evaluated with respect to a current parent
row by using CONNECT BY clause
81. In a hierarchical query if the START WITH clause is omitted then Oracle will
display all the rows, uses all, rows in the table as root rows
82. In a hierarchical query if one row is both the parent(or grand parent or direct
ancestor) and a child (or a grand child or a direct decendent of another row then
Oracle return on error.
83. For a root node the pseudo column LEVEL returns the value 1
84. In a hierarchical query with the clause “CONNECT BY prior emp no = mgr.and sal
>comm.; the prior operator applies only to empno
85. The LIKE operator helps in making a wild card search or pattern matching
operation.
86. The search string used to pattern match all strings that have ‘D’ as the second
character is ‘_D%’
87. The tool that can be used to force priority is ()
88. To project a column alias with a space in if we have to enclose the column is “ “
89. In a hierarchical query the root node(s) or row(s) is identified from the Start with
clause.
90. To list a range of lines m to n from the SQL buffer the editing command used is l
mn
91. double ampersand, DEFINE,ACCEPT commands are used to assign a value to a
variable in SQL * plus
92. Data types can be checked, more explanatory prompts, response values can be
hidden are the benefits in using ACCEPT to define substitution variables
93. Values can be supplied to the substitution variables in command files as
parameters using the command
94. The DEFINE command is used to find out if a variable is already defined and to
define a variable.
95. The SQL * plus environment the last SQL command issued is stored in a part of
memory called the SQL Builder
96. The command that displays and runs the current SQL command in the buffer is
run
97. the command used to open the default editor in order to edit contents of a saved
file is ED filter
98. The SQL * plus variable type used to store individual values which may be
assigned and read at run-time is bind variable
99. The option with the ACCEPT command that will help suppress the user response is
hide.
100. The value returned by SIGN(n) when n > 1 is 1
101. The output of LTRIM(‘BILL CLINTON’,’BALL’) is ILL CLINTON
102. The output of SUBSTR(‘CREAE’,3,3) is EAT
103. The conversion function that can be used to store the date in a different format
than one specified by the NLS_DATE_FORMAT is TO_CHAR
104. The written data type of NVL(expr 1, expr 2) is same as expr 1
105. A function is similar to an operator in that it manipulates data items and returns a
result
106. Single row functions are also known as scalar functions
107. A group function returns a single result row for a group of queried rows.
108. The value returned by MOD(M,0) is M
109. Homonyms in the English language can be found out using the soundex function
110. The SELECT statement contains the GROUP By clause, the select list can only
34
contain constants & group functions and GROUP BY clause expressions
111. The sequence in which WHERE, GROUP BY, HAVING
112. DISTINCT OPERATOR, GROUP BY and SET operator clause constants cannot be
used in a SELECT statement with a FOR UPDATE clause.
113. COUNT () and VARIANCE() are group functions.
114. Group clause can contain any columns in the tables regardless of whether the
columns appear in the select list, Multiple expressions and Multiple columns
115. A group function returns a single result row for a group of queried rows.
116. Many group functions accept the options distinct and all
117. The having clause is used to restrict which groups of rows defined by the GROUP
BY clause are returned by the query.
118. The FOR UPDATE clause locks the rows selected by the query.
119. You can substitute a value for a NULL using the NVL function.
120. The number of minimum join conditions tat are required to join ‘n’ tables is ‘n-1’
121. In an outer join (+) sign is placed on the deficient table side
122. In a vertical join, to return all rows retrieved by the first query that are not in the
second. We use minus operator.
123. The select statement used in the vertical join must select some number of
columns with corresponding columns having same data type
124. In a vertical join SELECT statements are executed from Top to bottom
125. The outer join extends the result of a simple or equi
126. If a join query does not contain the WHERE clause then such a join would be a
product or cartisian join
127. If a table containing ‘n’ records is Cartesian joined with a table with ‘m’ records
then the resultant table will have n*m records
128. In a vertical join, column names from the first query appear in the result
129. Temporary labels used in the FROM clause of query are called table aliases.
130. IN and =ANY are multirow comparison operator
131. A sub query can appear WHERE,HAVING & SET operator clauses and operator.
132. In SELECT statement Boolean conditions figures WHERE,HAVING,STARTWITH and
CONNECT BY clauses
133. A sub query is a SELECT statement that is nested with in another SELECT
statement.
134. When a sub query returns only one row, such a sub query is called single row sub
query.
135. The =ANY operator is similar to IN and SOME operators.
136. The all operator compares a value to every value returned by a sub query
137. A nested or sub query is used to answer multiple part question.
138. If WHERE clause is not specified in an UPDATE statement then all rows are
updated
139. Privileges can be granted to user(s), Role and Public
140. A person can grant a privilege on an object if he is the owner of the object, he has
the grant any privilege and he has been granted a privilege with GRANT OPTION.
141. A grantee can also alter a role granted to him with the ADMIN option
142. Granting Alter privilege on an object allows the grantee to change the object.
143. A correlated object is a sub query that is evaluated once for each row processed
by the parent statement.
144. In a correlated sub query if the tables in a sub query and parent query contain a
column with the some name, a reference to the column in the parent query must
be fixed by the table names & table users
145. A sub query is identified by the use of an outer queries column in the inner
queries predicate clause.
146. In an UPDATE statement the set clause determines which columns are updated
and what new values are stored in them
147. The difference between a DELETE and TRUNCATE command is the action of
truncation is auto commited.
148. Joins, SET OPERATORS, GROUP FUNCTIONS, ORDER BY CLAUSE, GROUP BY,
35
CONNECT BY or START WITH clause constructs should not be used in the view
query to enable DML’s on the view
149. The data base object from which multiple users may generate unique integers is
sequence
150. Maximum 16 columns that an index can contain.
151. Cluster columns must correspond to columns in each of the cluster tables in data
type
152. Profiles & rules and roll back segments and table spaces objects are stored in the
database, but are not in contained in a schema.
153. A view is also called a virtual or logical table
154. The tables upon which a view is based are called base table
155. To ensure that inserts and updates performed through the view must result in
rows that the view query can select we use the with check option
156. The first reference to the NEXT VAL of a sequence returns the start with value.
157. Tables can be added to an existing cluster by issuing a CREATE table statement
with the cluster clause.
158. The display of the number of records selected in a query can be set by using
FEEDBACK.
159. To make SQL * plus wait for you to press(return) before displaying a new page of
output, you have to set PAUSE
160. The option used with the COLUMN command that sets and nulls in the column to a
specified string is NULL
161. The breaks in reports can be active on COLUMNS, ROWS/PAGES and REPORT
162. The clause in COMPUTE COMMAND THAT HELPS IN COMPUTING COUNT OF ROWS
NUMBER
163. The SQL * plus command which displays any database table structure is describe
164. The SET command can be made the default for every session, by including them
in a file called login sql
165. To find out the value of a SET variable use the show command
166. The clear option with the COLUMN command removes the previous column
formatting command for that column.
167. The title and btitle command are used to produce titles on a page.
168. If a global identifier is re declared in sub-block, then in the sub-block the local
declaration prevails.
169. The assignment of a NUMBER value to a CHAR variable will result in Implicit data
type conversion
170. The reserved word which can be used instead of the assignment operator to
initialize variable and constants Default
171. The SQL function which are not available in procedural statements are GROUP
functions, GREATEST and LEAST
172. To distinguish non-PL/SQL variables, they are predefined by a colon and **
173. PL/SQL variables and constants have attributes, which are properties that let you
reference the data type and structure of an object without repeating its definition.
174. Identifiers declared in a PL/SQL block are considered local to that and global to all
its blocks, out blocks
175. The order in which operations are performed, operator precedence can be
controlled through the usage of paranthesis
176. The two functions provided by Pl/SQL in addition to the functions available in SQL
for error reporting are SQL CODE and SQL ERROR
177. A constant must be initialized in its declaration, other wise you get a compilation
error.
178. The IF-THEN-ELSE is a conditional control construct
179. The control construct that helps in conditional iteration is WHILE loop
180. The FOR loop control variable may be decremented, starting at the hight value by
using REVERSE in the loop
181. GOTO’s may pass control to labeled points with in the current block and an
enclosing block.
36
182. The bounds of a FOR loop range can be literals, variables or expressions but must
evaluate to INTGER
183. The flow of control through a program, is handled by using control structure
184. PL/SQL lets you process the data using conditional, interactive and sequential
control constructs.
185. In a IF-THEN-ELSE construct if all conditions evaluate to FALSE or NULL, the
statement in the else clause are executed
186. The lack of an exist or an exit-when statement in a basic loop will result in an
endless or infinite loop.
187. The FOR loop counter cannot be assign values, but can be referenced like a
constant.
188. The exception handler that catches all exceptions that the block does not name
specially is others
189. The predefined exception which is raised in SQL statement if the conversion of a
character string to number fails is Invalid Number
190. The procedure which lets you issue user-defined error messages from a stored
subprogram or database trigger is Raise-Application-Error
191. A SELECT INTO statement that calls a GROUP function will raise NO-DATA-FOUND.
192. The complier directive which tells the compile to associate a name with an oracle
error number is Exception_init.
193. The PL/SQL mechanism which lets you bullet proof, your program so that it can
continue operating in the presence of error is exception handling
194. Internal or predefined exception are raised implicitly(automatically) by the
runtime system.
195. The two main types of exceptions are predefined and user defined
196. PL/SQL declares predefined exceptions globally in a package called STANDARD
197. To declare an exception by introducing its name, the key word exception is used.
198. Data can be retrieved into variables using which of the following options INSERT
INTO and FETCH
199. The formal parameters of a cursor must be IN parameter
200. Actual parameters in an open statement can be associated with formal
parameters in a cursor declaration using positional notation and named notation
201. which of the following does a cursor FOR loop do open cursor, fetch rows of values
from active set and close cursor.
202. We can test whether a FETCH was successful or not by checking the FOUND and
NOT FOUND attribute.
203. A PL/SQL construct called a cursor lets you name a private SQL area and access its
stored information
204. Oracle used work areas called private SQL area to execute SQL statements and
stored processing information.
205. There are two kinds of cursor Explicit and implicit.
206. The set of rows returned by a multi row query is called as an active set
207. Updates or deletes can be applied on the single row currently being addressed in
a explicit cursor by using the where current of clause.
208. The advantages of a sub program are Modularity, reusability, maintainability,
abstraction and Extensibility.
209. You can use the same name for several different sub programs as long as their
formal parameters differ in number, order or data type family. The feature is also
called overloading.
210. The parameter which acts like an uninitialized variable inside the subprogram is
INOUT parameter
211. You cannot overload two subprograms if their formal parameters differ only in
Name and parameter mode and data types in the same family.
212. PL/SQL has two types of subprogram called procedures and functions.
213. PL/SQL programs have two parts the specification and the functions.
214. The behavior of formal parameters can be defined using parameter nodes
215. Inside the subprogram, an IN parameter acts like a constant.
37
216. You can pass different number of actual parameters to a sub program if the
default values are defined for the IN and INOUT parameters
217. In a function specification the RETURN clause specifies data type of the RETURN
value.
218. Calls to user defined function can appear in procedural statement.
219. The variables declared in a subprogram specification and referenced in the
subprogram body are Formal parameters.
220. Higher productivity, Better Performance, Memory savings and Tighter Security are
offered by Stored subprograms.
221. A subprogram is valid if, since its last compilation.
222. Functions and procedures are structured alike, except that function has the return
clause.
223. A function subprogram is called as part of an expression.
224. The problem of defining mutually recursive subprograms is solved by using
Forward declaration.
225. Recursive programs are more elegant and efficient less when compared to an
interactive version.
226. PL/SQL declares built-in functions globally in Standard package.
227. A package can contain Subprogram, Cursors, Types and Exceptions.
228. A package need not have a body if it contains only constraints and variables,
exceptions and types.
229. SQL statements and subprogram calls can appear in a trigger body.
230. The correlation names :new and :old can be replaced by using REFERENCING
CLAUSE.
231. Database triggers are used to maintain Business integrity.
232. A package is a database object that groups logically related PL/SQL types, objects
and subprograms.
233. A subprogram defined in a package body may not be accessible outside its
specification is included in the package specifications.
234. To reference the types, objects and subprograms declared within a package
specification we have to prefix their names with the Package name.
235. The package which contains the subprograms PUT, PUT_LINE, GET and GET_LINE
is DBMS_OUTPUT.
236. The LOB that supports a multi byte character set it NCLOB
237. DBMS_LOB package, API’s(Application Programming Interface) and OCI(Oracle Call
Interface) are the valid methods for manipulating LOB data.
238. SUBSTR and INSTR are available in the DBMS_LOB package.
239. You can use the alter table command to perform exchange, drop, split and
truncate on a partition.
240. DBA is a role.
241. For each of the LOB columns, Oracle will store a locate value that tell It where to
find any out-of-line data stored for the record.
242. If an internally stored LOB column’s value is NULL, then you will have to set it to
an empty locater value before updating it to a non-null value.
243. To create an index-only table, you use the Organisation index clause of the create
table command.
244. Oracle uses the partitions check constraints to determine which partition the
record should be inserted into.
245. A role is set of privileges.
246. A varying array is a column object, collection.
247. Polymorphism object oriented concepts are not supported by Oracle 8
248. ‘THE’ key word can be used to flatten a nested table
249. The ability of the same instruction to be interpreted in different ways by different
objects is called Polymorphism
250. The information about the attributes of a user’s abstract data types is available
with which of the following data dictionary tables USER_TYPE_ATTRS and
ALL_TYPE_ATTRS
38
251. Abstract data types are data types that consist of one or more sub types.
252. An object has a name, a standard representation, and a standard collection of
operations that affect it.
253. To create you own methods use the create type body command.
254. Oracle creates methods, called constructor methods, for data management when
you create an abstract data type.
255. The operations that affect the object are called methods.
256. A nested table is an example of Embedded object and column object
257. The difference between nested tables, LOB’s and Varying arrays are they are
stored out of line.
258. You create a method to an abstract data type by using create type body
command.
259. Drop cannot performed on a type that is in use by a table.
260. To show the full structure of the abstract data types used by an object table on a
querying you have to use value.
261. An embedded object is one that is completely contained within abother.
262. Each row within the object table has an OID, Object Interface value
263. The DEREF operator takes a reference value as input and returns the value of the
row objects.
264. If you delete the object to which a reference points we have a dangling REF in the
record of the referencing table.
265. To use an abstract data type owned by another user you ought to have the
execute privilege on that type.
39
Oracle Notes:
Oracle 8i
Oracle 8(ORDBMS)
-Parallel enhancement, faster connection
-Table partitioning, Connection increased to 30000, Table column unto 1000
-database size increased from few tera byte to 10 tera. , Data file inc 65,533
-Support MTS, provides LOB
Oracle Start
Oracle instance start -Allocates SGA and start Background processes.
Mount Oracle DB-Method of Associating DB with previous started instance
Opening DB-To make available.
Normalization
It's a technique through. which we can design the database. During normalization
dependencies can be identified which can cause pbs during deletion & updation. It
is used in simplifying the structure of table.
De-normalization
At the same time when information is required from more than one table at faster
rate then it is wiser to add some sort of dependencies.
40
Rolling Forward
To reapply to Data file to all changes that are recorded in Redo log file due to which
data file contains committed & uncommitted data.
Forward Declaration
To declares variable and procedures before using it.
2- Tier Arch. dis advantages-When Business Rule changes.
Table space : Profile-To control system resources, memory, disk space and CPU
time.
We can find rows affected by %row count.
Positional and Named Notation : The actual arguments are associaed with formal
arguments by position k/s Positional Notation. It’s commonly used.
A Trigger doesn't accept argument & have same name as table or procedure as it
exist in separate namespace.
SQL Language Extension: Oracle * provide new built-in datatype, object datatypes,
nested tables, and a no of other features that require new DDL extension.
VARRAY
REF
LOBS
Create table AA(a N (10)
B date,
C varchar2 (10));
The UTLBSTAT and UTLESTAT script to get general overview of database 's
performance over a certain period of time.
UTLBSTAT creates table and views containing cumulative database performance
summary information at the time when the script runs .All the objects create by
UTLBSTAT contain word login.
41
Utlbstat.sql
The shared pool is one of the memory structures in SGA. It is comprised of the data
dictionary and the library cache. Check v$sgastat. The data dictionary cache buffers
data dictionary objects that contain data about tables, indexes, users and all other
objects. The Library Cache/SQL Cache buffers previously executed queries, so that
they need not be reloaded and reparsed if user calls them again. Otherwise if the
information is not in the buffer then oracle must get it from disk. The V$LIBRAY
CACHE View stores performance data for library cache and V$rowCACHE view stores
performance data for the data dictionary cache. Sometime we may have to increase
the value of initialization parameter SHARED_POOL_SIZE.
To improve the performance .
Redo Log --
Oracle 8 stores all changes to the database, even uncommitted changes, in the redo
log files. LGWR writes .
By querying the V$SESSION view , we can determine who is logged on ,as well as
information such as the time of logon .
Unbalanced Index –
if we do have lot on index on a table and we are doing I/U/D frequently then there is
a problem of disk contention . To check this problem sees the BLEVEL value in
DBA_INDEXES and if it is 1,2,3,4 then it’s ok else rebuild the index .
42