SQL Questions
SQL Questions
2. What is SQL?
SQL stands for Structured Query Language. SQL was derived from the
Greek word called "SEQUEL". SQL is a non- procedural language that
is written in simple English.
3. What is a transaction?
4. What is a commit?
5. What is a Rollback?
6. What is DDL?
7. What is DML?
E.g. inserting a row into a table, delete a row from a table etc.
8. What is locking?
When two users attempt to perform actions that interfere with one
another,this situation is defined as Deadlock.
E.g.: - If two users try to change both a foreign and its parent key
value at the same time.
The type of lock that permits other users to perform a query, but
could not manipulate it, i.e. it cannot perform any modification
or insert or delete a data.
The type of lock that permits users to query data but not change
it and does not permits another user to any type of lock
on the same data. They are in effect until the end of the transaction.
The Functions that are used to get summary information’s about group
Or set of rows in a table.
The group functions are also termed as aggregate functions.
View is like a window through which you can view or change the information in table. A view is
also termed as a 'virtual table'.
17. What is a Rowid?
For each row in the database, The ROWID pseudo column returns a row's
address. ROWID values contain information necessary to locate a row:
Example:
CREATE TABLE loans (account NUMBER (6),
loan_number NUMBER(6),
...
CONSTRAINT loan_pk PRIMARY KEY
(account, loan_number));
Example:
CREATE TABLE loans (
Loan_number NUMBER (6) NOT NULL UNIQUE,
...
);
Examples:
* Entity integrity
* Referential Integrity
* General Business rules
* Foreign key
* Update Delete restricts action
* Delete Cascade action
24. What are different data types?
The Char datatype length is 1byte. The maximum size of the Char datatype is
255. Oracle compares Char values using the blank-padded comparison semantics.
If you insert a value that is shorter than the column length, Oracle blank-
pads the value to the column length.
There are two data types %TYPE and %ROWTYPE. The first one declares
a variable to be of the data type of the column of the table to which
it is referring.
my_empno emp.empno%TYPE
then, my_empno will have the data type of the empno column of the
table emp.
my_emprec emp%ROWTYPE
then, my_emprec will have the data type of all the fields of the emp
table.
The columns that are not part of the table are called as pseudo columns.
The type of function that will return value after every row is being
processed.
New_time function returns date and time in a time zone b and time in time
zone. a and b are character expressions.
Soundex (char);
1. Logical expression
2. Compound expression
3. Arithmetic expression
4. Negating expression.
1. if <condition>
then
elsif<condition> then
end if
2. While <condition>
loop
end loop
3. loop
exit when<conditon>
end loop
Declare a exception;
Begin
statements....
-----
if x > y
then
raise a;
end if;
exception
when a then
statements,
rollback;
when others then
commit;
end;
PCTFREE: - PCTFREE controls how much of the space in a block is reserved for
statements that update existing rows in the object.
PCTUSED: - PCTUSED is a percentage of used space in a block that triggers the
database to return to the table's free space list.
A client application ("the front end") is the part of the system that users
employ to interact with data. The client applications in a client/server
database system focus on jobs such as
* Transaction Rollback
* Read consistency
The library cache and dictionary cache makes up the shared pool. The shared
pool combined with buffer-cache make up the System Global Area.
Library Cache: - It stores the SQL Statements and PL/SQL Procedures.
Dictionary Cache: - Holds dictionary information in memory.
Buffer and Cache: - the place where the data related to recently requested
transaction is stored.
Foreground handles the request from client processes while background handle
other specific row of the database server like writing data to data and
transaction Log Files.
81. SQL*DBA?
SQL*DBA is a utility through which you can manage a database system
effectively.
Using insert statement we cannot create a table but can only append
the data into the table
1. Close database
Sql*Forms3.0 is a Client.
1. Key-triggers
2. Navigational Triggers.
3. Transactional Triggers.
4. Query-based Triggers
5. Validation Triggers
6. Message - Error handling Triggers.
104. What is the difference between the restricted and Un-Restricted Packaged Procedure?
Any packaged procedure that does not interfere with the basic function
of SQL*Forms is an unrestricted packaged procedure. The Un-restricted
Packaged procedure can be used in all types of triggers.
1. Form
2. Block
3. Fields
4. Pages
5. Triggers
6. Form-Level-Procedures.
109. What are a Block and its types? Explain the different types of blocks?
Block is an object of Forms that describes section of a form or a subsection
of a Form and serve as the basis of default database interface.
Types of Blocks:
1. Control Block: Control block is not associated with any table in the
database. It is made up of fields that are base table fields, such as
temporary data fields.
4. Multi-record Block: A multi-record block can display more than one record
at a time.
6. Single-record Block: A single record block can display only one record at
a time.
When call runs an indicated form while keeping the parent form active.
SQL*Forms runs the called form with the same SQL*Forms options as the
parent form.
Trigger Text:
Procdurename<paramaters>
Matrix Report is a Report that consists of Two Parent Queries and one Child
Query.
Import is a utility with which we can write the data from Export file
to database. Export Files can be only read by Import.
3. What is the maximum limit for creating blocks and canvas in forms 4.5?
Unlimited
Forms 3.0: triggers (75)
Forms 4.5: triggers (121)
6. What are the differences between form4.5 and forms 3.0 with regards to master detail
relationship explain all the properties of master detail in detail?
On clear details, On populate details in forms 3.0 for 1 child only one
parent but not so in forms4.5
7. What are the difference types of triggers that will be created for master deletes
properties such as isolated, non isolated, cascading?
For non-isolated
1) On-clear-details
2) On-populate-details
3) On-check-delete-master (checks for existence for child record)
For isolated
1) On-clear-details
2) On-populate-details
For cascading
1) On-clear-details
2) On-populate-details
3) Pre-delete
Coordination properties
a) Deferred by default false
Autoquery by default false
If deferred true, autoquery true->defered with autoquery
Here the child block waits for navigation once navigated to,
Automatically corresponding child rows will be displayed.
b) Deferred true, autoquery false->child block needs navigation as well as
explicit execute query.
c) Deferred false, autoquery true ->invalid as it has the same effect as
that of first (deferred false, autoquery false) Prevent masterless operation
->if true without going to the master, child rows can't be
manipulated.prevents any manipulation without master record.
8. What is the difference between creating a master detail new block window and creating
relations after creation of the blocks?
9. How to set relation properties dynamically?
Set_relation_property
11.What are the different types of list items and the triggers
associated with them?
Pop_list, Combo box, T list
When list changed, When list activated
13 what are the different types customs items and the triggers associated with them?
OLE, VBX.Trigger: When custom item event
14 What is the radio group? Is a dummy radio button necessary? What is the associated
trigger? How to disable a radio button dynamically?
Set radio button property (block name.radio group name, button name
, enabled,property false)
When radio changed
17.What is difference between single line text items and multi line
text items?
18.What are the types of items that are always control items?
push button(not available in the base table items.Hence they are control
items)
21.What are the values that a where clause can reference in lov?
Block.item name, parameter, global variable
23.What is a record group? Different types record group? How to create query record
group dynamically?
Static, query, non query
Design time->static, query only
For run time you can have all the three
25 Give an live example where you can use non query record group?
Multi record validation
41 Define a) property class b) Visual attributes what are the differences between property
class and visual attributes?
1.if property class, visual attributes are attached to a particular
item or objects, visual attributes take precedence over property
Class
set_block_property(block name,current_record_attribute,'va name')
Trigger can be written on property class dynamically VA can be attached to
an object but PC can not be attached
43. If i change a property in the field, which is, attached to a VA what will happen?
Changes from user_defined to customs
53 what are the ways of references you will be using in writing a menu code?
54 What is an alert? How to change an alert message dynamically? What types of window
is an alert? What is the max no of char?
Response window, modal window, 200,set_alert_property (an, alert_message_
text,'message');
71 what are the triggers that are valid in enter query mode?
Key-triggers, on-error, on-message, in when triggers except
When-database-record, when-val-item, when-val-rec
72 what does the property called secure? What will happen when it is set true?
For passwords settings at item level
76 what is all the property of items that you can validate without
Writing triggers?
default value,range,data typpe,required,primary key etc.,
88 what is anchor?
93 what are the diff types of report triggers? List the sequence in which they fire?
94 can I use dml stmts. in format triggers?
98 in the table I have a value for ename as Allen but I want to Print it as **** in the
preview screen printer is it possible if so how?
Set_item_property ('itna', secure, property_true);
100 how to integrate reports 2.5 with forms 4.5 how to pass parameters from forms to
reports?
Run_product ();
***********************************************************************
ORACLE NON-DBA FAQ (Frequently Asked Questions)
-----------------------------------------------
TABLE OF CONTENTS
=================
1. GENERAL QUESTIONS
1.1. What is Oracle?
1.2. What are the advantages of Oracle?
1.3. What are potential disadvantages of Oracle?
1.4. What is SQL?
1.5. What is PL/SQL?
1.6. What is Procedural Option?
1.7. What products are available from Oracle?
1.8. What Public Domain interfaces are there?
1.9. What third party interfaces are available?
1.10. How portable is Oracle applications to other RDBMS?
1.11. What Query Optimizers are there?
1.12. Is there an anonymous FTP site for Oracle stuff?
1.13. What mail lists are there?
1.14. What bulletin boards are there?
1.15. What news groups are there?
1.16. How does Oracle compare to...?
2. SQL QUESTIONS
2.1. How can I avoid a divide by zero error?
2.2. Can I update tables from other tables?
2.3. Can I remove duplicate rows?
2.4. Can I update using a view?
2.5. Are views automatically updated when I update base tables?
2.6. Should we use complex views that cruel performance?
2.7. Can I implement tree-structured queries?
2.8. How can I get information on the row based on group information?
2.9. How can I get a name for a temporary table that will not clash?
2.10. How can I find out about what tables, columns and indices
there are ?
2.11. Is there a formatter for SQL statements?
2.12. What is the DUAL table?
2.13. What is the difference between CHAR and VARCHAR?
2.14. What is ROWNUM good for?
2.15. How do I get a top ten?
2.16. How can I control the rollback segment I use?
2.17. How can I order a union?
2.18. How can I rename a column?
2.19. Who are SCOTT/TIGER, SYSTEM and SYS?
2.20. Who do various access methods compare?
2.21. What are clusters?
2.22. How can I update a big table without blowing rollback segments?
2.23. Why don't I get records for the date I want?
3. SQL*PLUS QUESTIONS
3.1. How can I control the startup configuration of SQL*Plus?
3.2. Can I get a column value into a substitution variable?
3.3. How can I change the (hated default) editor to my favorite?
3.4. What is the difference between & and &&?
3.5. What is the difference between "host" and "!”?
3.6. Why can't I use a table name in a substitution variable?
3.7. How can I see all of a LONG?
3.8. How can I force a column to begin on the left of the page?
3.9. Can I alias SQL commands?
3.10. Can I escape significant punctuation marks?
4. SQL*FORMS 3 QUESTIONS
4.1. How can I get a list of values from a hard coded list?
4.2. How can I get find to look at description with list of values?
4.3. Can I edit SQL*Forms code with my text editor?
4.4. Can I edit SQL*Forms code by updating the database?
4.5. Why can't I see data in a control field?
4.6. Why is my terminal scrambled in a user exit?
4.7. What happens to LONGs?
4.8. What are user-written form level functions?
4.9. How can I use regular expressions for field validation?
4.10. What is a user-exit?
4.11. How can I call a popup window for field validation?
5. SQL*FORMS 4 QUESTIONS
5.1. What new features can be expected in forms 4
generator from CASE ?
5.2. What new features can be expected in forms 4?
6. PRO*C QUESTIONS
6.1. Why are my C variables overwritten?
6.2. Can I use C preprocessor definitions for VARCHAR size?
6.3. What can I do about "line too long" errors with version control?
6.4. Why do my compiles crash or weird things happen?
6.6. How do I use OPS$login?
7. CASE QUESTIONS
7.1. Can CASE generate forms with owner propounded to table names?
7.2. Can CASE generate V7 databases?
8. UNIX QUESTIONS
8.1. Can I create a compressed export on the fly without needing to
have the space for both the export file and the compressed file?
8.2. How can I prevent trailing spaces in a spooled report?
8.3. How can I get an environmental variable into SQL*Plus variables?
8.4. Can I pipe stuff through SQL*Plus?
8.5. Why does Pro*C compiles or programs crash on my Sun?
8.6. How can I find a lost Oracle export file?
8.7 How can I tell make about SQL*Forms?
9. MISC QUESTIONS
9.1. How can I alter table storage parameters from an export file?
9.2. What makes the best Oracle server for a network?
9.3. How can I implement version control?
9.4. What books are available about Oracle?
1. GENERAL QUESTIONS
1.1. What is Oracle?
Oracle is a trademark of Oracle Corporation and in common usage
refers to the database engine (which actually looks after the
data) and a range of front-end products.
Oracle is the largest selling SQL based RDBMS and on the whole,
is in my opinion, the most commercially useful.
b. 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. Oracle
has the largest independent RDBMS market share in VMS, UNIX and
OS/2 Server fields. 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 supported and also, proficient
staff are relatively easy to get.
c. Version Changes
Oracle seem very good at informing you in detail as to what is
not going to be supported in the next major release and usually
have some knob you can twiddle for good backward compatibility,
or simply leave it working, but with "don't use this, use xxxx
instead" warnings in the manual. Backward compatibility is very
good meaning you will not be in for an application re-write when
You upgrade the DBMS. [Compare this with the Ingress v5-6 OSQL
upgrade from hell.] I've worked with Oracle since V4 Beta and
have never been in for nasty surprises as far as syntax goes.
However, see "Version Changes" under disadvantages.
e. Performance
Speed of a *tuned* Oracle database and application is quite good,
even with large databases. Oracle refer to 100 GB databases and
I have personal experience administering 10 GB databases. The
performance is not only "raw", but includes consideration of
performance with locking and transaction control.
f. Cursor Support
Oracle, like Ingress, but unlike Sybase (until Release 10 I think),
supports cursors, which ease programming when performance is needed.
A cursor basically lets you do row-by-row processing. Oracle supports
multiple cursors per Oracle connection in line with ANSI standards.
g. SQL Dialect
The dialect of SQL offered by Oracle is in my opinion superior
to the others in the extensions it offers over ANSI-2, which is
very much a lowest common denominator. Constructs such as the
absolute function and decode keyword are very powerful Oracle
additions to the standard SQL.
i. PL/SQL
PL/SQL, the procedural extensions, is a draft ANSI standard for
procedural DBMS languages. See main discussion on PL/SQL.
j. Declarative Integrity
Oracle V7 supports declarative database integrity (the current
ANSI standard) and V6 permit you to enter the declarations.
With V6, you can get the toolset (such as SQL*Forms 3) to read
the declarations and automatically generate the required code.
With V7, not even this is required, as the database engine
automatically enforces the integrity. This means that you can
open up your database to end-users through simple third party
interfaces as they simply cannot break your business rules even
even if they try. It makes it easy to administer changes in
business and data rules as there is only one spot where the
change needs to be made. This lowers the cost of required
modification to the system because you do not have to edit all
applications code that works with the table.
The basic idea of SQL is to accept and process requests for the
information you want without you knowing how to extract it (like
you do for network databases).
1. SQL*Plus
Known in days of yore as UFI (User Friendly Interface), this is
the basic "shell" for queries, basic reports and database
manipulation. It can be used interactively or driven from scripts.
It is a must-have, as installation requires scripts to be run
through this interface and most general administration by
programmers will be carried out through it.
Apart from the basic ability to issue SQL and PL/SQL commands,
it has a number of extensions to permit programming (parameter
passing, variables, prompting for user input, etc) and report
formatting.
2. SQL*DBA
A user-unfriendly version of SQL*Plus with extra power for DBA's.
The history editing facilities of SQL*Plus have been removed so
that you do not spend all your time in a product that has extra
(needed but dangerous) capabilities to do things like start up
and shut down your database.
sqldba lmode=y
3. SQL*Net
Needs to run on PC's and Mac's before you can access Oracle on
other machines. Most mid-range and larger machines have it as
part of the core product.
Note that if you are running mess-Windows, you can get into real
difficulty as the SQL*Net driver cannot handle two cursors
returning data the same instant - mainly because windows is not
true multi-tasking. (Broken As Designed?).
Mind you, SQL*Net v2 is out soon and even gets over the
problem of OPS$logins when you do not actually log in to the
Oracle server.
4. SQL*Async
Gives functionality of SQL*Net but over a dialup-type line.
5. SQL*Connect
SQL Based DBMS Gateways
6. Open Gateway
SQL based and Procedural based DBMS Gateways
7. Net Interchange
Software Protocol Converter
8. SQL*Forms
A development tool for screen based applications that allows
code to be stored in database tables. Version 3.0 and above use
PL/SQL for procedural parts of the code.
Version 4 is coming out and has SQL*Menu facilities built-in.
9. SQL*ReportWriter
Helps write reports and like Forms, permits source code to be
stored in the database. Version 2, soon to be released,
includes triggered events, the ability to update the database
and uses PL/SQL. Version 1, on the other hand, is perhaps the
one Oracle product tried and discarded by most sites. Despite
improvements, Version 2 looks to be getting the same reputation.
11. Oracle*CASE
A nifty set of data dictionary (once known as SDD) and design
tools that let you model your database and processes and then
generate reasonable first cut forms, etc from the definitions.
The design sides need a GUI for model display. This product is
good, like anything out of the Oracle UK group that used to be
an independent company that Oracle purchased.
Various reviewers have commented that while there are "me too"
modeling and design tools, (and of course, no others take
advantage of Oracle-specific enhancements), Oracle*CASE has the
best capability to reverse engineer existing Oracle applications
back into the modeling dictionary.
11. SQL*Menu
A suite of tools that allows the developer to enter menu details
into a database and generate a menu from it. It integrates well
with the other Oracle tools and has the capacity to produce
quite useful end-user documentation.
Nearly every DBA who has had to install SQL*Menu (on UNIX platforms at
least) that I have spoken to had a hard time. Once that is done,
however, it is easy to look after.
12. Oracle*Card
Helps develop HyperCard like applications in Windows and
Mac environments.
14. SQL*Graph
Prepares graphs from Oracle data.
15. SQL*Loader
Loads data from flat files into Oracle. Data can be loaded into
more than one table at a time (e.g. if your incoming data is in
the format of a master record followed by a number of detail
records).
16. RPT/RPF
An ancient reporting tool with a syntax like runoff that because
of its ability to perform updates, is still used by some batch
processes where its procedural capabilities are useful, especially
where PL/SQL is not necessarily available and the
developer does not want to put SQL in a compiled language like
C. You need this for some aspects of Oracle*CASE. The RPT part
is the program which goes through the tables and feeds data to
the RPF (formatting part). If you are using this for reports
you need more than a fair share of disk for temporary files,
especially if the RPT part must finish before RPF can start the
formatting and there is a lot of data to process. It has advantages
over SQL*ReportWriter in that the code is ASCII and HUMAN
READABLE, and can thus be put under version control tools. Also, it is
a lot faster than SQL*ReportWriter and can be altered much quicker than
wading through a m[ae]ss of menus.
18. Data*Query
A fairly new product that permits you to generate reports fairly
easily. The nice thing about this (again from Oracle UK) is that
if you have put constraints into the dictionary, then this will
pick up those relationships, so you do not have to constantly
specify the linking field between the EMP and DEPT tables, for
example. It will also do break processing and allow you to
define calculated fields easily so you do not have to retype them
all the time.
19. Data*Browser
Running under a window this gives graphical and analysis capabilities
according to one reviewer and is pretty good.
21. co-author
A grammar checking Utility
23. Oracle*Financials
A BIG product with modules for accounting, human resources, etc.
If you are a large company, worth considering if you have lots of
disk and cash to spare. Even Oracle admit that if you are not a
large company, it is not worth putting on your short list. It
is reported to cost about $20K per user.
24. Oracle*TextRetrieval
Lets you access text documents using queries. Next release (2)
will support storage of common PC and Mac formats (e.g.MesS-Word
and WordPerfect). Can do keyword searches.
26. Oracle*Terminal
Terminal specification utility, that replaced the CRT suite used
by Forms 2.3. Lets you map logical key names, key help and display
attributes to custom escape sequences. Offers much more power
than CRT, but most of us DBA's could drive CRT. If ReportWriter
is the least used because of its limitations, Terminal is the
second least used, because the documentation is limited and it
is hard to see how it all hangs together. Please someone, send
in some hints.
27. Oracle*Alert
Lets you define certain conditions that when met trigger an
event, usually an Oracle*Mail message, to someone. For example,
if monthly sales go to low, fire off a message to the sales
manager.
....
It should probably be noted that Oracle*Forms (4.0),
Oracle*ReportWriter (2.0), Oracle*Graphics (2.0), and
Oracle*Menu will be all integrated together into one large
Oracle*Tools package, the CDE (I think it stands for Common
Development Environment).
Oracle 7.1 has been announced and will include Parallel Query and
Multi-Media extensions. Alpha Now, Beta mid year, Production end
of year.
1. Oraperl
The Oraperl patches to perl are available from comp.sources.misc
archives and were written by Kevin Stock. These patch perl from
Larry Wall (see GNU or comp.sources.unix archives and
Comp.lang.perl newsgroup) to give it access to Oracle at a
fairly basic level, permitting you to even have simultaneous
connections to one or more databases (e.g. under different
Oracle logins). The perl language is available (as far as I
know) for UNIX, VMS, DOS, OS/2 and Macintoshes and is a cross
between the UNIX shell and C, and gaining rapidly in popularity.
One major advantage is that it makes many C libraries available
for use in an interpretive script language, and is thus more
powerful than the shell.
usenet/comp.sources.misc/volume3[0-9]/oraperl-v2/*
Note that you need to get perl (and check it compiles as is), from
any GNU archive site (e.g. archie.au in ~ftp/gnu). I am using
perl v4 patch 36 at the moment with oraperl v2 patch 3. I
will put in patch 4 soon. Version 5 of perl is currently in
alpha release on ftp@netlabs.com.
[Also available are perl patches to Sybase, Ingress and RDB. You
could possibly link them all together, although the SQL
functions have different names and syntax depending on which
interface you are using.]
2. DBperl
Soon to be available is DBperl, which unifies the syntax of the
Sybase and Oracle patches to perl. It will also permit access
to Ingress and Interbase, with consideration now being given to
xBase requirements.
3. Unload
Another utility is unload (which a lot of people rename to
sqlunload). It takes a SQL statement and creates two files, a
data loader control file and the data file. I think this was in
comp.sources.misc. I'll post it up to comp.databases.oracle if
need be (I forget where it came from originally). If anyone
Knows where it comes from and where it is archived, let me know.
I have tried to contact the author, but mail bounces.
4. TCL extensions
TCL is a GUI oriented language. Tom Poindexter has extended it
(Pretty much like perl is extended) to permit access to Sybase
and Oracle. Tom can be reached by tpoindex@nyx.cs.du.edu and
the extensions should be available from the TCl archives at
harbor.ecn.purdue.edu. Further information would be available
via the comp.lang.tcl newsgroup. TCl/Tk is also available from
Sprite.berkely.edu
5. XSQL
Just written by Jeff Stander, this takes an SQL statement and
sends the results to an X-window. See credits for his address.
7. Documentation
While they are still in draft mode, SQL93 standards are
available via gatekeeper.dec.com:~ftp/pub/standards/sql
MS-Access and ODBC is fairly new. One criticism is that you are
prevented from using the native SQL (which removes the ability
to use Oracle extensions) because the front-end product is too
"smart" and builds the SQL for you. However, if you ask
Microsoft *nicely* they will give you access to a routine that
you can send a straight SQL statement to that is passed to the
backed RDBMS without modification, thus bypassing this problem.
(Don't you hate mushroom treatment?)
Database Editor
Version 2 comes bundled with Excel4 for Win.
Version 5 can be bought as an upgrade, and is
well worth looking at.
Permits easy generation of queries from various
sources and generation of summary information.
End users can build a parameterized query
and then save it.
Has forms and report painter.
Can edit SQL text directly.
Has script ability for talking via OLE and DDE
and permitting multiple commands.
(No IF, WHILE type constructs tho).
Comes with connect library for driving Q+E
from C, Visual basic, etc.
Comes with demo templates for WinWord, add-ins
for Excel, Ami-Pro, Actor, C and
VisBasic.
Less common ODBC drivers are also available.
Contact:
Pioneer Software (US) developed it.
In Australia, contact Azonic in Sydney. (02) 878-6600
Other Notes:
Most comments about these products are very favorable and
generally include the terms "rugged" and "well-designed".
Rumor has it there are quite a few ex-Oracle guys at Pioneer.
IDAPI will be supported, but ODBC is preferred.
Apparently someone in Finland markets an OO C++
extension to the database library.
Do not know if you can open two different types of DB at
once - that would be really useful.
Clear Access
------------
Platforms: Macintosh and MS-Windows
Requires: SQL*Net
Features:
1. Point and click SQL data retrieval to applications
such as MS-Excel or flat files.
2. Script manager
3. Can link applications directly to SQL servers, e.g.
An Excel macro button can populate a worksheet.
4. Supports DAL.
Pricing:
$450 (US?) lists per station, but there are volume discounts.
Contact:
Clear Access Corp, 200 West Lowe Fairfield, and Iowa 52556
(515) 472-7077 FAX (515) 472-7198
Other Notes:
Got this info from the vendor. Have heard no reviews.
SQR
---
Platforms: Various OS and databases
Features:
1. Report generation language
2. Can update the database
3. Normal OS file interface capability
Contact:
US:
Australia: Sequel P/L, Melbourne
Other Notes:
Good if you have different database and OS platforms and
want to use similar code. I used it for a short time a
few years ago, but others I trust who used it more loved
it. Quite popular.
PowerBuilder
------------
Developer tool for management of databases and generation
of front-end forms and reports.
Platform:
MS-Windows
Features:
Some CASE and OO constructs for front-end
A few internal CASE tables for back-ends
Can generate ASCII files of DDL
(No triggers or procedures)
Looks useful as a working DBA tool as well.
Interfaces to most common RDBMSs.
Contact:
Powersoft, the developer.
Other Notes:
Smells of original design for Sybase.
SuperNOVA
---------
Platforms:
MS-Windows, Motif, OpenLook
UNIX, MS-DOS, VMS
Oracle, Sybase, Ingress, Informix, C-ISAM, Teradata
Contact:
Four Seasons Software, Bilthoven, Holland.
Fax: +44 81 446 9143?
Phone: +44 81 446 6481?
SQL*ETON
--------
Meant to be like "skeleton" for Oracle Forms development.
Features:
Application development skeletons and utilities
Uses standard Oracle tools
E.g. Straight forms; no user-exits
Can retrofit existing forms.
Contact:
Logical Technologies Pvt. Ltd.
2nd Floor, 535 Flinders Lane, Melbourne, Vic, 3000, Australia
Ph: +61 3 629 5200, Fax: 629 8383
Notes:
Logical also makes Forms 2.3 to 3.0 converters - more on
this soon. They also have "Definition", an alternative
to SQL*Case.
Some local user groups are setting up there own bulletin boards.
One is the Victorian Oracle Users Group here in Australia. Are
there any others?
Sybase:
I would be most likely to choose Sybase if
Mainly OS/2 site
Ingress:
Oracle has better SQL
Oracle has more robust backend
Oracle is more portable
Oracle has more flexible security.
Ingress front-end tools are niftier
I would be most likely to choose Ingress if
Most using X-terminals on UNIX host
Had DBA with good UNIX SysAdmin skills
Informix:
SQL interfaces can "pipe" output of SQL SELECTS through
a host UNIX command. Nifty!
Has SQL dialect like cross of Ingress and Oracle.
I would be most likely to choose Informix if
Hosted under UNIX on small systems
Dollars were scarce
DB2:
I would be most likely to choose DB2 if
What? Me? In an IBM shoppe?
2. SQL QUESTIONS
-----------------
2.1. How can I avoid a divide by zero error?
Use the DECODE function. This function is absolutely brilliant
and functions like a CASE statement, and can be used to return
different columns based on the values of others.
select PRODUCT,
Decode (NUM_SOLD,
0, NULL,
TOTAL_REVENUE/NUM_SOLD) AVG_SELL_PRICE
from my_table;
Update dept_summary s
Set num_emps = (select count (*) from emp e
Where e.deptno = s.deptno);
The other good thing about ROWID is that it is the quickest way to
reference a particular row in a table, providing that no table
reorganization happens in the meantime. A possible use is to
select information from a table including the row number into a
block in SQL*Forms, and pass the ROWID to a user-exit that goes
and picks up the LONG RAW in that table and displays it as a
picture.
You use the start with clause to specify the start of the
Tree(s). More than one record can match the starting condition.
One disadvantage of a CONNECT BY PRIOR is that you cannot
Perform a join to other tables. Still, I have not managed to see
anything else like the CONNECT BY PRIOR in the other vendor
Offerings and I like trees. Even trying to doing this
Programmatically in embedded SQL/C is difficult as you have to
do the top level query, for each of them open a cursor to look
for child nodes, for each of these open a cursor .... Pretty
soon you blow the cursor limit for your installation.
The way around this is to use PL/SQL, open the driving cursor with
the CONNECT BY PRIOR statement, and "join" programmatically for
each row returned.
2.8. How can I get information on the row based on group information?
Imagine we have the EMP table and want details on the employee
Who has the highest salary. You need to use a subquery.
2.9. How can I get a name for a temporary table that will not clash?
Use a sequence, and use the number to help you build the
Temporary table name. Note that SQL-93 is developing specific
Constructs for using temporary tables.
2.10. How can I find out about what tables, columns and indices there are?
Oracle maintains a live set of views that you can query to tell
You what you have available. In V6, the first two to look at
are DICT and DICT_COLUMNS which act as a directory of the other
dictionary views. It is a good idea to be familiar with these.
Not all of these views are accessible by all users. If you are
a DBA you should also create private DBA synonyms by running
$ORACLE_HOME/rdbms/admin/dba_syn.sql in your account.
Note that you CANNOT use cb and indent with Pro*C as both these
Programs will screw up the embedded SQL code.
If DUAL has NO rows or more than one, many forms under 2.3
syntax (or 2.3 triggers in forms 3) will not work properly.
At worst, the logic of some of the triggers in your form will be
reversed, without any message to the user and data could be
destroyed.
When I was writing Forms 2.3 code, the *first* thing I did
was to check that there was one row (and only one row) in
the DUAL table, otherwise I displayed a message to contact the
DBA and then quit the form. This was done in KEY-STARTUP.
There are some performance gains that MIGHT be possible with padded
Strings: if the initial strings or keys are padded, then the back-end
Engine can quickly skip to the field rather than scanning for field
delimiters.
I do not believe that straight SQL is the way to go for such problems
when you have PL/SQL available.
Say we are getting a list of names and codes and want it ordered
by the name, using both EMP and DEPT tables:
select DEPTNO, DNAME from DEPT
union
select EMPNO, ENAME from EMP
order by 2;
Oh, and don't complain about the passwords being told here. These are
default passwords. For SYSTEM and SYS they ***MUST*** be altered for
security reasons. After all, everybody knows them.
The logic behind this is that you probably most use the
dependent records after you have accessed the master table.
Also, the master and dependent records of other tables must fit
into an Oracle block, typically 2k (though adjustable at install
time by a brave DBA). Now, if you are thinking of cluster
transactions with an account master record, how long before you
have blown 2k ?
No Oracle DBA I ever knew, apart from Oracle staff, thought that
using clusters was worth the hassle.
Imagine you have a HUGE table and need to update it, possibly
updating the key. You cannot update it in one go because your
rollback segments are too small. You cannot open a cursor and
commit every n records, because the cursor will close. You
cannot have a number of updates of a few records each because
the keys may change - causing you to visit records more than
once.
The solution I have used was to have one process (with SET
TRANSACTION READ ONLY) select ROWID from the appropriate rows
and pump these (via standard I/O) to another process that
looped around reading ROWIDs from standard input, updating the
appropriate record and committing every 10 records or so. This
was very easy to program and also was quite fast in execution.
The number of locks and size of rollback segments required was
minimal.
You *know* there are records for that day - but none of them are
coming back to you.
What has happened is that your records are not set to midnight?
(Which is the default value if time of day not specified).
You can either use to_char and to_date functions, which can be a
bad move regarding SQL performance, or you can say
WHERE date_field = '18-jun-60' AND date_field < '19-jun-60'
3. SQL*PLUS QUESTIONS
----------------------
3.1. How can I control the startup configuration of SQL*Plus?
COLUMN x OLD_VALUE y
SELECT surname x
FROM employee
WHERE emp_id = 1234;
PROMPT I found employee with surname &&y
Use of a & does not create a permanent version and will prompt
you for a value if the variable does not exist (as will &&).
However, next time you reference the variable with & or &&, it
will ask you for the value again.
Try the following to figure it out (do not enter the "SQL" and
remember to type something in when asked, make it different each
time).
SQL undefine try_1
SQL prompt &try_1
SQL prompt &try_1
SQL prompt &&try_1
SQL prompt &&try_1
SQL prompt &try_1
SQL prompt &&try_1
define WORK_TABLE="EMP"
select &&WORK_TABLE.DEPTNO
from &&WORK_TABLE;
define XYZ="ABC"
prompt &&XYZ.abc
Select &&WORK_TABLE.DEPTNO
from &&WORK_TABLE;
(You can change this meaning of "." if it bugs you use the SET
command with the CONCAT argument but I do not recommend changing
it without lots of thought).
3.8. How can I force a column to begin on the left of the page?
Use the COLUMN FORMAT command with FOLD (BEFORE|AFTER).
For example:
rem alter the character
set define "~"
select "This & that are normal" from dual;
accept your input prompt "Give me a string"
Select ~your input from dual;
Set define "&"
Now this is fairly painful if you want keep track of things and
there are some characters you cannot escape.
Do a "SHOW ALL" and you'll see all the various things you can
play with.
4. SQL*FORMS 3 QUESTIONS
-------------------------
4.1. How can I get a list of values from a hard coded list?
4.2. How can I get find to look at description with list of values?
Imagine that you are have the following list of values text for
a key (e.g. for the DEPTNO field of the EMP block):
Select DEPTNO, DNAME, LOC into: EMP.DEPTNO from DEPT
If you are using a text editor, you must remember to reload the
form back input the database using the iac program. You will
have to remove it using "iac -d" first.
One thing worth noting is the fact that the text file (and the
database definition) permits association of prompt text to be
associated with the field, and position above or to the left of
the field, moving automatically when you edit the position of
the field. You can also automatically have the prompt repeated
in multi-row blocks.
Using these tables for reports can also be handy to compare the
definition and consistency of columns and fields that use it as
well as for technical documentation (such as "where is
Such-and-such a table used?).
This can be a *lot* faster than opening up all the forms under
SQL*Forms designer, navigating a million menus and then doing
heaps of typing.
Depending on how you set up forms, most users see tables like
SYSTEM.FORM_APP, SYSTEM.FORM_BLK, etc. These contain code for
forms owned by that user. If you are SYSTEM, then you can see
tables SYSTEM.FORM_APP_, SYSTEM.FORM_BLK_, etc that have code
for all users in them.
How to deal with LONGs using forms is to get the ROWID into a
field in your form. Your user exit picks this up and selects
from the base table using the ROWID, then breaks the LONG up
into a number of forms fields.
DEFINE PROCEDURE
NAME = TO_FAHRENHEIT
DEFINITION = <<<
function MY_FUNCTION (
VNAME in number
) return number is
Begin
Return ((VNAME * 9 / 5) + 32);
end;
ENDDEFINE PROCEDURE
OK, you're probably a UNIX person asking this. For those of you
that are not, regular expressions are a much more expressive way
of specifying a "wildcard string", analogous to % and _ used
with the "LIKE" keyword of SQL.
For example [A-C]*T would match T, AT, CT, CAT, BAT, BBACACCACT.
You need to write a C user exit that uses the sedstr () function.
This permits both matching (and tells you the position of the
match) or substitution (hence the name - "sed" on C strings).
This is available from any comp.sources.unix archive. This also
uses other PD code, the "regexp" package out of EMACS. You can
get EMACS from any GNU archive. Of course, you could write the
whole thing from scratch using the regexp routines provided
straight from the C libraries, but sedstr() is *MUCH* easier to
use. Novice C programmers can use sedstr (), they cannot use the
standard regexp package.
User exits are called from your PL/SQL and can be passed an
argument as a bit fat string up to 255 chars. They can read and
write forms fields using "get" and "put" functions.
[Warning: Ad On]
Actually I've written a few of these, along with the parsing of
the single command argument into argc, **argv for you C
Programmers. Cannot release it though as it is proprietary,
although good deals negotiable with my lords and masters.
[Ad Off]
Proprietary). User-exits are good for things that are (1) not
in sqlforms area of expertise and/or (2) to be done at the front
end, not via V7 DBMS pipes. Good examples would be routines to
perform regex searches, read data from non-Oracle sources, send
Inter-process communication messages routines to calculate Normal
distribution stuff, read stuff from text files into fields.
5. SQL*FORMS 4 QUESTIONS
-------------------------
5.1. What new features can be expected in forms 4 generator from CASE?
Bitmap editor.
6. PRO*C QUESTIONS
-------------------
6.1. Why are my C variables overwritten?
This question only gets phrased this way once you've got to the
stage of debugging your programs by putting printf() calls
everywhere because you cannot figure out what is going on. It
usually stems from the fact that you have been writing C for
some time and are new to the Pro*C precompiler.
This can pose a problem if you want to deal with varchar data
from other files, as Pro*C does the declaration for you. You
can pass the varchar across to other functions by pointers.
Put the EXEC SQL DECLARE section inside C comments and make the
size of the char to be 6, easy if you know that the column is
char(6). Note that the EXEC keyword must NOT appear on the line
in which the comment opens, but further down.
E.g.
/* Begin C comment
This stuff not seen by C but still visible
to Pro*C
EXEC SQL BEGIN DECLARE SECTION;
myvar char(6);
EXEC SQL END DECLARE SECTION;
End of C comment */
char myvar[7] = { 0,0,0,0,0,0,0 } ;
6.3. What can I do about "line too long" errors with version control?
7. CASE QUESTIONS
------------------
7.1. Can CASE generate forms with owner prepended to table names?
Set the TABOWN option.
8. UNIX QUESTIONS
------------------
8.1. Can I create a compressed export on the fly without needing to
have the space for both the export file and the compressed file?
You can do a similar thing the other way to import the file.
You may also have GNU C installed on your system. This too is
based upon BSD.
The BSD and AT&T compilers use libraries and include files from
different directories, reflecting the system libraries of the two
different dialects of UNIX. Sometimes the function is just called
under another name, sometimes the number of parameters (and their
ordering) is different.
Examples include
Get working directory getcwd vs. getwd
Copy Memory memcpy vs bcopy
Compare Memory memcmp vs bcmp
What to Do
----------
Oracle recommends that when using Pro*C (or even installing and
linking Oracle) you have the /5bin directory ahead of /bin in your
PATH variable.
[This is good practice anyway, because you will get used to the
System V versions of commands (df and ps are good examples of this -
I usually create a soft link to /bin/ps and /bin/df as
/usr/local/bin/bps and /usr/local/bin/bdf - a similar practice to
HP when they supply both versions of a utility). ]
You might like to try the following if you *really* want to use
the GNU C (or other BSD) compiler.
(1) Using GNU C, but point at System V libraries
(2) Using GNU C and libraries but add in your own, written
in GNU C that mimic the system V calls. You'll know
which ones you need, as they will be the unresolved
references. Some of these may simply be stubs that call
the BSD function of a different name or reorder the
parameters.
(3) Extract the functions you need from the System V libraries
and add them to your list to be linked in via the make
file.
Look, I know it involves some hacking, but if you are that keen on Gnu
C and only using your products in-house, you should be OK. I am not
knocking Gnu C, mind you. Gnu C is a must for many shops developing
in-house code and compiling things from the net. One R&D shop I
worked in tried it out on our code, and it gave tighter executables
than the native HP compiler at the time!
One other thing to note if you are running Solaris 2 is that the
good C compiler has been unbundled. The compiler that comes
standard with Suns now is reported by some to be dain bramaged.
If you are serious about your compiler (and you should be if you
are running Oracle) then spend the money and get the *REAL*
developers kit. (At least this is not as bad as some UNIX
systems distributed without a compiler!)
. Inp.frm:
- rm $*.frm $*.erf
- $(IAG) $* $(OUP) $*. inp.err 2&1
test $*.frm
. inp.dbi:
- rm $*.frm $*.erf
- $(IAG) $* $(OUP) $*. inp.err 2&1
test $*.frm
- $(IAC) -d $* $* $(OUP)
$(IAC) -i $* $* $(OUP)
touch $*.dbi
. dbo.inp:
- mv $*.inp $*.inp.bak
$(IAC) $* $* $(OUP)
- touch $*.dbo
touch $*.inp
9. MISC QUESTIONS
------------------
9.1. How can I alter table storage parameters from an export file?
Example:
imp scott/tiger filename=myexport.dmp indexfile=myexport.sql
Actually, Oracle and Sun get to look at each other's source code
at early development levels and are HEAVILY allied against the
common enemy, a.k.a Bill Gates.
For low end users, even though a Novell, or OS/2 server might
look cheaper, I do think that UNIX makes a better architecture
for something as complex as a multi-user database to live in.
Unless, of course, rumors of Novell bundling Oracle sometime in
the future are true and the price becomes impossible to resist.
The (apparent) lack of Virtual Memory in Novell means the Oracle
server could run out of memory and blow up.
a. Reports and management are more user friendly than SCCS, the
default tool for UNIX, our main development platform (although
our network includes DOS and VMS nodes).
c. The binary files used to store initial code and deltas (from
which any version can be retrieved) are compatible across
architectures. For example, I can use the DOS RCS programs to
extract source files from the binary RCS files transferred from
the UNIX machine.
e. Perusal of Oracle source code for scripts and the like shows
that they use RCS. If it's good enough for them to use PD
products .....
For ASCII files, RCS looks for certain keywords, and on check
out, substitutes the version specific information. These
keywords are enclosed between dollar signs.
You can also cause RCS to include in your source all comments
made specific to that version, for example, the reason why
changes had to be made using the Log keyword.
Note that with ASCII files, only storage for the changes between
successive versions are required. For binary files, the entire
file is stored - chewing up disk fairly quickly.
Thus for forms, use the .inp file, for menus, the .sql file
produced by "exporting" the menu. For SQL*Reports, .rex files
rather than .rep files are put under version control.
The keywords are placed in the source, however you like, the
ASCII file produced checked in to RCS. When moving to a
testing or production environment, the source is checked out of
RCS (resulting in keyword substitution) and "compiled" in the
target environment to produce the runtime application.
4. General Caveat
------------------
Where source code for an Oracle application can be stored in the
database (such as forms or menu), keyword expansion of the Id
keyword can be dangerous, as it may expand to MORE than the
database allows to be stored. Thus, rather than use Id, I use
the more atomic keywords on different lines, these being
unlikely to expand above legal limits.
B. SQL*Forms
RCS keywords are placed in the comments at forms level.
Selected keywords are placed as default values for
Non-enterable fields, so that the user can see version
information.
C. SQL*Menu
RCS keywords are placed either in the title section of
a menu or in the default value for a parameter,
depending on how we want to use the keyword. If you
do not want to do this, put a wraparound function to
create the Remark line(s) at the top of the .sql file
prior to checking it in. This will NOT affect
Compilation of the resulting .dmm.
D. SQL*ReportWriter
Major BUMMER, .rex files are not "sensible" ASCII that
will permit expansion of RCS keywords. The only way I
know how to solve this is to version an ASCII file
produced by selecting the data out of the report writer
internal tables and versioning that, then using
SQL*Loader to put them back into the SQL*ReportWriter
tables in the production environment. While this would
work, I have not tried it myself (as we do not use RW),
but apparently some group in the US has a tool that
performs this task. If anyone knows how I can contact
that group, let me know please.
Notes:
1. RCS and CVS, together with the GNU compiler you may need
are available from most GNU archive sites. If you are in
Australia, try archie.au in ~ftp/gnu. Less up-to-date
versions are also available in comp.sources.unix.
2. Mastering Oracle V6
Daniel Cronin and Joe Lee
Provides a good overview of V6 application development
in one handy book with an almost complete application
used as an example. This book came out very soon after
The release of V6 and thus only discusses Forms 2.3 and
has a V5 to V6 migration guide. Not really detailed
enough for power programming, does not go into Pro*XXX
languages, but great for somebody just moving into RDBMS
or Oracle. It would be nice to see a new edition for
V7.
3. ??????
George Koch
Have not seen this book, but has generally received
favorable reviews. Apparently the V7 stuff seems tacked
on to the end.
New Questions
--------------------------------------------------------------------------------
What built-in functions/operators are available for manipulating strings?
The most useful ones are LENGTH, SUBSTR, INSTR, and ||:
LENGTH (str) returns the length of str in characters.
SUBSTR (str,m,n) returns a portion of str, beginning at character m, n characters long. If n is omitted,
all characters to the end of str will be returned.
INSTR (str1,str2,n,m) searches str1 beginning with its n-th character for the m-th occurrence of str2
and returns the position of the character in str1 that is the first character of this occurrence.
str1 || str2 returns the concatenation of str1 and str2.
The example below shows how to convert a string name of the format 'last, first' into the format 'first
last':
SUBSTR (name, INSTR (name,',',1,1)+2)
|| ' '
|| SUBSTR (name, 1, INSTR (name,',',1,1)-1)
For case-insensitive comparisons, first convert both strings to all upper case using Oracle's built-in
function upper() (or all lower case using lower()).
--------------------------------------------------------------------------------
Can I print inside a PL/SQL program?
Strictly speaking PL/SQL doesn't currently support I/O. But, there is a standard package DBMS_OUTPUT
that lets you do the trick. Here is an example:
-- create the procedure
CREATE PROCEDURE nothing AS
BEGIN
DBMS_OUTPUT.PUT_LINE('I did nothing');
-- use TO_CHAR to convert variables/columns
-- to printable strings
END;
.
RUN;
-- set output on; otherwise you won't see anything
SET SERVEROUTPUT ON;
-- invoke the procedure
BEGIN
nothing;
END;
.
RUN;
Then you should see "I did nothing" printed on your screen.
DBMS_OUTPUT is very useful for debugging PL/SQL programs. However, if you print too much, the
output buffer will overflow (the default buffer size is 2KB). In that case, you can set the buffer size to
a larger value, e.g.:
BEGIN
DBMS_OUTPUT.ENABLE(10000);
nothing;
END;
.
RUN;
--------------------------------------------------------------------------------
Is it possible to write a PL/SQL procedure that takes a table name as input and does something with
that table?
For pure PL/SQL, the answer is no, because Oracle has to know the schema of the table in order to
compile the PL/SQL procedure. However, Oracle provides a package called DBMS_SQL, which allows
PL/SQL to execute SQL DML as well as DDL dynamically at run time. For example, when called, the
following stored procedure drops a specified database table:
CREATE PROCEDURE drop_table (table_name IN VARCHAR2) AS
cid INTEGER;
BEGIN
-- open new cursor and return cursor ID
cid := DBMS_SQL.OPEN_CURSOR;
-- parse and immediately execute dynamic SQL statement
-- built by concatenating table name to DROP TABLE command
DBMS_SQL.PARSE(cid, 'DROP TABLE ' || table_name, dbms_sql.v7);
-- close cursor
DBMS_SQL.CLOSE_CURSOR(cid);
EXCEPTION
-- if an exception is raised, close cursor before exiting
WHEN OTHERS THEN
DBMS_SQL.CLOSE_CURSOR(cid);
-- reraise the exception
RAISE;
END drop_table;
.
RUN;
--------------------------------------------------------------------------------
What is the correct syntax for ordering query results by row-type objects?
As a concrete example, suppose we have defined an object type PersonType with an ORDER MEMBER
FUNCTION, and we have created a table Person of PersonType objects. Suppose you want to list all
PersonType objects in Person in order. You'd probably expect the following to work:
SELECT * FROM Person p ORDER BY p;
But it doesn't. Somehow, Oracle cannot figure out that you are ordering PersonType objects. Here is a
hack that works:
SELECT * FROM Person p ORDER BY DEREF(REF(p));
--------------------------------------------------------------------------------
How do I kill long-running queries in sqlplus, Pro*C, and JDBC?
Sometimes it is necessary to stop long-running queries, either because they take longer to run than
you'd like, or because you realize you've made a mistake. It is important kill off such queries properly
so that they don't take up extra computational resources and prevent others from using the system,
especially near project deadlines when resources are most strained.
As a general precautionary measure, please be sure to test your queries under sqlplus prompt before
running them through CGI or JDBC. It is much easier to kill a query in sqlplus than in CGI or JDBC. If
your test query takes a long time to run under sqlplus, you can simply hit Ctrl-C to terminate it.
Never close an ssh or telnet or xterm window without properly logging out. Always quit your programs
(including sqlplus), stop Java servlets, and type "exit" or "logout" to quit. If you force-close your
ssh/telnet/xterm window, there may still be processes running in the background, and you may be
taking up system resources without knowing it.
If, for some reason, you cannot logout normally (for example, the system is not responding), you should
open another window, login to the same machine where you have the problem, and kill the processes
that is causing trouble:
Type "ps -aef | grep [username]" to find the Process IDs of your processes (replace [username] with
your leland user name), and kill the processes you want to terminate using "kill [processID]". Always
use the "kill" command without the -9 flag first. Use -9 flag only if you cannot kill it otherwise.
If you closed the window by mistake and do not remember which sweet hall machine you were logged
into, open another window immediately and log into any sweet hall machine, then type "sweetfinger
[username]" (replace [username] with your actual leland user name). It will give you the machine
names you were on a few minutes ago. Then, log in to the appropriate machine and kill your processes
there.
If you issued a query through JDBC that is taking a long time to execute and you want to kill it, you
should stop your Java servlet. In most cases this will kill the query. You can also use the
setQueryTimeout([time in seconds]) method on a statement object to stop queries that run too long.
If you issued a query through CGI that is taking a long time to execute, normally the CGI service will
kill it for you within 10 seconds. However, the above occasionally fails to work, and we do not know of
any better way of killing runaway queries issued by JDBC or CGI (other than asking the administrator to
kill them for you). That's why we ask you to always test your queries under sqlplus first. It is much
easier to kill queries there.
--------------------------------------------------------------------------------
In Pro*C, why do I get a strange "break outside loop or switch" error message?
If you get an error message
"break" outside loop or switch
when compiling your Pro*C program, chances that you have the following statement somewhere before
a loop:
This would cancel the previous WHENEVER statement. If you do not do this, you may get the error
message at subsequent SQL calls.
Oracle Faq’s
"Oracle 8i is what type of database?
","A) hierarchical network
B) object network
C) hierarchical relational
D) object relational","D) object relational
"
"Which two (if any) of the following three WHERE clauses are equivilent. (Note - the numbers are for reference
only, they are not part of the WHERE clauses)
1 WHERE ename = 'SMITH'
2 WHERE UPPER(ename) = 'smith'
3 WHERE ename = UPPER('smith')","A) 1 and 2
B) 1 and 3
C) 2 and 3
D) each will yield different results","B) 1 and 3"
"Which keyword is used to suppress duplicate rows from being displayed?","A) SUPPRESS
B) DISTINCT
C) UNIQUE
D) NONDUPLICATE","B) DISTINCT"
"A primary key can be made up of","A) one column
B) two columns
C) three or more columns
D) A, B, or C
E) None of the above","D) A, B, or C"
"Which of the following Oracle versions meets ANSI standards?","A) SQL*Plus
B) PL/SQL
C) SQL
D) ISO","C) SQL"
"Which of the following is not a PL/SQL section?","A) LOOP
B) EXCEPTION
C) DECLARE
D) BEGIN","A) LOOP"
"Which of the following does have a semi-colon at the end?","A) A FROM clause which is followed by a WHERE
clause
B) The keyword END at the end of a PL/SQL block
C) The keyword DECLARE at the beginning of a PL/SQL block
D) A SELECT clause","B) The keyword END at the end of a PL/SQL block"
"Which was the first object-capable database developed by Oracle?","A) Oracle 5.2
B) Oracle 7
C) Oracle 8
D) Oracle 8i","C) Oracle 8"
"Which of the following is not a component of the relational model?","A) random file capability on DASD
B) collections of objects or relations that store data
C) a set of operators that act on the relations to produce other relations
D) data integrity for accuracy and consistency","A) random file capability on DASD"
"Which of the following is not a key component of the ER model?","A) entities
B) hierarchies
C) attributes
D) relationships","B) hierarchies"
"Which of the following is a DML statement?","A) SELECT
B) COMMIT
C) UPDATE
D) DROP","C) UPDATE"
"Which of the following is not a DML statement?","A) SELECT
B) INSERT
C) DELETE
D) UPDATE","A) SELECT"
"Which constraint is displayed via the DESCRIBE command?","A) UNIQUE KEY
B) CHECK
C) PRIMARY KEY
D) NOT NULL","D) NOT NULL"
"Which of the following is a DML statement?","A) CREATE
B) COMMIT
C) INSERT
D) DROP","C) INSERT"
"Which SQL*Plus command is equivalent to START?","A) @
B) $
C) !
D) (+)","A) @"
"Which of the following is a DML statement?","A) CREATE
B) TRUNCATE
C) ROLLBACK
D) DELETE","D) DELETE"
"A field is defined in Oracle as the intersection of what?","A) attribute and table
B) select and from
C) data type and PL/SQL
D) row and column","D) row and column"
"Which of the following is a DDL statement?","A) GRANT
B) COMMIT
C) DELETE
D) CREATE","D) CREATE"
"Which of the following is not a DDL statement?","A) ALTER
B) INSERT
C) RENAME
D) DROP","B) INSERT"
"How many keywords are there in the following?
SELECT ename, sal, hiredate
FROM emp
WHERE deptno = '10'
ORDER BY ename;","A) 1
B) 2
C) 3
D) 4
E) 5
F) 6","E) 5"
"How many clauses are there in the following?
SELECT ename, sal, hiredate
FROM emp
ORDER BY ename;","A) 1
B) 2
C) 3
D) 4
E) 5
F) 6","C) 3"
"How many statements are there in the following?
SELECT ename, sal, hiredate
FROM emp
WHERE deptno = 10
AND empno > 7900
ORDER BY ename;","A) 1
B) 2
C) 3
D) 4
E) 5
F) 6","A) 1"
"A relational database can contain at most one table.","True/False","False"
"A given table can many rows.","True/False","True"
"SQL keywords are case sensitive.","True/False","False"
"PL/SQL is the ANSI created language for SQL systems.","True/False","False"
"Commands within SQL*Plus can be abbreviated.","True/False","True"
"A column is made up of many rows, and rows are made up of many tables.","True/False","False"
"A column which serves as the primary key for a table can have duplicate values if the constraint UNIQUE VALUE
is set to NULL.","True/False","False"
"A primary key can not contain any null values.","True/False","True"
"Keywords within SQL can be abbreviated.","True/False","False"
"A column which has the UNIQUE KEY constraint will have an index created for it
automatically.","True/False","True"
"A column which has the UNIQUE KEY constraint can contain NULL values.
","True/False","True"
"What does 'ER' stand for, as in 'ER Modeling'?
","Short Answer","Entity Relationship"
"Two tables can be related via their common column. In one table this column would be the Primary Key. What
term describes the related column in the other table?","Short Answer","Foreign Key"
"What does SQL stand for?
","Short Answer","Structured Query Language"
"What does PL/SQL stand for?","Short Answer","Procedural Language/SQL"
"What does ANSI stand for?
","Short Answer","American National Standards Institute"
"What does ISO stand for?
","Short Answer","International Standards Organization"
"List the three (3) DML statements. Also, what does DML stand for?","Short Answer","INSERT
UPDATE
DELETE
-also-
SELECT avg(sal)
FROM emp
WHERE job <> 'SALESMAN';"
"Write a statement to retrieve employees' name and salary for those who earn less than the average for all
employees.","Short Answer","SELECT ename, sal
FROM emp
WHERE sal < (SELECT avg(sal)
FROM emp);"
"Write a statement to retrieve the ename and loc for all employees, plus sort the data by loc ascending, then within
loc by ename descending.","Short Answer","SELECT ename, loc
FROM emp e, dept d
WHERE e.deptno = d.deptno
ORDER BY loc, ename DESC;"
"Write a statement to display the number of employees at each location (New York, Dallas, Chicago, and
Boston).","Short Answer","SELECT loc, count(*)
FROM emp e, dept d
WHERE e.deptno = d.deptno
GROUP BY loc;"
"The LINE_ITEM table contains these columns
LINE_ITEM_ID NUMBER(9) Primary Key
ORDER_ID NUMBER(9)
PRODUCT_ID VARCHAR2(9)
QUANTITY NUMBER(5)
Which statement is true concerning the results of executing this statement?","A) The results are sorted numerically
only.
B)
ALTER TABLE table_name
STATUS = ENABLE CONSTRAINT constraint_name;
C)
ALTER TABLE table_name
ENABLE CONSTRAINT constraint_name;
D)
ALTER TABLE table_name
STATUS ENABLE CONSTRAINT constraint_name;
E)
ALTER TABLE table_name
TURN ON CONSTRAINT constraint_name;","C"
"The EMPLOYEES table contains these columns:
LAST_NAME VARCHAR2 (25)
SALARY NUMBER (6,2)
COMMISSION_PCT NUMBER (6)
D) An error statement","C"
"Which SELECT statement should you use to extract the year from the system date and display it in the format
'1998'?","A)
SELECT TO_CHAR(SYSDATE, 'yyyy')
FROM dual;
B)
SELECT TO_DATE(SYSDATE, 'yyyy')
FROM dual;
C)
SELECT DECODE(SUBSTR(SYSDATE, 8), 'YYYY')
FROM dual;
D)
SELECT DECODE(SUBSTR(SYSDATE, 8), 'year')
FROM dual;
E)
SELECT TO_CHAR(SUBSTR(SYSDATE, 8, 2), 'yyyy')
FROM dual;","A"
"Which of the following correctly describes the precedence of mathematical operators?","A) Multiplication,
Division, Addition, Subtraction
B) Subtraction, Division, Addition, Multiplication
C) Multiplication, Addition, Division, Subtraction
D) Subtraction, Division, Addition, Multiplication","A"
"Which of the following correctly describes the precedence of comparison and logical operators?","A) And, Not, All
comparison operators, Or
B) Not, And, Or, All comparison operators
C) All comparision operators, Not, And, Or
D) All comparison operators, Or, Not, And","C"
"For a hire date of December 10, 1999, what does the following function evaluate to?
B)
SELECT *
FROM emp;
C)
SELECT all
FROM emp;
D)
SELECT */
FROM emp
E)
SELECT &&
FROM emp/","B"
"Which of the following is the correct format to clear a column?","A)
CLEAR COLUMN column_name
B)
COLUMN column_name CLEAR
C)
DELETE COLUMN column_name
D)
UNDEFINE COLUMN column_name","B"
"Which is the correct order of the mathematical operators?","A)
-+/*
B)
+/-*
C)
*/+-
D)
* + - /","C"
"The WHERE clause restricts which of the following?","A)
Rows
B)
Columns
C)
Groups
D)
Tables","A"
"Is PL/SQL a programming language or a way to gather data?","Short Answer","It is a programming lanugauge. It
uses SQL to gather data."
"How do you read specific data from a table (such as name, department, etc)?","Short Answer","With a SELECT
statement, such as:
If your intention is to see which columns are in a table, use the DESCRIBE command of SQL*Plus.
DESCRIBE emp"
"Does Oracle store all data in upper case, lower case, or mixed?","Short Answer","Data is stored in both upper and
lower case, such as an employee's name 'Jones'.
Column names and table names are stored in the Data Dictionary in upper case."
"Which statement would produce the following results:
B)
SELECT empno, ename, sal, mgr
FROM emp
WHERE mgr IN (7902, 7566, 7788);
C)
SELECT empno, ename, mgr
FROM emp
WHERE empno NOT IN (7902, 7566, 7788);
D)
SELECT empno, ename, sal, mgr
FROM emp
WHERE empno IN (7902, 7566, 7788);","B"
"Why are Aliases better?","A)
They make the column/table name more meaningful
B)
They take up less memory
C)
They just look better
D)
They simplify things and make them more readable","D"
"If '&dept_name' is being inserted into the column department_name, what type of data is department_name?","A)
number
B) blob
C) varchar2
D) date","C
Note: Single quotes (apostrophes) are also used when inserting dates, however 'department_name' would be a very
bogus column name for a date column."
"How many rows can you insert into a table.","A)
As many as you want
B)
As many as the physical space of the database will allow
C)
Depends on which version of Oracle you are running
D)
Both B and C","Unknown, although I would guess D"
"Which of the following will always SELECT all columns and all rows from the emp table?","A)
SELECT ALL
FROM emp;
B)
SELECT *
FROM emp
WHERE sal IS NOT NULL;
C)
SELECT *
FROM emp;
D)
SELECT *
FROM emp
HAVING ALL ROWS;","C"
"For a given row which contains the value 'variable' in a column named 'type', what does the following function
return?
B) 'iable'
C) 'able'
D) 'ble'
B) 'nso'
C) 'nosn'
D) 'nos'","B"
"Which of the following is not a valid type of JOIN?","A) Non-Equijoin
B) Self-join
C) Limited-join
D) Outer-join
E) All the above are valid","C"
"How do PRIMARY KEY and UNIQUE KEY Constraints differ?","A) They do not differ, but are two different
ways to achieve the same result
B) The UNIQUE KEY Constraint allows Null values, PRIMARY KEY does not
C) The PRIMARY KEY Constraint allows Null values, UNIQUE does not
[ ] A unique key column CAN contain NULL values, however, if values are present (non-NULL), then the values
must be unique."
"List the types of joins which are available.","Short Answer","Non-Equijoin
Equi-join
Self-join
Outer-join"
"Evaluate the following expression:
8 * 2 / 4","Short Answer","8 * 2 / 4
16 / 4
4"
"Evaluate the following expression:
3+ 50
53"
"Evaluate the following expression:
8 - 2 + 4","Short Answer","8 - 2 + 4
6 +4
10"
"Evaluate the following expression:
7 * (8 - 4) + (3 * 2)","Short Answer","7 * (8 - 4) + (3 * 2)
7 * (4) + (6)
7* 4 + 6
28 + 6
34"
"Evaluate the following expression:
2 *2
4
"
"Evaluate the following expression:
100 / (100)
100 / 100
1"
"Evaluate the following expression:
2 + 2 - 4","Short Answer","2 + 2 - 4
4 -4
0"
"A null in a character column is equivalent to blank, and in a numeric column is equivalent to
zero.","True/False","False"
"A column alias precedes the column name in the select clause.","True/False","False"
"The keyword AS is optional when using column aliases.","True/False","True"
"The following syntax is correct for using a column alias:
The alias should be enclosed in DOUBLE quotes instead of SINGLE quotes (apostrophes)."
"Under which of the following circumstances should you use double quotes around a column alias?","A) It contains
spaces
B) It contains special characters
C) It is case sensitive
D) All of the above
E) None of the above, you should use single quotes instead","D) All of the above"
"Within a SQL statement, a column alias CAN be used with both the SELECT and the ORDER BY clauses, but can
NOT be used in the WHERE clause.","True/False","True"
"If a column alias is NOT enclosed in double quotes, it will be displayed in all capital letters.","True/False","True"
"What is the concatenation operator?","A) &&
B) ++
C) $$
D) ||","D) ||"
"Which of the following SQL statements will result in the following display for a table with only three rows?
CUSTOMERS
---------
Flo Jones
Moe King
Joe Brown
3 rows selected.","A)
SELECT first_name, ' ', last_name 'CUSTOMERS'
FROM cust;
B)
SELECT first_name ' ' || ' ' last_name 'Customers'
FROM cust;
C)
SELECT first_name || last_name CUSTOMERS
FROM cust;
D)
SELECT first_name || ' ' || last_name Customers
FROM cust;","D)"
"Date and character literals are enclosed within single quotes, whereas aliases are enclosed within double
quotes.","True/False","True"
"Date and character literals are enclosed within double quotes, whereas aliases are enclosed within single
quotes.","True/False","False"
"Compose a SQL statement to concatenate the employee name, the literal ' works in ', and the location with a
column heading in all caps of WORKSWHERE. A typical output would look like this:
WORKSWHERE
---------------------------------
KING works in NEW YORK
...
14 rows selected.","Short Answer","SELECT e.ename
|| ' works in '
|| d.loc workswhere
FROM emp e, dept d
WHERE e.deptno = d.deptno;"
"Which of the following uses the correct syntax for eliminating duplicate rows?","A)
SELECT ename, sal, deptno
FROM emp DISTINCT;
B)
SELECT DISTINCT ename, sal, deptno
FROM emp;
C)
SELECT UNIQUE ename, sal, deptno
FROM emp;
D)
SELECT ename, sal, deptno
FROM emp NONDUPLICATE;","B)
SELECT DISTINCT ename, sal, deptno
FROM emp;"
"Which of the following is based on ANSI standards?","A) SQL
B) SQL*Plus","A) SQL"
"Which of the following has keywords which CAN be abbreviated?","A) SQL
B) SQL*Plus","B) SQL*Plus"
"Which of the following has keywords which can NOT be abbreviated?","A) SQL
B) SQL*Plus","A) SQL"
"Which of the following does NOT have a continuation character?","A) SQL
B) SQL*Plus","A) SQL"
"Which of the following DOES have a continuation character?","A) SQL
B) SQL*Plus","B) SQL*Plus
Its continuation character is the dash (-)."
"Which of the following uses a termination character to execute the command immediately?","A) SQL
B) SQL*Plus","A) SQL - uses the semi-colon"
"What three pieces of information do you provide to SQL*Plus when logging in remotely?","Short Answer","User
Name
Password
Host String"
"What is the special character used to join the password and host string when using the CONNECT
command?","Short Answer","@
as in:
DESC"
"List some common SQL datatypes.","Short Answer","NUMBER(p,s)
VARCHAR2(n)
CHAR(n)
DATE"
"What SQL*Plus command is used to empty out the SQL buffer?","Short Answer","CLEAR BUFFER
or
CL BUFF"
"What SQL*Plus command is used to display the contents of the SQL buffer?","Short Answer","LIST
or
L"
"What SQL*Plus command is used to execute the contents of the SQL buffer?","Short Answer","RUN
or
/"
"What SQL*Plus command is used to start recording of the screen display to an ASCII file?","Short
Answer","SPOOL filename
"
"What SQL*Plus command is used to stop spooling of the screen display?","Short Answer","SPOOL OFF"
"List the comparison operators (also known as relational operators).","Short Answer","=
>
<
>=
<=
<>
BETWEEN . . . AND . . .
LIKE
IN
IS NULL
IS NOT NULL
!=
"
"Which of the following will result in one or more rows being retrieved?","A)
SELECT sal
FROM emp
WHERE sal BETWEEN 1500 AND 500;
B)
SELECT sal
FROM emp
WHERE BETWEEN 1500 AND 500;
C)
SELECT sal
FROM emp
WHERE sal BETWEEN 500 AND 1500;
D)
SELECT sal
FROM emp
WHERE BETWEEN 500 AND 1500;","C)
SELECT sal
FROM emp
WHERE sal BETWEEN 500 AND 1500;"
"Which of the following WHERE clauses uses the correct syntax?","A)
WHERE IN 7902, 7566, 7788;
B)
WHERE mgr IN 7902, 7566, 7788;
C)
WHERE IN(7902, 7566, 7788);
D)
WHERE mgr IN(7902, 7566, 7788);","D)
WHERE mgr IN(7902, 7566, 7788);"
"The comparison operator BETWEEN . . . AND . . . excludes the end points of the range.","True/False","False"
"The comparison operator BETWEEN . . . AND . . . includes the end points of the range.","True/False","True"
"Given: A table has fourteen (14) rows with the following salaries (sal):
500, 600, 799, 799, 800, 800, 801, 1000,
1100, 1499, 1499, 1500, 1500, and 1501.
How many rows will be retrieved with the following SQL statement?
SELECT sal
FROM emp
WHERE sal BETWEEN 800 AND 1500;","A) 5
B) 7
C) 9
D) 12","C) 9"
"The LIKE comparison operator uses which wildcard characters?","Short Answer","%
(percent sign)
for zero or many characters
_
(underscore)
denotes one character"
"For a column named 'tag' with a datatype of CHAR(6), what WHERE clause would you specify to look for all tags
that had unknown characters in the first two positions, followed by a 'C' in the third position, followed by an
unknown character in the fourth position, and '47' in the last two positions?","Short Answer","WHERE tag LIKE
'__C_47';"
"Which of the following WHERE clauses results in listing all employees whose name begins with the letter
'H'?","A)
WHERE ename LIKE 'H%';
B)
WHERE ename LIKE 'H+';
C)
WHERE ename LIKE 'H?';
D)
WHERE ename LIKE 'H_';","A)
WHERE ename LIKE 'H%';"
"List the three logical operators.","Short Answer","NOT
AND
OR"
"What is the correct order of evaluation for logical operators?","A) AND, NOT, OR
B) AND, OR, NOT
C) NOT, AND, OR
D) NOT, OR, AND
E) OR, AND, NOT
F) OR, NOT, AND","C) NOT, AND, OR"
"For the logical operator AND, fill in the following Truth Table (aka a Logic Table)?
NOT Result
TRUE ------
FALSE ------
NULL ------","Short Answer","NOT Result
TRUE FALSE
FALSE TRUE
NULL NULL"
"Which of the following statements ALWAYS results in NO rows being retrieved?","A)
SELECT * FROM emp
WHERE sal < 1500
AND sal > 500;
B)
SELECT * FROM emp
WHERE sal > 1500
OR sal < 500;
C)
SELECT * FROM emp
WHERE sal > 1500
AND sal < 500;
D)
SELECT * FROM emp
WHERE sal < 1500
OR sal > 500;","C)
SELECT * FROM emp
WHERE sal > 1500
AND sal < 500;"
"Which of the following statements ALWAYS results in ALL rows being retrieved?","A)
SELECT * FROM emp
WHERE sal < 1500
AND sal > 500;
B)
SELECT * FROM emp
WHERE sal > 1500
OR sal < 500;
C)
SELECT * FROM emp
WHERE sal > 1500
AND sal < 500;
D)
SELECT * FROM emp
WHERE sal < 1500
OR sal > 500;","D)
SELECT * FROM emp
WHERE sal < 1500
OR sal > 500;"
"Which of the WHERE clauses below (multiple-choice) is equivalent to the following WHERE clause?
B)
WHERE sal <= 800 AND sal >= 1500;
C)
WHERE sal <= 800 OR sal >= 1500;
D)
WHERE sal >= 800 OR sal <= 1500;","A)
WHERE sal >= 800 AND sal <= 1500;"
"Which clause is used to sort rows?","Short Answer","ORDER BY
"
"What is the default way in which rows are sorted when using the ORDER BY clause?","A) Ascending - ASC
B) Descending - DESC","A) Ascending - ASC"
"If neither ASC nor DESC is used in conjunction with ORDER BY, which is the default?","Short Answer","ASC"
"Column aliases CAN be used in an ORDER BY clause.","True/False","True"
"Which of the following ORDER BY clauses results in both columns being sorted in descending order?","A)
ORDER BY state, tag DESC;
B)
ORDER BY state DESC, tag DESC;
C)
ORDER BY DESC state, tag;
D)
ORDER BY DESC state, DESC tag;","B)
ORDER BY state DESC, tag DESC;"
"List nine (9) single row character functions.","Short Answer","LOWER
UPPER
INITCAP
CONCAT
SUBSTR
LENGTH
INSTR
LPAD
TRIM"
"What results from the following function?
CONCAT ('Adam', 'Ant')","Short Answer","'AdamAnt'"
"Given: A product code such as 'ABC123MI99' contains the state where the product was manufactured. Compose a
function to pick off the letters 'MI' from this string.","Short Answer","SUBSTR('ABC123MI99', 7, 2)"
"The column loc_code contains a two letter state abbreviation, a five digit zip code, and a one character plant code.
Which of the following extracts the zip code from that column? An example of a value contained in loc_code is:
'MI49017B'
","A)
SUBSTR(loc_code, 7, 3)
B)
SUBSTR(loc_code, 3, 7)
C)
SUBSTR(loc_code, 3, 5)
D)
SUBSTR(loc_code, 5, 3)","C)
SUBSTR(loc_code, 3, 5)"
"What value does the following function return?
LENGTH('ABC123')","Short Answer","6"
"What values do the following functions return? (You will have four answers)
1 - ROUND(10.849, 1)
2 - ROUND(13.35, 1)
3 - ROUND(88.4649, 2)
2 - 13.4
3 - 88.46
4 - 88.47"
"What values do the following functions return? (You will have four answers)
1 - TRUNC(10.849, 1)
2 - TRUNC(13.35, 1)
3 - TRUNC(88.4649, 2)
2 - 13.3
3 - 88.46
4 - 88.46"
"What value is returned by the following function?
1 - MONTHS_BETWEEN('01-MAY-02', '01-MAY-03')
2 - MONTHS_BETWEEN('01-MAY-03', '01-MAY-02')
3 - ADD_MONTHS('31-JUL-99',3)
4 - NEXT_DAY('07-OCT-02', 'WEDNESDAY')
5 - LAST_DAY('15-OCT-02')
6 - NEXT_DAY(LAST_DAY('13-OCT-02'), 'SATURDAY')
","Short Answer","1 - minus 12 (-12)
2 - positive 12 (12)
3 - '31-OCT-99'
4 - '09-OCT-02'
5 - '31-OCT-02'
6 - '02-NOV-02'"
"List some common elements used when converting a number to a character value.","Short Answer","$
dollar sign
9
digit nine
,
comma
0
digit zero
.
decimal point"
"List some common elements used when converting a date to a character value.","Short Answer","YYYY
YEAR
MM
MONTH
DY
DAY
DDD
DD
D
fm"
"List the three conversion functions.","Short Answer","TO_CHAR
TO_DATE
TO_NUMBER
"
"When converting a date column to a character value, the TO_CHAR function is used. What does the fill mode 'fm'
at the beginning of the format do? (As below)
TO_CHAR(hiredate, 'fmDAY MONTH YYYY')","Short Answer","It suppresses leading zeroes and removes
padded blanks."
"How would you display 'No Commission' for those employees with either a zero commission or a null
commission?","Short Answer","SELECT
DECODE( NVL(comm, 0),
0, 'No Commission',
comm) commission
FROM emp;"
"What is wrong with the following function?
NVL(comm, 'No Commission')","Short Answer","The column comm is a numeric column, therefore the
replacement value must also be numeric.
"
"Which function is used to replace null values with a replacement value?","Short Answer","NVL
"
"What function and what format would you use to display the numerica value 1234567.99 as:
$1,234,567.99
","Short Answer","TO_CHAR(1234567.99, '$9,999,999.99')"
"Compose a function to associate an employee's job with a required level of experience. Use the following table:
CLERK none
SALESMAN some
ANALYST moderate
MANAGER high
PRESIDENT high
all others unknown","Short Answer","DECODE(job, 'CLERK', 'none',
'SALESMAN', 'some',
'ANALYST', 'moderate',
'MANAGER', 'high',
'PRESIDENT', 'high',
'unknown')"
"What term is used to describe the placing of one function inside another function?","Short Answer","nesting"
"If two tables are used to display data, but a WHERE clause is not used, what type of join results?","Short
Answer","Cartesian Join
aka
Cartesian Product"
"If one table has 10 rows and the second table has 15 rows, how many rows result from a Cartesian Join?","A) 10
B) 15
C) 25
D) 150","D) 150"
"How many aliases are in the following SQL statement?
SELECT ename employee,
sal salary,
loc location
FROM emp e, dept d;
Also, what type of join does the above illustrate?","Short Answer","Five aliases:
3 column aliases, and
2 table aliases
A Cartesian Join:
Because there is no WHERE condition"
"List seven (7) group functions.","Short Answer","AVG
COUNT
MAX
MIN
STDDEV
SUM
VARIANCE"
"Which of the following Equijoins is correctly written?","A)
SELECT ename, loc
FROM emp, dept
WHERE deptno = deptno;
B)
SELECT ename, loc
FROM emp e, dept d
WHERE deptno = deptno;
C)
SELECT ename, loc
FROM e.emp, d.dept
WHERE e.deptno = d.deptno;
D)
SELECT ename, loc
FROM emp e, dept d
WHERE e.deptno = d.deptno;","D)
SELECT ename, loc
FROM emp e, dept d
WHERE e.deptno = d.deptno;"
"Which of the following Non-equijoins is correctly written?","A)
SELECT e.ename, e.sal, s.grade FROM emp, salgrade
WHERE losal = sal;
B)
SELECT ename, sal, grade FROM emp e, salgrade s
WHERE e.sal >= s.losal AND e.sal <= s.hisal;
C)
SELECT ename, sal, grade FROM emp, salgrade
WHERE e.sal BETWEEN s.losal AND s.hisal;
D)
SELECT e.ename, e.sal, s.grade FROM emp e, salgrade s
WHERE sal >= losal OR sal <= hisal;","B)
SELECT ename, sal, grade FROM emp e, salgrade s
WHERE e.sal >= s.losal AND e.sal <= s.hisal;"
"What is the outer join operator?","Short Answer","(+)
Select sal from (select distinct (sal) from emp order by sal desc)
Where rownum < 6
Top – n- Analysis.
Select rownum as Rank, ename, Sal from (select ename, Sal from emp order by sal desc) where rownum
<=3
3. Given a Procedure in a Package and a Procedure standalone what is the diff between the two and which is
better to use?
Advantages of a package:
Package specification
PROCEDURE add_dept
(v_name IN dept.dname%TYPE DEFAULT 'unknown',
v_loc IN dept.loc%TYPE DEFAULT 'unknown');
END over_pack;
Package Body
PROCEDURE add_dept
(v_name IN dept.dname%TYPE DEFAULT 'unknown',
v_loc IN dept.loc%TYPE DEFAULT 'unknown')
IS
BEGIN
INSERT INTO dept
VALUES (dept_deptno.NEXTVAL,v_name,v_loc);
END add_dept;
END over_pack;
If you call ADD_DEPT with an explicitly provided department number, PL/SQL uses the first version of
the procedure. If you call ADD_DEPT with no department number, PL/SQL uses the second version.
EXECUTE OVER_PACK.ADD_DEPT (76,'MARKETING','ATLANTA')
EXECUTE OVER_PACK.ADD_DEPT ('SUPPORT','ORLANDO')
• Allow Oracle8 to read multiple objects into memory at once.
• When you call a packaged PL/SQL construct (subprogram) for the first time, the whole package is
loaded into memory. Thus, later calls to related constructs require no disk I/O.
PL/SQL allows for a special subprogram declaration called a forward declaration. It consists of the
subprogram specification in the package body terminated by a semicolon. You can use forward declarations
to do the following:
• Define subprograms in logical or alphabetical order.
• Define mutually recursive subprograms. (Both calling each other).
• Group subprograms in a package
PROCEDURE award_bonus(. . .)
IS -- subprograms defined
BEGIN -- in alphabetical order
calc_rating(. . .);
...
END;
PROCEDURE calc_rating(. . .)
IS
BEGIN
...
END;
END forward_pack;
5. PRAGMA RESTRICT_REFERENCES:
•Checks that the restrictions of using functions in SQL statements are not violated
•Allows packaged functions to be used in SQL statements
•Verifies the purity of a function at compilation. The purity level asserts the extent to which the function
permits database operations like insert,update or delete.
Example
Encapsulate the function, TAX, in a package, TAXES_PACK. The function will be called from SQL
statements on remote databases. Therefore, you need to assert the RNPS, WNPS, and WNDS purity levels,
because remote functions can neither read nor write the package variables, nor modify database tables when
called from a SQL statement.
Note: we can declare the public (global) cursor in the package specification.
DBMS_PIPE Package
The DBMS_PIPE package performs the following functions:
•It allows two or more sessions connected to the same instance (vis) to communicate through a pipe just
like pipes used in UNIX
•Each pipe works asynchronously
•Depending on your security requirements, you can use either a public pipe or a private pipe
•Once buffered information is read by one user, it is emptied from the buffer, and is not available for other
readers of the same pipe
•To send a message, first make one or more calls to PACK_MESSAGE to build your message. Then call
SEND_MESSAGE to send the message on the named pipe
•To receive a message from a pipe, first call RECEIVE_MESSAGE, and then call UNPACK_MESSAGE
to access the individual items in the message
Oracle pipes buffer information in the SGA, which means that information is lost if you shut down your
instance.
Example:
Dynamic SQL
Advantages:
• Dynamic SQL to create a procedure that operates on a table whose name is not known until runtime, or to
write and execute a data definition language (DDL) statement in PL/SQL.
In Oracle8, and earlier, you have to use DBMS_SQL to write dynamic SQL.
In Oracle 8i, you can use DBMS_SQL, EXECUTE IMMEDIATE. If the statement is a multirow
SELECT, you can use DBMS_SQL or OPEN-FOR, FETCH, and CLOSE statements.
Disadvantage of dbms_sql:
• Using this package to execute DDL statements can result in a deadlock. The most likely reason for this is if,
for example, the package is being used to drop a procedure, which is still in use by you.
SYNTAX of DBMS_SQL:
DBMS_DDL Package
Uses:
•You can recompile your modified procedures, functions, and packages using
DBMS_DDL.ALTER_COMPILE.
ALTER_COMPILE (object_type, owner, object_name)
DBMS_DDL.ALTER_COMPILE('PROCEDURE','A_USER','QUERY_EMP')
•You can analyze a single object, using DBMS_DDL.ANALYZE_OBJECT. (There is a way of analyzing
more than one object at a time, using DBMS_UTILITY.)
•This package gives developers access to ALTER and ANALYZE SQL statements through PL/SQL
environments.
DBMS_JOB Package
Note : USER_JOBS – Data dictionary view is used to see the jobs in the queue.
Example:
•You can force a job in the queue to run now, if you supply the job number
DBMS_JOB.RUN (jobno)
DBMS_OUTPUT Package
•DBMS_ALERT
•DBMS_APPLICATION_INFO
•DBMS_DESCRIBE
•DBMS_LOCK
•DBMS_SESSION
•DBMS_SHARED_POOL
•DBMS_TRANSACTION
•DBMS_UTILITY
•UTL_FILE
Sequence of firing:
Create one trigger to restrict all data manipulation events on the EMP table to certain business hours,
Monday through Friday.
--After deleting or inserting or updating on emp –insert the data in audit_emp_table to track all the
changes done on emp table.
To restrict the trigger action to those rows that satisfy a certain condition, provide a WHEN clause.
Example:
Create a trigger on the EMP table to calculate an employee’s commission when a row is added to the EMP
table or an employee’s salary is modified.
The NEW qualifier does not need to be prefixed with a colon in the WHEN clause.
Note: If we use after insert or update then we will get a compilation error.
ORA-04084: cannot change NEW values for this trigger type
Bcoz new can only be used with before triggers.
Instead of trigger is a trigger created on a complex view (with more than 1 table) to modify them, as
complex views are inherently non-modifiable.
These triggers are called INSTEAD OF triggers, because, unlike other triggers,
Oracle server fires the trigger instead of executing the triggering statement
(insert/update/delete). . Ex- create trigger tst instead of insert on emp_view …do
something
Triggers Procedure
Use CREATE TRIGGER Use CREATE PROCEDURE
Data dictionary contains source and p-code Data dictionary contains source and p-code
Implicitly invoked Explicitly invoked
COMMIT, SAVEPOINT, ROLLBACK not allowed COMMIT, SAVEPOINT, ROLLBACK allowed
You can create this trigger to monitor how often you log on and off, or you may want to write a report on
how long you are logged on for.
Example:
SQL> CREATE OR REPLACE TRIGGER LOGON_TRIG
2 AFTER logon ON SCHEMA
3 BEGIN
4 INSERT INTO log_trig_table
5 (user_id, log_date, action)
6 VALUES (user, sysdate, 'Logging on');
7 END;
CALL statement is used to call a stored procedure, rather than coding the PL/SQL body in the trigger itself.
The EMP table is mutating, or in a state of change therefore the trigger cannot
read from it.
17. Some commands to do Auditing?
AUDIT ROLE;
AUDIT ROLE WHENEVER SUCCESSFUL;
AUDIT ROLE WHENEVER NOT SUCCESSFUL;
AUDIT SELECT TABLE, UPDATE TABLE;
AUDIT SELECT TABLE, UPDATE TABLE BY scott, blake;
AUDIT DELETE ANY TABLE;
It is a procedure that lets you issue user-defined error messages from stored subprograms.
raise_application_error (error_number,
message[, {TRUE | FALSE}]);
19. What is an exception and what are its types ? Name some pre-defined exceptions.
Non-PreDefined exceptions:
- first name the exception ----Declare
- Code the pragma EXCEPTION_INIT ----Associate
- Handle the raised exception or explicitly raise it by RAISE command. --Reference
Ex- Trap for Oracle7 Server error number -2292 an integrity constraint violation.
/* PRAGMA EXCEPTION_INIT (initialize) used to associate the exception with an error number */
DECLARE
e_products_remaining EXCEPTION;
PRAGMA EXCEPTION_INIT (e_products_remaining, -2292);
...
BEGIN
...
EXCEPTION
WHEN e_products_remaining THEN
TEXT_IO.PUT_LINE ('Referential integrity constraint violated.');
...
END;
User Defined exceptions:
- first name the exception ----Declare
- Explicitly raise it by RAISE command
[DECLARE]
e_amount_remaining EXCEPTION;
...
BEGIN
. . .if….then
RAISE e_amount_remaining;
...
EXCEPTION
WHEN e_amount_remaining THEN
:g_message := 'There is still an amount in stock.';
...
END;
DECLARE
v_error_code NUMBER;
v_error_message VARCHAR2(255);
BEGIN
...
EXCEPTION
...
WHEN OTHERS THEN
ROLLBACK;
v_error_code := SQLCODE ;
v_error_message := SQLERRM ;
INSERT INTO errors VALUES(v_error_code, v_error_message);
END;
21. In which scenario database triggers will be used.Name the database triggers. Diff between database triggers
and form transactional triggers ?
While loop
WHILE v_counter <= 10 LOOP
INSERT INTO s_item (ord_id, item_id)
VALUES (v_ord_id, v_counter);
v_counter := v_counter + 1;
END LOOP;
For loop
FOR index in [REVERSE]
lower_bound..upper_bound LOOP
Statement1;
Statement2;
...
END LOOP;
Basic Loop
LOOP
INSERT INTO s_item (ord_id, item_id)
VALUES (v_ord_id, v_counter);
v_counter := v_counter + 1;
EXIT WHEN v_counter > 10;
END LOOP;
SQL%ROWCOUNT Number of rows affected by the most recent SQL statement (an integer
value).
SQL%FOUND Boolean attribute that evaluates to TRUE if the most recent SQL
statement affects one or more rows.
SQL%NOTFOUND Boolean attribute that evaluates to TRUE if the most recent SQL
statement does not affect any rows.
SQL%ISOPEN Always evaluates to FALSE because PL/SQL closes implicit cursors
immediately after they are executed.
BEGIN
FOR emp_record IN (SELECT empno, ename
FROM EMP) LOOP
-- Implicit open and implicit fetch occur
IF emp_record.empno = 7839 THEN
...
END LOOP; -- implicit close occurs
END;
25. Can we pass Parameters in cursor? If yes then how do we populate them?
What is cursor for loop? Why is WHERE CURRENT OF clause used in cursors?
Cursor for loop (shortcut for explicit cursors, no need to open, fetch and close)
CURSOR emp_cursor
(v_dept NUMBER, v_job VARCHAR2) IS
SELECT last_name, salary, start_date
FROM s_emp
WHERE dept_id = v_dept
AND title = v_job;
Begin
For emp_data in emp_cursor loop –no need to declare variable emp_data.
--------Emp_data.last_name: = ‘Sharma’;
End loop;
Syntax:
CURSOR emp_cursor IS
SELECT...
FOR UPDATE;
BEGIN
...
FOR emp_record IN emp_cursor LOOP
UPDATE...
WHERE CURRENT OF emp_cursor;
...
END LOOP;
COMMIT;
END;
DECLARE
CURSOR my_cursor IS
SELECT t1.deptno, dname,STAFF
FROM dept t1, (SELECT deptno, count (*) STAFF
FROM EMP
GROUP BY deptno) t2 –retrieves count of staff in each dept.This query is
used in place of a table
WHERE t1.deptno = t2.deptno
AND STAFF >= 5;
•PL/SQL variables
–Scalar
–Composite
–Reference
–LOB (large objects)
Internal LOBs:
- CLOB (Character LOB)
- BLOB (Binary LOB) - photos
- NLOB (national language character large object)
External LOBs:
- BFILE (binary file) – files in database or O/s system
•Non-PL/SQL variables
–Bind and host variables
DBMS_LOB.READ
Call the READ procedure to read and return piecewise a specified AMOUNT of data from a given LOB,
starting from OFFSET.
DBMS_LOB.WRITE
Call the WRITE procedure to write piecewise a specified AMOUNT of data into a given LOB, from the
user-specified BUFFER, starting from an absolute OFFSET from the beginning of the LOB value.
DBMS_LOB.SUBSTR (substr from clob)
DBMS_LOB.INSTR (search information from clob)
The use of function EMPTY_CLOB() or EMPTY_BLOB() means that the LOB is initialized, but not
populated with data.Later can be populated by update statement. If you use NULL as the value for the LOB
column, the LOB is not initialized; therefore, it can not be populated using an update statement.
29. What is the diffrence between Long Raw and LOB datatype?
Advantage:
–Contain internal components.
–Are reusable.
•PL/SQL TABLES
–Are composed of two components:
•Primary key of datatype BINARY_INTEGER
•Column of scalar datatype
Syntax:
DECLARE
TYPE ename_table_type IS TABLE OF emp.ename%TYPE
INDEX BY BINARY_INTEGER;
TYPE hiredate_table_type IS TABLE OF DATE
INDEX BY BINARY_INTEGER;
ename_table ename_table_type;
hiredate_table hiredate_table_type;
BEGIN
ename_table(1) := 'CAMERON';
hiredate_table(8) := SYSDATE + 7;
IF ename_table.EXISTS(1) THEN
INSERT INTO ...
...
END;
The primary key (i.e index value) can be negative. Indexing need not start with 1.
Note: The table.EXISTS(i) statement returns TRUE if at least one row with index i is returned. Use the
EXISTS statement to prevent an error which is raised in reference to a non-existing table element.
PL/SQL RECORD
•Treat a collection of fields as a logical unit.
•Are convenient for fetching a row of data from a table for processing.emp_recordpe IS RECORD
(last emp_record_type;
Syntax:
PROCEDURE all_dept
(v_dept_id IN NUMBER)
IS
dept_record s_dept%ROWTYPE;
BEGIN
SELECT *
INTO dept_record --PL/SQL RECORD
FROM s_dept
WHERE id = v_dept_id;
...
END all_dept;
gender CHAR(1));
31. Uses of decode function with example?
•ACCEPT
–Accepts input from the user and stores the input into a variable.
Sql> ACCEPT p_sal PROMPT 'Enter the salary: '
/*salary entered by user is stored in p_sal */
•VARIABLE
–Declares a bind or host variable.
Sql> Variable abc Number (10)
Sql> Print abcINE DNAME = SALES
SQL>SELT NAME FROM S_DEPT WHERE
LO
•DEFINE
Sql> Define dname = ‘sales’
Sql> Select dname from dept where dname = ‘&dname’ --sales value is assigned to dname initially so
query gives result for sales dept.
UNDEFINE command is used to clear the variable.
NA SQL>DEFINE DNAME = SALES
SQL>
•PRINT
–Displays the current value of bind variables.
Example : Input the monthly salary. Output the calculated annual salary.
DECLARE
v_sal NUMBER := &p_sal;
BEGIN
:g_year_sal := v_sal * 12;
END;
/
PRINT g_year_sal
•EXECUTE
–Executes a particular sql statement.
33. Can we drop a column in oracle 8i ? If yes then what is the command
To do that ?
ALTER TABLE A
DROP COLUMN ENO;
34. A table contains a column – gender with values ‘Male’ and ‘Female’.Write a query to find the count of all
male and female emplyees in the company . Output should give 2 columns showing the count of male and
female employees ?
35. In a select statement if count function is used and a group by clause is not used then will it give an error? If
yes then which error?
36. What is the difference between ‘IN ‘ and ‘EXISTS’ operator in sql ?
Select…..
Group by…
Having…
Orderby..
•MONTHS_BETWEEN('01-SEP-95','11-JAN-94') 1.9774194
•ADD_MONTHS('11-JAN-94',6) '11-JUL-94'
•NEXT_DAY('01-SEP-95','FRIDAY') '08-SEP-95'
•LAST_DAY('01-SEP-95') '30-SEP-95'
43. Can 2 subprograms say one function and the other procedure can have same name.
No. 2 subprograms of different type cannot have same name.U will get error saying that –
ORA-00955: name is already used by an existing object.
When an sql statement fails then only that statement is rolled back bcoz oracle creates an implicit savepoint
for each statement.
Explicit rollback is given by user.
45. How can we drop a table and its dependent integrity constraints?
Sql>show user
51. What is the difference between PK and Unique key? What is a candidate and composite primary key and
foreign key?
PK can never be null and is always unique while unique key column can be null.
Candidate key is a key that can be used as a PK.
Composite primary key is formed with more than one PK column.
A foreign key (FK) is a column or combination of columns in one table that refers to a PK or unique key
(UK) in the same table or in another table.
Constraint that can only be defined at column level is: NOT NULL constraint.
Note: When u create a table by using a subquery then only the NOT NULL
Constraint is copied.
Add a NOT NULL constraint by using the MODIFY clause
–Allows deletion in the parent table and deletion of the dependent rows in the child table.
54. Suppose we create a sequence ,insert data in the table using that sequence and then drop that sequence ?
what will happen to the present state of data.
You can add comments to a table or column by using the COMMENT command.
56. What are WITH CHECK OPTION CONSTRAINT and WITH READ ONLY in a view?
Rule Description
First normal form All attributes must be single-valued.(Intersection of a row and column must be a
single value).
Second normal form An attribute must depend upon its entity's entire UID (Unique identifier).
( Each table should have a PK column and Other columns of a table must
depend on PK column of the table)
Third normal form No non-UID attribute can be dependent upon another non-UID attribute.
•Entity
–No part of a primary key can be NULL and the value must be unique. A NULL is an absence of a value.
•Referential
–Foreign key values must match a primary key or be NULL.
•Column
–Values in the column must match the defined datatype.
•User-defined
–Values must comply with the business rules.
59. Write a query to select all even and odd number of rows from the table? (Hint :usemod function)
60. How the null values are displayed in case of order by clause by asc or desc.
For asc – 1---1000 null values are displayed at the end.
For desc – 1000---1 null values are displayed first.
61. Advantage & Disadvantage of using Truncate command over Delete command?
IN OUT IN OUT
1. Default must be specified. Must be specified.
Value is
Passed into Returned to calling Passed into subprogram;
subprogram. Environment. Returned to calling env.
Actual parameter
Can be a literal, Must be a variable Must be a variable.
expression,
constant, or
initialized variable.
Ex- of IN OUT parameter.
A procedure containing one OUT parameter can be rewritten as a function containing a RETURN
statement.
Ex- of a user defined function:
FUNCTION tax
(v_value IN NUMBER)
RETURN NUMBER
IS
BEGIN
RETURN (v_value * .08);
END tax;
Procedure Function
1. Execute as a PL/SQL statement Invoke as part of an expression
2. No RETURN datatype Must contain a RETURN datatype
3. Can return none, one or many values Must return a single value
67. Triggers for master detail relation? How they change with realtional properties.
72. What is dynamic sql? Package used for that and syntax?
73. Diff between sql and sql* commands?
Object Column –here table selected is the object table YES YES
but column selected will have object datatype.
• Query record Group –Design time & run time ----based on select stmt.
• Non-Query record group –Run time ----not based on select stmt.
• Static record group -- Design time ---- not based on select stmt.
• NCHAR stores fixed-length (blank-padded if necessary) NLS character data. How the data is represented
internally depends on the national character set, which might use a fixed-width encoding such as US7ASCII or
a variable-width encoding such as JA16SJIS.
• NVARCHAR2 stores variable-length NLS character data. How the data is represented internally depends on
the national character set, which might use a fixed-width encoding such as WE8EBCDIC37C or a variable-
width encoding such as JA16DBCS.
• SIGNTYPE lets you restrict an integer variable to the values -1, 0, and 1, which is useful in programming tri-
state logic.
• FLOAT is a subtype of NUMBER. However, you cannot specify a scale for FLOAT variables. You can only
specify a binary precision.
• NATURALN is like subtype NATURAL, but prevents the assignment of NULL.
• POSITIVEN is like subtype POSITIVE, but prevents the assignment of NULL.
• PLS_INTEGER stores signed integers. Its magnitude range is -2147483647 .. 2147483647. PLS_INTEGER
values require less storage than NUMBER values. Also, PLS_INTEGER operations use machine arithmetic, so
they are faster than NUMBER and BINARY_INTEGER operations, which use library arithmetic.
Besides the database character set, which is used for identifiers and source code, PL/SQL8
now supports a second character set called the national character set, which is used for NLS
data. The PL/SQL datatypes NCHAR and NVARCHAR2 allow you to store character strings
formed from the national character set.
78. Example of FORMS_DDL, FORM_SUCCESS, DBMS_ERROR_CODE & DBMS_ERROR_TEXT
A form can show different output each time if it is stored as a function by giving different options in the
options field while registration.
Oracle
1) What is the Back ground processes in Oracle and what are they.
1) 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.
The various background processes in oracle are
a) Data Base Writer (DBWR) :: Data Base Writer Writes Modified blocks from Database buffer
cache to Data Files. This is required since the data is not written whenever a transaction is
commited.
b) LogWriter (LGWR) :: LogWriter writes the redo log entries to disk. Redo Log data is
generated in redo log buffer of SGA. As transaction commits and log buffer fills, LGWR writes
log entries into a online redo log file.
c) System Monitor (SMON) :: The System Monitor performs instance recovery at instance
startup. This is useful for recovery from system failure
d) Process Monitor (PMON) :: The Process Monitor performs process recovery when user
Process fails. Pmon Clears and Frees resources that process was using.
e) CheckPoint (CKPT) :: At Specified times, all modified database buffers in SGA are written to
data files by DBWR at Checkpoints and Updating all data files and control files of database to
indicate the
most recent checkpoint
f) Archieves (ARCH) :: The Archiver copies online redo log files to archival storal when they are
busy.
g) Recoveror(RECO) :: The Recoveror is used to resolve the distributed transaction in network
h) Dispatcher (Dnnn) :: The Dispatcher is useful in Multi Threaded Architecture
i) Lckn :: We can have upto 10 lock processes for inter instance locking in parallel sql.
7) How many Integrity Rules are there and what are they?
7) 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 Integrity rule is about the complex business processes
which cannot be implemented by the above 2 rules.
15) How many minimum groups are required for a matrix report
15) The minimum number of groups in matrix report are 4
19) What is the difference between candidate key, unique key and primary key
19) Candidate keys are the columns in the table that could be the primary keys and the
primary key
is the key that has been selected to identify the rows. Unique key is also useful for
identifying the distinct rows in the table.
20)What is concurrency
20) Concurrency is allowing simultaneous access of same data by different users. Locks
useful for accessing 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.
31) What is the Difference between a post query and a pre query
31) A post query will fire for every row that is fetched but the pre query will fire only once.
34) A pseudo column behaves like a table column, but is not actually
stored in the table. You can select from pseudo columns, but you
cannot insert, update, or delete their values. This section
describes these pseudo columns:
* CURRVAL
* NEXTVAL
* LEVEL
* ROWID
* ROWNUM
In extents .
* NON-ISOLATED (default)
* ISOLATED
a) on clear details
b) on populate details
* CASCADE
a) per-delete
b) on clear details
c) on populate details
Restrictions:
The statement you pass to FORMS_DDL may not contain bind variable references in the string,
but the
values of bind variables can be concatenated into the string before passing the result to
FORMS_DDL.
11) What are property classes? Can property classes have trigger?
11) Property class inheritance is a powerful feature that allows you to quickly define objects that
conform to
your own interface and functionality standards. Property classes also allow you to make global
changes to
applications quickly. By simply changing the definition of a property class, you can change the
definition
of all objects that inherit properties from that class.
Yes . All type of triggers .
* 12 a) If you have property class attached to an item and you have same trigger written for the
item.
Which will fire first?
12)Item level trigger fires , If item level trigger fires, property level trigger won't fire.
Triggers at the lowest level are always given the first preference. The item level trigger fires
first and then the block and then the Form level trigger.
13) What are record groups ? * Can record groups created at run-time?
13)A record group is an internal Oracle Forms data structure that has a column/row framework
similar to a
database table. However, unlike database tables, record groups are separate objects that belong
to the
form module in which they are defined. A record group can have an unlimited number of
columns of type
CHAR, LONG, NUMBER, or DATE provided that the total number of columns does not exceed
64K.
Record group column names cannot exceed 30 characters.
Programmatically, record groups can be used whenever the functionality offered by a two-
dimensional
array of multiple data types is desirable.
TYPES OF RECORD GROUP:
Query Record Group A query record group is a record group that has an associated
SELECT statement.
The columns in a query record group derive their default names, data types, and lengths from
the database columns referenced in the SELECT statement. The records in a query record group
are the rows retrieved by the query associated with that record group.
Non-query Record Group A non-query record group is a group that does not have an associated
query, but whose structure and values can be modified programmatically at runtime.
Static Record Group A static record group is not associated with a query; rather, you define its
structure and row values at design time, and they remain fixed at runtime.
15) Can a button have icon and label at the same time ?
15) -NO
When Mouse Navigate is set to False, Oracle Forms does not perform navigation (and the
resulting validation) to move to the item when an operator activates the item with the mouse.
The following questions might not be asked in an Average Interview and could be asked
when the Interviewer wants to trouble u and go deeppppppppppppp……He cannot go
further…..
8) what is precompiler?
8) It is similar to C precompiler directives.
Locking mode :
Specifies when Oracle Forms should attempt to obtain database locks on rows that correspond to
queried records in the form.
a) immediate b) delayed
11) What are savepoint mode and cursor mode properties ? level?
11) Specifies whether Oracle Forms should issue savepoints during a session. This property is
included primarily for applications that will run against non-ORACLE data sources. For
applications that will run against ORACLE, use the default setting.
Cursor mode - define cursor state across transaction
Open/close.
GUI
Reports 2.5
1) How many types of columns are there and what are they
1) Formula columns :: For doing mathematical calculations and returning one value
Summary Columns :: For doing summary calculations such as summations etc.
Place holder Columns :: These columns are useful for storing the value in a variable
5) What is Flex
5) Flex is the property of moving the related fields together by setting the flex property on
6) What are the minimum number of groups required for a matrix report
6) The minimum of groups required for a matrix report are 4
DataBase Assignment
Question 1.
Record Tracking
In any competitive event there are records that stand and records that are broken.The event categories
contains the world record and commonwealth record figures for all events as this meeting.As the events have their
heats and finals run some of the records get broken with new records being set.
Your task in this question is to write PL/SQL program to determine who ,if anyone,broke records during
the meeting .First you will need to create a table to store history into.Initially this new table will contain the current
world and commonwealth records for each event category.Then,as the races are completed ,each change to either the
commonwealth or the world record time should be recorded by adding a new row to the table. Once completed your
program will have recorded, in the table you create, the initial time for each record and all subsequent changes to the
records. Note that only the first person to finish a race can break a record since anyone finishing after them will have
a slower time than the record they just set.
The table you create to store the history of the records should have columns for the event description, the
gender of competitors, the name of the competitor who set the record, the record type (either W or C for the
commonwealth), the date the record was set, and the record time. For records which existed prior to the meeting
(which are stored in the Event Categories table) the name, and date of the record will be null.
You must report the record history in order of the event description, within event description sort by
gender, within gender sort by record type,within record type sort in the descending order of time.
No table joins are permitted.Your procedure should have multiple cursors and pass
parameters.Examples of parameter passing are included in the study guide and will
also appear in lectures slides during the semester.
Question 2
The stored procedure should accept an input parameter of competitor ID.For the competitor selected,the following
information should be presented on the screen.
Competitor Name
For each race in which the competitor has completed,the following information:
No table joing are permitted.Your procedure should have multiple cursors and pass
parameters.
Submit the following for both PL/SQL questions:
• The PL/SQL code printed out.
• The actual output from the execution of the program.
The CountryID represents the three letter abbreviation used fo rthe country in the Commonwealth Games
competition.The country name is the name usually used when referring to the country.
Competitors
The competitors table contains a list of the competitors who may or may not compete in these games.Not all
competitors in the competitors table actually compete in the games.
The countryID represents a countryID from the Countries table and acts as foreign key into that table.Gender is a
single character field that contains a code representing the gender of the competitor.This column will contain M for
male competitors or F for female competitors.
Event Categories
The EventCategories table contains the various categories of events that are contested at the games.For example,one
such event category is the Men’s 100m Backstroke.Notice that an event category consists of an event description
and a gender.Also recorded in this table are the world and commonwealth record time for the particular event as
they stood just prior to the competion.
Events
The Events table contains the particular events being contested at the games.In this table the events are actual
races, which are ither eheats or finals and have a scheduled start time.
The EventNo column contains a unique integer used as the primary key for the event.The EventCatNo provides a
foreign key into the event categories table and enables an association between the event and its details including the
records.EventType is a single character coding which shows whether an event is a heat(H) or a final(f).
Entries
The Entries table associates a competitor with a particular event.It not only records the fact that the competitor has
entered the event but also the resulting time that they have achieved, the lane that they were assigned and a flag to
indicate whether or not they were disqualified.
Create table Entries
(EventNo number(4) not null,
CompetitorNo number(4) not null,
Lane number(1),
ResultTime number(8,4),
Disqualified char(1),
CONSTRAINT Entries_pk primary key (EventNo, competitorNo),
CONSTRAINT Entries_Evts_fk foreign key (EventNo) references Events(EventNo),
CONSTRAINT Entries_Comp_fk foreign key (competitotNo) references Competitors(CompetitorNo));
The EventNo column is a foreign key into the Events table.The competitorNo column provides a foreign key back to
the competitors table.Disqualified contain a Y if the competitor has been disqualified and an N otherwise.A
disqualified competitor is not eligible for any medals not are they able to break any records, regardless of the time
they swim.
INDEX
1. The following query retrieves "2" highest paid employees FROM each
Department :
2. Query that will display the total no. of employees, and of that total the number
who were hired in 1980, 1981, 1982, and 1983. Give appropriate column
headings.
Index
SELECT a.deptno, ename, sal, (SELECT SUM(sal) FROM emp b WHERE a.deptno = b.deptno)
FROM emp a
ORDER BY a.deptno;
OUTPUT :
=======
DEPTNO ENAME SAL SUM (SAL)
========= ======= ==== =========
10 KING 5000 11725
30 BLAKE 2850 10900
10 CLARK 2450 11725
10 JONES 2975 11725
30 MARTIN 1250 10900
30 ALLEN 1600 10900
30 TURNER 1500 10900
30 JAMES 950 10900
30 WARD 2750 10900
20 SMITH 8000 33000
20 SCOTT 3000 33000
20 MILLER 20000 33000
Index
4. Create a matrix query to display the job, the salary for that job based on
department number, and the total salary for that job for all departments, giving
each column an appropriate heading.
SELECT job "Job", SUM (DECODE (deptno, 10, sal)) "Dept 10",
SUM (DECODE (deptno, 20, sal)) "Dept 20",
SUM (DECODE (deptno, 30, sal)) "Dept 30",
SUM (sal) "Total"
FROM emp
GROUP BY job ;
Index
th
5. 4 Top Salary of all the employees :
Index
Index
7. Tree Query :
Index
Index
9. Displaying EVERY 4th row in a table : (If a table has 14 rows, 4,8,12 rows will
be selected)
SELECT *
FROM emp
WHERE (ROWID,0) IN (SELECT ROWID, MOD(ROWNUM,4)
FROM emp);
Index
Index
11. How does one count/sum RANGES of data values in a column? A value x will be
between values y and z if GREATEST(x, y) = LEAST(x, z).
SELECT
f2,
COUNT(DECODE(greatest(f1,59), least(f1,100), 1, 0)) "Range 60-100",
COUNT(DECODE(greatest(f1,30), least(f1, 59), 1, 0)) "Range 30-59",
COUNT(DECODE(greatest(f1,29), least(f1, 0), 1, 0)) "Range 00-29"
FROM my_table
GROUP BY f2;
Index
Index
Index
SELECT num
FROM satyam
GROUP BY num
HAVING COUNT(*) > 1;
Index
16. Query for getting the following output as many number of rows in the table :
*
**
***
****
*****
SELECT RPAD(DECODE(temp,temp,'*'),ROWNUM,'*')
FROM srinu1;
Index
FUNCTION F_BALANCE_VALUE
(p_business_group_id number, p_payroll_action_id number,
p_balance_name varchar2, p_dimension_name varchar2) RETURN NUMBER
IS
l_bal number;
l_defined_bal_id number;
l_assignment_action_id number;
BEGIN
SELECT assignment_action_id
INTO l_assignment_action_id
FROM
pay_assignment_actions
WHERE
assignment_id = :p_assignment_id
AND payroll_action_id = p_payroll_action_id;
SELECT
defined_balance_id
INTO
l_defined_bal_id
FROM
pay_balance_types pbt,
pay_defined_balances pdb,
pay_balance_dimensions pbd
WHERE
pbt.business_group_id = p_business_group_id
AND UPPER(pbt.balance_name) = UPPER(p_balance_name)
AND pbt.business_group_id = pdb.business_group_id
AND pbt.balance_type_id = pdb.balance_type_id
AND UPPER(pbd.dimension_name) = UPPER(p_dimension_name)
AND pdb.balance_dimension_id = pbd.balance_dimension_id;
l_bal := pay_balance_pkg.get_value(l_defined_bal_id,l_assignment_action_id);
RETURN (l_bal);
exception
WHEN no_data_found THEN
RETURN 0;
END;
Index
FUNCTION f_element_value(
p_classification_name in varchar2,
p_element_name in varchar2,
p_business_group_id in number,
p_input_value_name in varchar2,
p_payroll_action_id in number,
p_assignment_id in number
)
RETURN number
IS
l_element_value number(14,2) default 0;
l_input_value_id pay_input_values_f.input_value_id%type;
l_element_type_id pay_element_types_f.element_type_id%type;
BEGIN
SELECT DISTINCT element_type_id
INTO l_element_type_id
FROM pay_element_types_f pet,
pay_element_classifications pec
WHERE pet.classification_id = pec.classification_id
AND upper(classification_name) = upper(p_classification_name)
AND upper(element_name) = upper(p_element_name)
AND pet.business_group_id = p_business_group_id;
SELECT input_value_id
INTO l_input_value_id
FROM pay_input_values_f
WHERE upper(name) = upper(p_input_value_name)
AND element_type_id = l_element_type_id;
SELECT NVL(prrv.result_value,0)
INTO l_element_value
FROM pay_run_result_values prrv,
pay_run_results prr,
pay_assignment_actions paa
WHERE prrv.run_result_id = prr.run_result_id
AND prr.assignment_ACTION_ID = paa.assignment_action_id
AND paa.assignment_id = p_assignment_id
AND input_value_id = l_input_value_id
AND paa.payroll_action_id = p_payroll_action_id;
RETURN (l_element_value);
exception
WHEN no_data_found THEN
RETURN 0;
END;
Index
SELECT ename,
NVL(LENGTH(REPLACE(TRANSLATE(UPPER(RTRIM(ename)),'ABCDEFGHIJKLMNOPQRSTUVWX
YZ'' ',' @'),' ',''))+1,1) word_length
FROM emp;
Explanation :
TRANSLATE(UPPER(RTRIM(ename)),'ABCDEFGHIJKLMNOPQRSTUVWXYZ'' ','
@') -- This will translate all the characters FROM A-Z including a single quote to a space. It
will also translate a space to a @.
REPLACE(TRANSLATE(UPPER(RTRIM(ename)),'ABCDEFGHIJKLMNOPQRSTUVWXYZ'' ','
@'),' ','') -- This will replace every space with nothing in the above result.
LENGTH(REPLACE(TRANSLATE(UPPER(RTRIM(ename)),'ABCDEFGHIJKLMNOPQRSTUVWXYZ''
',' @'),' ',''))+1 -- This will give u the count of @ characters in the above
result.
Index
Index
SELECT
TRANSLATE(LOWER(ssn),'abcdefghijklmnopqrstuvwxyz- ','')
FROM DUAL;
Index
SELECT
TRANSLATE(INITCAP(temp),
SUBSTR(temp, INSTR(temp,'''')+1,1), LOWER(SUBSTR(temp, INSTR(temp,'''')+1)))
FROM srinu1;
Index
Index
Index
DELETE
FROM srinu
WHERE (ROWID,0) IN (SELECT ROWID, MOD(ROWNUM,2)
FROM srinu);
Index
DELETE
FROM srinu
WHERE (ROWID,1) IN (SELECT ROWID, MOD(ROWNUM,2)
FROM srinu);
Index
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Error');
END;
/
Index
SELECT case
WHEN sex = 'm' THEN 'male'
WHEN sex = 'f' THEN 'female'
ELSE 'unknown'
END
FROM mytable;
Index
29. Create table adding Constraint to a date field to SYSDATE or 3 months later:
Index
30. Query to list all the suppliers who supply all the parts supplied by supplier
'S2' :
SELECT DISTINCT a.SUPP
FROM ORDERS a
WHERE a.supp != 'S2'
AND a.parts IN
(SELECT DISTINCT PARTS FROM ORDERS WHERE supp = 'S2')
GROUP BY a.SUPP
HAVING
COUNT(DISTINCT a.PARTS) >=
(SELECT COUNT(DISTINCT PARTS) FROM ORDERS WHERE supp = 'S2');
Table : orders
SUPP PARTS
-------------------- -------
S1 P1
S1 P2
S1 P3
S1 P4
S1 P5
S1 P6
S2 P1
S2 P2
S3 P2
S4 P2
S4 P4
S4 P5
Index
Index
table data :
id name parent_id
-------------------------------
1 a NULL - the top level entry
2 b 1 - a child of 1
3 c 1
4 d 2 - a child of 2
5 e 2
6 f 3
7 g 3
8 h 4
9 i 8
10 j 9
SELECT ID
FROM MY_TABlE
WHERE PARENT_ID IS NOT NULL
MINUS
SELECT PARENT_ID
FROM MY_TABlE;
Index
Index
DBMS_OUTPUT.PUT_LINE(xQuery);
Index
Index
Index
SELECT column_name
FROM all_tab_columns
WHERE TABLE_NAME = 'ORDERS';
Index
Place the following lines of code in a file and execute the file in SQLPLUS :
Index
Index
To display rows 5 to 7 :
OR
SELECT ename
FROM emp
GROUP BY ROWNUM, ename
HAVING ROWNUM > 1 and ROWNUM < 3;
Index
SELECT COUNT(column_name)
FROM user_tab_columns
WHERE table_name = 'MYTABLE';
Index
DECLARE
BEGIN
dbms_output.enable(4000);
FOR i IN 1..400
LOOP
DBMS_OUTPUT.PUT_LINE(i);
END LOOP;
END;
/
Index
Index
Index
Sample :1
CREATE OR REPLACE PROCEDURE CNT(P_TABLE_NAME IN VARCHAR2)
AS
SqlString VARCHAR2(200);
tot number;
BEGIN
SqlString:='SELECT COUNT(*) FROM '|| P_TABLE_NAME;
EXECUTE IMMEDIATE SqlString INTO tot;
DBMS_OUTPUT.PUT_LINE('Total No.Of Records In ' || P_TABLE_NAME || ' ARE=' || tot);
END;
Sample :2
DECLARE
sql_stmt VARCHAR2(200);
plsql_block VARCHAR2(500);
emp_id NUMBER(4) := 7566;
salary NUMBER(7,2);
dept_id NUMBER(2) := 50;
dept_name VARCHAR2(14) := ’PERSONNEL’;
location VARCHAR2(13) := ’DALLAS’;
emp_rec emp%ROWTYPE;
BEGIN
EXECUTE IMMEDIATE 'CREATE TABLE bonus (id NUMBER, amt NUMBER)';
Sample 3
CREATE OR REPLACE PROCEDURE DEPARTMENTS(NO IN DEPT.DEPTNO%TYPE) AS
v_cursor integer;
v_dname char(20);
v_rows integer;
BEGIN
v_cursor := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(v_cursor, 'select dname from dept where deptno > :x',
DBMS_SQL.V7);
DBMS_SQL.BIND_VARIABLE(v_cursor, ':x', no);
DBMS_SQL.DEFINE_COLUMN_CHAR(v_cursor, 1, v_dname, 20);
v_rows := DBMS_SQL.EXECUTE(v_cursor);
LOOP
IF DBMS_SQL.FETCH_ROWS(v_cursor) = 0 THEN
EXIT;
END IF;
DBMS_SQL.COLUMN_VALUE_CHAR(v_cursor, 1, v_dname);
DBMS_OUTPUT.PUT_LINE('Deptartment name: '||v_dname);
END LOOP;
DBMS_SQL.CLOSE_CURSOR(v_cursor);
EXCEPTION
WHEN OTHERS THEN
DBMS_SQL.CLOSE_CURSOR(v_cursor);
raise_application_error(-20000, 'Unknown Exception Raised: '||sqlcode||' '||
sqlerrm);
END;
Index
Index
SELECT organization_id,name
FROM hr_all_organization_units
WHERE organization_id in
(
SELECT ORGANIZATION_ID_CHILD FROM PER_ORG_STRUCTURE_ELEMENTS
CONNECT BY PRIOR
ORGANIZATION_ID_CHILD = ORGANIZATION_ID_PARENT
START WITH
ORGANIZATION_ID_CHILD = (SELECT organization_id
FROM hr_all_organization_units
WHERE name = 'EBG Corporate Group'));
Index
v_file_id := UTL_FILE.FOPEN(c_path,c_file_name,'r');
UTL_FILE.GET_LINE(v_file_id, v_buffer);
DBMS_OUTPUT.PUT_LINE(v_buffer);
UTL_FILE.FCLOSE(v_file_id);
END;
/
Index
49. Query to display random number between any two given numbers :
Index
50. How can I get the time 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 my_table;
Index
LOT 8 CONC3 RR
Using instr and substr, I want to take whatever value follows LOT and put
it into a different column and whatever value follows CONC and put it into
a different column
Index
Index
Index
54. Columns of a table
Index
Index
56.CLOB to Char
1) This function helps if your clob column value not exceed 4000 bytes
(varchar2 limit).if clob column's data exceeds 4000 limit, you have to
follow different approach.
--change next line if you create temporary table with different name
pos:=pos+amt;
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
END;
END LOOP;
--change next line if you create temporary table with different name
open rvar for select vchar from temp_tab where id=n;
END;
END;
Index
Index
declare
-- we need one here to get a single quote into the variable
v_str varchar2 (20) := 'O''reilly''s';
begin
DBMS_OUTPUT.PUT_LINE ( 'original single quoted v_str= ' || v_str );
v_str := replace(v_str, '''', '''''');
DBMS_OUTPUT.PUT_LINE ( 'after double quoted v_str= ' || v_str );
end;
SQL> /
original single quoted v_str= O'reilly's
after double quoted v_str= O''reilly''s
Index
Index
Index
61.Running Jobs
Index
62.Switching Columns
Update tblname
Set column1 = column2,
Column2 = column1;
Index
Index
01-jan-2002
Index
65.Create Sequence
create sequence sh increment by 1 start with 0;
Index
66.Cursors
cursor is someting like pointers in C language.
u fetch the data using cursor.( wiz...store it somewhere temporarily). u
can do any manipulation to the data that is fetched by the cursor. like
trim, padd, concat or validate. all this are done in temporary areas called
as context area or the cursor area. u can insert this data again in some
other table or do anything u want!!...like setting up some flags etc.
U can display the contents of cursor using the dbms_output only. U can
create an anonymous plsql block or a stored procedure. the major advantage
of cursors is that you can fetch more thatn one row and u can loop through
the resultset and do the manupulations in a secure manner.
Index
67.Current Week
NEXT_DAY( NEXT_DAY(
--------- ---------
07-APR-02 13-APR-02
Index
PL/SQL Questions:
1. Describe the difference between a procedure, function and anonymous pl/sql block.
Level: Low
Expected answer : Candidate should mention use of DECLARE statement, a function must return a
value while a procedure doesn’t have to.
2. What is a mutating table error and how can you get around it?
Level: Intermediate
Expected answer: This happens with triggers. It occurs because the trigger is trying to
update a row it is currently using. The usual fix involves either use of views or temporary
tables so the database is selecting from one while updating the other.
4. What packages (if any) has Oracle provided for use by developers?
Level: Intermediate to high
Expected answer: Oracle provides the DBMS_ series of packages. There are many
which developers should be aware of such as DBMS_SQL, DBMS_PIPE,
DBMS_TRANSACTION, DBMS_LOCK, DBMS_ALERT, DBMS_OUTPUT, DBMS_JOB,
DBMS_UTILITY, DBMS_DDL, UTL_FILE. If they can mention a few of these and
describe how they used them, even better. If they include the SQL routines provided by
Oracle, great, but not really what was asked.
8. What are SQLCODE and SQLERRM and why are they important for PL/SQL
developers?
Level: Intermediate
Expected answer: SQLCODE returns the value of the error number for the last error
encountered. The SQLERRM returns the actual error message for the last error
encountered. They can be used in exception handling to report, or, store in an error log
table, the error that occurred in the code. These are especially useful for the WHEN
OTHERS exception.
DBA
1. Give one method for transferring a table from one schema to another:
Level:Intermediate
Expected answer:There are several possible methods, export-import, CREATE
TABLE... AS SELECT, or COPY.
2. What is the purpose of the IMPORT option IGNORE? What is it’s default setting?
Level: Low
Expected answer: The IMPORT IGNORE option tells import to ignore "already exists"
errors. If it is not specified the tables that already exist will be skipped. If it is specified,
the error is ignored and the tables data will be inserted. The default value is N.
3. You have a rollback segment in a version 7.2 database that has expanded beyond
optimal, how can it be restored to optimal?
Level: Low
Expected answer: Use the ALTER TABLESPACE ..... SHRINK command.
4. If the DEFAULT and TEMPORARY tablespace clauses are left out of a CREATE
USER command what happens? Is this bad or good? Why?
Level: Low
Expected answer:The user is assigned the SYSTEM tablespace as a default and
temporary tablespace. This is bad because it causes user objects and temporary
segments to be placed into the SYSTEM tablespace resulting in fragmentation and
improper table placement (only data dictionary objects and the system rollback segment
should be in SYSTEM).
5. What are some of the Oracle provided packages that DBAs should be aware of?
Level: Intermediate to High
Expected answer: Oracle provides a number of packages in the form of the DBMS_
packages owned by the SYS user. The packages used by DBAs may include:
DBMS_SHARED_POOL, DBMS_UTILITY, DBMS_SQL, DBMS_DDL,
DBMS_SESSION, DBMS_OUTPUT and DBMS_SNAPSHOT. They may also try to
answer with the UTL*.SQL or CAT*.SQL series of SQL procedures. These can be
viewed as extra credit but aren’t part of the answer.
7. What happens if a tablespace clause is left off of a primary key constraint clause?
Level: Low
Expected answer: This results in the index that is automatically generated being
placed in then users default tablespace. Since this will usually be the same tablespace
as the table is being created in, this can cause serious performance problems.
8. What is the proper method for disabling and re-enabling a primary key constraint?
Level: Intermediate
Expected answer: You use the ALTER TABLE command for both. However, for the
enable clause you must specify the USING INDEX and TABLESPACE clause for
primary keys.
9. What happens if a primary key constraint is disabled and then enabled without fully
specifying the index clause?
Level: Intermediate
Expected answer: The index is created in the user’s default tablespace and all sizing
information is lost. Oracle doesn’t store this information as a part of the constraint
definition, but only as part of the index definition, when the constraint was disabled the
index was dropped and the information is gone.
10. (On UNIX) When should more than one DB writer process be used? How many should
be used?
Level: High
Expected answer:If the UNIX system being used is capable of asynchronous IO then
only one is required, if the system is not capable of asynchronous IO then up to twice
the number of disks used by Oracle number of DB writers should be specified by use of
the db_writers initialization parameter.
11. You are using hot backup without being in archivelog mode, can you recover in the
event of a failure? Why or why not?
Level: High
Expected answer:You can’t use hot backup without being in archivelog mode. So no,
you couldn’t recover.
12. What causes the "snapshot too old" error? How can this be prevented or mitigated?
Level: Intermediate
Expected answer: This is caused by large or long running transactions that have either
wrapped onto their own rollback space or have had another transaction write on part of
their rollback space. This can be prevented or mitigated by breaking the transaction into
a set of smaller transactions or increasing the size of the rollback segments and their
extents.
14. A user is getting an ORA-00942 error yet you know you have granted them permission
on the table, what else should you check?
Level: Low
Expected answer: You need to check that the user has specified the full name of the
object (select empid from scott.emp; instead of select empid from emp;) or has a
synonym that points to the object (create synonym emp for scott.emp;)
15. A developer is trying to create a view and the database won’t let him. He has the
"DEVELOPER" role which has the "CREATE VIEW" system privilege and SELECT
grants on the tables he is using, what is the problem?
Level: Intermediate
Expected answer: You need to verify the developer has direct grants on all tables used
in the view. You can’t create a stored object with grants given through views.
16. If you have an example table, what is the best way to get sizing data for the production
table implementation?
Level: Intermediate
Expected answer: The best way is to analyze the table and then use the data provided
in the DBA_TABLES view to get the average row length and other pertinent data for the
calculation. The quick and dirty way is to look at the number of blocks the table is
actually using and ratio the number of rows in the table to its number of blocks against
the number of expected rows.
17. How can you find out how many users are currently logged into the database? How can
you find their operating system id?
Level: high
Expected answer: There are several ways. One is to look at the v$session or
v$process views. Another way is to check the current_logins parameter in the v$sysstat
view. Another if you are on UNIX is to do a "ps -ef|grep oracle|wc -l’ command, but this
only works against a single instance installation.
18. A user selects from a sequence and gets back two values, his select is:
SELECT pk_seq.nextval FROM dual;
What is the problem?
Level: Intermediate
Expected answer: Somehow two values have been inserted into the dual table. This
table is a single row, single column table that should only have one value in it.
19. How can you determine if an index needs to be dropped and rebuilt?
Level: Intermediate
Expected answer: Run the ANALYZE INDEX command on the index to validate its
structure and then calculate the ratio of LF_BLK_LEN/LF_BLK_LEN+BR_BLK_LEN and
if it isn’t near 1.0 (i.e. greater than 0.7 or so) then the index should be rebuilt. Or if the
ratio
BR_BLK_LEN/ LF_BLK_LEN+BR_BLK_LEN is nearing 0.3.
SQL/ SQLPlus
2. You want to include a carriage return/linefeed in your output from a SQL script, how
can you do this?
Level: Intermediate to high
Expected answer: The best method is to use the CHR() function (CHR(10) is a
return/linefeed) and the concatenation function "||". Another method, although it is hard
to document and isn’t always portable is to use the return/linefeed as a part of a quoted
string.
4. How do you execute a host operating system command from within SQL?
Level: Low
Expected answer: By use of the exclamation point "!" (in UNIX and some other OS) or
the HOST (HO) command.
5. You want to use SQL to build SQL, what is this called and give an example
Level: Intermediate to high
Expected answer: This is called dynamic SQL. An example would be:
set lines 90 pages 0 termout off feedback off verify off
spool drop_all.sql
select ‘drop user ‘||username||’ cascade;’ from dba_users
where username not in ("SYS’,’SYSTEM’);
spool off
Essentially you are looking to see that they know to include a command (in this case
DROP USER...CASCADE;) and that you need to concatenate using the ‘||’ the values
selected from the database.
7. You want to group the following set of select returns, what can you group on?
Max(sum_of_cost), min(sum_of_cost), count(item_no), item_no
Level: Intermediate
Expected answer:The only column that can be grouped on is the "item_no" column,
the rest have aggregate functions associated with them.
8. What special Oracle feature allows you to specify how the cost based system
treats a SQL statement?
Level: Intermediate to high
Expected answer: The COST based system allows the use of HINTs to control the
optimizer path selection. If they can give some example hints such as FIRST ROWS,
ALL ROWS, USING INDEX, STAR, even better.
9. You want to determine the location of identical rows in a table before attempting to place
a unique index on the table, how can this be done?
Level: High
Expected answer: Oracle tables always have one guaranteed unique column, the
rowid column. If you use a min/max function against your rowid and then select against
the proposed primary key you can squeeze out the rowids of the duplicate rows pretty
quick. For example:
select rowid from emp e
where e.rowid > (select min(x.rowid)
from emp x
where x.emp_no = e.emp_no);
In the situation where multiple columns make up the proposed key, they must all be
used in the where clause.
10. What is a Cartesian product?
Level: Low
Expected answer: A Cartesian product is the result of an unrestricted join of two or
more tables. The result set of a three table Cartesian product will have x * y * z number
of rows where x, y, z correspond to the number of rows in each table involved in the
join.
11. You are joining a local and a remote table, the network manager complains about the
traffic involved, how can you reduce the network traffic?
Level: High
Expected answer:Push the processing of the remote data to the remote instance by
using a view to pre-select the information for the join. This will result in only the data
required for the join being sent across.
12. What is the default ordering of an ORDER BY clause in a SELECT statement?
Level: Low
Expected answer: Ascending
15. How do you set the number of lines on a page of output? The width?
Level: Low
Expected answer: The SET command in SQLPLUS is used to control the number of
lines generated per page and the width of those lines, for example SET PAGESIZE 60
LINESIZE 80 will generate reports that are 60 lines long with a line width of 80
characters. The PAGESIZE and LINESIZE options can be shortened to PAGES and
LINES.
17. How do you prevent Oracle from giving you informational messages during and after a
SQL statement execution?
Level: Low
Expected answer: The SET options FEEDBACK and VERIFY can be set to OFF.
18. How do you generate file output from SQL?
Level: Low
Expected answer: By use of the SPOOL command
Tuning Questions:
1. A tablespace has a table with 30 extents in it. Is this bad? Why or why not.
Level: Intermediate
Expected answer: Multiple extents in and of themselves aren’t bad. However if you also
have chained rows this can hurt performance.
3. You see multiple fragments in the SYSTEM tablespace, what should you check first?
Level: Low
Expected answer: Ensure that users don’t have the SYSTEM tablespace as their
TEMPORARY or DEFAULT tablespace assignment by checking the DBA_USERS view.
4. What are some indications that you need to increase the SHARED_POOL_SIZE
parameter?
Level: Intermediate
Expected answer: Poor data dictionary or library cache hit ratios, getting error ORA-
04031. Another indication is steadily decreasing performance with all other tuning
parameters the same.
5. What is the general guideline for sizing db_block_size and db_multi_block_read for an
application that does many full table scans?
Level: High
Expected answer: Oracle almost always reads in 64k chunks. The two should have a
product equal to 64 or a multiple of 64.
7. Explain the use of TKPROF? What initialization parameter should be turned on to get
full TKPROF output?
Level: High
Expected answer: The tkprof tool is a tuning tool used to determine cpu and execution
times for SQL statements. You use it by first setting timed_statistics to true in the
initialization file and then turning on tracing for either the entire database via the
sql_trace parameter or for the session using the ALTER SESSION command. Once the
trace file is generated you run the tkprof tool against the trace file and then look at the
output from the tkprof tool. This can also be used to generate explain plan output.
8. When looking at v$sysstat you see that sorts (disk) is high. Is this bad or good? If bad
-How do you correct it?
Level: Intermediate
Expected answer: If you get excessive disk sorts this is bad. This indicates you need to
tune the sort area parameters in the initialization files. The major sort are parameter is
the SORT_AREA_SIZe parameter.
9. When should you increase copy latches? What parameters control copy latches?
Level: high
Expected answer: When you get excessive contention for the copy latches as shown by
the "redo copy" latch hit ratio. You can increase copy latches via the initialization
parameter LOG_SIMULTANEOUS_COPIES to twice the number of CPUs on your
system.
10. Where can you get a list of all initialization parameters for your instance? How about
an indication if they are default settings or have been changed?
Level: Low
Expected answer: You can look in the init<sid>.ora file for an indication of manually set
parameters. For all parameters, their value and whether or not the current value is the
default value, look in the v$parameter view.
11. Describe hit ratio as it pertains to the database buffers. What is the difference between
instantaneous and cumulative hit ratio and which should be used for tuning?
Level: Intermediate
Expected answer: The hit ratio is a measure of how many times the database was able
to read a value from the buffers verses how many times it had to re-read a data value
from the disks. A value greater than 80-90% is good, less could indicate problems. If
you simply take the ratio of existing parameters this will be a cumulative value since the
database started. If you do a comparison between pairs of readings based on some
arbitrary time span, this is the instantaneous ratio for that time span. Generally speaking
an instantaneous reading gives more valuable data since it will tell you what your
instance is doing for the time it was generated over.
12. Discuss row chaining, how does it happen? How can you reduce it? How do you correct
it?
Level: high
Expected answer: Row chaining occurs when a VARCHAR2 value is updated and the
length of the new value is longer than the old value and won’t fit in the remaining block
space. This results in the row chaining to another block. It can be reduced by setting the
storage parameters on the table to appropriate values. It can be corrected by export and
import of the effected table.
13. When looking at the estat events report you see that you are getting busy buffer waits.
Is this bad? How can you find what is causing it?
Level: high
Expected answer: Buffer busy waits could indicate contention in redo, rollback or data
blocks. You need to check the v$waitstat view to see what areas are causing the
problem. The value of the "count" column tells where the problem is, the "class" column
tells you with what. UNDO is rollback segments, DATA is data base buffers.
14. If you see contention for library caches how can you fix it?
Level: Intermediate
Expected answer: Increase the size of the shared pool.
15. If you see statistics that deal with "undo" what are they really talking about?
Level: Intermediate
Expected answer: Rollback segments and associated structures.
16. If a tablespace has a default pctincrease of zero what will this cause (in relationship to
the smon process)?
Level: High
Expected answer: The SMON process won’t automatically coalesce its free space
fragments.
17. If a tablespace shows excessive fragmentation what are some methods to defragment
the tablespace? (7.1,7.2 and 7.3 only)
Level: High
Expected answer: In Oracle 7.0 to 7.2 The use of the 'alter session set events
'immediate trace name coalesce level ts#';’ command is the easiest way to defragment
contiguous free space fragmentation. The ts# parameter corresponds to the ts# value
found in the ts$ SYS table. In version 7.3 the ‘alter tablespace <name> coalesce;’ is
best. If the free space isn’t contiguous then export, drop and import of the tablespace
contents may be the only way to reclaim non-contiguous free space.
21. If you see a pin hit ratio of less than 0.8 in the estat library cache report is this a
problem? If so, how do you fix it?
Level: Intermediate
Expected answer: This indicate that the shared pool may be too small. Increase the
shared pool size.
22. If you see the value for reloads is high in the estat library cache report is this a matter
for concern?
Level: Intermediate
Expected answer: Yes, you should strive for zero reloads if possible. If you see
excessive reloads then increase the size of the shared pool.
23. You look at the dba_rollback_segs view and see that there is a large number of shrinks
and they are of relatively small size, is this a problem? How can it be fixed if it is a
problem?
Level: High
Expected answer: A large number of small shrinks indicates a need to increase the size
of the rollback segment extents. Ideally you should have no shrinks or a small number
of large shrinks. To fix this just increase the size of the extents and adjust optimal
accordingly.
24. You look at the dba_rollback_segs view and see that you have a large number of wraps
is this a problem?
Level: High
Expected answer: A large number of wraps indicates that your extent size for your
rollback segments are probably too small. Increase the size of your extents to reduce
the number of wraps. You can look at the average transaction size in the same view to
get the information on transaction size.
25. In a system with an average of 40 concurrent users you get the following from
a query on rollback extents:
ROLLBACK CUR EXTENTS
--------------------- --------------------------
R01 11
R02 8
R03 12
R04 9
SYSTEM 4
You have room for each to grow by 20 more extents each. Is there a problem?
Should you take any action?
Level: Intermediate
Expected answer: No there is not a problem. You have 40 extents showing and an
average of 40 concurrent users. Since there is plenty of room to grow no action is
needed.
26. You see multiple extents in the temporary tablespace. Is this a problem?
Level: Intermediate
Expected answer: As long as they are all the same size this isn’t a problem. In fact, it
can even improve performance since Oracle won’t have to create a new extent when a
user needs one.
Installation/Configuration
1. Define OFA.
Level: Low
Expected answer: OFA stands for Optimal Flexible Architecture. It is a method of
placing directories and files in an Oracle system so that you get the maximum flexibility
for future tuning and file placement.
3. What should be done prior to installing Oracle (for the OS and the disks)?
Level: Low
Expected Answer: adjust kernel parameters or OS tuning parameters in accordance
with installation guide. Be sure enough contiguous disk space is available.
4. You have installed Oracle and you are now setting up the actual instance. You have been
waiting an hour for the initialization script to finish, what should you check first to
determine if there is a problem?
Level: Intermediate to high
Expected Answer: Check to make sure that the archiver isn’t stuck. If archive logging is
turned on during install a large number of logs will be created. This can fill up your
archive log destination causing Oracle to stop to wait for more space.
5. When configuring SQLNET on the server what files must be set up?
Level: Intermediate
Expected answer: INITIALIZATION file, TNSNAMES.ORA file, SQLNET.ORA file
6. When configuring SQLNET on the client what files need to be set up?
Level: Intermediate
Expected answer: SQLNET.ORA, TNSNAMES.ORA
7. What must be installed with ODBC on the client in order for it to work with Oracle?
Level: Intermediate
Expected answer: SQLNET and PROTOCOL (for example: TCPIP adapter) layers of
the transport programs.
8. You have just started a new instance with a large SGA on a busy existing server.
Performance is terrible, what should you check for?
Level: Intermediate
Expected answer: The first thing to check with a large SGA is that it isn’t being swapped
out.
9. What OS user should be used for the first part of an Oracle installation (on UNIX)?
Level: low
Expected answer: You must use root first.
10. When should the default values for Oracle initialization parameters be used as is?
Level: Low
Expected answer: Never
11. How many control files should you have? Where should they be located?
Level: Low
Expected answer: At least 2 on separate disk spindles. Be sure they say on separate
disks, not just file systems.
12. How many redo logs should you have and how should they be configured for maximum
recoverability?
Level: Intermediate
Expected answer: You should have at least three groups of two redo logs with the two
logs each on a separate disk spindle (mirrored by Oracle). The redo logs should not be
on raw devices on UNIX if it can be avoided.
13. You have a simple application with no "hot" tables (i.e. uniform IO and access
requirements). How many disks should you have assuming standard layout for SYSTEM,
USER, TEMP and ROLLBACK tablespaces?
Expected answer: At least 7, see disk configuration answer above.
Data Modeler
1. Describe third normal form?
Level: Low
Expected answer: Something like: In third normal form all attributes in an entity are
related to the primary key and only to the primary key
3. What is an ERD?
Level: Low
Expected answer: An ERD is an Entity-Relationship-Diagram. It is used to show the
entities and relationships for a database logical model.
5. What does a hard one-to-one relationship mean (one where the relationship on both ends
is "must")?
Level: Low to intermediate
Expected answer: This means the two entities should probably be made into one entity.
7. What is an artificial (derived) primary key? When should an artificial (or derived)
primary key be used?
Level: Intermediate
Expected answer: A derived key comes from a sequence. Usually it is used when a
concatenated key becomes too cumbersome to use as a foreign key.
2. How can you determine the number of SQLNET users logged in to the UNIX system?
Level: Intermediate
Expected answer: SQLNET users will show up with a process unique name that begins
with oracle<SID>, if you do a ps -ef|grep oracle<SID>|wc -l you can get a count of the
number of users.
8. The system has a program that always includes the word nocomp in its name, how can
you determine the number of processes that are using this program?
Level: intermediate
Expected answer: ps -ef|grep *nocomp*|wc -l
9. What is an inode?
Level: Intermediate
Expected answer: an inode is a file status indicator. It is stored in both disk and memory
and tracts file status. There is one inode for each file on the system.
10. The system administrator tells you that the system hasn’t been rebooted in 6 months,
should he be proud of this?
Level: High
Expected answer: Maybe. Some UNIX systems don’t clean up well after themselves.
Inode problems and dead user processes can accumulate causing possible
performance and corruption problems. Most UNIX systems should have a scheduled
periodic reboot so file systems can be checked and cleaned and dead or zombie
processes cleared out.
13. How can you find all the processes on your system?
Level: Low
Expected answer: Use the ps command
18. If you aren’t sure what command does a particular UNIX function what is the best way
to determine the command?
Expected answer: The UNIX man -k <value> command will search the man pages for
the value specified. Review the results from the command to find the command of
interest.
Oracle Troubleshooting
1. How can you determine if an Oracle instance is up from the operating system level?
Level: Low
Expected answer: There are several base Oracle processes that will be running on
multi-user operating systems, these will be smon, pmon, dbwr and lgwr. Any answer
that has them using their operating system process showing feature to check for these
is acceptable. For example, on UNIX a ps -ef|grep dbwr will show what instances are
up.
3. Users from the PC clients are getting the following error stack:
Level: Low
ERROR: ORA-01034: ORACLE not available
ORA-07318: smsget: open error when opening sgadef.dbf file.
HP-UX Error: 2: No such file or directory
What is the probable cause?
Expected answer: The Oracle instance is shutdown that they are trying to access,
restart the instance.
4. How can you determine if the SQLNET process is running for SQLNET V1? How about
V2?
Level: Low
Expected answer: For SQLNET V1 check for the existence of the orasrv process. You
can use the command "tcpctl status" to get a full status of the V1 TCPIP server, other
protocols have similar command formats. For SQLNET V2 check for the presence of the
LISTENER process(s) or you can issue the command "lsnrctl status".
5. What file will give you Oracle instance status information? Where is it located?
Level: Low
Expected answer: The alert<SID>.ora log. It is located in the directory specified by the
background_dump_dest parameter in the v$parameter table.
6. Users aren’t being allowed on the system. The following message is received:
Level: Intermediate
ORA-00257 archiver is stuck. Connect internal only, until freed
What is the problem?
Expected answer: The archive destination is probably full, backup the archive logs and
remove them and the archiver will re-start.
7. Where would you look to find out if a redo log was corrupted assuming you are using
Oracle mirrored redo logs?
Level: Intermediate
Expected answer: There is no message that comes to the SQLDBA or SRVMGR
programs during startup in this situation, you must check the alert<SID>.log file for this
information.
11. You get a call from you backup DBA while you are on vacation. He has corrupted all of
the control files while playing with the ALTER DATABASE BACKUP CONTROLFILE
command. What do you do?
Level: High
Expected answer: As long as all datafiles are safe and he was successful with the
BACKUP controlfile command you can do the following:
CONNECT INTERNAL
STARTUP MOUNT
(Take any read-only tablespaces offline before next step ALTER DATABASE
DATAFILE .... OFFLINE;)
RECOVER DATABASE USING BACKUP CONTROLFILE
ALTER DATABASE OPEN RESETLOGS;
(bring read-only tablespaces back online)
Shutdown and backup the system, then restart
If they have a recent output file from the ALTER DATABASE BACKUP CONTROL FILE
TO TRACE; command, they can use that to recover as well.
If no backup of the control file is available then the following will be required:
CONNECT INTERNAL
STARTUP NOMOUNT
CREATE CONTROL FILE .....;
However, they will need to know all of the datafiles, logfiles, and settings for
MAXLOGFILES, MAXLOGMEMBERS, MAXLOGHISTORY, MAXDATAFILES for the
database to use the command.
ORACLE database is comprised of three types of files. One or more Data files, two are more
redo Log files, and one or more Control files.
A database is divided into Logical Storage Unit called table spaces. A table space is used to
grouped related logical structures together.
Every ORACLE database contains a table space named SYSTEM, which is automatically
created when the database is created. The SYSTEM table
Space always contains the data dictionary tables for the entire database.
5. Explain the relationship among Database, Table space and Data file?
6. What is schema?
A view is a virtual table. Every view has a Query attached to it. (The Query is a SELECT
statement that identifies the columns and rows of the table(s) the view uses.)
Yes.
A sequence generates a serial list of unique numbers for numerical columns of a database's
tables.
Synonyms are used to: Mask the real name and owner of an object.
Provide public access to an object
Provide location transparency for tables, views or program units of a remote database.
Simplify the SQL statements for database users.
An Index is an optional structure associated with a table to have direct access to rows,
which can be created to increase the performance of data retrieval. Index can be created
on ones or more columns of a table.
Indexes are automatically maintained and used by ORACLE. Changes to table data are
automatically incorporated into all relevant indexes.
Clusters are groups of one or more tables physically stores together to share common
columns and are often used together.
The related column of the tables in a cluster is called the Cluster Key.
A row is stored in a hash cluster based on the result of applying a hash function to the row's
cluster key value. All rows with the same hash key value are stores together on disk.
Hash clusters are better choice when a table is often queried with equality queries. For such
queries the specified cluster key value is hashed. The resulting hash key value points
directly to the area on disk that stores the specified rows.
A database link is a named object that describes a "path" from one database to another.
Private Database Link, Public Database Link & Network Database Link.
Public database link is created for the special user group PUBLIC. A public database link can
be used when any user in the associated database specifies a global object name in a SQL
statement or object definition.
Network database link is created and managed by a network domain service. A network
database link can be used when any user of any database in the network specifies a global
object name in a SQL statement or object definition.
ORACLE database's data is stored in data blocks. One data block corresponds to a specific
number of bytes of physical database space on disk.
A data block size is specified for each ORACLE database when the database is created. A
database users and allocated free database space in ORACLE data blocks. Block size is
specified in INIT.ORA file and can’t be changed latter.
In Circumstances, all of the data for a row in a table may not be able to fit in the same data
block. When this occurs, the data for the row is stored in a chain of data block (one or
more) reserved for that segment.
Each Non-clustered table has a data segment. All of the table's data is stored in the extents
of its data segment. Each cluster has a data segment. The data of every table in the cluster
is stored in the cluster's data segment.
Temporary segments are created by ORACLE when a SQL statement needs a temporary
work area to complete execution. When the statement finishes execution, the temporary
segment extents are released to the system for future use.
Every ORACLE database has one or more physical data files. A database's data files contain
all the database data. The data of logical database structures such as tables and indexes is
physically stored in the data files allocated for a database.
A data file can be associated with only one database. Once created a data file can't change
size.
One or more data files form a logical unit of database storage called a table space.
The set of Redo Log files for a database is collectively known as the database's redo log.
The Primary function of the redo log is to record all changes made to data.
The Information in a redo log file is used only to recover the database from a system or
media failure prevents database data from being written to a database's data files.
A Control file records the physical structure of the database. It contains the following
information.
Database Name
Names and locations of a database's files and redo log files.
Time stamp of database creation.
50. What is the use of Control File?
When an instance of an ORACLE database is started, its control file is used to identify the
database and redo log files that must be opened for database operation to proceed. It is
also used in database recovery.
The data dictionary of an ORACLE database is a set of tables and views that are used as a
read-only reference about the database.
It stores information about both the logical and physical structure of the database, the valid
users of an ORACLE database, integrity constraints defined for tables in the database and
space allocated for a schema object and how much of it is being used.
An integrity constraint is a declarative way to define a business rule for a column of a table.
53. Can an Integrity Constraint be enforced on a table if some existing table data does not
satisfy the constraint?
No.
55. What is difference between UNIQUE constraint and PRIMARY KEY constraint?
A column defined as UNIQUE can contain Nulls while a column defined as PRIMARY KEY
can't contain Nulls.
A rule defined on a column (or set of columns) in one table that allows the insert or update
of a row only if the value for the column or set of columns (the dependent value) matches
a value in a column of a related table (the referenced value). It also specifies the type of
data manipulation allowed on referenced data and the action to be performed on dependent
data as a result of any action on referenced data.
57. What are the Referential actions supported by FOREIGN KEY integrity constraint?
UPDATE and DELETE Restrict - A referential integrity rule that disallows the update or
deletion of referenced data.
DELETE Cascade - When a referenced row is deleted all associated dependent rows are
deleted.
58. What is self-referential integrity constraint?
If a foreign key reference a parent key of the same table is called self-referential integrity
constraint.
The condition must be a Boolean expression evaluated using the values in the row being
inserted or updated and can't contain sub queries, sequence, the SYSDATE, UID, USER or
USERENV SQL functions, or the pseudo columns LEVEL or ROWNUM.
60. What is the maximum number of CHECK constraints that can be defined on a column?
No Limit.
SYSTEM ARCHITECTURE:
Database buffers store the most recently used blocks of database data. It can also contain
modified data that has not yet been permanently written to disk.
DATA ACCESS
The goal of the optimizer is to choose the most efficient way to execute a SQL statement.
98. What are the different approaches used by Optimizer in choosing an execution plan?
Rule-based and Cost-based.
99. What are the factors that affect OPTIMIZER in choosing an Optimization approach?
The OPTIMIZER_MODE initialization parameter Statistics in the Data Dictionary the
OPTIMIZER_GOAL parameter of the ALTER SESSION command hints in the statement.
100. What are the values that can be specified for OPTIMIZER MODE Parameter?
COST and RULE.
101. Will the Optimizer always use COST-based approach if OPTIMIZER_MODE is set to
"Cost'?
Presence of statistics in the data dictionary for at least one of the tables accessed by the
SQL statements is necessary for the OPTIMIZER to use COST-based approach. Otherwise
OPTIMIZER chooses RULE-based approach.
This value causes the optimizer to choose the rule_based approach for all SQL statements
issued to the instance regardless of the presence of statistics.
103. What are the values that can be specified for OPTIMIZER_GOAL parameter of the
ALTER SESSION Command?
CHOOSE, ALL_ROWS, FIRST_ROWS and RULE.
104. What is the effect of setting the value "CHOOSE" for OPTIMIZER_GOAL, parameter of
the ALTER SESSION Command?
The Optimizer chooses Cost_based approach and optimizes with the goal of best throughput
if statistics for at least one of the tables accessed by the SQL statement exist in the data
dictionary. Otherwise the OPTIMIZER chooses RULE_based approach.
105. What is the effect of setting the value "ALL_ROWS" for OPTIMIZER_GOAL parameter of
the ALTER SESSION command?
This value causes the optimizer to the cost-based approach for all SQL statements in the
session regardless of the presence of statistics and to optimize with a goal of best
throughput.
106. What is the effect of setting the value 'FIRST_ROWS' for OPTIMIZER_GOAL
parameter of the ALTER SESSION command?
This value causes the optimizer to use the cost-based approach for all SQL statements in
the session regardless of the presence of statistics and to optimize with a goal of best
response time.
107. What is the effect of setting the 'RULE' for OPTIMIER_GOAL parameter of the ALTER
SESSION Command?
This value causes the optimizer to choose the rule-based approach for all SQL statements in
a session regardless of the presence of statistics.
PROGRAMMATIC CONSTRUCTS
110. 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.
117. What are the differences between Database Trigger and Integrity constraints?
A declarative integrity constraint is a statement about the database that is always true. A
constraint applies to existing data in the table and any statement that manipulates the
table.
A trigger does not apply to data loaded before the definition of the trigger, therefore, it does
not guarantee all data in a table conforms to the rules established by an associated trigger.
DATABASE SECURITY
DYNAMIC PRIVILEGE MANAGEMENT - When the privileges of a group must change, only the
privileges of the role need to be modified. The security domains of all users granted the
group's role automatically reflect the changes made to the role.
124. What are the system resources that can be controlled through Profile?
The number of concurrent sessions the user can establish the CPU processing time available
to the user's session the CPU processing time available to a single call to ORACLE made by a
SQL statement the amount of logical I/O available to the user's session the amount of
logical I/O available to a single call to ORACLE made by a SQL statement the allowed
amount of idle time for the user's session the allowed amount of connect time for the user's
session.
Commit - Phase - If all participants respond to the coordinator that they are prepared, the
coordinator asks all nodes to commit the transaction, if all participants cannot prepare, the
coordinator asks all nodes to roll back the transaction.
140. What are the different modes of mounting a Database with the Parallel Server?
Exclusive Mode If the first instance that mounts a database does so in exclusive mode, only
that Instance can mount the database.
Parallel Mode If the first instance that mounts a database is started in parallel mode, other
instances that are started in parallel mode can also mount the database.
144.WhatisOn-lineRedoLog?
The On-line Redo Log is a set of tow or more on-line redo files that record all committed
changes made to the database. Whenever a transaction is committed, the corresponding
redo entries temporarily stores in redo log buffers of the SGA are written to an on-line redo
log file by the background process LGWR. The on-line redo log files are used in cyclical
fashion.
147. What are the advantages of operating a database in ARCHIVELOG mode over
operating it in NO ARCHIVELOG mode?
Complete database recovery from disk failure is possible only in ARCHIVELOG mode.
Online database backup is possible only in ARCHIVELOG mode.
Rolling back transactions that have been explicitly rolled back or have not been committed
as indicated by the rollback segments regenerated in step a.
Releasing any resources (locks) held by transactions in process at the time of the failure.
Resolving any pending distributed transactions undergoing a two-phase commit at the time
of the instance failure.
Introduction to DBA
A database instance (Server) is a set of memory structure and background processes that
access a set of database files.
The memory structure that are used to store most queried data from database. This helps
up to improve database performance by decreasing the amount of I/O performed against
data file.
3. What is a Schema?
Group of tables physically stored together because they share common columns and are
often used together is called Cluster.
The related columns of the tables are called the cluster key. The cluster key is indexed
using a cluster index and its value is stored only once for multiple tables in the cluster.
It consists of
One or more data files.
One or more control files.
Two or more redo log files.
The Database contains
Multiple users/schemas
One or more rollback segments
One or more table spaces
Data dictionary tables
User objects (table, indexes, views etc.,)
The server that access the database consists of
SGA (Database buffer, Dictionary Cache Buffers, Redo log buffers, Shared SQL pool)
SMON (System MONito)
PMON (Process MONitor)
LGWR (LoG Write)
DBWR (Data Base Write)
ARCH (ARCHiver)
CKPT (Check Point)
RECO
Dispatcher
User Process with associated PGS
Two processes waiting to update the rows of a table, which are locked, by the other process
then deadlock arises.
In a database environment this will often happen because of not issuing proper rowlock
commands. Poor design of front-end application may cause this situation and the
performance of server will reduce drastically.
9. What is SGA? How it is different from Ver 6.0 and Ver 7.0?
The System Global Area in a Oracle database is the area in memory to facilitates the
transfer of information between users. It holds the most recently requested structural
information between users. It holds the most recently requested structural information
about the database.
The structure is Database buffers, Dictionary cache, Redo Log Buffer and Shared SQL pool
(ver 7.0 only) area.
The data dictionary cache is stored in an area in SGA called the Shared SQL Pool. This will
allow sharing of parsed SQL statements among concurrent users.
Data segment are the physical areas within a database block in which the data associated
with tables and clusters are stored.
13. What are the factors causing the reparsing of SQL statements in SGA?
Monitor the ratio of the reloads takes place while executing SQL statements. If the
ratio is greater than 1 then increase the SHARED_POOL_SIZE.
Database buffers are cache in the SGA used to hold the data blocks that are read from the
data segments in the database such as tables, indexes and clusters DB_BLOCK_BUFFERS
parameter in INIT.ORA decides the size.
Dictionary cache is information about the database objects stored in a data dictionary table.
Number of times processes repeatedly query the dictionary table is called recursive hints. It
is due to the data dictionary cache is too small. By increasing the SHARED_POOL_SIZE
parameter we can optimize the size of Data Dictionary Cache.
18. How will you swap objects into a different table space for an existing database?
19. List the Optional Flexible Architecture (OFA) of Oracle database? Or how can we
organize the table spaces in Oracle database to have maximum performance?
A free extent is a collection of continuous free blocks in table space. When a segment is
dropped its extents are reallocated and are marked as free.
22. How free extents are managed in Ver 6.0 and Ver 7.0?
23.Which parameter in Storage clause will reduce no. of rows per block?
PCTFREE parameter
Row size also reduces no of rows per block.
We can plan the storage for a table as how much initial extents are required, how much can
be extended next, how much % should leave free for managing row updations etc.,
This is used to reserve certain amount of space in a block for expansion of rows.
To manage the database level transactions such as modifications of the data dictionary table
that record information about the free space usage.
Create a database that implicitly creates a SYSTEM Rollback Segment in a SYSTEM table
space.
Make new rollback segment available (After shutdown, modify init.ora file and Start
database)
Deactivate Rollback Segment R0 and activate the newly created rollback segments.
30. How the space utilisation takes place within rollback segments?
It will try to fit the transaction in a cyclic fashion to all existing extents. Once it found an
extent is in use then it forced to acquire a new extent (No. of extents is based on the
optimal size)
34. List the sequence of events when a large transaction that exceeds beyond its optimal
value when an entry wraps and causes the rollback segment to expand into another extend.
Transaction Begins.
The entry attempts to wrap into second extent. None is available, so that the RBS must
extent.
36. How will you estimate the space required by a non-clustered table?
37. It is possible to use raw devices as data files and what are the advantages over file.
System files?
Yes.
I/O will be improved because Oracle is bye-passing the kernnel which writing into disk.
Disk Corruption will be very less.
Database's overall physical architecture is maintained in a file called control file. It will be
used to maintain internal consistency and guide recovery operations. Multiple copies of
control files are advisable.
39. How to implement the multiple control files for an existing database?
40. What is meant by Redo Log file mirrorring ? How it can be achieved?
This can be achieved by creating group of log files together, so that LGWR will automatically
writes them to all the members of the current on-line redo log group. If any one group fails
then database automatically switch over to next group. It degrades performance.
Shadow set of disks save as a backup in the event of disk failure. In most Operating System
if any disk failure occurs it automatically switchover to place of failed disk.
Improved performance because most OS support volume shadowing can direct file I/O
request to use the shadow set of files instead of the main set of files. This reduces I/O load
on the main set of disks.
They allow the database to maintain read consistency between multiple transactions.
It is the set of before image data blocks that contain rows that are modified by a
transaction.
Each Rollback Segment entry must be completed within one rollback segment.
A single rollback segment can have multiple rollback segment entries.
It is a measure of well the data cache buffer is handling requests for data.
Hit Ratio = (Logical Reads - Physical Reads - Hits Misses)/ Logical Reads.
The tar command cannot be used for physical file backup, instead we can use dd command,
which is less flexible and has limited recoveries.
47. List the factors that can affect the accuracy of the estimations?
The space used transaction entries and deleted records do not become free immediately
after completion due to delayed cleanout.
Inserts of, updates to and deletes of rows as well as columns larger than a single data
block, can cause fragmentation a chained row pieces.
A user account is not a physical structure in Database but it is having important relationship
to the objects in the database and will be having certain privileges.
Instead grant the ability to access the procedures that access the tables.
When procedure executed it will execute the privilege of procedures owner. Users cannot
access tables except via the procedure.
50. What are the dictionary tables used to monitor a database spaces ?
DBA_FREE_SPACE
DBA_SEGMENTS
DBA_DATA_FILES.
51. What are the responsibilities of a Database Administrator ?
52. What are the roles and user accounts created automatically with the database ?
SYS user account - The DBA role will be assigned to this account. All of the basetables
and views for the database's dictionary are store in this schema and are manipulated only
by ORACLE.
SYSTEM user account - It has all the system privileges for the database and additional
tables and views that display administrative information and internal tables and views
used by oracle tools are created using this username.
54. What are the database administrators utilities avaliable ?
SQL * DBA - This allows DBA to monitor and control an ORACLE database.
SQL * Loader - It loads data from standard operating system files (Flat files) into ORACLE
database tables.
Export (EXP) and Import (imp) utilities allow you to move existing data in ORACLE format
to and from ORACLE database.
55. What are the minimum parameters should exist in the parameter file (init.ora) ?
DB NAME - Must set to a text string of no more than 8 characters and it will be stored
inside the datafiles, redo log files and control files and control file while database creation.
DB_DOMAIN - It is string that specifies the network domain where the database is
created. The global database name is identified by setting these parameters (DB_NAME &
DB_DOMAIN)
CONTORL FILES - List of control filenames of the database. If name is not mentioned then
default name will be used.
Each server and background process can write an associated trace file. When an internal
error is detected by a process or user process, it dumps information about the error to
its trace. This can be used for tuning the database.
Roles are the easiest way to grant and manage common privileges needed by different
groups of database users.
Assign each role to group of users. This will simplify the job of assigning privileges to
individual users.
58. What are the steps to switch a database's archiving mode between NO ARCHIVELOG
and ARCHIVELOG mode ?
60. How can we specify the Archived log file name format and destination ?
LOG_ARCHIVE_FORMAT = arch %S/s/T/tarc (%S - Log sequence number and is zero left
paded, %s - Log sequence number not padded. %T - Thread number lef-zero-paded
and %t - Thread number not padded). The file name created is arch 0001 are if %S is
used.
LOG_ARCHIVE_DEST = path.
- to collect statisties about object used by the optimizer and store them in the data
dictionary.
- to delete statistics about the object used by object from the data dictionary.
- to validate the structure of the object.
- to identify migrated and chained rows of the table or cluster.
Updating or Inserting records in remote database through database triggers. It may fail if
remote database is having any problem.
Time the references to occur when master tables are not in use.
Peform the reference the manually immdiately locking the master tables. We can join
tables in snopshots by creating a complex snapshots that will based on the master tables.
COMPLETE - Tables are completly regenerated using the snapshot's query and the
master tables every time the snapshot referenced.
FAST - If simple snapshot used then a snapshot log can be used to send the changes to
the snapshot tables.
FORCE - Default value. If possible it performs a FAST refresh; Otherwise it will perform a
complete refresh.
We must be able to create a after row trigger on table (i.e., it should be not be already
available )
We cannot specify snapshot log name because oracle uses the name of the master table
in the name of the database objects that support its snapshot log.
(The table name created will be MLOGS_tablename, and trigger name will be TLOGS
name).
Database on other servers can be updated and those transactions can be grouped
together with others in a logical unit.
Database uses a two phase commit.
- Logical Backups
- Cold Backups
- Hot Backups (Archive log)
Logical backup involves reading a set of databse records and writing them into a file.
Export utility is used for taking backup and Import utility is used to recover from backup.
Cold backup is taking backup of all physical files after normal shutdown of database. We
need to take.
- All Data files.
- All Control files.
- All on-line redo log files.
- The init.ora file (Optional)
Taking backup of archive log files when database is open. For this the ARCHIVELOG
mode should be enabled. The following files need to be backed up.
All data files. All Archive log, redo log files. All control files.
Flag to indicate whether export should compress fragmented segments into single
extents.
A flag to indicate whether grants on databse objects will be exported or not. Value is 'Y'
or 'N'.
A flag to indicate whether statistical information about the exported objects should be
written to export dump file.
A flag to indicate whether a read consistent version of all the exported objects should be
maintained.
The name of the file which log of the export will be written.
A flag to indicate whether the import should ignore errors encounter when issuing CREATE
commands.
A flag to indicate whether rows should be imported. If this is set to 'N' then only DDL for
database objects will be exectued.
Data Definition Language: CREATE, ALTER, DROP, TRUNCATE, REVOKE, NO AUDIT &
COMMIT.
Data Manipulation Language: INSERT, UPDATE, DELETE, LOCK TABLE, EXPLAIN PLAN &
SELECT.
Transactional Control: COMMIT & ROLLBACK
Session Control: ALTERSESSION & SET ROLE
System Control: ALTER SYSTEM.
2. What is a transaction?
Transaction is logical unit between two commits and commit and rollback.
TRUNCATE commits after deleting entire table i.e., can’t be rolled back. Database triggers
do not fire on TRUNCATE
DELETE allows the filtered deletion. Deleted records can be rolled back or committed.
Database triggers fire on DELETE.
Join is a query, which retrieves related columns or rows from multiple tables.
Subquery is a query whose return values are used in filtering conditions of the main query.
ROWID is a pseudo column attached to each row of a table. It is 18character long, block no,
row number are the components of ROWID.
Using ROWID.
CONSTRAINTS
----------------------
12. What is an Integrity Constraint?
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.
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.
17. What is difference between CHAR and VARCHAR2? What is the maximum SIZE
allowed for each type?
CHAR pads blank spaces to the maximum length. VARCHAR2 does not pad blank spaces.
For CHAR it is 255 and 2000 for VARCHAR2.
18. 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.
22. 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.
Database Link is a named path through which a remote database can be accessed.
24. 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?
It is not possible. Only if you access next value in the session, current value can be
accessed.
CYCLE specifies that the sequence continues to generate values after reaching either
maximum or minimum value. After pan ascending sequence reaches its maximum value, it
generates its minimum value. After a descending sequence reaches its minimum, it
generates its maximum.
NO CYCLE specifies that the sequence cannot generate more values after reaching its
maximum or minimum value.
28.If a View on a single base table is manipulated will the changes be reflected on the base
table?
If changes are made to the tables which are base tables of a view will the changes be
reference on the view.
SQL *forms is 4GL tool for developing and executing; Oracle based interactive application.
BLOCK
False.
6. Can we create two blocks with the same name in form 3.0?
No.
7. While specifying master/detail relationship between two blocks specifying the join
condition is a must? True or False.
True.
8. What is a Trigger?
1. Navigational Triggers.
2. Transaction Triggers.
11. What is the difference between a Function Key Trigger and Key Function Trigger?
Function key triggers are associated with individual SQL*FORMS function keys
You can attach Key function triggers to 10 keys or key sequences that normally do not
perform any SQL * FORMS operations. These keys referred as key F0 through key F9.
These triggers are executes when inserting, deleting and updating operations are
performed and can be used to change the default function of insert, delete or update
respectively.
For E.g., instead of inserting a row in a table an existing row can be updated in the same
table.
It fires when a value in a field has been changed and the field status is changed or new and
the key has been pressed. If the field status is valid then any further change to the value
in the field will not fire the on-validate-field trigger.
17. A query fetched 10 records how many times do a PRE-QUERY Trigger and POST-QUERY
Trigger will get executed?
When you changes the Existing value to null, the On-validate field trigger will fire post
change trigger will not fire. At the time of execute-query post-change trigger will fire, on-
validate field trigger will not fire.
20. What is the difference between a POST-FIELD trigger and a POST-CHANGE trigger?
Post-field trigger fires whenever the control leaving from the filed.
Post-change trigger fires at the time of execute-query procedure invoked or filed validation
status changed.
No.
24. Is a Key startup trigger fires as result of a operator pressing a key explicitly?
No.
25. How can you execute the user defined triggers in forms 3.0?
Execute_Trigger (trigger-name)
It will fires whenever SQL * Forms would normally attempt to lock a row.
Navigational Trigger.
31. What is the difference between restricted and unrestricted package procedure ?
Restricted package procedure that affects the basic basic functions of SQL * Forms. It
cannot used in all triggers execpt key triggers.
Unrestricted package procedure that does not interfere with the basic functions of SQL *
Forms it can be used in any triggers.
32. Classify the restricted and unrestricted procedure from the following.
a. Call
b. User-Exit
c. Call-Query
d. Up
e. Execute-Query
f. Message
g. Exit-From
h. Post
i. Break
a. Call - unrestricted
b. User Exit - Unrestricted
c. Call_query - Unrestricted
d. Up - Restricted
e. Execute Query - Restricted
f. Message - Restricted
g. Exit_form - Restricted
h. Post - Restricted
i. Break - Unrestricted.
No.
It synchoronizes the terminal screen with the internal state of the form.
35. What are the unrestricted procedures used to change the popup screen position
during run time ?
Anchor-view
Resize -View
Move-View.
36. What Enter package procedure does ?
1. Error_Code
2. Error_Text
3. Form_Failure
4. Form_Fatal
5. Message_Code
Post writes data in the form to the database but does not perform database commit
Commit permenently writes data in the form to the database.
43. What package procedure used for invoke sql *plus from sql *forms ?
False.
45. EXIT_FORM is a restricted package procedure ?
a. True b. False
True.
46. When the form is running in DEBUG mode, If you want to examine the values of
global variables and other form variables, What package procedure command you would use
in your trigger text ?
Break.
SYSTEM VARIABLES
1. System.block_status
2. System.current_block
3. System.current_field
4. System.current_value
5. System.cursor_block
6. System.cursor_field
7. System.field_status.
User Exits :
A user exit is a subroutine which are written in programming languages using pro*C pro
*Cobol , etc., that link into the SQL * forms executable.
Page :
Pages are collection of display information, such as constant text and graphics.
53. How many pages you can in a single form ?
Unlimited.
a. True.
55.What is the significance of PAGE 0 in forms 3.0 ?
Hide the fields for internal calculation.
56. Deleting a page removes information about all the fields in that page ?
a. True. b. False
a. True.
Popup Window :
Pop-up windows are screen areas that overlay all or a portion of the
display screen when a form is running.
Alert :
An alert is window that appears in the middle of the screen overlaying a portion of the
current display.
FORMS 4.0
Form
Menu
Library
The Layout Editor is a graphical design facility for creating and arranging items and
boilerplate text and graphics objects in your application's interface.
05. BLOCK
Block is a single mechanism for grouping related items into a functional unit for
storing,displaying and manipulating records.
ITEMS
07. List the Types of Items?
Text item.
Chart item.
Check box.
Display item.
Image item.
List item.
Radio Group.
User Area item.
A navigable item is one that operators can navigate to with the keyboard during default
navigation, or that Oracle forms can navigate to by executing a navigational
built-in procedure.
09. Can you change the color of the push button in design time?
No.
A Check Box is a two state control that indicates whether a certain condition or value
is on or off, true or false. The display state of a check box is always either "checked"
or "unchecked".
PL/SQL
Basiscs of PL/SQL
1. What is PL/SQL ?
PL/SQL is a procedural language that has both interactive SQL and procedural
programming language constructs such as iteration, conditional branching.
PL/SQL uses block structure as its basic structure. Anonymous blocks or nested blocks
can be used in PL/SQL.
Datatypes PL/SQL
Some scalar data types such as NUMBER, VARCHAR2, DATE, CHAR, LONG, BOOLEAN.
Some composite data types such as RECORD & TABLE.
6. What are % TYPE and % ROWTYPE ? What are the advantages of using these over
datatypes?
% TYPE provides the data type of a variable or a database column to that variable.
% ROWTYPE provides the record type that represents a entire row of a table or view or
columns selected in the cursor.
The advantages are : I. Need not know about variable's data type
ii. If the database definition of a column in a table changes, the data type of a variable
changes accordingly.
E.g. TYPE r_emp is RECORD (eno emp.empno% type,ename emp ename %type
);
e_rec emp% ROWTYPE
cursor c1 is select empno,deptno from emp;
e_rec c1 %ROWTYPE.
Objects of type TABLE are called "PL/SQL tables", which are modelled as (but not the
same as) database tables, PL/SQL tables use a primary PL/SQL tables can have one column
and a primary key.
Cursors
9. What is a cursor ? Why Cursor is required ?
Cursor is a named private SQL area from where information can be accessed. Cursors are
required to process rows individually for queries returning multiple rows.
There are two types of cursors, Implict Cursor and Explicit Cursor.
PL/SQL uses Implict Cursors for queries.
User defined cursors are called Explicit Cursors. They can be declared and used.
DECLARE CURSOR cursor name, OPEN cursor name, FETCH cursor name INTO or
Record types, CLOSE cursor name.
Cursor for loop implicitly declares %ROWTYPE as loop index,opens a cursor, fetches rows of
values from active set into fields in the record and closes
when all the records have been processed.
eg. FOR emp_rec IN C1 LOOP
salary_total := salary_total +emp_rec sal;
END LOOP;
The cursor having query as SELECT .... FOR UPDATE gets closed after
COMMIT/ROLLBACK.
The cursor having query as SELECT.... does not get closed even after
COMMIT/ROLLBACK.
Database Triggers
Database trigger is stored PL/SQL program unit associated with a specific database table.
Usages are Audit data modificateions, Log events transparently, Enforce complex
business rules Derive column values automatically, Implement complex security
authorizations. Maintain replicate tables.
17. How many types of database triggers can be specified on a table ? What are they ?
If FOR EACH ROW clause is specified, then the trigger for each Row affected by the
statement.
If WHEN clause is specified, the trigger fires according to the retruned boolean value.
It is not possible. As triggers are defined for each table, if you use COMMIT of
ROLLBACK in a trigger, it affects logical transaction processing.
19. What are two virtual tables available during database trigger execution ?
20. What happens if a procedure that updates a column of table X is called in a database
trigger of the same table ?
I & ii.
Exception :
Exception is the error handling part of PL/SQL block. The types are Predefined and
user_defined. Some of Predefined execptions are.
CURSOR_ALREADY_OPEN
DUP_VAL_ON_INDEX
NO_DATA_FOUND
TOO_MANY_ROWS
INVALID_CURSOR
INVALID_NUMBER
LOGON_DENIED
NOT_LOGGED_ON
PROGRAM-ERROR
STORAGE_ERROR
TIMEOUT_ON_RESOURCE
VALUE_ERROR
ZERO_DIVIDE
OTHERS.
The PRAGMA EXECPTION_INIT tells the complier to associate an exception with an oracle
error. To get an error message of a specific oracle error.
e.g. PRAGMA EXCEPTION_INIT (exception name, oracle error number)
25. What are the return values of functions SQLCODE and SQLERRM ?
SQLCODE returns the latest code of the error that has occured.
SQLERRM returns the relevant error message of the SQLCODE.
30. What are the modes of parameters that can be passed to a procedure ?
IN,OUT,IN-OUT parameters.
BEGIN
Executable statements.
Exception.
exception handlers
end;
33. Give the structure of the function ?
34. Explain how procedures and functions are called in a PL/SQL block ?
The Same procedure name is repeated with parameters of different datatypes and
parameters in different positions, varying number of parameters is called overloading of
procedures.
The two parts of package are PACKAGE SPECIFICATION & PACKAGE BODY.
Package Specification contains declarations that are global to the packages and local to the
schema.
Package Body contains actual procedures and local declaration of the procedures and
cursor declarations.
38. What is difference between a Cursor declared in a procedure and Cursor declared in a
package specification ?
39. How packaged procedures and functions are called from the following?
a. Stored procedure or anonymous block
b. an application program such a PRC *C, PRO* COBOL
c. SQL *PLUS
40. Name the tables where characteristics of Package, procedure and functions are
stored ?
FORMS4.0
12. what is a display item?
Display items are similar to text items but store only fetched or assigned values. Operators
cannot navigate to a display item or edit the value it contains.
16. How many maximum number of radio buttons can you assign to a radio group?
17. can you change the default value of the radio button group at run time?
No.
Visual Attributes.
19. What is a visual attribute?
Visual Attributes are the font, color and pattern characteristics of objects that operators
see and intract with in our application.
Window
A window, byitself , can be thought of as an empty frame. The frame provides a way
to intract with the window, including the ability to scroll, move, and resize the window.
The content of the window ie. what is displayed inside the frame is determined by the
canvas View or canvas-views displayed in the window at run-time.
No.
24. List the buil-in routine for controlling window during run-time?
Find_window,
get_window_property,
hide_window,
move_window,
resize_window,
set_window_property,
show_View
26. What built-in is used for changing the properties of the window dynamically?
Set_window_property
Canvas-View
28. Give the equivalent term in forms 4.0 for the following.
Page, Page 0?
Page - Canvas-View
Page 0 - Canvas-view null.
A content view is the "Base" view that occupies the entire content pane of the window in
which it is displayed.
A stacked view differs from a content canvas view in that it is not the base view for the
window to which it is assigned
31. List the built-in routines for the controlling canvas views during run-time?
Find_canvas
Get-Canvas_property
Get_view_property
Hide_View
Replace_content_view
Scroll_view
Set_canvas_property
Set_view_property
Show_view
Alert
An alert is a modal window that displays a message notifies the operator of some
application condition
No
35. What built-in is used for showing the alert during run-time?
Show_alert.
36. Can you change the alert messages at run-time?
If yes, give the name of th built-in to chage the alert messages at run-time.
Yes. Set_alert_property.
37. What is the built-in function used for finding the alert?
Find_alert
Editors
Default editor
User_defined editors
system editors.
Edit_text item
show_editor
LOV
Yes.
42. Can you attach an lov to a field at run-time? if yes, give the build-in name.
Yes. Set_item_proprety
Show_lov
44. What is the built-in used to get and set lov properties during run-time?
Get_lov_property
Set_lov_property
Record Group
A record group is an internal oracle forms data structure that has a simillar column/row
frame work to a database table
46. What are the different type of a record group?
Create_group (Function)
Create_group_from_query(Function)
Delete_group(Procedure)
Add_group_column(Function)
Add_group_row(Procedure)
Delete_group_row(Procedure)
Populate_group(Function)
Populate_group_with_query(Function)
Set_group_Char_cell(procedure)
48. What is the built_in routine used to count the no of rows in a group?
Get_group _row_count
System Variables
49. List system variables available in forms 4.0, and not available in forms 3.0?
System.cordination_operation
System Date_threshold
System.effective_Date
System.event_window
System.suppress_working
False
Yes
The library pll files is a portable design file comparable to an fmb form file
The library lib file is a plat form specific, generated library file comparable to a fmx
form file
The pld file is Txt format file and can be used for source controlling your library
files
Parameter
54. How do you pass the parameters from one form to another form?
To pass one or more parameters to a called form, the calling form must perform the
following steps in a trigger or user named routine excute the create_parameter_list built_in
function to programatically.
Create a parameter list to execute the add parameter built_in procedure to add
one or more parameters list.
Execute the call_form, New_form or run_product built_in procedure and include the
name or id of the parameter list to be passed to the called form.
54. What are the built-in routines is available in forms 4.0 to create and manipulate a
parameter list?
Add_parameter
Create_Parameter_list
Delete_parameter
Destroy_parameter_list
Get_parameter_attr
Get_parameter_list
set_parameter_attr
55. What are the two ways to incorporate images into a oracle forms application?
Boilerplate Images
Image_items
A fetch from a long raw database column PL/Sql assignment to executing the
read_image_file built_in procedure to get an image from the file system.
57. What are the triggers associated with the image item?
Image_add
Image_and
Image_subtract
Image_xor
Image_zoom
Raise form_trigger_failure
61. What are the menu items that oracle forms 4.0 supports?
FORMS4.5
object groups
An object group is a container for a group of objects, you define an object group when you
want to package related objects. so that you copy or reference them in another
modules.
02. what are the different objects that you cannot copy or reference in object groups?
canvas views
Most Canvas views are content canvas views a content canvas view is the "base" view
that occupies the entire content pane of the window in which it is displayed.
Stacked canvas view is displayed in a window on top of, or "stacked" on the content canvas
view assigned to that same window. Stacked canvas views obscure some part of the
underlying content canvas view, and or often shown and hidden programmatically.
Tool bar canvas views are used to create tool bars for individual windows Horizontal tool
bars are display at the top of a window, just under its menu bar.
Vertical Tool bars are displayed along the left side of a window
Get_view_property, Set_view_property
Windows
Canvas views are the back ground objects on which you place the interface items (Text
items), check boxes, radio groups etc.,) and boilerplate
objects (boxes, lines, images etc.,) that operators interact with us they run your form .
Each canvas views displayed in a window.
Modalless windows
Modal windows
More than one modelless window can be displayed at the same time, and operators can
navigate among them if your application allows them to do so . On most GUI platforms,
modelless windows can also be layered to appear either in front of or behind other windows.
Modal windows are usually used as dialogs, and have restricted functionality
compared to modelless windows. On some platforms for example operators cannot resize,
scroll or iconify a modal window.
The console includes the status line and message line, and is displayed at the bottom of the
window to which it is assigned.
To specify that the console should be displayed, set the console window form property
to the name of any window in the form. To include the console, set console window to
Null.
For a modelless window, it determines whether oracle forms hides the window automatically
when the operators navigates to an item in the another window.
Only one window in a form can display the console, and you cannot chage the console
assignment at runtime.
14. Can you have more than one content canvas view attached with a window?
Yes.
Each window you create must have atleast one content canvas view assigned to it.
You can also create a window that has manipulate contant canvas view. At run time only
one of the content canvas views assign to a window is displayed at a time.
When_window_activated
When_window_closed
When_window_deactivated
When_window_resized
Within this triggers, you can examine the built in system variable
system.event_window to determine the name of the window for which the trigger fired.
Modules
18. What are the default extensions of the files careated by forms modules?
19. What are the default extentions of the files created by menu module?
.mmb, .mmx
20 What are the default extension of the files created by library module?
The default file extensions indicate the library module type and storage format
.pll - pl/sql library module binary
Master Detail
A master detail relationship is an association between two base table blocks- a master
block and a detail block. The relationship between the blocks reflects a primary key to
foreign key relationship between the tables on which the blocks are based.
Any event that makes a different record in the master block the current record is a
coordination causing event.
25. What are the different types of Delete details we can establish in Master-Details?
Cascade
Isolate
Non-isolote
26. What are the different defaust triggers created when Master Deletes Property is set
to Non-isolated?
Master Delets Property Resulting Triggers
----------------------------------------------------
Non-Isolated(the default) On-Check-Delete-Master
On-Clear-Details
On-Populate-Details
26. Whar are the different default triggers created when Master Deletes Property is set to
Cascade?
Ans: Master Deletes Property Resulting Triggers
---------------------------------------------------
Cascading On-Clear-Details
On-Populate-Details
Pre-delete
28. What are the different default triggers created when Master Deletes Property is set to
isolated?
30. What are the different types of Coordinations of the Master with the Detail block?
42. What is the User-Named Editor?
A user named editor has the same text editing functionality as the default editor, but,
becaue it is a named object, you can specify editor attributes such as windows display size,
position, and title.
A user named editor can be displayed programmatically with the built in procedure
SHOW-EDITOR, EDIT_TETITEM independent of any particular text item.
Show editor is the generic built_in which accepts any editor name and takes some input
string and returns modified output string. Whereas the edit_textitem built_in needs
the input focus to be in the text item before the built_in is excuted.
46. What is the basic data structure that is required for creating an LOV?
Record Group.
47. What is the "LOV of Validation" Property of an item? What is the use of it?
When LOV for Validation is set to True, Oracle Forms compares the current value of the
text item to the values in the first column displayed in the LOV.
Whenever the validation event occurs.
If the value in the text item matches one of the values in the first column of the LOV,
validation succeeds, the LOV is not displayed, and processing continues normally.
If the value in the text item does not match one of the values in the first column of
the LOV, Oracle Forms displays the LOV and uses the text item value as the search criteria
to automatically reduce the list.
48. What are the built_ins used the display the LOV?
Show_lov
List_values
49. What are the built-ins that are used to Attach an LOV programmatically to an item?
set_item_property
get_item_property
(by setting the LOV_NAME property)
50. What are the built-ins that are used for setting the LOV properties at runtime?
get_lov_property
set_lov_property
A record group can have an unlimited number of columns of type CHAR, LONG, NUMBER,
or DATE provided that the total number of column does not exceed 64K.
A query record group is a record group that has an associated SELECT statement. The
columns in a query record group derive their default names, data types, had lengths from
the database columns referenced in the SELECT statement. The records in query record
group are the rows retrieved by the query associated with that record group.
A non-query record group is a group that does not have an associated query, but whose
structure and values can be modified programmatically at runtime.
A static record group is not associated with a query, rather, you define its structure and
row values at design time, and they remain fixed at runtime.
58. What are the built-ins used for Creating and deleting groups?
CREATE-GROUP (function)
CREATE_GROUP_FROM_QUERY(function)
DELETE_GROUP(procedure)
59.What are the built -ins used for Modifying a group's structure?
ADD-GROUP_COLUMN (function)
ADD_GROUP_ROW (procedure)
DELETE_GROUP_ROW(procedure)
60. POPULATE_GROUP(function)
POPULATE_GROUP_WITH_QUERY(function)
SET_GROUP_CHAR_CELL(procedure)
SET_GROUP_DATE_CELL(procedure)
SET_GROUP_NUMBER_CELL(procedure)
61. What are the built-ins used for Getting cell values?
GET_GROUP_CHAR_CELL (function)
GET_GROUP_DATE_CELL(function)
GET_GROUP_NUMBET_CELL(function)
GET_GROUP_ROW_COUNT(function)
GET_GROUP_SELECTION_COUNT(function)
GET_GROUP_SELECTION(function)
RESET_GROUP_SELECTION(procedure)
SET_GROUP_SELECTION(procedure)
UNSET_GROUP_SELECTION(procedure)
63. What are the built-ins used for finding Object ID function?
FIND_GROUP(function)
FIND_COLUMN(function)
64. Use the ADD_GROUP_COLUMN function to add a column to a record group that was
created at design time.
I) TRUE II)FALSE
II) FALSE
65. Use the ADD_GROUP_ROW procedure to add a row to a static record group
I) TRUE II)FALSE
I) FALSE
61. What are the built-in used for getting cell values?
Get_group_char_cell(function)
Get_group_date_cell(function)
Get_group_number_cell(function)
Get_group_row_count(function)
Get_group_selection_count(function)
Get_group_selection(function)
Reset_group_selection(procedure)
Set_group_selection(procedure)
Unset_group_selection(procedure)
63. What are the built-ins used for finding object ID functions?
Find_group(function)
Find_column(function)
64. Use the add_group_column function to add a column to record group that was created
at a design time?
False.
65. Use the Add_group_row procedure to add a row to a static record group 1. true or
false?
False.
parameters
Parameters provide a simple mechanism for defining and setting the values
of inputs that are required by a form at startup. Form parameters are variables of type
char,number,date that you define at design time.
67. What are the Built-ins used for sending Parameters to forms?
You can pass parameter values to a form when an application executes the call_form,
New_form, Open_form or Run_product.
The maximum no of chars the parameter can store is only valid for char parameters,
which can be upto 64K. No parameters default to 23Bytes and Date parameter default to
7Bytes.
69. How do you call other Oracle Products from Oracle Forms?
Run_product is a built-in, Used to invoke one of the supported oracle tools products and
specifies the name of the document or module to be run. If the called product is unavailable
at the time of the call, Oracle Forms returns a message to the opertor.
In Pl/Sql, You can reference and set the values of form parameters using bind variables
syntax. Ex. PARAMETER name = '' or :block.item = PARAMETER
Parameter name
To indirectly reference a parameter use the NAME IN, COPY 'built-ins to indirectly set
and reference the parameters value' Example name_in ('capital parameter my param'),
Copy ('SURESH','Parameter my_param')
Text Parameters
Data Parameters
73. When do you use data parameter type?
When the value of a data parameter being passed to a called product is always the
name of the record group defined in the current form. Data parameters are used to
pass data to produts invoked with the run_product built-in subprogram.
No.
IMAGES
76. What is the difference between boiler plat images and image items?
Boiler plate Images are static images (Either vector or bit map) that you import from the
file system or database to use a grapical elements in your form, such as company logos and
maps Image items are special types of interface controls that store and display
either vector or bitmap images. Llike other items that store values, image items can be
either base table items(items that relate directly to database columns) or control items.
The definition of an image item is stored as part of the form module FMB and FMX files,
but no image file is actualy associated with an image item until the item is populate at run
time.
79. How do you create a new session while open a new form?
False
81. An open form can not be execute the call_form procedure if you chain of called forms
has been initiated by another open form?
True
82. When a form is invoked with call_form, Does oracle forms issues a save point?
True
Mouse Operations
83. What are the various sub events a mouse double click event involves?
Double clicking the mouse consists of the mouse down, mouse up, mouse click, mouse
down & mouse up events.
System.mouse_button_pressed
System.mouse_button_shift_state
system.mouse_item
system.mouse_canvas
system.mouse_record
OLE
Object Linking & Embadding provides you with the capability to integrate objects from
many Ms-Windows applications into a single compound document creating integrated
applications enables you to use the features form .
86. What is the difference between object embedding & linking in Oracle forms?
In Oracle forms, Embedded objects become part of the form module, and linked objects
are references from a form module to a linked source file.
87. What is the difference between OLE Server & Ole Container?
An Ole server application creates ole Objects that are embedded or linked in ole
Containers ex. Ole servers are ms_word & ms_excell. OLE containers provide a place to
store, display and manipulate objects that are created by ole server applications. Ex.
oracle forms is an example of an ole Container.
In place activation
External activation
A property clause is a named object that contains a list of properties and thier settings.
Once you create a property clause you can base other object on it. An object based on a
property can inherit the setting of any property in the clause that makes sense for that
object.
Yes
92. What are the important difference between property clause and visual attributes?
Named visual attributes differed only font, color & pattern attributes, property clauses
can contain this and any other properties. You can change the appearance of objects at
run time by changing the named visual attributes programatically , property clause
assignments cannot be changed programatically. When an object is inheriting from both a
property clause and named visual attribute, the named visual attribute settings take
precedence, and any visual attribute properties in the class are ignored.
Form Build-ins
It allows you to read and write information to a file in the file system.
Calls the user exit named in the user_exit_string. Invokes a 3Gl programe by name
which has been properly linked into your current oracle forms executable.
It is a terminal screen with the internal state of the form. It updates the screen display to
reflect the information that oracle forms has in its internal representation of the screen.
Issues dynamic Sql statements at run time, including server side pl/SQl and DDL
Triggers
Fires when oracle forms first marks a record as an insert or an update. The trigger fires as
soon as oracle forms determines through validation that the record should be processed by
the next post or commit as an insert or update. c generally occurs only when the operators
modifies the first item in the record, and after the operator attempts to navigate out of the
item.
98. What are the master-detail triggers?
On-Check_delete_master
On_clear_details
On_populate_details
It represents the coordination causing event that occur on the master block in master-detail
relation.
101. What are the difference between lov & list item?
Lov is a property where as list item ias an item. A list item can have only one column, lov
can have one or more columns.
Pop_list
Text_list
Combo box
The pop list style list item appears initially as a single field (similar to a text item field).
When the operator selects the list icon, a list of available choices appears.
The text list style list item appears as a rectangular box which displays the fixed number of
values. When the text list contains values that can not be displayed, a vertical scroll bar
appears, allowing the operator to view and select undisplayed values.
Display items are similar to text items with the exception that display items only store
and display fetched or assigned values.Display items are generaly used as boilerplate or
conditional text.
When one form invokes another form by executing new_form oracle form exits the first
form and releases its memory before loading the new form calling new form completely
replace the first with the second. If there are changes pending in the first form,the operator
will be prompted to save them before the new form is loaded.
Library's provide a convenient means of storing client-side program units and sharing
them among multipule applications. Once you create a library, you can attach it to any
other form,menu,or library modules. When you can call library program units from triggers
menu items commands and user named routine, you write in the modules to which you
have attach the library.
when a library attaches another library ,program units in the first library can reference
program units in the attached library. Library support dynamic loading-that is library
program units are loaded into an application only when needed. This can significantly
reduce the run-time memory requirements of an applications.
Removes the source code from the library file and generates a library files that contains
only pcode.The resulting file can be used for final deployment, but can not be
subsequently edited in the designer.
Vbx control provide a simple mehtod of buildig and enhancing user interfaces.The
controls can use to obtain user inputs and display program outputs.vbx control where
originally develop as extensions for the ms visual basic environments and include such
items as sliders,grides and knobs.
Timer is a "internal time clock" that you can programmatically create to perform an action
each time the timer expires.
115. what are difference between post database commit and post-form commit?
Post-form commit fires once during the post and commit transactions process, after
the database commit occures. The post-form-commit trigger fires after inserts,updates
and deletes have been posted to the database but before the transactions have been
finalished in the issuing the command.The post-database-commit trigger fires after
oracle forms issues the commit to finalished transactions.
Fires during the execute query and count query processing after oracle forms constructs
the select statement to be issued, but before the statement is actually issued.
The pre-query trigger fires just before oracle forms issues the select statement to the
database after the operator as define the example records by entering the query criteria in
enter query mode.
When-timer-expired.
Using transactional triggers we can control or modify the default functionality of the
oracle forms.
REPORTS
1. What are the different file extensions that are created by oracle reports?
Previewer.
It is a command line argument that allows you to specify a file that contain a set of
arguments for r20run.
7.Where is a procedure return in an external pl/sql library executed at the client or at the
server?
At the client.
At the server.
9. What are the default parameter that appear at run time in the parameter screen?
10. Which parameter can be used to set read level consistency across multiple queries?
Read only.
The term is terminal definition file that describes the terminal form which you are using
r20run.
The term file which key is correspond to which oracle report functions.
13. Is it possible to insert comments into sql statements return in the data model editor?
Yes.
14. If the maximum record retrieved property of the query is set to 10 then a summary
value will be calculated?
15. What are the sql clauses supported in the link property sheet?
16. To execute row from being displayed that still use column in the row which property
can be used?
Format trigger.
17. Is it possible to set a filter condition in a cross product group in matrix reports?
No.
18. If a break order is set on a column would it effect columns which are under the
column? No.
19. With which function of summary item is the compute at options required?
20. What is the purpose of the product order option in the column property sheet?
Yes.
Yes.
A placeholder column is used to hold a calculated values at a specified place rather than
allowing is to appear in the actual row where it has to appeared.
A hidden column is used to when a column has to embedded into boilerplate text.
A break group is used to display one record for one group ones.While multiple related
records in other group can be displayed.
28. If two groups are not linked in the data model editor, What is the hierarchy between
them?
Two group that is above are the left most rank higher than the group that is to right or
below it.
29.The join defined by the default data link is an outer join yes or no?
Yes.
30. How can a text file be attached to a report while creating in the report writer?
By using the link file property in the layout boiler plate property sheet.
No.
32. Can a field be used in a report wihtout it appearing in any data group?
Yes.
33. For a field in a repeating frame, can the source come from the column which does not
exist in the data group which forms the base for the frame?
Yes.
34. Is it possible to center an object horizontally in a repeating frame that has a variable
horizontal size?
Yes.
35. If yes,how?
36. What are the two repeating frame always associated with matrix object?
37. Is it possible to split the printpreviewer into more than one region?
Yes.
38. Does a grouping done for objects in the layout editor affect the grouping done in
the datamodel editor?
No.
39. How can a square be drawn in the layout editor of the report writer?
40. To display the page no. for each page on a report what would be the source & logical
page no. or & of physical page no.?
& physical page no.
41. What does the term panel refer to with regard to pages?
A panel is the no. of physical pages needed to print one logical page.
An anchoring object is a print condition object which used to explicitly or implicitly anchor
other objects to itself.
A frame is a holder for a group of fields. A repeating frame is used to display a set of
records when the no. of records that are to displayed is not known before.
REPORT TRIGGERS.
Before report, Before form, After form , Between page, After report.
46. Does a Before form trigger fire when the parameter form is suppressed.
Yes.
47. At what point of report execution is the before Report trigger fired?
After the query is executed but before the report is executed and the
records are displayed.
48. Is the After report trigger fired if the report execution fails?
Yes.
Before form , After form , Before report, Between page, After report.
No.
51. What are the ways to monitor the performance of the report?
Because for each query, report has to open a separate cursor and has to
rebind, execute and fetch data.
55. Why is a Where clause faster than a group filter or a format trigger?
56. What is the main diff. bet. Reports 2.0 & Reports 2.5?
57. What is the diff. bet. setting up of parameters in reports 2.0 reports
2.5?
58. How is link tool operation different bet. reports 2 & 2.5?
In Reports 2.0 the link tool has to be selected and then two fields to be
linked are selected and the link is automatically created. In 2.5 the first
field is selected and the link tool is then used to link the first field to
the second field.
59.What are the two types views available in the object navigator(specific
to report 2.5)?
view by structure.
62. How is it possible to select generate a select ste. for the query in
the query property sheet?
By using the tables/columns button and then specifying the table and the
column names.
While both reports 2.0 and 2.5 create the parameter, report 2.5 gives a
message that a bind parameter has been created.
No.
When confine mode is on, an object cannot be moved outside its parent in
the layout.
66. What is the diff. when Flex mode is mode on and when it is off?
When flex mode is on, reports automatically resizes the parent when the
child is resized.
67. How can a button be used in a report to give a drill down facility?
By setting the action asscoiated with button to Execute pl/sql option and
using the SRW.Run_report function.
68. What are the two ways by which data can be generated for a parameter's
list of values?
1. Using static values.
2. Writing select statement.
69. What are the two panes that Appear in the design time pl/sql
interpreter?
70. What are three panes that appear in the run time pl/sql interpreter?
By selecting the cross products tool and drawing a new group surrounding
the base group of the cross products.
A group that forms part of a cross product will have a thicker border.
73. Atleast how many set of data must a data model have before a data model
can be base on it?
Four.
No.
75. Is it possible to link two groups inside a cross products after the
cross products group has been created?
No.
76. What is an user exit used for?
A way in which to pass control (and possibly arguments ) form Oracle report
to another Oracle products of 3 GL and then return control ( and ) back
to Oracle reprots.
78. How can values be passed bet. precompiler exits & Oracle call
interface?
Oracle DBA
1. SNAPSHOT is used for
[DBA] a] Synonym, b] Table space, c] System server, d] Dynamic data
replication
Ans : D
Ans : B
13. Which of the following is not an reason for the fact that most of the
processing is done at the
server ?
a] To reduce network traffic. b] For application sharing, c] To
implement business rules
centrally, d] None of the above
Ans : D
16. What is the difference between a LIST BOX and a COMBO BOX ?
a] In the list box, the user is restricted to selecting a value from a
list but in a combo box
the user can type in a value which is not in the list
b] A list box is a data entry area while a combo box can be used only
for control purposes
c] In a combo box, the user is restricted to selecting a value from a
list but in a list box the
user can type in a value which is not in the list
d] None of the above
Ans : A
22. The system variable that records the select statement that SQL * FORMS
most recently used
to populate a block is
a] SYSTEM.LAST_RECORD
b] SYSTEM.CURSOR_RECORD
c] SYSTEM.CURSOR_FIELD
d] SYSTEM.LAST_QUERY
Ans: D
23. Which of the following is TRUE for the ENFORCE KEY field
a] ENFORCE KEY field characterstic indicates the source of the value
that SQL*FORMS
uses to populate the field
b] A field with the ENFORCE KEY characterstic should have the INPUT
ALLOWED
charaterstic turned off
a] Only 1 is TRUE
b] Only 2 is TRUE
c] Both 1 and 2 are TRUE
d] Both 1 and 2 are FALSE
Ans : A
27. The packaged procedure that makes data in form permanent in the
Database is
a] Post
b] Post form
c] Commit form
d] None of the above
Ans : C
28. Which of the following is TRUE for the SYSTEM VARIABLE $$date$$
a] Can be assigned to a global variable
b] Can be assigned to any field only during design time
c] Can be assigned to any variable or field during run time
d] None of the above
Ans : B
32. Name the two files that are created when you generate a form using
Forms 3.0
a] FMB & FMX, b] FMR & FDX, c] INP & FRM, d] None of the above
Ans : C
35. All datafiles related to a Tablespace are removed when the Tablespace
is dropped
a] TRUE
b] FALSE
Ans : B
45. A database trigger doesnot apply to data loaded before the definition
of the trigger
a] TRUE
b] FALSE
Ans : A
47. Which of the following does not affect the size of the SGA
a] Database buffer
b] Redolog buffer
c] Stored procedure
d] Shared pool
Ans : C
51. Declare
fvar number := null; svar number := 5
Begin
goto << fproc>>
if fvar is null then
<< fproc>>
svar := svar + 5
end if;
End;
What will be the value of svar after the execution ?
a] Error
b] 10
c] 5
d] None of the above
Ans : A
Ans : C
Ans : C
Ans : D
Ans : C
Ans : A
57. Is it possible to use Transactional control statements in Database
Triggers ?
a] Yes
b] No
Ans : B
Ans : A
Ans C
Ans : B
61. Which of the following is not correct about the "TABLE" datatype ?
a] Can contain any no of columns
b] Simulates a One-dimensional array of unlimited size
c] Column datatype of any Scalar type
d] None of the above
Ans : A
Ans C
Ans : B
Ans : C
Ans : C
66. Declare
a number := 5; b number := null; c number := 10;
Begin
if a > b AND a < c then
a := c * a;
end if;
End;
What will be the value of 'a' after execution ?
a] 50
b] NULL
c] 5
d] None of the above
Ans : C
67. Does the Database trigger will fire when the table is TRUNCATED ?
a] Yes
b] No
Ans : B
Ans : A
Select SAL from EMP E1 where 3 > ( Select count(*) from Emp E2
where E1.SAL > E2.SAL ) will retrieve
a] 3500,5000,2500
b] 5000,2850
c] 2850,5750
d] 5000,5750
Ans : A
Ans B
Ans : B
Ans : C
75. The Data Manipulation Language statements are
a] INSERT
b] UPDATE
c] SELECT
d] All of the above
Ans : D
Ans : C
Ans : B
Ans : C
79. What built-in subprogram is used to manipulate images in image items ?
a] Zoom_out
b] Zoom_in'
c] Image_zoom
d] Zoom_image
Ans : C
Ans : A
81. SHOW_ALERT function returns
a] Boolean
b] Number
c] Character
d] None of the above
Ans : B
Ans : A
Ans : C
Ans : C
Ans : A
Ans : D
Ans : B
Ans : C - Please check the Correcness of this Answer ( The correct answer
is 2 )
Ans : C
Ans : C
Ans : B
Ans : B
94. What type of file is used for porting Forms 4.5 applications to various
platforms ?
a] .FMB file
b] .FMX file
c] .FMT file
d] .EXE file
Ans : C
Ans A
96. When a form is invoked with CALL_FORM does Oracle forms issues
SAVEPOINT ?
a] Yes
b] No
Ans : A
97. Can we attach the same LOV to different fields in Design time ?
a] Yes
b] No
Ans : A
98. How do you pass values from one form to another form ?
a] LOV
b] Parameters
c] Local variables
d] None of the above
Ans : B
99. Can you copy the PROGRAM UNIT into an Object group ?
a] Yes
b] No
Ans : B
Ans : A
Ans : C
102. What is a Built_in subprogram ?
a] Library
b] Stored procedure & Function
c] Collection of Subprograms
d] None of the above
Ans : D
Ans : A
Ans : C
Ans : B
Ans : A
Ans : B
Ans D
109. Oracle precompiler translates the EMBEDDED SQL statemens into
a] Oracle FORMS
b] Oracle REPORTS
c] Oracle LIBRARY
d] None of the above
Ans : D
Ans : D
Ans : D
Ans : A
Ans : A
Ans : D
115. For a field in a repeating frame, can the source come from a column
which does not exist in
the datagroup which forms the base of the frame ?
a] Yes
b] No
Ans : A
116. What are the different file extensions that are created by Oracle
Reports ?
a] .RDF file & .RPX file
b] .RDX file & .RDF file
c] .REP file & .RDF file
d] None of the above
Ans : C
117. Is it possible to Disable the Parameter form while running the report
?
a] Yes
b] No
Ans : A
118.What are the SQL clauses supported in the link property sheet ?
a] WHERE & START WITH
b] WHERE & HAVING
c} START WITH & HAVING
d] WHERE, START WITH & HAVING
Ans : D
119. What are the types of Calculated columns available ?
a] Summary, Place holder & Procedure column
b] Summary, Procedure & Formula columns
c] Procedure, Formula & Place holder columns
d] Summary, Formula & Place holder columns
Ans.: D
120. If two groups are not linked in the data model editor, what is the
hierarchy between them?
a] There is no hierarchy between unlinked groups
b] The group that is right ranks higher than the group that is to the
left
c] The group that is above or leftmost ranks higher than the group
that is to right or below
it
d] None of the above
Ans : C
121. Sequence of events takes place while starting a Database is
a] Database opened, File mounted, Instance started
b] Instance started, Database mounted & Database opened
c] Database opened, Instance started & file mounted
d] Files mounted, Instance started & Database opened
Ans : B
122. SYSTEM TABLESPACE can be made off-line
a] Yes
b] No
Ans : B
123. ENQUEUE_RESOURCES parameter information is derived from
a] PROCESS or DDL_LOCKS & DML_LOCKS
b] LOG BUFFER
c] DB_BLOCK_SIZE
d] DB_BLOCK_BUFFERS
Ans : A
124. SMON process is used to write into LOG files
a] TRUE
b] FALSE
Ans : B
125. EXP command is used
a] To take Backup of the Oracle Database
b] To import data from the exported dump file
c] To create Rollback segments
d] None of the above
Ans : A
126. SNAPSHOTS cannot be refreshed automatically
a] TRUE
b] FALSE
Ans : B
127. The User can set Archive file name formats
a] TRUE
b] FALSE
Ans : A
Ans: B
131. It is very difficult to grant and manage common priveleges needed by
Different groups of
Database users using roles
a] TRUE
b] FALSE
Ans: B
132. The status of the Rollback segment can be viewed through
a] DBA_SEGMENTS
b] DBA_ROLES
c] DBA_FREE_SPACES
d] DBA_ROLLBACK_SEG
Ans: D
Ans: A
Ans: A
Quiz – 1
1)Display the names of all the employees and their experience in years.
SELECT ENAME,ROUND(MONTHS_BETWEEN(SYSDATE,HIREDATE)/12) AS EXPERINCE FROM EMP
3)Display the employee's name, department's name ,grade and manager's name.
SQL> SELECT a.ENAME,DNAME,s.grade,B.ENAME
2 FROM emp a,EMP B,DEPT D,salgrade s
3 WHERE a.mgr=b.empno
4 AND A.DEPTNO=D.DEPTNO
5 And a.sal between s.losal and s.hisal
5 /
4)Display the emp name and salary those earn more than the average salary of
the company.
select ename,sal from emp where sal>(select avg(sal) from emp);
5)Display all the employees who earn more than their manager's salary.
SELECT A.EMPNO FROM EMP A,EMP B
WHERE B.EMPNO=A.MGR
AND A.SAL>B.SAL
6)Display all the employees whose grade is the same as that of JONES.
7)Display all employee names and their salaries whose salary is not in the
range on 1500 and 2850
The Column Heading to be displayed as
Emp Monthly
Name Salary
---- ------
SQL> column ename heading 'Emp|Name'
SQL> column sal heading 'Monthly|Salary'
SQL> select ename,sal
2 from emp
3 where sal not between 1500 and 2850;
8)Display the name of the employee who don't have any manager.
select ename from emp where mgr is null;
9)Display the name ,salary and commission for all employees whose commission
amount is greater than their salary increased by 10%
select ename,sal,comm from emp where comm >(1.1*sal);
10)Display the Ename,salary and salary increased by 15% expressed as a whole
number.Label the column New Salary.In addition to this display the Increase
of salary over the previous one.For Example.
11)Display the Employee name ,hiredate, salary review date which is the first
Monday after 6 months of the service.
12)Create a query that will display the employee name ,dept number and all
the employees name that work in tha same dept as a given employee.
select a.ename,a.deptno,b.ename
from emp a,emp b
where b.deptno=a.deptno
and a.ename !=b.ename
order by a.deptno,a.ename
13) Display the Job and the no. of persons working in each job type.
select job,count(job) from emp group by job;
14) Display dept name,location,number of employees and the average salary for
all employees in that dept.
select dname,loc,count(empno),avg(sal)
from emp,dept
where emp.deptno(+)=dept.deptno
group by dname,loc
EXERCISE 1
Quiz - 2
3. Display Employee name and Job information from employee in the following
fashion.
SMITH Works as CLERK.
select ename||' Works as '||job from emp
4. Display all the information from department table where second character
of city name is 'A'.
SELECT * FROM DEPT WHERE LOC LIKE '_A%'
9. Display 'YOU ARE GOOD IN SQL' text as 'You Are Good In Sql' in a Select
statement.
SELECT INITCAP('U ARE GOOD IN SQL')FROM DUAL;
Group Functions
===============
6.Select employee name ,Hiredate in the format of "2nd of july 1997" for
deptno 10 and 20.
SELECT ENAME,TO_CHAR(HIREDATE,'ddth "of" month rrrr')
from emp
where deptno in(10,20)
7.Display employee names in lower case whose salary is greater than 2000 and
less than 2800.
select lower(ename) from emp where sal between 2000 and 2800;
9.Select employee name whose job is Manager or Clerk and Salary greater than
1000 and commission greater than 100 and deptno is either 10 or 20.
4. Diplay employee name, department name, job from employee and department tables
who job is CLERK.
select ename,dname,job from emp,dept
where emp.deptno=dept.deptno
and job='CLERK'
5. Display employee name, deptno, dname from employee and department table where
location is DALLAS.
select ename,A.dEPTNO,DNAME from emp A,dept
where A.deptno=dept.deptno
and LOC='DALLAS'
6. Display employee number, name, address and city from employee, employee
address tables.
Select a.empno,a.ename,b.address,b.city from emp a,address b
Where a.empno=b.empno;
7. Display employee nmae, address from employee and employee address tables
who lives in zip code 75039
8. Display employee name, department name, location who were getting comm as
null.
Select ename,dname,loc from emp,dept
Where emp.deptno=dept.deptno
And comm is null;
9. Display first 3 characters of employee name, job, sal, comm, location from
employee and department tables who works in department 20 or 30, salary
should be more than 1000 comm as not null.
Select substr(ename,1,3),job,sal,comm,loc
From emp,dept
Where emp.deptno=dept.deptno
And emp.deptno in(20,30)
And sal >1000
And comm is not null;
Select loc,dname,length(loc),length(dname)
From emp,dept where emp.deptno=dept.deptno
And empno in (1001,1008,1009);
3. Display job and averge salary paid for each jobs in the company.
select job,avg(sal) from emp
group by job
/
4. Display location and sum of the salary spending for employees on that
location respectively.
select loc,sum(sal) from emp,dept
where emp.deptno(+)=dept.deptno
group by loc
Select job,count(empno),max(sal),min(sal)
From emp group by job
10. Select department name, job and sum of salary by each job with in the department.
Select dname,job,sum(sal) from emp,dept
Where emp.deptno=dept.deptno
Group by dname,job
6.Display Current date, day, 70 days after current date and its day also.
SELECT SYSDATE,TO_CHAR(SYSDATE,'DAY'),SYSDATE+70,TO_CHAR(SYSDATE+70,'DAY')
FROM DUAL;
7.Display the months between ‘JAN-10-65’ and ‘JUN-23-98’ take the input in
specified format.
select (months_between(to_date('JAN-10-65','MON-DD-RR' ),to_date('JUN-23-
98','MON-DD-RR') ))
from dual
/
8.Display the current date as Today’s date is : current date from system.
SELECT 'Today''s date is : '||sysdate from dual;
10.Display the day like Sunday or what for this date ‘July 4 1998’
select to_char(to_date('July 4 1998' ,'fmMonthfmdd yyyy'),'Day') from dual
One of the most often uses of the pseudo column rownum is to provide serial numbers to the
records in a query. This feature is widely used in reports to represent systematic display of
information.
For instance
Listing A
Select rownum, ename, empno
from emp10;
Table A
However, when we order this statement the rownum gets disturbed as shown below ( Listing B
and Table B).
Listing B
select rownum, ename, empno from emp10
order by ename;
Table B
ROWNUM ENAME EMPNO
--------- ---------- ---------
2 BLAKE 7698
3 CLARK 7782
4 JONES 7566
1 KING 7839
5 MARTIN 7654
As we can see from above the employee names did get ordered but the rownum also got the
wrong order. The desired result was BLAKE having rownum 1 , CLARK having a rownum of 2
and so on. To achieve this we have to outer join this table with dual that process forces a implicit
order on the rownum as shown below ( Listing C, Table C).
Listing C
select rownum, ename, empno from emp10 a , dual d
where a.ename = d.dummy (+)
order by ename;
Table C
ROWNUM ENAME EMPNO
------- ---------- ---------
1 BLAKE 7698
2 CLARK 7782
3 JONES 7566
4 KING 7839
5 MARTIN 7654
The trick is to do an outer join with the column that you want to order and this process
does not disturb the rownum order. In addition to that if the column is of number
datatype then one should make sure to use TO_CHAR datatype conversion function.
What are the difference between DDL, DML and DCL commands?
DDL is Data Definition Language statements. Some examples:
• CREATE - to create objects in the database
• ALTER - alters the structure of the database
• DROP - delete objects from the database
• TRUNCATE - remove all records from a table, including all spaces allocated for the
records are removed
• COMMENT - add comments to the data dictionary
• GRANT - gives user's access privileges to database
• REVOKE - withdraw access privileges given with the GRANT command
DML is Data Manipulation Language statements. Some examples:
• SELECT - retrieve data from the a database
• DELETE - deletes all records from a table, the space for the records remain
• SAVEPOINT - identify a point in a transaction to which you can later roll back
• SET TRANSACTION - Change transaction options like what rollback segment to use
How does one escape special characters when building SQL queries?
The LIKE keyword allows for string searches. The '_' wild card character is used to match exactly one character, '%'
is used to match zero or more occurrences of any characters. These characters can be escaped in SQL. Example:
SELECT name FROM emp WHERE id LIKE '%\_%' ESCAPE '\';
Use two quotes for every one displayed. Example:
SELECT 'Franks''s Oracle site' FROM DUAL;
SELECT 'A ''quoted'' word.' FROM DUAL;
SELECT 'A ''''double quoted'''' word.' FROM DUAL;
Create your table with a NOT NULL column (say SEQNO). This column can now be populated with unique values:
SQL> UPDATE table_name SET seqno = ROWNUM;
or use a sequences generator:
SQL> CREATE SEQUENCE sequence_name START WITH 1
INCREMENT BY 1;
SQL> UPDATE table_name SET seqno = sequence_name.NEXTVAL;
Finally, create a unique index on this column.
How does one get the time difference between two date columns?
The SYSDATE pseudo-column shows the current system date and time. Adding 1 to SYSDATE will advance the
date by 1 day. Use fractions to add hours, minutes or seconds to the date. Look at these examples:
SQL> select sysdate, sysdate+1/24, sysdate +1/1440,
sysdate + 1/86400 from dual;
NOW NOW_PLUS_30_SECS
-------------------- --------------------
03-JUL-2002 16:47:23 03-JUL-2002 16:47:53
Use this simple query to count the number of data values in a column:
select my_table_column, count(*)
from my_table
group by my_table_column;
A more sophisticated example...
select dept, sum( decode(sex,'M',1,0)) MALE,
sum( decode(sex,'F',1,0)) FEMALE,
count(decode(sex,'M',1,'F',1)) TOTAL
from my_emp_table
group by dept;
A value x will be between values y and z if GREATEST(x, y) = LEAST(x, z). Look at this example:
select f2,
sum(decode(greatest(f1,59), least(f1,100), 1, 0))
"Range 60-100",
sum(decode(greatest(f1,30), least(f1, 59), 1, 0))
"Range 30-59",
sum(decode(greatest(f1, 0), least(f1, 29), 1, 0))
"Range 00-29"
from my_table
group by f2;
For equal size ranges it might be easier to calculate it with DECODE(TRUNC(value/range), 0, rate_0, 1, rate_1, ...).
Eg.
select ename "Name", sal "Salary",
decode( trunc(f2/1000, 0), 0, 0.0,
1, 0.1,
2, 0.2,
3, 0.31) "Tax rate"
from my_table;
One can easily select all even, odd, or Nth rows from a table using SQL queries like this:
Method 1: Using a subquery
SELECT *
FROM emp
WHERE (ROWID,0) IN (SELECT ROWID, MOD(ROWNUM,4)
FROM emp);
Method 2: Use dynamic views (available from Oracle7.2):
SELECT *
FROM ( SELECT rownum rn, empno, ename
FROM emp
) temp
WHERE MOD(temp.ROWNUM,4) = 0;
Please note, there is no explicit row order in a relational database. However, these queries are quite fun and may
even help in the odd situation.
Form Oracle8i one can have an inner-query with an ORDER BY clause. Look at this example:
SELECT *
FROM (SELECT * FROM my_table ORDER BY col_name_1 DESC)
WHERE ROWNUM < 10;
Use this workaround with prior releases:
SELECT *
FROM my_table a
WHERE 10 >= (SELECT COUNT(DISTINCT maxcol)
FROM my_table b
WHERE b.maxcol >= a.maxcol)
ORDER BY maxcol DESC;
Tree-structured queries are definitely non-relational (enough to kill Codd and make him roll in his grave). Also, this
feature is not often found in other database offerings.
The SCOTT/TIGER database schema contains a table EMP with a self-referencing relation
(EMPNO and MGR columns). This table is perfect for tesing and demonstrating tree-structured
queries as the MGR column contains the employee number of the "current" employee's boss.
The LEVEL pseudo-column is an indication of how deep in the tree one is. Oracle can handle
queries with a depth of up to 255 levels. Look at this example:
select LEVEL, EMPNO, ENAME, MGR
from EMP
connect by prior EMPNO = MGR
start with MGR is NULL;
One can produce an indented report by using the level number to substring or lpad() a series of spaces, and
concatenate that to the string. Look at this example:
select lpad(' ', LEVEL * 2) || ENAME ........
One uses the "start with" clause to specify the start of the tree. More than one record can match the starting
condition. One disadvantage of having a "connect by prior" clause is that you cannot perform a join to other tables.
The "connect by prior" clause is rarely implemented in the other database offerings. Trying to do this
programmatically is difficult as one has to do the top level query first, then, for each of the records open a cursor to
look for child nodes.
One way of working around this is to use PL/SQL, open the driving cursor with the "connect by
prior" statement, and the select matching records from other tables on a row-by-row basis,
inserting the results into a temporary table for later retrieval.
The Oracle decode function acts like a procedural statement inside an SQL statement to return different values or
columns based on the values of other columns in the select statement.
Some examples:
select decode(sex, 'M', 'Male', 'F', 'Female', 'Unknown')
from employees;
DUMP(COL1)
Typ=96 Len=4: 65,66,67,32
From Oracle8i one can DROP a column from a table. Look at this sample script, demonstrating the ALTER TABLE
table_name DROP COLUMN column_name; command.
Other workarounds:
1. SQL> update t1 set column_to_drop = NULL;
SQL> rename t1 to t1_base;
SQL> create view t1 as select <specific columns> from t1_base;
From Oracle8 you can just type "password" from SQL*Plus, or if you need to change another
user's password, type "password user_name".
How does one find the next value of a sequence?
Perform an "ALTER SEQUENCE ... NOCACHE" to unload the unused cached sequence numbers from the Oracle
library cache. This way, no cached numbers will be lost. If you then select from the USER_SEQUENCES dictionary
view, you will see the correct high water mark value that would be returned for the next NEXTVALL call.
Afterwards, perform an "ALTER SEQUENCE ... CACHE" to restore caching.
You can use the above technique to prevent sequence number loss before a SHUTDOWN
ABORT, or any other operation that would cause gaps in sequence values.
Workaround for snapshots on tables with LONG columns
You can use the SQL*Plus COPY command instead of snapshots if you need to copy LONG and LONG RAW
variables from one location to another. Eg:
COPY TO SCOTT/TIGER@REMOTE -
CREATE IMAGE_TABLE USING -
SELECT IMAGE_NO, IMAGE -
FROM IMAGES;
Note: If you run Oracle8, convert your LONGs to LOBs, as it can be replicated.