first normal form (1nf) sets the very basic rules for an organized database: eliminate duplicative columns

from the same table. create separate tables for each group of related data and identify each row with a unique column or set of columns (the primary key). second normal form (2nf) further addresses the concept of removing duplicative data: meet all the requirements of the first normal form. remove subsets of data that apply to multiple rows of a table and place them in separate tables. create relationships between these new tables and their predecessors through the use of foreign keys. third normal form (3nf) goes one large step further: meet all the requirements of the second normal form. remove columns that are not dependent upon the primary key. finally, fourth normal form (4nf) has one additional requirement: meet all the requirements of the third normal form. a relation is in 4nf if it has no multi-valued dependencies. http://mercury.cs.weber.edu/dferro/cs0/chapter8/programs/normalizationjeremiahchristensen/cs3350_final.html http://oracle.basisconsultant.com/introduction_to_oracle.htm data log the data (of the database) resides in datafiles. because these datafiles are visible (as files) they're called physical structures as opposed to logical structures. one ore more datafiles make up a tablespace. besides of datafiles, there are two other types of physical structures: redo log files and control files the logical structures are tablespace, schema control files an oracle database must at least have one control file, but usually (for backup und recovery reasons) it has more than one (all of which are exact copies of one control file). the control file contains a number of important information that the instance needs to operate the database. the following pieces of information are held in a control file: the name (os path) of all datafiles that the database consists of, the name of the database, the timestamp of when the database was created, the checkpoint (all database changes prior to that checkpoint are saved in the datafiles) and information for rman. when a database is mounted, its control file is used to find the datafiles and redo log files for that database. because the control file is so important, it is imperative to back up the control file whenever a structural change was made in the database. redo log whenever something is changed on a datafile, oracle records it in the redo log. the name redo log indicates its purpose: when the database crashes, oracle can redo all changes on datafiles which will take the database data back to the state it was when the last redo record was written. \ use v$log, v$logfile, v$log_history and v$thread to find information about the

redo log of your database. what is pl/sql and what is it used for? pl/sql is oracle's procedural language extension to sql. pl/sql's language syntax, structure and data types are similar to that of ada. the pl/sql language includes object oriented programming techniques such as encapsulation, function overloading, information hiding (all but inheritance). pl/sql is commonly used to write data-centric programs to manipulate data in an oracle database. how can one see if somebody modified any code? code for stored procedures, functions and packages is stored in the oracle data dictionary. one can detect code changes by looking at the last_ddl_time column in the user_objects dictionary view. example: select object_name, to_char(created, 'dd-mon-rr hh24:mi') create_time, to_char(last_ddl_time, 'dd-mon-rr hh24:mi') mod_time, status from user_objects where last_ddl_time > '&check_from_date'; how can i protect my pl/sql source code? pl/sql v2.2, available with oracle7.2, implements a binary wrapper for pl/sql programs to protect the source code. this is done via a standalone utility that transforms the pl/sql source code into portable binary object code (somewhat larger than the original). this way you can distribute software without having to worry about exposing your proprietary algorithms and methods. sql*plus and sql*dba will still understand and know how to execute such scripts. just be careful, there is no "decode" command available. the syntax is: wrap iname=myscript.sql oname=xxxx.plb what is the difference between %type and %rowtype? the %type and %rowtype constructs provide data independence, reduces maintenance costs, and allows programs to adapt as the database changes to meet new business needs. %rowtype is used to declare a record with the same types as found in the specified database table, view or cursor. example: declare v_emprecord emp%rowtype; %type is used to declare a field with the same type as that of a specified table's column. example: declare v_empno ============== which of the following statements is true about implicit cursors? implicit cursors are used for sql statements that are not named. developers should use implicit cursors with great care. implicit cursors are used in cursor for loops to handle data processing. emp.empno%type;

implicit cursors are no longer a feature in oracle. which of the following is not a feature of a cursor for loop? record type declaration. opening and parsing of sql statements. fetches records from cursor. requires exit condition to be defined. a developer would like to use referential datatype declaration on a variable. the variable name is employee_lastname, and the corresponding table and column is employee, and lname, respectively. how would the developer define this variable using referential datatypes? use employee.lname%type. use employee.lname%rowtype. look up datatype for employee column on lastname table and use that. declare it to be type long. which three of the following are implicit cursor attributes? %found %too_many_rows %notfound %rowcount %rowtype if left out, which of the following would cause an infinite loop to occur in a simple loop? loop end loop if-then exit which line in the following statement will produce an error? cursor action_cursor is select name, rate, action into action_record from action_table; there are no errors in this statement. the command used to open a cursor for loop is open fetch parse none, cursor for loops handle cursor opening implicitly. what happens when rows are found using a fetch statement it causes the cursor to close it causes the cursor to open it loads the current row values into variables it creates the variables to hold the current row values what is the maximum number of handlers processed before the pl/sql block is exited when an exception occurs? only one all that apply all referenced none for which trigger timing can you reference the new and old qualifiers?

