Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
SQL/Scenarios
PLSQL/Scenarios
Oracle Apps /API/Migration
FORMS PERSONALISATION
XML PUBLISHER REPORT/RDF Report
OAF
Sl.No
1
2
3
4
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Question
Basic
Which datatype stores data outside Oracle Database?
Write a query searches for PRODUCT_ID values that begin with DI_ from the ORDERS table?
Consider the following two SQL statements:
1. SELECT empno, ename, sal, comm
FROM emp WHERE comm IN (0, NULL);
2. SELECT empno, ename, sal, comm
FROM emp WHERE comm = 0 OR comm IS NULL;
Will it provide same result?
SINGLE_ROW Functions
SELECT last_name, first_name, start_date
FROM employees
WHERE hire_date < TRUNC(SYSDATE) - 5;
Use of INSTR
SUBSTR
FILE_PATH
C:\ORACLE\ORADATA\W11GR1\USERS01.DBF
C:\ORACLE\ORADATA\W11GR1\EXAMPLE01.DBF
Get me the file_name, using INSTR and SUBSTR.
DECODE function
CHAR VS VARCHAR2
Create table temp
(City CHAR(10),
Street VARCHAR(10));
Insert into temp
values('Pune','Oxford');
select length(city), length(street) from temp;
COALESCE
Difference between Primary key and unique key
How to get max salary from emp table.
How to get second max salary from emp table.
what is the difference between count(*) and count(column_name)
Difference between rownum and rowid
Difference between view and materialized view
How to refresh a materialized view
Ans
BFILE
Yes
empno
Self-Join
Rank
AnalyticFunction
ORDER BY- Yes
WHERE - No
3
1000
No
COALESCE(x1,x2,x3,x4)
DBMS_SNAPSHOT.REFRESH( 'v_materialized_foo_tbl','f');
second defines type of fresh f- fast refresh
Explanantion
The BFILE datatype stores only the locator to an external file in the database the actual data
RENAME TABLE tbl_name TO new_tbl_name
[, tbl_name2 TO new_tbl_name2]
OR
ALTER TABLE orig_name RENAME new_name;
A simple view can be updated. Rows cannot be deleted through a view if the view definition contains t
OR REPLACE
DELETE FROM
table_name A
WHERE
a.rowid >
ANY (
SELECT
B.rowid
FROM
table_name B
WHERE
A.col1 = B.col1
AND
A.col2 = B.col2
);
For NULL comparison you should be use with only IS NULL. The comm IN (0, NULL) will be treated as c
INSTR(c1, c2[,i[,j]]) takes four arguments, where c1 and c2 are character strings and i and j are intege
function returns the numeric character position in c1 where the j occurrence of c2 is found. The search
character position in c1. INSTR returns a 0 when the requested string is not found. If i is negative, the
performed backward, from right to left, but the position is still counted from left to right. Both i and j d
cannot be negative.
Eg: SELECT INSTR('mississippi','i',4,1) from dual; - Ans: 5
Here is another example using a negative argument for the beginning character position. The search f
start at the fourth position from the end and move to the left.
SELECT INSTR('mississippi','is',4,1) from dual; Ans: 5
SUBSTR(c1, x [, y]) takes three arguments, where c1 is a character string and both x and y are integer
function returns the portion of c1 that is y characters long, beginning at position x. If x is negative, the
backward (that is, right to left). This function returns NULL if y is 0 or negative. y defaults to the remai
count(*) will give including NULL values, count(column_name) exclude NULL value
Sl.No
Question
1 Can you please write a plsql structure
11 Cursor Attributes
DECLARE
BEGIN
update emp set sal = sal*2
where deptno = 100;
EXECPTION
WHEN NO DATA FOUND
WHEN OTHER
END;
IF deptno 100 is not available in emp table. Which exception it will raise
28
29 BULK COLLECT AND DYNAMIC SQL
Ans
NULL
USER_DEFINED and PRE-DEFINED
DECLARE
v_zip zipcode.zip%type := '&sv_zip';
e_child_exists EXCEPTION;
PRAGMA EXCEPTION_INIT(e_child_exists, -2292);
BEGIN
DELETE FROM zipcode
WHERE zip = v_zip;
DBMS_OUTPUT.PUT_LINE ('Zip '||v_zip||' has been deleted');
COMMIT;
EXCEPTION
WHEN e_child_exists THEN
DBMS_OUTPUT.PUT_LINE ('Delete students for this '||
'zipcode first');
END;
The purpose of using the FOR UPDATE clause is to lock the rows of the
tables you want to
update so that another user cannot perform an update until you
perform your update and
release the lock.
Yes
12
These tables do not reside in the system catalogs and are not
persistent. Temporary tables exist only during the connection that
declared them and cannot be referenced outside of that connection.
When the connection closes, the rows of the table are deleted, and the
in-memory description of the temporary table is dropped.
A PL/SQL record is a data structure that can hold data items of different
kinds. Records consist of different fields, similar to a row of a database
table.
Table Based
Cursor Based
User Defined
Explanantion
% 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.
TOO_MANY_ROWS,NO_DAT_FOUND,ZERO_DIVIDE,INVALID_CURSOR
Pass By Reference : Using the NOCOPY hint tells the compiler to use pass by reference,
RAISE_APPLICATION_ERROR (-20000, 'An id cannot be negative');
CURSOR c_course IS
SELECT course_no, cost
FROM course FOR UPDATE;
Application Trigger and Database Trigger.
Based on Level:
Statement Level and Row Level.
Based on Timings:
Before,After,Instead of.
Records:
Table Based, Cursor Based, Program Defined.
PLSQL Tables:
Varrays:
Nested Tables:
TYPE type_name IS TABLE OF element_type [NOT NULL]
INDEX BY element_type;
table_name TYPE_NAME;
EMPNO
ENAME
7369 SMITH
7499 ALLEN
7521 WARD
7566 JONES
7654 MARTIN
7698 BLAKE
7782 CLARK
7788 SCOTT
7839 KING
7844 TURNER
7876 ADAMS
7900 JAMES
7902 FORD
7934 MILLER
SALARY
COMM
DEPTNO
800
20
1600
300
30
1250
500
30
2975
20
1250
30
2850
30
2450
24500
10
3000
20
5000
50000
10
1500
0
30
1100
20
950
30
3000
20
1300
13000
10