The Oracle Server

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 14

The Oracle Server

The Oracle server is an object-relational database management


system that provides an open, comprehensive, and integrated
approach to information management. An Oracle server consists of an
Oracle database and an Oracle server instance

An Oracle Instance
Every time a database is started, a system global area (SGA) is
allocated and Oracle background processes are started. The system
global area is an area of memory used for database information
shared by the database users. The combination of the background
processes and memory buffers is called an Oracle instance.
=> A user process executes the code of an application program (such
as an Oracle Forms application) or an Oracle Tool (such as Oracle
Enterprise Manager).
=>Oracle processes are server processes that perform work for the
user processes and
background processes that perform
maintenance work for the Oracle server.

SQL CONCEPTS :
OPERATOR :
UNARY - Operated only on one operand.
e.g. operator operand
BINARY - Operated on two operands.
e.g. operand1 operator operand 2
Arithmatic Operator used in an expression to add, negate, subtract,multiply or divide
numeric values.

do not use two consecutive minus signs (--) in arithmatic


expressions to indicate double negation or subtraction of a
negative value. (--) is used to begin comments within SQL
statements.

CONCATENATION OPERATOR:
Manipulates character strings. Result of concatenating two character
strings is a character strings. If both have datatype CHAR, the result
also is of CHAR datatype.
COMPARISON OPERATOR:
Compares one expression with another. Result can be TRUE,FALSE or
UNKNOWN.
NOT IN OPERATOR :
If any item in list following a NOT IN operation is NULL, all rows
evaluate to 'UNKNOWN' (and no rows are returned).
LIKE OPERATOR :
It is used in character string comparisons with pattern matching. It
matches a portion of one character value to another by searching the
first value for the pattern specified by the second.
LOGICAL OPERATOR :
It combines the results of two component conditions to produce a
single result based on them or to invert the result of a single
condition.
e.g. NOT, AND, OR.
SET OPERATORS :
Combine results of two component queries into single result.
e.g. UNION(ALL), INTERSECT, MINUS.
UNION - eliminates duplicate selected rows.
USE-DEFINED OPERATORS :
They take a set of operands as input and return a result.

FUNCTIONS :

SQL functions are built into Oracle and are available for use in various
appropriate SQL statements. Do not confuse SQL functions with user
functions written in PL/SQL. If you call a SQL function
with a null argument, the SQL function automatically returns null.

Single-Row Functions

Single-row functions return a single result row for every row of a


queried table or view. These functions can appear in select lists,
WHERE clauses, START WITH clauses,and CONNECT BY clauses.

Number Functions
Number functions accept numeric input and return numeric values.

Character Functions Returning Character Values


CHR
CONCAT
INITCAP
LOWER
LPAD
LTRIM
NLS_INITCAP
NLS_LOWER
NLSSORT
NLS_UPPER
REPLACE
RPAD
RTRIM
SOUNDEX
SUBSTR
SUBSTRB
TRANSLATE
TRIM
UPPER

Character Functions Returning Number Values


ASCII
INSTR
INSTRB
LENGTH
LENGTHB

Date Functions
Date functions operate on values of the DATE datatype. All date
functions return a value of DATE datatype, except the
MONTHS_BETWEEN function, which returns a number.

Conversion Functions
Conversion functions convert a value from one datatype to another.
Generally, the form of the function names follows the convention
datatypeTO datatype.

Miscellaneous Single-Row Functions


Aggregate Functions
Aggregate functions return a single result row based on groups of
rows, rather than on single rows. Aggregate functions can appear in
select lists and in ORDER BY and HAVING clauses. They are
commonly used with the GROUP BY clause in a SELECT statement.
If you omit the GROUP BY clause, Oracle applies aggregate functions
in the select list to all the rows in the queried table or view.
All aggregate functions except COUNT(*) and GROUPING
ignore nulls.
You can nest aggregate functions.

Analytic Functions
Analytic functions compute an aggregate value based on a group of
rows. The group of rows is called a window and is defined by the
analytic clause. Analytic functions are the last set of operations
performed in a query except for the final ORDER BY clause. All joins
and all WHERE, GROUP BY, and HAVING clauses are completed before
the analytic functions are processed. Therefore, analytic functions can
appear only in the select list or ORDER BY clause.

Object Reference Functions


Object functions manipulate REFs, which are references to objects of
specified object types.

User-Defined Functions
You can write user-defined functions in PL/SQL or Java to provide
functionality that is not available in SQL or SQL functions. User
functions can appear in a SQL statement anywhere SQL functions can
appear, that is, wherever an expression can occur.

Data Manipulation Language Statements


Data manipulation language (DML) statements query or manipulate
data in existing schema objects. They enable you to:

Retrieve data from one or more tables or views (SELECT)


Add new rows of data into a table or view (INSERT)
Change column values in existing rows of a table or view
(UPDATE)
Remove rows from tables or views (DELETE)
See the execution plan for a SQL statement (EXPLAIN PLAN)
Lock a table or view, temporarily limiting other users' access
(LOCK TABLE)

Transaction Control Statements


