Professional Documents
Culture Documents
TABLES are like Arrays, used for temporary storage. The declaration of TABLE
involves 2 steps: Declare the table structure using TYPE statement and then declare the
actual table.
External tables can be used to load flat files into the database. Steps: First create a
directory say ext_dir and place the flat file (file.csv) in it and grant read/write access to it.
Then create the table as below: create table erp_ext_table ( i Number, n Varchar2(20), m
Varchar2(20) ) organization external ( type oracle_loader default directory ext_dir access
parameters ( records delimited by newline fields terminated by , missing field values are
null ) location (file.csv) ) reject limit unlimited;
Can two users update the same row at the same time? if so how?
How do you retrieve the last N records from a table?
The RANK() and DENSE_RANK() functions can be used to determine the LAST N or
BOTTOM N rows.
Declare ... Excep_name exception; procedure Excep_name is begin raise some_exc; end
Excep_name; Begin .... end;
Updates done wouldn't be Rolled Back as CREATE statement which is a DDL would
issue a COMMIT after the creation of the table.
TRUNCATE will completely erase the data where as in DELETE you have the option to
delete only few rows. TRUNCATE is DDL command where as DELETE is DML
command
Yes only INSTEAD OF trigger can be used to modify a view. CREATE OR REPLACE
TRIGGER trigger_name INSTEAD OF INSERT ON view name begin ... end;
A ref cursor is a variable, defined as a cursor type, which will point to a cursor result. The
advantage that a ref cursor has over a plain cursor is that is can be passed as a variable to
a procedure or a function. Ref Cursors are of 2 types: Weak and Strong. In the case of
Strong type, the data type of the returned cursor result is defined whereas in Weak type, it
is not defined. Eg:type erp_cursor is ref cursor; -- weak type erp_cursor is ref cursor
returning erp%rowtype; --strong declare 2 type erp_cursor is ref cursor; 3 c1 erp_cursor;
4 r_c1 articles%rowtype; 5 r2_c1 scripts%rowtype; 6 7 begin 8 open c1 for select * from
articles; 9 fetch c1 into r_c1; 10 close c1; 11 open c1 for select * from scripts; 12 fetch c1
into r2_c1; 13 close c1; 14 end;
Yes
What are the three files that are generated when you load data using SQL Loader?
Function has to return a value where procedure may or maynot return values. Function
can be used in SQL statements and procedures can not.
FND_REQUEST.SUBMIT_REQUEST()
Materialized view will not be refreshed everytime you query the view so to have good
performance when data is not changed so rapidly we use Materialized views rather than
normal views which always fetches data from tables everytime you run a query on it.
Triggers are simply stored procedures that are ran automatically by the database
whenever some event happens. The general structure of triggers is: CREATE [OR
REPLACE] TRIGGER trigger_name BEFORE (or AFTER) INSERT OR UPDATE [OF
COLUMNS] OR DELETE ON tablename [FOR EACH ROW [WHEN (condition)]]
BEGIN ... END;
TRUNCATE commits after deleting entire table i.e., cannot be rolled back. Database
triggers do not fire on TRUNCATE
What is ROWID?
To protect some of the columns of a table from other users. - To hide complexity of a
query. - To hide complexity of calculations.
What are SQLCODE and SQLERRM and why are they important for PL/SQL
developers?
SQLCODE returns the value of the error number for the last error encountered. The
SQLERRM returns the actual error message for the last error encountered. They can be
used in exception handling to report, or, store in an error log table, the error that occurred
in the code. These are especially useful for the WHEN OTHERS exception.
The tkprof tool is a tuning tool used to determine cpu and execution times for SQL
statements. You use it by first setting timed_statistics to true in the initialization file and
then turning on tracing for either the entire database via the sql_trace parameter or for the
session using the ALTER SESSION command. Once the trace file is generated you run
the tkprof tool against the trace file and then look at the output from the tkprof tool. This
can also be used to generate explain plan output.
Global temporary tables are session specific, meaning the users in other sessions cannot
see or manipulate the data in the temporary table you have created. Only you can access
or insert or delete or perform anything with the data in the temporary table in your
session and the other users cannot use or access this. Once you end your session, the data
in the temporary table will be purged.