statement and row statement only row only oracle forms trigger which procedure can be used to create a customized error message? raise_error sqlerrm raise_application_error raise_server_error the check_theater trigger of the theater table has been disabled. which command can you issue to enable this trigger? alter trigger check_theater enable; enable trigger check_theater; alter table check_theater enable check_theater; enable check_theater; ===================== brief descriptions of the predefined exceptions follow: exception raised when ... access_into_null ------------ your program attempts to assign values to the attributes of an uninitialized (atomically null) object. collection_is_null ----------- your program attempts to apply collection methods other than exists to an uninitialized (atomically null) nested table or varray, or the program attempts to assign values to the elements of an uninitialized nested table or varray. cursor_already_open ------ your program attempts to open an already open cursor. a cursor must be closed before it can be reopened. a cursor for loop automatically opens the cursor to which it refers. so, your program cannot open that cursor inside the loop. dup_val_on_index -------- your program attempts to store duplicate values in a database column that is constrained by a unique index. invalid_cursor ------- your program attempts an illegal cursor operation such as closing an unopened cursor. invalid_number ------ in a sql statement, the conversion of a character string into a number fails because the string does not represent a valid number. (in procedural statements, value_error is raised.) login_denied ------- your program attempts to log on to oracle with an invalid username and/or password. no_data_found -------- a select into statement returns no rows, or your program references a deleted element in a nested table or an uninitialized element in an index-by table. sql aggregate functions such as avg and sum always return a value or a null. so, a select into statement that calls a aggregate function will never raise no_data_found. the fetch statement is expected to return no rows eventually, so when that happens, no exception is raised. not_logged_on ------ your program issues a database call without being connected to oracle.

program_error ----

pl/sql has an internal problem.

rowtype_mismatch ---- the host cursor variable and pl/sql cursor variable involved in an assignment have incompatible return types. for example, when an open host cursor variable is passed to a stored subprogram, the return types of the actual and formal parameters must be compatible. self_is_null ----- your program attempts to call a member method on a null instance. that is, the built-in parameter self (which is always the first parameter passed to a member method) is null. storage_error----pl/sql runs out of memory or memory has been corrupted.

subscript_beyond_count----- your program references a nested table or varray element using an index number larger than the number of elements in the collection. subscript_outside_limit----- your program references a nested table or varray element using an index number (-1 for example) that is outside the legal range. sys_invalid_rowid------ the conversion of a character string into a universal rowid fails because the character string does not represent a valid rowid. timeout_on_resource-----resource. a time-out occurs while oracle is waiting for a

too_many_rows------ a select into statement returns more than one row. value_error----- an arithmetic, conversion, truncation, or size-constraint error occurs. for example, when your program selects a column value into a character variable, if the value is longer than the declared length of the variable, pl/sql aborts the assignment and raises value_error. in procedural statements, value_error is raised if the conversion of a character string into a number fails. (in sql statements, invalid_number is raised.) zero_divide------ your program attempts to divide a number by zero. there are seven types of tables in oracle. heap organized tables index organized tables create table labor_hour ( work_date date, employee_no varchar2(8), constraint pk_labor_hour primary key ( employee_no)) organization index; create table labor_hour ( work_date date, employee_no varchar2(8), constraint pk_labor_hour primary key ( employee_no)) organization index overflow tablespace data_sml including employee_no;

partition by range (work_date) (partition yr80 values less than (to_date('01-jan-1990', 'dd-monyyyy')) tablespace data1, partition yr99 values less than (maxvalue) tablespace data0); create table t ( x int, y int, constraint pk_t_iot primary key(x)) organization index mapping table; clustered tables hash clustered tablels nested tables temporary tables object tables pro*cobol supports four status variables that serve as error handling mechanisms: sqlcode sqlstate sqlca (using the whenever statement) oraca you are the database administrator of your company. you are administering the company's database systems. you want to make use of the sys uer account sys (default password: change_on_install) system (default password: manager) http://www.adp-gmbh.ch/ora/concepts/tables.html associating a pl/sql exception with a number: pragma exception_init to handle error conditions (typically ora- messages) that have no predefined name, you must use the others handler or the pragma exception_init. a pragma is a compiler directive that is processed at compile time, not at run time. in pl/sql, the pragma exception_init tells the compiler to associate an exception name with an oracle error number. that lets you refer to any internal exception by name and to write a specific handler for it. when you see an error stack, or sequence of error messages, the one on top is the one that you can trap and handle. you code the pragma exception_init in the declarative part of a pl/sql block, subprogram, or package using the syntax pragma exception_init(exception_name, -oracle_error_number); where exception_name is the name of a previously declared exception and the number is a negative value corresponding to an ora- error number. the pragma must appear somewhere after the exception declaration in the same declarative section, as shown in the following example: declare deadlock_detected exception; pragma exception_init(deadlock_detected, -60); begin ... -- some operation that causes an ora-00060 error exception when deadlock_detected then

-- handle the error end; default pacakages:dbms_shared_pool dbms_profiler dbms_oracle_trace_user dbms_ldap dbms_iot default set command :auto[commit] {on|off|imm[ediate]|n} autop[rint] {on|off} autorecovery {on|off} autot[race] {on|off|trace[only]} serverout[put] {on|off} note that in general, not in and not exists are not the same!!! sql> select count(*) from emp where empno not in ( select mgr from emp ); count(*) ---------0 apparently there are no rows such that an employee is not a mgr -- everyone is a mgr (or are they) sql> select count(*) from emp t1 2 where not exists ( select null from emp t2 where t2.mgr = t1.empno ); count(*) ---------9 ahh, but now there are 9 people who are not managers. beware the null value and not in!! (also the reason why not in is sometimes avoided). not in can be just as efficient as not exists -- many orders of magnitude better even -- if an "anti-join" can be used (if the subquery is known to not return nulls)

Sign up to vote on this title
UsefulNot useful