Transaction control statements manage the changes made by DML
statements and group DML statements into transactions. They enable
you to:

Make a transaction's changes permanent (COMMIT)


Undo the changes in a transaction, either since the transaction
started or since a savepoint (ROLLBACK)
Set a point to which you can roll back (SAVEPOINT)
Establish properties for a transaction (SET TRANSACTION

System Control Statements


System Control Statements
System control statements change the properties of the Oracle server
instance.

The only system control statement is ALTER SYSTEM. It enables you


to change settings (such as the minimum number of shared servers),
to kill a session, and to perform other tasks.

Cursors
A cursor is a handle or name for a private SQL area--an area in
memory in which a parsed statement and other information for
processing the statement are kept.
Although most Oracle users rely on the automatic cursor handling of
the Oracle utilities, the programmatic interfaces offer application
designers more control over cursors. In application development, a
cursor is a named resource available to a program and can be used
specifically for the parsing of SQL statements embedded within the
application.
Each user session can open multiple cursors up to the limit set by the
initialization parameter OPEN_CURSORS. However, applications should
close unneeded cursors to conserve system memory. If a cursor
cannot be opened due to a limit on the number of cursors, then the
database administrator can alter the OPEN_CURSORS initialization
parameter.

Parsing
Parsing is one stage in the processing of a SQL statement. When an
application issues a SQL statement, the application makes a parse call
to Oracle
A parse operation by Oracle allocates a shared SQL area for a SQL
statement. Once a shared SQL area has been allocated for a
statement, it can be executed repeatedly without being reparsed.
STAGES IN CREATING CURSORS:
Stage 1: Create a Cursor

Stage 2: Parse the Statement


Stage 3: Fetch Rows of a Query
Stage 4: Close the Cursor

SQL Statements
ALTER TABLE
Purpose
Use the ALTER TABLE statement to alter the definition of a
nonpartitioned table, a partitioned table, a table partition, or a table
subpartition.

Prerequisites
The table must be in your own schema, or you must have ALTER
privilege on the table, or you must have ALTER ANY TABLE system
privilege. For some operations you may also need the CREATE ANY
INDEX privilege.
Specify the name of the table to be altered.
You can modify, or drop columns from, or rename a temporary table.
However, for a temporary table, you cannot:
Add columns of nested-table or varray type. You can add
columns of other types.
Specify referential integrity (foreign key) constraints for an
added or modified column
Specify the following clauses of the LOB_storage_clause for an
added or modified LOB column: TABLESPACE, storage_clause,
LOGGING or NOLOGGING, or the LOB_index_clause.
Specify the physical_attribute_clause,
nested_table_storage_clause, parallel_clause,

allocate_extent_clause, deallocate_unused_clause, or any of the


index_organized_table clauses
Exchange partitions between a partition and a temporary table
Specify LOGGING or NOLOGGING
Specify MOVE

ALTER TABLESPACE:
Purpose
Use the ALTER TABLESPACE statement to alter an existing tablespace
or one or more of its datafiles or tempfiles.

Prerequisites
If you have ALTER TABLESPACE system privilege, you can perform any
of this statement's operations. If you have MANAGE TABLESPACE
system privilege, you can only perform the following operations:
Take the tablespace online or offline
Begin or end a backup
Make the tablespace read only or read write

ALTER TRIGGER :
Purpose
Use the ALTER TRIGGER statement to enable, disable, or compile a
database trigger.

Prerequisites
The trigger must be in your own schema or you must have ALTER ANY
TRIGGER system privilege.
In addition, to alter a trigger on DATABASE, you must have the
ADMINISTER DATABASE TRIGGER system privilege.

ALTER USER :
Purpose

Use the ALTER USER statement to change the authentication or


database resource characteristics of a database user.
ALTER USER syntax does not accept the old password. Therefore it
neither authenticates using the old password nor checks the new
password against the old before setting the new password. If these
checks against the old password are important, use the
OCIPasswordChange() call instead of ALTER USER.

Prerequisites
You must have the ALTER USER system privilege. However, you can
change your own password without this privilege.

ALTER VIEW :
Purpose
Use the ALTER VIEW statement to explicitly recompile a view that is
invalid. Explicit recompilation allows you to locate recompilation errors
before run time. You may want to recompile a view explicitly after
altering one of its base tables to ensure that the alteration does not
affect the view or other objects that depend on it.
When you issue an ALTER VIEW statement, Oracle recompiles the
view regardless of whether it is valid or invalid. Oracle also invalidates
any local objects that depend on the view.

Prerequisites
The view must be in your own schema or you must have ALTER ANY
TABLE system privilege.

COMMENT
Purpose
Use the COMMENT statement to add a comment about a table, view,
snapshot, or column into the data dictionary.
You can view the comments on a particular table or column by
querying the data dictionary views USER_TAB_COMMENTS,

DBA_TAB_COMMENTS, or ALL_TAB_COMMENTS or
USER_COL_COMMENTS, DBA_COL_COMMENTS, or
ALL_COL_COMMENTS.

Prerequisites
The table, view, or snapshot must be in your own schema or you must
have COMMENT ANY TABLE system privilege.

COMMIT
Purpose
Use the COMMIT statement to end your current transaction and make
permanent all changes performed in the transaction. A transaction is a
sequence of SQL statements that Oracle treats as a single unit. This
statement also erases all savepoints in the transaction and releases
the transaction's locks.
You can also use this statement to
Commit an in-doubt distributed transaction manually
Terminate a read-only transaction begun by a SET
TRANSACTION statement.

Prerequisites
You need no privileges to commit your current transaction.
To manually commit a distributed in-doubt transaction that you
originally committed, you must have FORCE TRANSACTION system
privilege. To manually commit a distributed in-doubt transaction that
was originally committed by another user, you must have FORCE ANY
TRANSACTION system privilege.

SYNONYMS :
A synonym is an alias for any table, view, snapshot, sequence,
procedure, function, or package. Because a synonym is simply an
alias, it requires no storage other than its definition in the data
dictionary.
Synonyms are often used for security and convenience. For example,
they can do the following:

Mask the name and owner of an object

Provide location transparency for remote objects of a distributed


database

Simplify SQL statements for database users

You can create both public and private synonyms. A public synonym is
owned by the special user group named PUBLIC and every user in a
database can access it. A private synonym is in the schema of a
specific user who has control over its availability to others.
Synonyms are very useful in both distributed and nondistributed
database environments. Synonyms can also simplify SQL statements
for users in a distributed database system.
ROLLBACK STATEMENTS :
Each database contains one or more rollback segments. A rollback
segment records the old values of data that were changed by each
transaction (whether or not committed). Rollback segments are used
to provide read consistency, to roll back transactions, and to recover
the database.
Information in a rollback segment consists of several rollback entries.
Among other information, a rollback entry includes block information
(the file number and block ID corresponding to the data that was
changed) and the data as it existed before an operation in a
transaction.
Oracle uses the rollback entries in a rollback segment to perform a
transaction rollback and to create read-consistent results for queries.
Rollback segments record the data prior to change on a pertransaction basis. For every transaction, Oracle links each new change
to the previous change. If you must roll back the transaction, Oracle
applies the changes in a chain to the data blocks in an order that
restores the data to its previous state.
When you commit a transaction, Oracle releases the rollback
information but does not immediately destroy it. The information
remains in the rollback segment to create read-consistent views of
pertinent data for queries that started before the transaction

committed. Each rollback segment can handle a fixed number of


transactions from one instance.
The number of transactions that a rollback segment can handle
is a function of the data block size, which depends on the
operating system.

DROP STATEMENT :
Data definition language (DDL) statements define, alter the structure
of, and drop schema objects. DDL statements enable you to:
Create, alter, and drop schema objects and other database structures,
including the database itself and database users (CREATE, ALTER,
DROP).

UPDATE STATEMENT :
Data definition language (DDL) statements define, alter the structure
of, and drop schema objects. DDL statements enable you to: Change
column values in existing rows of a table or view (UPDATE)

INDEXES :
Indexes are optional structures associated with tables and clusters.
You can create indexes on one or more columns of a table to speed
SQL statement execution on that table. Just as the index in this
manual helps you locate information faster than if there were no
index, an Oracle index provides a faster access path to table data.
Indexes are the primary means of reducing disk I/O when properly
used.
You can create an unlimited number of indexes for a table if the
combination of columns differs for each index. You can create more
than one index using the same columns if you specify distinctly
different combinations of the columns.
You cannot create an index that references only one column in a table
if another such index already exists.
Oracle provides several indexing schemes, which provide
complementary performance functionality:
.

B-tree indexes
B-tree cluster indexes

Hash cluster indexes


Reverse key indexes
Bitmap indexes

Oracle also provides support for function-based indexes and domain


indexes specific to an application or cartridge.
An index is merely a fast access path to the data. Indexes are
logically and physically independent of the data in the associated
table.
Advantages of B-tree Structure :

B-tree indexes automatically stay balanced.


All blocks of the B-tree are three-quarters full on the average.
B-trees provide excellent retrieval performance for a wide range
of queries, including exact match and range searches.

B-tree performance is good for both small and large tables, and
does not degrade as the size of a table grows.
REVERSE KEY INDEXES :
Creating a reverse key index, compared to a standard index, reverses
the bytes of each column indexed (except the rowid) while keeping
the column order. Such an arrangement can help avoid performance
degradation in an Oracle Parallel Server environment where
modifications to the index are concentrated on a small set of leaf
blocks. By reversing the keys of the index, the insertions become
distributed across all leaf keys in the index.
BITMAP INDEXES :
The purpose of an index is to provide pointers to the rows in a table
that contain a given key value. In a regular index, this is achieved by
storing a list of rowids for each key corresponding to the rows with
that key value. Oracle stores each key value repeatedly with each
stored rowid. In a bitmap index, a bitmap for each key value is used
instead of a list of rowids.
Bitmap indexing efficiently merges indexes that correspond to several
conditions in a WHERE clause.

You might also like