Sie sind auf Seite 1von 12

1. Your work exp. (focus more on what you got to do.. what you know abt..

abt th
e style of coding.. how are the things structured.. your role is :: (your intera
ction with the business requirements with the business analysts... + co-develope
rs + feasibility analysis and impact analysis for the change being made + design
aspect with the DBA's + Data architects... also mention that you are involved i
n all the phases of the SLDC life cycle .. also say that you work on a agile fas
hion and organize your releases in the sprints (if possible try to create a stor
y line ;D )..
Myself Gautam raavi , Over the couple of years I have worked as a Oracle PL SQL
Developer on oracle 11g.I am good in developing the PL/SQL codes on the basis of
the requests for the change or the development implementing bussiness rules, an
d was been working on agile methodology with 7 weeks release with 3 iteration p
er release.I have good knowledge in oracle architecture, which helped me under
stand the oracle system better, to improve the performance of the system where
I have worked.I have good experience on working different tools for the pl/sql d
evelopment like toad, sql plus, sql developer etc,I have been acitvlely invovled
in planning,defining,design, develop, testing and deploying for the projects/te
ams that have been assigned to me.I have also performed the quality assurance ac
tivities and unit testing. Currently working in middle ware application in prov
iding services data flows for deploying small cells, the team consists of Techni
cal director, architect,team lead,5 application developers,2 database developers
along with usual support team like DBA`s and testing team. On daily scrum calls
we all interact to discuss on the current release issues and next releases enha
ncements or the new additons. I have a masters degree in engineering field,love
working as a part of a team, and am very motivated. I am a badminton player, re
presented my city during my bachelors.
tables (creation of tables with partitions) also look at the option like "nologg
ing" and mention abt that "compress query high" during creation of tables with p
artitions.. (have the answer why you do so?) Also look at the syntaxes if you ha
ve the create a table with collections?? at least tell you know conceptually tho
ugh never used..
Tables are the basic unit of data storage in an Oracle Database. Data is
stored in rows and columns.
Types
heap-organized table := does not store r
ows in any particular order.
Index table will improve performance ov
er the heap , here data is stored in the sequence of primary key.
external table is a read-only table whos
e metadata is stored in the database but whose data in stored outside the databa
se
With Oracle 11g, OLTP compression method
is recommended for OLTP databases. Now, with Oracle Exadata we can use QUERY L
OW, QUERY HIGH, ARCHIVE LOW, and ARCHIVE HIGH compression methods called HCC (Hy
brid Columnar Compression).
QUERY LOW
This will take more space but insert tim
e is shorter
create table talip_test_query_low nologg
ing compress for query low
QUERY HIGH
If we want to save more space, we need t
o use COMPRESS FOR QUERY HIGH method. But heres the insert time will be longer.
ARCHIVE LOW
If we have archive data then we can use
compress for archive method to save more space and less insert time.
ARCHIVE HIGH
If the time is not so important and we w
ant to save more space then we use the keyword HIGH COMPRESS FOR ARCHIVE.

Partitions
Partitioning enables us to decompose ver
y large tables and indexes into smaller and more manageable pieces called partit
ions.
Why ?
Increased availability :
Easier administration of schema objects
Reduced contention for shared resources
in OLTP systems: In some OLTP systems, partitions can decrease contention for a
shared resource.
Enhanced query performance in data wareh
ouses : data warehouse, partitioning can speed processing of ad hoc queries
Types
Range Partitioning
In range partitioning, the database maps
rows to partitions based on ranges of values of the partitioning key. Range par
titioning is the most common type of partitioning and is often used with dates.
PARTITION BY RANGE(sales_date)
(PARTITION sales_jan2000 VALUES LESS THAN(TO_DATE('02
/01/2000','DD/MM/YYYY')),
List Partitioning
In list partitioning, the database uses
a list of discrete values as the partition key for each partition.
Hash Partitioning
Interval Partitioning new feature in ora
cle 11g!!
constraints on tables
Oracle Database does not enforce
view constraints. However, we can enforce constraints on views through constrai
nts on base tables
Six Constraints
1) Not Null will not accept any
nulls
2) Unique can be null but no du
plicates accepted
3)Primary key (unique+Not null)
only one primary key allowed for a table but composite primary key can have 32
columns together as primary key.
4)Foreign key is also called as
referential integrity key, designates a column as the foreign key and establishe
s a relationship between that foreign key and a specified primary or unique key,
called the referenced key
On delete Cascade : this will de
lete the foreign key values in the child table
on delete SET NULL with replace
foreign key values with NULL
5)Check Constraint checks for th
e conditions to pass before any insert/update
6) REF Constraint ??
decode & switch differences
Decision making statements canno
t be used in the place of DECODE expression or
DECODE works with expressions wh
ich are scalar values
CASE can be directly used in PL/
SQL but DECODE can be used in PL/SQL through SQL only
nvl & nvl2
NVL ( expr1 , expr2 )
If expr1 is null, then NVL retur
ns expr2. If expr1 is not null, then NVL returns expr1.
NVL2 ( expr1 , expr2 , expr3 )
If expr1 is null, then NVL2 retu
rns expr3. If expr1 is not null, then NVL2 returns expr2.
COALESCE(expr[,expr])
Returns the first non-null expr
in the expression list.
grants & revokes (roles??) system level privilages???
A role groups several privileges
and roles, so that they can be granted to and revoked from users simultaneously
System level privileges are thos
e privileges that you need to actually do something on the system

CONNECT :Includes only the foll
owing system privilege: CREATE SESSION
Connect to the database (create
session)

SELECT_CATALOG_ROLE Provides
SELECT privilege on objects in the data dictionary
EXECUTE_CATALOG_ROLE Provides
EXECUTE privilege on objects in the data dictionary. Also, HS_ADMIN_ROLE.
DELETE_CATALOG_ROLE Provides
DELETE privilege on the system audit table (AUD$)
Create objects (create table, cr
eate index)
Perform DBA activities, like bac
kup the database (SYSDBA, SYSOPER)
sequences
CREATE SEQUENCE sequence_name
MINVALUE value
MAXVALUE value
START WITH value
INCREMENT BY value
CACHE value;
A sequence is an object in Oracl
e that is used to generate a number sequence.
CACHE Specify how many values of
the sequence the database preallocates and keeps in memory for faster access.
JOINS
Equi Join A join which contains
a equal to operator in the joins condition
non equi join A join which conta
ins other than equal to operator in the joins condition
self join joining the table itse
lf
cross join This will gives the c
ross product
natural join joining two tables
on common columns
left outer join all the rows of
left tablea and matched records of the right table
right outer join similar
full outer join all the matched,
not matched of two tables
inner join only matched records
why regular expresssions? regex_substr/regex_replace etc) why patterns?? advanta
ges?
when group by /where /having
the having clause and the group
by statement work together when using aggregate functions like SUM, AVG, MAX, et
c
Where is used to filter the reco
rds
where is performed before fecthi
ng the records but having is done once the grouping is compeleted.
analytical functions (with syntaxes and scenarios)
Rank (skip numbers), Dense_rank,
Last, First, Lag, Lead, First_value, Last_value
Syntax
analytic_function([ arguments ])
OVER (analytic_clause) -- basic
[ query_partition_clause ] [ ord
er_by_clause [ windowing_clause ] ] -- further split
SELECT empno, deptno, sal,
AVG(sal) OVER (PARTITION BY dept
no) AS avg_dept_sal
FROM emp; -- simple analytica
l function which will show avg sal against each record.
order by clause is added
SELECT empno, deptno, sal,
FIRST_VALUE(sal IGNORE NULLS) OV
ER (PARTITION BY deptno ORDER BY sal ASC NULLS LAST) AS first_val_in_dept
FROM emp;
Windowing clause
RANGE BETWEEN start_point AND en
d_point
ROWS BETWEEN start_point AND end
_point
UNBOUNDED PRECEDING : The window
starts at the first row of the partition. Only available for start points.
UNBOUNDED FOLLOWING : The window
ends at the last row of the partition. Only available for end points.
CURRENT ROW : The window starts
or ends at the current row. Can be used as start or end point.
value_expr PRECEDING : A physica
l or logical offset before the current row using a constant or expression that e
valuates to a positive numerical value. When used with RANGE, it can also be an
interval literal if the order_by_clause uses a DATE column.
value_expr FOLLOWING : As above,
but an offset after the current row.
OLAP VS OLTP
OLTP (On-line Transaction Proces
sing) deals with operational data, which is data involved in the operation of a
particular system and it is characterized by a large number of short on-line tra
nsactions (INSERT, UPDATE, and DELETE).
The main emphasis for OLTP syste
ms is put on very fast query processing, maintaining data integrity in multi-acc
ess environments and an effectiveness measured by number of transactions per sec
ond.
In addition, in an OLTP system,
the data is frequently updated and queried and to prevent data redundancy and to
prevent update anomalies the database tables are normalized, which makes the wr
ite operation in the database tables more efficient.
Example: In a banking System, yo
u withdraw amount through an ATM. Then account Number, ATM PIN Number, Amount yo
u are withdrawing and Balance amount in account are operational data elements.
An OLAP (On-line Analytical Proc
essing) deal with Historical Data or Archival Data, and it is characterized by r
elatively low volume of transactions. In addition, the Queries needed for these
systems are often very complex and involve aggregations as for OLAP systems the
response time is an effectiveness measure.
Example: If we collect last 10 y
ears data about flight reservation, the data can give us much meaningful informa
tion such as the trends in reservation. This may give useful information like pe
ak time of travel, and what kinds of people are traveling in the various classes
available (Economy/Business).
views, synonyms , DB links , materialized views (prebuilt tables/refresh interva
ls)
Views are the virtual tables. Vi
ews do not contain any data - it is just a stored query in the database that can
be executed when called.
Synonyms which is an alternative
name for a table, view, sequence, procedure, stored function, package, and so o
n .Synonyms provide both data independence and location transparency.
Public and Private synonyms , Pr
ivate synonym is to restrict the users.
Materialized View : A materializ
ed view is a replica of a target master from a single point in time.
CREATE MATERIALIZED VIEW view-na
me
BUILD [IMMEDIATE | DEFERRED]
REFRESH [FAST | COMPLETE | FORCE
]
ON [COMMIT | DEMAND ]
[[ENABLE | DISABLE] QUERY REWRIT
E]
[ON PREBUILT TABLE]
AS
SELECT ...;
build_clause
The build_clause lets you specif
y when to populate the materialized view.
IMMEDIATE Specify IMMEDIATE to i
ndicate that the materialized view is to be populated immediately. This is the d
efault.
DEFERRED Specify DEFERRED to ind
icate that the materialized view is to be populated by the next REFRESH operatio
n.
FAST : REFRESHES ON COMMIT OR ON
DEMAND
COMPLETE : TRUNCATES and COMPILE
S ON COMMIT OR DEMAND
FORCE: IF FAST FAILS IT DOES COM
PLETE.
The QUERY REWRITE clause tells t
he optimizer if the materialized view should be consider for query rewrite opera
tions.
The ON PREBUILT TABLE clause tel
ls the database to use an existing table segment, which must have the same name
as the materialized view and support the same column structure as the query.
CREATE MATERIALIZED VIEW LOG ON
employees

?*Refresh Intervals*?
WITH PRIMARY KEY
INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW emp_dat
a
PCTFREE 5 PCTUSED 60
TABLESPACE example
STORAGE (INITIAL 50K NEXT 50K
)
REFRESH FAST NEXT sysdate + 7

AS SELECT * FROM employees;
packages (one time procedures, global & private variables & constants)..
Packages provide the following a
dvantages:
Cohesion: all the procedures and
functions relating to a specfic sub-system are in one program unit. This is jus
t good design practice but it's also easier to manage, e.g. in source control.
Constants, sub-types and other u
seful things: there's more to PL/SQL than stored procedures. Anything we can def
ine in a package spec can be shared with other programs, for instance user-defin
ed exceptions.
Overloading: the ability to defi
ne a procedure or function with the same name but different signatures.
Security: defining private proce
dures in the package body which can only be used by the package because they are
n't exposed in the specification.
Sharing common code: another ben
efit of private procedures.
We only need to grant EXECUTE on
a package rather than on several procedures.
Forward Declaration declaring the proced
ure inside the body before calling the procedure.
Functions Restrictions to be use
d in SQL
PL/SQL function should not have
out parameter, if it is called from SQL. overcome by execute :b1:=ft(:b1) bind
variable
DML from functions are not allow
ed if function is called from sql
Function should not be called fr
om DML statement, if function is selecting the same table.
cannot perform a DDL, commit or
rollback inside a function
Composite Type (Objects & Records)
Records are another type of data
types which oracle allows to be defined as a placeholder. Records are composite
datatypes, which means it is a combination of different scalar datatypes like c
har, varchar, number etc
Objects ??
Collections
A collection is an ordered group
of elements, all of the same type.
Index-By Tables (Associative Arr
ays)
Nested Table
Varrays
The first type of collection is
known as index-by tables. These behave in the same way as arrays except that hav
e no upper bounds, allowing them to constantly extend. As the name implies, the
collection is indexed using BINARY_INTEGER values, which do not need to be conse
cutive. these have been renamed to Associative Arrays and can be indexed by BIN
ARY INTEGER or VARCHAR2.
A VARRAY is similar to a nested
table except you must specifiy an upper bound in the declaration. Like nested ta
bles they can be stored in the database, but unlike nested tables individual ele
ments cannot be deleted so they remain dense.
Nested table collections are an
extension of the index-by tables. The main difference between the two is that ne
sted tables can be stored in a database column but index-by tables cannot. In ad
dition some DML operations are possible on nested tables when they are stored in
the database.
Choosing Between Nested Tables a
nd Associative Arrays
Both nested tables and associati
ve arrays (formerly known as index-by tables) use similar subscript notation, bu
t they have different characteristics when it comes to persistence and ease of p
arameter passing.
Nested tables can be stored in a
database column, but associative arrays cannot. Nested tables are appropriate f
or important data relationships that must be stored persistently.
Associative arrays are appropria
te for relatively small lookup tables where the collection can be constructed in
memory each time a procedure is called or a package is initialized. They are go
od for collecting information whose volume is unknown beforehand, because there
is no fixed limit on their size. Their index values are more flexible, because a
ssociative array subscripts can be negative, can be nonsequential, and can use s
tring values instead of numbers when appropriate.
PL/SQL automatically converts be
tween host arrays and associative arrays that use numeric key values. The most e
fficient way to pass collections to and from the database server is to use anony
mous PL/SQL blocks to bulk-bind input and output host arrays to associative arra
ys.
Choosing Between Nested Tables a
nd Varrays
Varrays are a good choice when t
he number of elements is known in advance, and when the elements are usually all
accessed in sequence. When stored in the database, varrays retain their orderin
g and subscripts.
Each varray is stored as a singl
e object, either inside the table of which it is a column (if the varray is less
than 4KB) or outside the table but still in the same tablespace (if the varray
is greater than 4KB). You must update or retrieve all elements of the varray at
the same time, which is most appropriate when performing some operation on all t
he elements at once. But you might find it impractical to store and retrieve lar
ge numbers of elements this way.
Nested tables can be sparse: you
can delete arbitrary elements, rather than just removing an item from the end.
Nested table data is stored out-of-line in a store table, a system-generated dat
abase table associated with the nested table. This makes nested tables suitable
for queries and updates that only affect some elements of the collection. You ca
nnot rely on the order and subscripts of a nested table remaining stable as the
table is stored and retrieved, because the order and subscripts are not preserve
d when a nested table is stored in the database.
Cursors
implicit cursor
A SQL (implicit) cursor is opene
d by the database to process each SQL statement that is not associated with an e
xplicit cursor
explicit cursor
An explicit cursor is a named po
inter to a private SQL area that stores information for processing a specific qu
ery or DML statementtypically, one that returns or affects multiple rows.
Ref cursors
A ref cursor is a variable, defi
ned as a cursor type, which will point to, or reference a cursor result. The adv
antage that a ref cursor has over a plain cursor is that is can be passed as a v
ariable to a procedure or a function. The REF CURSOR can be assigned to other RE
F CURSOR variables.
This is a powerful capability in
that the cursor can be opened, then passed to another block for processing, the
n returned to the original block to be closed. The cursor variable can also be r
eturned by a function and assigned to another variable. The REF CURSOR variable
is not a cursor, but a variable that points to a cursor. Before assigning a curs
or variable, a cursor type must be defined.
type author_cursor is ref cursor
; week typed
type author_cursor is ref cursor
returning author%rowtype; str
ong typed
open c1 for select * from author
Cursor attributes
isopen %notfound %found
%Count....
Exception handling
SQLLDR
A conventional path load executes SQL IN
SERT statements to populate tables in an Oracle database. A direct path load eli
minates much of the Oracle database overhead by formatting Oracle data blocks an
d writing the data blocks directly to the database files.
A direct load does not compete with othe
r users for database resources, so it can usually load data at near disk speed.
To start SQL*Loader in direct path load
mode, set the DIRECT parameter to true on the command line or in the parameter f
ile, if used, in the format:
DIRECT=true
By default, the loading method is Conven
tional.
The script, which creates the views used
by the Direct Path, is: catldr.sql (OH\rdbms\admin)
Use a Larger Bind Array
Increase the input data buffer - The sq
lldr readsize parameter determines the input data buffer size used by SQL*Loader

Use ROWS=n to Commit Less Frequently.
For conventional data loads only, rows specifies the number of rows per commit.
Issuing fewer commits will enhance performance.

Use Parallel Loads. Available with dir
ect path data loads only, this option allows multiple SQL*Loader jobs to execute
concurrently.

$ sqlldr
control=first.ctl parallel=true direct=true
$ sqlldr
control=second.ctl parallel=true direct=true
Disable Archiving During Load & Use unre
coverable. The unrecoverable option (unrecoverable load data) disables the writ
ing of the data to the redo logs. This option is available for direct path load
s only.
Hierarchical sql
START WITH specifies the root row(s) of
the hierarchy.
CONNECT BY specifies the relationship be
tween parent rows and child rows of the hierarchy.
In a hierarchical query, one expression
in condition must be qualified with the PRIOR operator to refer to the parent ro
w.
SELECT employee_id, last_name, manager_i
d
FROM employees
CONNECT BY PRIOR employee_id = manage
r_id;


Triggers
Any operation that cannot be rolled back
should not be put in the triggers. like mailing, writing to file
Mutating errors occurs normally when per
forming some DML operations and we trying to select the affected record from the
same trigger overcome using autonomus transaciton, system/table trigger and co
mpound trigger
ROW Triggers and Statement Trigger
Before and After insert
Instead of triggers DML to Views (INSERT
,UPDATE, DELETE) and also to nested tables
Triggers of system events and user event
s SE : database startup and shutdown, Server error messages events UE: user lo
gon and logoff, DDL and DML statements.
TUnning
A SQL statement can be executed in many differen
t ways, including the following:
Full table scans
Index scans
Nested loops
Hash joins
Oracle server provides the cost-based (C
BO) and rule-based (RBO) optimization
delete from t
where rowid IN ( select rid
from (select rowid rid,
row_number() over (partition by
companyid, agentid, class , status, terminationdate
order by rowid) rn
from t)
where rn <> 1;

Correlated Subquery is a sub-query that uses
values from the outer query. In this case the inner query has to be executed for
every row of outer query.

aggregates take "many rows, collapse them int
o one"
analytics "do not, there is no row colla
psing"
Pipelining negates the need of build hug
e collections by piping rows out of the function as they are created saving me
mory and allowing subsequent proceesing to start before all the rows are generat
ed.

Das könnte Ihnen auch gefallen