Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
3Activity
0 of .
Results for:
No results containing your search query
P. 1
Oracle Questions and Answers 3

Oracle Questions and Answers 3

Ratings: (0)|Views: 36 |Likes:
Published by Ashok Babu

More info:

Published by: Ashok Babu on Oct 12, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

12/11/2012

pdf

text

original

 
Quick Reference
 
1.Triggers
There are two kinds of triggers basically.(1)Row Level Triggers(2)Statement Level TriggersIt can be again broadly classified as follows
Row Level
BEFORE INSERTAFTER INSERTBEFORE UPDATEAFTER UPDATEBEFORE DELETEAFTER DELETE
StatementLevel
BEFORE INSERTAFTER INSERTBEFORE UPDATEAFTER UPDATEBEFORE DELETEAFTER DELETE
2. Cursor
Oracle server uses work areas called private SQL areas to execute SQL statements and tostore processing information. PL/SQL cursors can be used to name a private SQL areaand access its stored information.There are two kinds of cursors namely(1)Implicit Cursor Declared for all DML and PL/SQL Select statements.Opens a work area called as SQL. Therefore the cursor attributes for implicit cursorswould prefix with SQL i.e., SQL%FOUND.
Note: We replace SQL with the cursor name for Explicit Cursors.
Usage
1. To find out the number of rows updated by an updated query.Sql%rowcount2. Suppose we want to know whether the query returns any value.Eg: select * from emp where emp_id = 1234;Sql%found gives TRUE it retrieves.(2) Explicit Cursor When we declare a cursor, it is called explicit cursor Eg: Cursor c is select * from EMP;
1
 
A
CTIVITIES
 
ASSOCIATED
 
WITH
C
URSORS
 1.Declaration of a curso2.Open a curso3.Fetch rows4.Close curso Note: for Explicit cursor above 4 activities are done by programmer where as for ImplicitOracle does it.
Cursor Attributes (cursor variables)
1.%found2.%notfound3.%isopen4.%rowcount
 
4. SQL Commands
1.DQL – Data query Language (select)2.DML – Data Manipulation Language (insert, update, delete)3.DDL – Data Definition Language (create, alter, drop, truncate)4.TCL – Transaction Control Language (commit, rollback, savepoint)5.DCL – Data Control Language (grant, revoke)
5. Truncate V/S DeleteTRUNCATEDELETE
Truncate reuse storage will retain thespaceRollback is possible for delete as itcreates rollback segmentsTruncate cannot be conditional.Delete can be conditional.Truncate resets high-water mark if dropstorage option is given.Delete don’t reset.
6. Joins
Joins are used to combine rows from two or more Tables. There are different kinds of Joins1.Self Join2.Equi Join/Inner Join(Natural Join)3.Outer Joins (Left/Right/Full)4. Cross JoinTo explain two table are used. See the Structure and data for the tables
EMPB
DPTB
2
 
SQL>
desc empb;
 Name Null? Type------------------------------- -------- ----ID NUMBER NAME CHAR(10)DPT NUMBER MNG NUMBER SQL>
desc dptb;
 Name Null? Type------------------------------- -------- ----DPT NUMBER DPT_NAME CHAR(10)SQL>
select * from empb;
ID NAME DPT MNG------------------------- ---------- ------------------------- -------------------------101 aaa 10 103102 bbb 15 101103 ccc 25 1023 rows selected.SQL>
select * from dptb;
DPT DPT_NAME------------------------- ----------10 uuu15 vvv20 www25 xxx30 yyy5 rows selected.
1. Self Join
Joining a table to itself.Self Join is used to combine rows of the same table in a different way by satisfyingcertain conditions. Take the case of table
EMPB.
Suppose we need to display the IDalong MNG (Manager) Names. See the Query given below.
SQL>select worker.id, manager.name from empb worker, empb managerwhere worker.MNG=manager.ID order by worker.id;
ID NAME-------------------- ---------------101 ccc102 aaa103 bbb3 rows selected.
3

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->