Oracle
Oracle
Oracle
Topics
How can one search PL/SQL code for a string/ key value?
The following query is handy if you want to know where a certain table, field or expression is referenced in your
PL/SQL source code.
SELECT TYPE, NAME, LINE
FROM
USER_SOURCE
WHERE UPPER(TEXT) LIKE '%&KEYWORD%';
Back to top of file
If you forget to set serveroutput on type SET SERVEROUTPUT ON once you remember, and then EXEC NULL;. If
you haven't cleared the DBMS_OUTPUT buffer with the disable or enable procedure, SQL*Plus will display the
entire contents of the buffer when it executes this dummy PL/SQL block.
Back to top of file
How does one get the value of a sequence into a PL/SQL variable?
As you might know, one cannot use sequences directly from PL/SQL. Oracle (for some silly reason) prohibits this:
i := sq_sequence.NEXTVAL;
However, one can use embedded SQL statements to obtain sequence values:
select sq_sequence.NEXTVAL into :i from dual;
Thanks to Ronald van Woensel
BEGIN
FOR dept_rec IN dept_cur LOOP
dbms_output.put_line('Employees in Department '||
TO_CHAR(dept_rec.deptno));
FOR emp_rec in emp_cur(dept_rec.deptno) LOOP
dbms_output.put_line('...Employee is '||emp_rec.ename);
END LOOP;
END LOOP;
END;
/
Back to top of file
How often should one COMMIT in a PL/SQL loop? / What is the best commit
strategy?
Contrary to popular believe, one should COMMIT less frequently within a PL/SQL loop to prevent ORA-1555
(Snapshot too old) errors. The higher the frequency of commit, the sooner the extents in the rollback segments will
be cleared for new transactions, causing ORA-1555 errors.
To fix this problem one can easily rewrite code like this:
FOR records IN my_cursor LOOP
...do some stuff...
COMMIT;
END LOOP;
... to ...
FOR records IN my_cursor LOOP
...do some stuff...
i := i+1;
IF mod(i, 10000) THEN
-- Commit every 10000 records
COMMIT;
END IF;
END LOOP;
If you still get ORA-1555 errors, contact your DBA to increase the rollback segments.
NOTE: Although fetching across COMMITs work with Oracle, is not supported by the ANSI standard.
Back to top of file
I can SELECT from SQL*Plus but not from PL/SQL. What is wrong?
PL/SQL respect object privileges given directly to the user, but does not observe privileges given through roles. The
consequence is that a SQL statement can work in SQL*Plus, but will give an error in PL/SQL. Choose one of the
following solutions:
Grant direct access on the tables to your user. Do not use roles!
GRANT select ON scott.emp TO my_user;
Define your procedures with invoker rights (Oracle 8i and higher);
Move all the tables to one user/schema.
Back to top of file
Another way this error can occur is if the trigger has statements to change the primary, foreign or unique key
columns of the table off which it fires. If you must have triggers on tables that have referential constraints, the
workaround is to enforce the referential integrity through triggers as well.
There are several restrictions in Oracle regarding triggers:
A row-level trigger cannot query or modify a mutating table. (Of course, NEW and OLD still can be
accessed by the trigger) .
A statement-level trigger cannot query or modify a mutating table if the trigger is fired as the result of a
CASCADE delete.
Etc.
Back to top of file
Object names are referenced in UPPER case unless you use SQLPASSTHROUGH. This only works for the
(default) Oracle setting of case-insensitive objects.
There is no support for SQL bind variables (i.e. "SELECT * FROM EMP WHERE ENAME = :name"). If
the value of your variable changes, you need to recreate the SQL statement and dynaset. This means that
the server must reparse the query and refetch the data.
There is no support for PL/SQL bind variables (in/out parameters). The workaround is to pass values in as
literals, and store the return values in a temporary table that you can then query on to get the results.
Multiple data controls (or database opens) use multiple database connections, even if they all reference the
same account on the same database. This can be a serious problem with databases that have a limit on the
total number of connections they will accept.
Oracle Objects has no such drawbacks:
Rows are accessed via their rowid. If a rowid can be obtained, then the data is updatable.
When creating a dynaset, some data is initially fetched and cached locally. Data is fetched and stored
locally as needed, as rows are traversed. Admittedly, this can lead to a large local data cache, so many
tunable cache parameters are provided to improve performance.
Snapshots have not been implemented, since a read-only dynaset is a reasonable equivalent.
Table joins are performed by the server.
Views, synonyms, column aliases and schema references can be used freely. The updatability of database
objects is only dependent SQL updatability rules and on the access you have been granted .
Objects names are not modified in any way. You may use upper or lower case in the names, which are caseinsensitive.
Support for SQL bind variables (i.e. "SELECT * FROM EMP WHERE ENAME = :name") is offered via
the Parameters collection. The server does not have to reparse the query before refetching data.
Support for PL/SQL bind variables is offered (in/out vars) via the Parameters collection.
Multiple data controls (or database opens) referencing the same account on the same database will all share
a single Oracle connection.
At first, the VB/JET/ODBC limitations may not sound serious, but consider a typical production Oracle environment
where most users only have access to data via synonyms and views. This means that VB/JET/ODBC users can only
read, not write data.
Oracle PL/SQL FAQ
Topics
How does one get the value of a sequence into a PL/SQL variable?
As you might know, oracle prohibits this:
i := sq_sequence.NEXTVAL;
(for some silly reason). But you can do this:
select sq_sequence.NEXTVAL into :i from dual;
Thanks to Ronald van Woensel
Topics
FROM
WHERE
Back to top of file
STATUS
USER_OBJECTS
LAST_DDL_TIME > '&CHECK_FROM_DATE';
How can one search PL/SQL code for a string/ key value?
The following query is handy if you want to know where a certain table, field or expression is referenced in your
PL/SQL source code.
SELECT TYPE, NAME, LINE
FROM
USER_SOURCE
WHERE UPPER(TEXT) LIKE '%&KEYWORD%';
Back to top of file
your proprietary algorithms and methods. SQL*Plus and SQL*DBA will still understand and know how to execute
such scripts. Just be careful, there is no "decode" command available.
The syntax is:
wrap iname=myscript.sql oname=xxxx.plb
Back to top of file
How does one get the value of a sequence into a PL/SQL variable?
As you might know, one cannot use sequences directly from PL/SQL. Oracle (for some silly reason) prohibits this:
i := sq_sequence.NEXTVAL;
However, one can use embedded SQL statements to obtain sequence values:
select sq_sequence.NEXTVAL into :i from dual;
Thanks to Ronald van Woensel
In Oracle8 one can call external 3GL code in a dynamically linked library (DLL or shared object). One just write a
library in C/ C++ to do whatever is required. Defining this C/C++ function to PL/SQL makes it executable. Look at
this External Procedure example.
Back to top of file
How often should one COMMIT in a PL/SQL loop? / What is the best commit
strategy?
Contrary to popular believe, one should COMMIT less frequently within a PL/SQL loop to prevent ORA-1555
(Snapshot too old) errors. The higher the frequency of commit, the sooner the extents in the rollback segments will
be cleared for new transactions, causing ORA-1555 errors.
To fix this problem one can easily rewrite code like this:
FOR records IN my_cursor LOOP
...do some stuff...
COMMIT;
END LOOP;
... to ...
FOR records IN my_cursor LOOP
...do some stuff...
i := i+1;
IF mod(i, 10000) THEN
-- Commit every 10000 records
COMMIT;
END IF;
END LOOP;
If you still get ORA-1555 errors, contact your DBA to increase the rollback segments.
NOTE: Although fetching across COMMITs work with Oracle, is not supported by the ANSI standard.
Back to top of file
I can SELECT from SQL*Plus but not from PL/SQL. What is wrong?
PL/SQL respect object privileges given directly to the user, but does not observe privileges given through roles. The
consequence is that a SQL statement can work in SQL*Plus, but will give an error in PL/SQL. Choose one of the
following solutions:
Grant direct access on the tables to your user. Do not use roles!
GRANT select ON scott.emp TO my_user;
Define your procedures with invoker rights (Oracle 8i and higher);
Move all the tables to one user/schema.
Back to top of file
I have some trouble with SQL*Net. How can I produce a trace file?
How can I set up a dedicated server connection?
Can I upgrade to SQL*Net V2 if I still have V1 clients?
How can I enable dead connection detection?
What are inband and out of band breaks?
What can be done to increase SQL*Net performance?
Can one get connected to a system regardless of machine failure?
Can one grant or restrict access to a system via SQL*Net?
Where can I get more info about SQL*Net/ Net8?
Oracle Names Topics:
How does one setup an Oracle Names Server?
How to get your listener to register itself with the Names Server?
How does one register an Oracle Names Server Entry?
How can I check if a listener registered itself with the Names Server?
Connection Manager Topics:
What is the Connection Manager and what is it good for?
How does one configure the Connection Manager?
How does one route data through the Connection Manager?
Default port
Start
command
Stop
command
Connect
string
SQL*Net V1
SQL*Net V2
Net8
1525/tcp
1521/tcp
1521/tcp
tcpctl start
lsnrctl start
lsnrctl start
tcpctl stop
lsnrctl stop
lsnrctl stop
protocol:host:sid eg.
T:SRV1:DB1
Specified in TNSNAMES.ORA
Specified in TNSNAMES.ORA
SID_LIST_LISTENER =
(SID_LIST=
(SID_DESC=
(SID_NAME=yourSID)
(ORACLE_HOME=YOUR_ORACLE_HOME)
)
)
NOTE: A wrong TNSNAMES.ORA entry on a line will block all valid entries below. Copy names to the top until
you find the incorrect entry.
Back to top of file
I have some trouble with SQL*Net. How can I produce a trace file?
Create/edit your SQLNET.ORA file. You will find this file in one of the following locations (SQL*Net V2 searches
for it in this order):
Directory pointed to by the TNS_ADMIN parameter ($TNS_ADMIN on Unix)
/etc (Unix only)
/var/opt/oracle (Unix only)
$ORACLE_HOME/network/admin or net8/admin directory
Your SQLNET.ORA file should contain the following lines to produce a trace file:
trace_level_client=16
trace_unique_client=yes
Sometimes it is useful to only trace TNSPING packets. Add the following parameters to your SQLNET.ORA file:
TNSPING.TRACE_LEVEL = 16
TNSPING.TRACE_DIRECTORY = /tmp/tnsping/
The following parameters are also worth setting:
trace_file_client = cli.trc
trace_directory_client = <path_to_trace_dir>
log_file_client = sqlnet.log
log_directory_client = <path_to_log_dir>
Back to top of file
While a SQL statement is running SQL*Net polls the client continuously to catch CONTROL-C situations.
This results into a lot of poll and fstat system calls.
The following SQLNET.ORA parameter can be specified to reduce polling overhead on your system:
BREAK_POLL_SKIP=n # Number of packets to skip between checking for
breaks (default=4)
2.
Prespawned server sessions. You can tell the listener to start up a pool of idle server processes. When a
connection request is made, it doesn't have to start a server process; it just hands one of the idle processes to
the client (and then starts a new connection in its own time). This is configured in LISTENER.ORA, in the
SID_LIST_LISTENER section, as follows:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = yourSID)
(PRESPAWN_MAX = 50)
(PRESPAWN_LIST =
(PRESPAWN_DESC = (PROTOCOL = TCP) (POOL_SIZE = 5)
(TIMEOUT = 2))))
)
PRESPAWN_MAX: if there are over 50 sessions connected to the database, the listener won't prespawn
any more.
POOL_SIZE: the listener will maintain an idle pool of 5 server processes. TIMEOUT: after a client
disconnects, the listener will keep the freed-up server process around for two minutes, waiting for a new
connection request, before killing that process.
Multiple listeners with load balancing. You can start multiple listeners on a server, and reference all of the
listeners in the TNSNAMES.ORA file. When a client makes a connection request, the SQL*Net client will
randomly pick one of the listeners to contact.
In LISTENER.ORA, specify multiple listeners as in:
# Define listener A...
3.
STARTUP_WAIT_TIME_LISTENER_A = 0
CONNECT_TIMEOUT_LISTENER_A = 10
LISTENER_A=
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = yourHost.domain)
(PORT = 1521)))
SID_LIST_LISTENER_A =
(SID_LIST =
(SID_DESC =
(SID_NAME = yourSID)
(PRESPAWN_MAX = 50)))
# Define the second listener...
STARTUP_WAIT_TIME_LISTENER_B = 0
CONNECT_TIMEOUT_LISTENER_B = 10
LISTENER_B=
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = yourHost.domain)
(PORT = 1522)))
SID_LIST_LISTENER_B =
(SID_LIST =
(SID_DESC =
(SID_NAME = yourSID)
(PRESPAWN_MAX = 50)))
The TNSNAMES.ORA service for this database would be something like:
oradb1.world =
(description_list=
(description=
(address_list=
(address=
(protocol=tcp)
(host=yourHost.domain)
(port=1521)))
(connect_data =
(sid = yourSID)))
(description =
(address_list =
(address=
(protocol=tcp)
(host=yourHost.domain)
(port=1522)))
(connect_data =
(sid = yourSID))))
Back to top of file
(ADDRESS =
(COMMUNITY = TCP_COMM)
(PROTOCOL = TCP)
(HOST = Machine01))
(ADDRESS =
(COMMUNITY = TCP_COMM)
(PROTOCOL = TCP)
(HOST = Machine02)))
(CONNECT_DATA=(
(SID=oradb1))))
Suppose Machine01 is down, then every new SQL*NET connection using service oradb1 will automatically login to
Machine02. However, there is one restriction, the SID must be the same on both machines. This feature can provide
guaranteed login for application servers and for the Oracle Parallel Server.
Back to top of file
How to get your listener to register itself with the Names Server?
Edit your LISTENER.ORA file and add a line USE_PLUGANDPLAY_listener_name=ON for each listener defined
on your machine. Secondly, assign a GLOBAL_DBNAME parameter for each listener.
Sample LISTENER.ORA file:
USE_PLUG_AND_PLAY_LISTENER = ON
LISTENER =
(ADDRESS_LIST =
(ADDRESS=
(PROTOCOL=IPC)
(KEY= wblp-nt-011b_orcl.companyX.com)
)
(ADDRESS=
(PROTOCOL=IPC)
(KEY= orcl)
)
(ADDRESS =
(COMMUNITY = TCPIP.companyX.com)
(PROTOCOL = TCP)
(Host = wblp-nt-011b.companyX.com)
(Port = 1526)
)
)
STARTUP_WAIT_TIME_LISTENER = 0
CONNECT_TIMEOUT_LISTENER = 10
TRACE_LEVEL_LISTENER = OFF
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = wblp-nt-011b_orcl.companyX.com)
(SID_NAME = orcl)
(ORACLE_HOME = /)
(PRESPAWN_MAX = 10)
)
)
Back to top of file
How can I check if a listener registered itself with the Names Server?
Issue the LSNRCTL command and type either SERVICES or STATUS. If the listener successfully registered itself
with the Oracle Names server you will notice the keyword "Registered" next to the service name. Example:
Services Summary...
oraweb(Registered)
has 1 service handler(s)
Back to top of file
Connenction Concentration
Access Control
Multiprotocol Support
Provide Java applets to connect to a database that is not on the machine the Java applet was downloaded
from.
Back to top of file
# Wildcard is "x"
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
...
Back to top of file
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 the select
matching records from other tables on a row-by-row basis, inserting the results into a temporary table for later
retrieval.
Back to top of file
DEPT10,
DEPT20,
DEPT30,
DEPT40
JOB
DEPT10
DEPT20
DEPT30
DEPT40
--------- ---------- ---------- ---------- ---------ANALYST
6000
CLERK
1300
1900
950
MANAGER
2450
2975
2850
PRESIDENT
5000
SALESMAN
5600
Back to top of file
How can one dump/ examine the exact content of a database column?
SELECT DUMP(col1)
FROM tab1
WHERE cond1 = val1;
DUMP(COL1)
------------------------------------Typ=96 Len=4: 65,66,67,32
For this example the type is 96, indicating CHAR, and the last byte in the column is 32, which is the ASCII code for
a space. This tells us that this column is blank-padded.
Back to top of file
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
Reports 2.5 :
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
1.
2.
3.
4.
5.
6.
7.
8.
What are the minimum priveleges required to be given to a newly created user?
What is a synonym? Diff between a view and a synonym
If Db is mounted but not open, which view can U access
Contents of a control file
How to mirror a control file?
What is a instance?
Where does oracle log its errors?
Which process does automatic recovery if an instance fails before writing into datafile but after issuing a
commit statement?
9. How can u maintain consistency across forms?
10. How do constraints differ from DB triggers?
11. If rollback statement has been dropped or corrupted( eg. By deleting the file in O.S ) what will hapen during
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
DBA RESPONSIBALITIES :
1)Install & upgrade the ORACLE7 server and application tools
2)Create primary database storage structures and primary objects
3)Allocate system storage and plan future storage requirements for the database system.
4)Modify the database structure
5)Enrol Users.
6)Control and monitor user access to the database
7)Backup and recover the database
8)Maintain system security.
9)Monitor and optimize database performance.
ORACLE ARCHITECTURE
Consists of System Global Area, Background processes, Database files, Redolog files, control files & Parameter
files
I. SYSTEM GLOBAL AREA consists of Shared Pool (Shared SQL Area), Database buffer Cache, Redolog
buffer.
Shared Pool consists of Library cache & Data Dictionary cache, Parsed form of the SQL or PL/SQL statements,
Execution Plan for SQL and PL/SQL statements, Data dictionary cache containing rows of datadictionary
information.
Three Phases of processing SQL statements.
I. PARSE
:Checks syntax, Queries the datadictionary for object resolution, security privileges and the most
effective search path, Determines the parse tree or Execution Plan.
II. EXECUTE :Applies parse tree to data buffers, performs physical reads or logical read writes.
III. FETCH
:Retrieves row of data for a select statement.
Database buffer Cache : The database buffer cache hold copies of data blocks read from disk, shared by all
ORACLE user processes concurrently connected to the instance, the size is determined by the parameter
DB_BLOCK_SIZE.
The number of block cached in memory is determined by the parameter
DB_BLOCK_BUFFERS.
REDOLOG Buffer
:The redo log buffer is a circular buffer containing information about changes made to the
database. Stores all changes made to the database in the redo entries of redo log buffer, used to reconstruct or
rollback changes made to the database when recovery is necessary. The size of redo log buffer is determined by the
parameter
LOG_BUFFER.
II.
BACKGROUND PROCESSES :
1)DBWR
2)User
3)LGWR
:Oracle records all changes made to the database in the redolog buffer. LGWR process writes the
information in the redo log buffer to disk when a commit occurs, the redo log buffer pool reaches one third full
threshold, the DBWR needs to clean the buffer blocks for a checkpoint or a time out(3 sec) occurs.
4)ARCH
become full.
:The Archiver process copies online redo log files to a designated storage device once they
5)PMON
:The Process Monitor cleans up abnormally terminated connections, Roll back uncommitted
transactions, Releases locks held by terminated process. Free SGA resources allocated to the failed processes,
Detects deadlocks and automatically resolves by rolling back the transaction.
6)SMON
7)RECO
8)LCkn :The Lock process performs inter instance locking in a parallel server system.
9)Dnnn :The Dispatcher process gets the request from user processes and puts in request que in SGA, & also gets
the response from response que in SGA and passes back to user process.
10)LISTENER :The listener process identifies the path and protocol in MTS environment.
11)Server
:A server process communicates with user process and SGA. & datafiles. Parses and executes SQL
statements, Reads datablock from disk into the shared database buffers of the SGA, returns the results of SQL
statements to the userprocesses.
12)CKPT
:process updates headers of data and control files after check point has been completed, more
frequent checkpoint will reduce the time necessary for recovering from instance failure, at the expense of
performance, the check point process is enabled through the parameter CHECKPOINT_PROCESS.
13)SNPn
Snapshot refresher
SGA
:Every time ORACLE is started, the SGA is allocated and the ORACLE background processes are started.
The combination of memory buffers and background processes is called an ORACLE instance
ORACLE database is composed of Control files, and the database and redo log files named in control files.
III
Data files
: Contain all the database data, logical structures such as tables and indexes, are
physically stored in the datafiles.
Redolog files
:Transaction logs record all changes made to the database and are used for data recovery, if the
redo log files are mirrored, the same redolog information is written to multiple online redo log files. The redo log
files are written to in a circular fashion, there must be at least two redo log groups.
Log Switches
:A log switch occurs when ORACLE switches from one relog to another, when LGWR has filled
one log file group, A log switch can be forced by a DBA when current redo log needs to be archived ( ALTER
SYSTEM SWITCH LOGFILE), At a log switch the current redo log is assigned a log sequence number that
identifies the information stored in that redo log and is also used for synchronization, A checkpoint automatically
occurs at logswitch.
CHECKPOINT :During a check point DBWR writes all dirty buffer in the database buffer cache to disk,
guaranteeing that all data blocks are modified since the Previous checkpoint are actually written to disk.
A Check point occurs at every log switch, a specified number of seconds after the last database checkpoint, when a
predetermined number of redo log blocks have been written to disk since the last check point, at instance shutdown,
when forced by DBA (ALTER SYSTEM CHECKPOINT) , when a table space is taken offline.
During a check point and after the log switch LGWR will update the headers of database and control files, unless
check point process has been started, The parameter LOG_CHECKPOINT_TIMEOUT determines the interval of
time after which another check point occurs, The parameter LOG_CHECKPOINT_INTERVAL determines the
number of newly filled redo log file blocks needed to initiate a checkpoint.
CONTROL FILES
:The control file is a small binary file that describes the structure of the database, All
necessary database files and log files are identified by the control files, the name of the database is stored in the
control file, the control file is required to open and access the database, synchronization information needed for
recovery is stored inside the control file. It is advised to have minimum of two control files on different disks. The
parameter CONTROL_FILES identifies the Control files. Parameter file points to control file, Control file points to
redo log files and database files.
STARTUP STEPS
1)The Init.ora is read, the SGA is created, the background processes are started and the instance is started.
PROCESSING A REQUEST
A user send a request to its dispatcher.
The dispatcher places the request into the request queue in the SGA.
A shared server picks up the request from the request queue and processes the request.
The shared server places the response on the calling dispatchers response queue
The dispatcher returns the response to the user.
Steps to configure Multi-threaded Server.
1. Configure and start the listener process.
2. Specify the dispatcher service name
3. Specify the initial number of dispatchers
4. Specify the maximum number of dispatchers
5. Specify the initial number of shared servers
6. specify the maximum number of shared servers
In the parameter file following parameter are to be set.
MTS_LISTENER_ADDRESS
:Address of listener process
(address=(protocol=tcp)(host=erseq5) (PORT=7000))
MTS_SERVICE
;Name of the service
MTS_DISPATCHERS
:Initial number of dispatcher process
MTS_MAX_DISPATCHERS
:Maximum number of dispatcher process
MTS_SERVERS
:Initial number of shared servers
MTS_MAX_SERVERS
:Maximum number of shared servers.
3)$lsnrctl start (this command will start the listener process, it is advised to start the listener process before the
starting database).
On the client end connect string has to be specified in the file tnsnames.ora
Colin = (Description = (Address=(Protocol=TCP) (Host=erseq5) (PORT=7000) (CONNECT_DATA=(SID=prod)))
$sqlplus scott/tiger@colin
DATABASE STORAGE
TERM
DEFINITION
BLOCK
EXTENT
SEGMENT
tablespace
:A set of one or more extents that contains all the data for a specific structure within a
DATABASE
An ORACLE datablock is the smallest unit of I/O used by the database also called logical blocks and ORACLE
blocks which corresponds to one or more physical blocks on disk. The size is determined upon database creation by
initialization parameter DB_BLOCK_SIZE which is constant throughout all datafiles. Size also determines the size
of each database buffer in SGA. The block size cannot be changed after database creation except by recreating the
database. The block size should be equal to the size of O.S block size or more that that, typically 2K or 4K bytes.
PARTS OF DATABASE BLOCK
HEADER
:Contain general block information, such as the block address, and the segment type. On the
average, the fixed and variable portions of the block total 85 to 100 bytes.
TABLE DIRECTORY
:Stores information about the tables in the cluster and is used with clustered segments.
ROW DIRECTORY
overhead per row.
:Contains row information about the actual rows in the block. Allow two bytes of
FREE SPACE
:Consists of set of bytes in the block that is still available for insert, or update space requirements.
ROW DATA
The PCTFREE parameter can also be specified when creating or altering indexes.
Increasing PCTFREE reduces the occurrence of rowchaining and row migration. A PCTFREE set too low for a
given table may result in row migration.
:Reduces processing costs because blocks are not often free, increases unused space.
:Increases processing costs because blocks may often become free, improves space usage.
INITTRANS
: is the initial number of transaction entries, for concurrent transactions, that are allocated in each
block header when block is allocated (default is 1, minimum 1, maximum 255). Each transaction entry is 23 bytes
in length.
MAXTRANS :is the maximum number of concurrent transaction that a block will support (default 255,
minimum 1, maximum 255)
EXTENTS
:
An extent is a set of contiguous blocks allocated to a segment, when a database object grows, space is
allocated to it.
Each segment in a database created with at least one extent to hold its data, Rollback segment, however always have
at least two extents.
The first extent is called the segments INITAL extent.
Subsequent extents are called the segments NEXT extent.
An object will only allocate a new extent if all of its currently allocated extents are already used.
Frequently de-allocation of extents can lead to fragmented physical data files.
Specified storage parameters:
INITIAL
:Size in bytes of the first extent allocated to a segment. Default is the equivalent of 5 data blocks.
NEXT
data blocks.
:Size in bytes of the next incremental extent allocated to a segment. Default is the equivalent of 5
MAXEXTENTS :Total number of extents that can ever be allocated for the segments. The maximum depends upon
the ORACLE block size, default is 121.
MINEXTENTS :Total number of extents to be allocated when the segment is created. Default is one extent.
PCTINCREASE:Percent by which each incremental extent grows over the last incremental extent allocated.
Default is 50 percent.
OPTIMAL
:Specifies the optimal size in bytes for a rollback segment. Default is null.
FREELISTS
A Segments is a set of one or more extents that contain all the data for a specific type of logical storage structure
within a tablespace.
A segment is a logical structure that can be created, will occupy storage, and can grow. Segments cannot span
tablespaces. An extent is a set of contiguous database blocks. The storage parameters for temporary segments
always use the default storage parameters set for the associated tablespace , they can never be set explicitly.
DATA SEGMENT
:A collection of extents that holds all the data for a table or a cluster. When a table is
created in table space data segment gets created.
Ex. Create Table tablename ( colname datatype)
PCTFREE 5 PCTUSED 65
STORAGE(
INITIAL
5M
NEXT
5M
PCTINCREASE
0
MINEXTENTS
1
MAXEXTENTS
121)
TABLESPACE tablespacename;
INDEX SEGMENT
:A collection of extents that holds all of the index data for search optimization on large
tables and clusters. If an index is created on a table, an index segment is created for each index.
Ex. Create Index indexname on tablename (colname)
STORAGE (INITIAL 500K NEXT 500K PCTINCREASE 0)
TABLESPACE tablespacename;
TEMPORARY SEGMENT
:A collection of extents that holds data belonging to temporary tables created
during a sort operation. Temporary segments provide workspace for the RDBMS to sort and join tables while
performing complex searches, reclaimed at the end of the transaction (SMON process), space allocation determined
by default storage of its tablespace, not protected by redolog.
ROLLBACK SEGMENT
:A collection of extents that hold rollback data for rollback, read-consistency or
recovery. Rollback segment entries are written in circular fashion for rollback, read consistency and recovery.
Consists of several rollback entries from multiple transactions.
Ex. SQL >CREATE PUBLIC ROLLBACK SEGMENT rbs01
TABLESPACE rbs
STORAGE(INITIAL 10K NEXT 10K OPTIMAL 20K MAXEXTENTS 121);
After creating set the rollback segment online.
SQL >ALTER ROLLBACK SEGMENT rbs01 ONLINE;
BOOTSTRAP SEGMENT
;An extent that contains dictionary definitions for dictionary tables to be loaded
when the database is opened. Requires no attention on the part of the Database storage Administrator
The bootstrap segment contains data dictionary tables to be loaded when the database is opened. It cannot be read,
modified, or dropped. Exists in system tablespace and is owned by the user sys. Usually needs less than 50
ORACLE BLOCKS.
TABLESPACES & DATAFILES
Data in an ORACLE database is logically stored in tablespaces and physically stored in database files.
The ORACLE database can be logically divided into separate tablespaces. The system tablespace must exist in
order for the database to run. Tablespaces are designated to contain sever database segments.
Each tablespaces contains one or more operating system files.
Tablespace can be brought online while the database is running.
Tablespace can be taken offline except the system tablespace, leaving database running.
Objects created in a tablespace can never be allocated space outside of their original tablespace.
TABLESPACE USAGES;
Control space allocation and assign space quotas to users.
Control availability of data by taking individual tablespaces online or offline.
Distribute data storage across devices to improve I/O performance and reduce I/O contention against a single disk.
Perform partial backup and partial recovery operations.
where as the On-Message will fire for all the message commands including
the error messages.
Generally an On-Message trigger is used for the following purposes:
A) I dont remember from top of my head right now but somewhere around 25.
7) In both?
A) No only in 4.0. Developed around another 15-20 in 3.0.
8) So roughly about 40. How about reports. You worked on both 2.0 and 1.1 right?
A) Right.
9) How many reports you developed in each of them?
A) Around 40 in reports 2.0 and 20 in 1.1.
10) How many of them were complex?
A) About 5 in 2.0 and in 1.1 most of them were simple.
11) OK so I will write about 10 in both of them. On the level of 1..5, 1 is trained, 2 is modest, 3 is average, 4 is
proficient and 5 is expert., how will you rate yourself in forms 4.0?
A) I will rate myself 4.
12) In forms 3.0?
A) Forms 3.0 also 4.
13) In reports 2.0 and 1.1
A) In reports 2.0 4 and 1.1 I rate myself 3.
14) How long you are working in SQL*Plus?
A) About 4 years
15) And in PL/SQL?
A) About three and half years.
16) How you rate your skills in these Oracle Tools?
A) In SQL*Plus, PL/SQL and SQL*Loader I rate myself 4.
17) Have you worked on Pro*C?
A) Not on any live projects but I have worked on C
18) How long you are working in C?
A) About 4-5 months.
19) How long you are working in Oracle Financials?
A) For about one and half years.
20) Which all modules you worked on Oracle Financials?
A) Mainly Accounts Payable.
21) How long? For one and half years?
A) It is difficult to say but for about one year because I worked on other modules also interactively?
22) Which other modules you have worked and approximately how long?
A) In Purchasing for 2 months and General Ledger for about 2-3 months.
23) Have you worked on Accounts Receivables? Or Manufacturing like Oracle MRP or BOM?
A) No.
24) Have you worked as a DBA?
A) No.
Oracle by default use the cost based optimization for finding the best execution path.
J : How do you go about tuning init.ora parameters ?
P : Monitoring the contention level of objects like database buffers, library cache, redo log buffer
over a period of time, we can alter the init.ora parameters for better performance.
J : How to identify badly written reports without using trace ?
P : Using v$sqlarea, one can monitor the performance of sql statements used in the reports.
J : Okay. Thank you. bye.
P : Okay. Thanks bye bye.
Date:
Venue :
Interviewee
Interviewer
:
24th Sep 1996
European Operations
:
T.Geresh and Rajkumar
:
Oracle Group
1)
2)
3)
4)
5)
6)
7)
8)
9)
10)
11)
12)
13)
14)
15)
16)
17)
18)
19)
20)
21)
22)
23)
24)
25)
26)
27)
28)
29)
30)
31)
32)
33)
34)
35)
36)
37)
38)
39)
40)
What are the multithreaded server and how it is different from dedicated server .
What are the new features incorporated in ORACLE 7.2 version.
What are the various difference between ORACLE 6.0 ORCALE7.0.
How many types of triggers U have used in your application.
What are the difference between WHEN-VALIDATE-ITEM and POST-CHANGE trigger.
What is Record group and what are the advantages of having it.
What is the differences between Tlist,ComboBox and PopList properties of list items.
What are the differences between copying and referencing an object.
What is MDI Window.
What is the procedure to call a Microsoft Application from forms 4.5.
What is VBX controls and how it helps to build an application in Forms 4.5.
How Parameters will be passed to other Oracle tools.
What kind of quality management Sonata is having.
What is meant by ISO9000 an dwhat are the advantage to have it.
What do you mean by debugger in Forms 4.5
While debugging we can change the script or not.
Can We have an OLE server for Oracle application.
are the various variables in Proc and how we are declaring it.
What is meant by Indicator variable in Pro*C
What is difference between SQLCA and ORACA.
How You are trapping errors in Pro*C program
What is meant by UserExits and how we You will call it from your forms 4.5 application.
What is difference between UserExits and Pro*C program
What are the various triggers that Reports 2.5 supports.
What is icon.
How many(minimum) groups are required to prepare a Matrix Report.
What do you mean by bind parameter and lexical parameter.
What are the various difference in UNIX and WINDOWS95 Operating systems.
What are the various differences in Forms 3.0 and Forms 4.5
Can I have a HTML document from Forms 45 application.
What do you mean by activation style property of an OLE object.
What is difference in Object embedding and object Linking.
What are the situations in which we can go for embedding and in which we can go for Linking.
How You are connecting to Oracle database and what is meant by connect string.
What are the difference between Post-fetch and Post-Query trigger and when they will fire.
What is meant by partition view.
What are various triggers that You have extensively used in your application.
What is difference between following built-ins
Create_group_with_query and Populate_group_with_query.
What is Dynamic SQL.
41)
42)
43)
44)
45)
46)
47)
48)
49)
50)
51)
52)
53)
54)
55)
56)
57)
58)
59)
60)
Venue : ODSI
Date : 16-Sep-96
Interviewers : Sushil Kumar (from CST)
Interviewee : Shridhar Kamat
(After initial introduction)
1) Since how long you have been in Oracle Financials?
A) Since January 95 I am in Oracle Financials
2) Tell me about the projects you have done?
A) (Explained to him about the Custom Purchasing report for Honeywell, Interface mapping system for Starkey.
Interrupting)
3) So you have worked on Purchasing, Have you worked on GL?
A) I have worked on GL, Purchasing and AP modules?
4) Have you worked on FA (Fixed Assets)?
A) No.
5) That is fine. What all work you did in your projects?
A) Mainly I was involved in writing custom reports. I have also written some PL/SQL blocks. I was handling the
technical side. After creating reports I also implemented it using AOL in .. (Interrupting)
6) OK! My client Hemal may give you call today. Give me your residence number
A) (Gave him the residence number)
7) He has requirements in Denver and Omaha. He is also an Indian. He is staying here for almost 15-20 years. You
have an excellent communication skills. However, when you talk to him, talk in American accent so that he will
be thoroughly impressed. He may give a call as soon as he receives your resume. Then I will give you call
sometime in the evening. Are you available?
A) Yes. Certainly. I will be in the Office till 5.00 pm after that you can reach at my residence.
8) OK! Bye now.
A) Bye
P: There is a concept called two-phase commit. In the first phase, the server makes sure that all sites are available for
transaction. If all are available, then the commit/rollback phase occurs. If any transaction is held up due to
unavailability of resources in the target site, the transaction is named in-doubt transaction and data is stored in the
data dictionary of the target site. This will be later committed/rolled back by RECO background process. DBA can
also see the status of in-doubt transaction and based on the comment given along with commit/rollback, he can take
commit/rollback manually.
A: what was your backup strategy ?
P: Everyday I used to take hot backup along with archived redo logs. Besides, I used to take ascii text backup for a
few important tables using exp command.
A: Have you done database recovery ?
P: Yes. 5 times I have recovered database, mostly data files using archived redo logs and old data files.
A: Have you done trigger based applications ?
P: Yes, I have done many applications using DBS triggers. If you are specific, I can tell you more.
A: Have you handled DML statements using triggers ?
P: Yes. I mentioned about the use of DBS triggers in one of my application.
A: How would you handle duplicate rows in a table ? I want to find out the duplicate rows. How to go about it using
primary key?
P: When one uses alter table command with exceptions clause, the duplicate row information will go into a predefined table structure.
A: Its okay with you. Do you have any questions ?
P: Yes, I want to know more about the client and nature of application.
A: He told about the clients business and the type of applications using the database.
P: Okay. Thanks. No more questions.
A: Okay. We will call you back. Thanks. Bye.
P: Thanks. Bye.
4) Oh! We have Legacy system here and we have a similar requirement for transferring data from Legacy to
Oracle tables.
A) What hardware platform you are working on?
5) We have a Sun Sparc stations here.
A) Oh! I worked for Sun Microsystems on the same platform.
6) Thats great. Did you find any difference in HP and Sun sparc.
A) I was using pentium PCs which were connected to the HP unix boxes. But I liked Sun Sparcs better.
7) Yeah! We also have some emulators which connects to the Unix system. I think I am done. Do you have any
questions?
A) What would be your highest priority?
8) We have lot of things to be done in Order Entry and Accounts Receivables.
A) When do you think you can get back to me about this project?
9) Well, I have no authority. Sharie is my project manager and she will get back to you. Do you have any other
questions?
A) No.
10) Ok! Thanks!
A) Thanks a lot
Interview Transcript (Telephonic)
Staff Name : Poominathan R.
Interviewer : Charles Schwab Financial Systems.
Date
: August 29, 1996.
Duration : 30 mins.
C: What is your experience on handling large databases ?
P: I have handled a database of size 2GB.
C: Can you tell me the memory structure of your database ?
P : The SGA size was of 20MB. I mentioned the size of database buffer, shared pool and redo log buffer caches.
C: How do you arrive at the SGA size ?
P: It depends on various parameters such as number of concurrent transactions at the peak hours, transaction size,
number of applications using the database, number of other processes using the system resources and system
configuration (dedicated/multi-threaded). We have to also ensure that no paging and swapping occurs for SGA.
C: How do you find whether the allotted memory resources are sufficient ?
P: We have to look for possible contention for memeory structures. for example, if the hit ratio for database buffer
cache is low, we can allot more database buffers. Likewise, we can monitor the contention for library cache, redolog
buffers, redo log latches and rollback segments.
C: Can you tell me the procedure to monitor rollback contention ?
P: Well, Using V$waitstat and V$sysstat we can see the how many times a server process waited for a free extent in
rollback segment. If the percentage of waiting is more than one, we can conclude that the number of rollback
segments are insufficient.
C: Why is OPTIMAL parameter used in rollback segment ?
P: OPTIMAL parameter is used to bring back the rollback segment size if it were to grow due to long transactions.
To arrive at the OPTIMAL size, We can monitor using MONITOR ROLLBACK from SQL*DBA. Using this, we
can see how much space ever allocated for each rollback segment in bytes, Cumulative number of times a
transaction writing from one extent in a rollback segment to another existing extent and average number of bytes in
active extents in the rollback segment, measured over a period of time.
C: What was your backup strategy ?
P: Everyday I used to take hot backup which includes taking of relevent datafiles and then control file. Maintenance
of archived redologs, taking of cold backup and maintaining ASCII version of a few tables data were the other
backup strategies formulated.
C: Have you done recovery ?
P: Yes, I have done recovery a lot many times.
C: How do you recover if a datafile is lost/damaged ?
P: First step is to see whether the database is in archivemode. Secondly, Whether the disk containing the datafile is
accessible. If not accessible, rename the datafile to another usable disk. If archived, restore the affected datafile and
archived redologs from backups; if the damaged file was part of the system tablespace, keep the database mounted
and closed; use alter database option to do recovery, if it belongs to a non-system tablespace, use alter tablespace
command to recover it after taking the tablespace offline.
C: How to recover if the database was in noarchivemode ?
P: Only way to recover the database is to restore the most recent complete backup.
C: Have you done tuning ?
P: Yes, I have tuned both applications and database.
C: How to tune an application ?
P: First, we have to ensure that the application uses well tuned SQL statements. We can use SQL trace facility and
TKPROF to see the execution plan for SQL statement. If we are not satisfied with the current execution plan, use
EXPLAIN PLAN command to see the execution plan for different versions of the SQL statement. We can choose
the SQL statement which gives faster response time as well as consumes less system resources.
C: OK. All right. You will get a call tomorrow. Do have any question to ask ?
P: Yes, I want to know what will be my role in your project.
M: The system is under development. You will be involved at this stage itself. It is expected to go to production in
Jan97.