This action might not be possible to undo. Are you sure you want to continue?
Explain the difference between a hot backup and a cold backup and the benefits associated with each. A hot backup is basically taking a backup of the database while it is still up and running and it must be in archive log mode. A cold backup is taking a backup of the database while it is shut down and does not require being in archive log mode. The benefit of taking a hot backup is that the database is still available for use while the backup is occurring and you can recover the database to any point in time. The benefit of taking a cold backup is that it is typically easier to administer the backup and recovery process. In addition, since you are taking cold backups the database does not require being in archive log mode and thus there will be a slight performance gain as the database is not cutting archive logs to disk. You have just had to restore from backup and do not have any control files. How would you go about bringing up this database? I would create a text based backup control file, stipulating where on disk all the data files where and then issue the recover command with the using backup control file clause. How do you switch from an init.ora file to a spfile? Issue the create spfile from pfile command. Explain the difference between a data block, an extent and a segment. A data block is the smallest unit of logical storage for a database object. As objects grow they take chunks of additional storage that are composed of contiguous data blocks. These groupings of contiguous data blocks are called extents. All the extents that an object takes when grouped together are considered the segment of the database object. Give two examples of how you might determine the structure of the table DEPT. Use the describe command or use the dbms_metadata.get_ddl package. Where would you look for errors from the database engine? In the alert log. Compare and contrast TRUNCATE and DELETE for a table. Both the truncate and delete command have the desired outcome of getting rid of all the rows in a table. The difference between the two is that the truncate command is a DDL operation and just moves the high water mark and produces a now rollback. The delete command, on the other hand, is a DML operation, which will produce a rollback and thus take longer to complete. Give the reasoning behind using an index. Faster access to data blocks in a table. Give the two types of tables involved in producing a star schema and the type of data they hold. Fact tables and dimension tables. A fact table contains measurements while dimension tables will contain data that will help describe the fact tables. What type of index should you use on a fact table? A Bitmap index. Give two examples of referential integrity constraints. A primary key and a foreign key. A table is classified as a parent table and you want to drop and re-create it. How would
5 6 7
10 11 12
you do this without affecting the children tables? Disable the foreign key constraint to the parent, drop the table, re-create the table, enable the foreign key constraint. Explain the difference between ARCHIVELOG mode and NOARCHIVELOG mode and the benefits and disadvantages to each. ARCHIVELOG mode is a mode that you can put the database in for creating a backup of all transactions that have occurred in the database so that you can recover to any point in time. NOARCHIVELOG mode is basically the absence of ARCHIVELOG mode and has the disadvantage of not being able to recover to any point in time. NOARCHIVELOG mode does have the advantage of not having to write transactions to an archive log and thus increases the performance of the database slightly. 14 15 What command would you use to create a backup control file? Alter database backup control file to trace. Give the stages of instance startup to a usable state where normal users may access it. STARTUP NOMOUNT - Instance startup STARTUP MOUNT - The database is mounted STARTUP OPEN - The database is opened What column differentiates the V$ views to the GV$ views and how? The INST_ID column which indicates the instance in a RAC environment the information came from. How would you go about generating an EXPLAIN plan? Create a plan table with utlxplan.sql. Use the explain plan set statement_id = 'tst1' into plan_table for a SQL statement Look at the explain plan with utlxplp.sql or utlxpls.sql How would you go about increasing the buffer cache hit ratio? Use the buffer cache advisory over a given workload and then query the v$db_cache_advice table. If a change was necessary then I would use the alter system set db_cache_size command. Explain an ORA-01555 You get this error when you get a snapshot too old within rollback. It can usually be solved by increasing the undo retention or increasing the size of rollbacks. You should also look at the logic involved in the application getting the error message. Explain the difference between $ORACLE_HOME and $ORACLE_BASE. ORACLE_BASE is the root directory for oracle. ORACLE_HOME located beneath ORACLE_BASE is where the oracle products reside. How would you determine the time zone under which a database was operating? select DBTIMEZONE from dual; Explain the use of setting GLOBAL_NAMES equal to TRUE. Setting GLOBAL_NAMES dictates how you might connect to a database. This variable is either TRUE or FALSE and if it is set to TRUE it enforces database links to have the same name as the remote database to which they are linking. What command would you use to encrypt a PL/SQL application? WRAP Explain the difference between a FUNCTION, PROCEDURE and PACKAGE.
Segment Level Statistics. They are also used to pipeline information in an ETL process. When creating a user. While a procedure does not have to return any values to the calling application. When a user process fails.25 A function and procedure are the same in that they are intended to be a collection of PL/SQL code that carries a single task. Buffer Cache Advice. Name three advisory statistics you can collect. Table functions are designed to return a set of rows through PL/SQL logic but are intended to be used as a normal table or view in a SQL statement. a function will return a single value. A package on the other hand is a collection of functions and procedures that are grouped together based on their commonality to a business function or application. what permissions must you grant to allow them to connect to the database? Grant the CONNECT to the user. in Windows the event viewer Explain materialized views and how they are used. What is the difference between a TEMPORARY tablespace and a PERMANENT tablespace? A temporary tablespace is used for temporary objects such as sort structures while permanent tablespaces are used to store those objects meant to be used as the true objects of the database. They are typically used in data warehouse or decision support systems. How would you force a log switch? ALTER SYSTEM SWITCH LOGFILE. & Timed Statistics Where in the Oracle directory tree structure are audit traces placed? In unix $ORACLE_HOME/rdbms/audit. grouped. Explain the use of table functions. Give two methods you could use to determine what DDL changes have been made. The SYSTEM tablespace. 26 27 28 29 30 31 32 33 34 35 36 37 38 . or aggregated from base tables. Name a tablespace automatically created when you create a database. what background process cleans up after it? PMON What background process refreshes materialized views? The Job Queue Processes. Redo logs are logical and physical structures that are designed to hold all the changes made to a database and are intended to aid in the recovery of a database. You could use Logminer or Streams What does coalescing a tablespace do? Coalescing is only valid for dictionary-managed tablespaces and de-fragments space by combining neighboring free extents into large single extents. How would you determine what sessions are connected and what resources they are waiting for? Use of V$SESSION and V$SESSION_WAIT Describe what redo logs are. Materialized views are objects that are reduced sets of information that have been summarized.
Change SQL prompt name SQL> set sqlprompt “Manimara > “ Manimara > Manimara > Switch to DOS prompt SQL> host How do I eliminate the duplicate rows? SQL> delete from table_name where rowid not in (select max(rowid) from table group by duplicate_values_field_name). Partitioning is a method of taking large tables and indexes and splitting them into smaller. Name two files used for network connection to a database.ORA and SQLNET. What is the difference between the SQL*Loader and IMPORT utilities? These two Oracle utilities are used for loading data into the database. TNSNAMES. What view would you use to look at the size of a data file? DBA_DATA_FILES What view would you use to determine free space in a tablespace? DBA_FREE_SPACE How would you determine who has added a row to a table? Turn on fine grain auditing for the table. 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 .ORA To see current user name Sql> show user. Explain what partitioning is and what its benefit is. more manageable pieces. The difference is that the import utility relies on the data being produced by another Oracle utility EXPORT while the SQL*Loader utility allows data to be loaded that has been produced by other utilities from different data sources just so long as it conforms to ASCII formatted or delimited files.SET_SQL_TRACE or Use ALTER SESSION SET SQL_TRACE = TRUE. How can you rebuild an index? ALTER INDEX <index_name> REBUILD. How can you enable a trace for a session? Use the DBMS_SESSION. You have just compiled a PL/SQL package but got errors.39 How do you add a data file to a tablespace? ALTER TABLESPACE <tablespace_name> ADD DATAFILE <datafile_name> SIZE <size> How do you resize a data file? ALTER DATABASE DATAFILE <datafile_name> RESIZE <new_size>. how would you view the errors? SHOW ERRORS How can you gather statistics on a table? The ANALYZE command.
--------. The output like.---------1 7782 CLARK 2 7788 SCOTT 3 7839 KING 4 7844 TURNER I know the nvl function only allows the same data type(ie.'NA') from emp. Example. ename from emp where rowid in (select rowid from emp where rownum <=&upto minus select rowid from emp where rownum<&Start).'NA') ----------------------NA 300 55 56 57 . Table Emp Empno Ename 101 Scott 102 Jiyo 103 Millor 104 Jiyo 105 Smith delete ename from emp a where rowid < ( select min(rowid) from emp b where a. 0)).or SQL> delete duplicate_values_field_name dv from table_name ta where rowid <(select min(rowid) from table_name tb where ta.).ename = b. Enter value for upto: 10 Enter value for Start: 7 ROWNUM EMPNO ENAME --------. ename from emp. Empno Ename 101 Scott 102 Millor 103 Jiyo 104 Smith How do I display row number with records? To achive this use rownum pseudocolumn with query. instead of blank space. if commission is null then the text “Not Applicable” want to display. empno. like SQL> SQL> select rownum. number or char or date Nvl(comm.dv). Output : NVL(TO_CHAR(COMM).ename). Output: 1 Scott 2 Millor 3 Jiyo 4 Smith Display the records between two range Select rownum.dv=tb. How do I write the query? SQL> select nvl(to_char(comm.
Enter value for n: 2 SAL --------3700 To view installed Oracle version information SQL> select banner from v$version. cursor_name%ISOPEN Implicit Cursor attributes Same as explicit cursor but prefixed by the word SQL SQL%Found. (' Rs.sal<=b.'JSP')) --------.'j'). 'jsp')) from emp. cursor_name%NOTFOUND. SQL%NOTFOUND. 'Jsp'))|| ' only.'J'). because oracle automatically closed the implicit cursor after executing SQL statements.sal)) FROM EMP B WHERE a. Eight Hundred only. SQL%ISOPEN Tips : 1.'j'). SQL> select sal "Salary ".')) "Sal in Words" from emp / Salary Sal in Words ------.-----------------------------------------------------800 Rs. the output like. For SQL queries returning a single row. Rs. One Thousand Two Hundred Fifty only. cursor_name%ROWCOUNT. the cursor needs to be explicitly declared. (to_char(to_date(sal. : 2. Three Thousand only. One Thousand Six Hundred only. 59 60 61 62 63 . For queries that returning more than one row. SAL (TO_CHAR(TO_DATE(SAL.----------------------------------------------------800 eight hundred 1600 one thousand six hundred 1250 one thousand two hundred fifty If you want to add some text like. PL/SQL declares all implicit cursors. 1250 Rs.sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal). PL/SQL construct to identify each and every work are used. Here SQL%ISOPEN is false. SQL%ROWCOUNT. Display the number value in Words SQL> select sal. Find out nth highest salary from emp table SELECT DISTINCT (a. Explicit Cursor attributes There are four cursor attributes used in Oracle cursor_name%Found. is called as Cursor. 1600 Rs.58 500 NA 1400 NA NA Oracle cursor : Implicit & Explicit cursors Oracle uses work areas called private SQL areas to create SQL statements. '|| (to_char(to_date(sal. 13. All are Boolean attributes.
0) in (select rowid. CURVAL. Invalid_Cursor Other way to replace query result null value with a text SQL> Set NULL ‘N/A’ to reset SQL> Set NULL ‘’ What are the more common pseudo-columns? SYSDATE. the type of optimizer will determine how indexes are used. can apply to a single table? 12 triggers. the fast execution of this task may be done at the expense of other tasks on the system as the buffer pool becomes flushed. Zero_Error. UID. ROWID.2) from emp) 2 4 6 Which date function returns number value? months_between Any three PL/SQL Exceptions? Too_many_rows. Others What are PL/SQL Cursor Exceptions? Cursor_Already_Open. USER . 65 66 67 68 69 70 71 72 Here we see a query where a full-table scan would be the most efficient processing method. mod(rownum. mod(rownum. Value_Error. but there are exceptions to this rule. 0 for Zero. How Oracle Chooses Indexes? It is interesting to note that the fastest execution for an individual task may not always be the best choice. it might be faster to perform a full-table scan. 1 3 5 Even number of records: select * from emp where (rowid. The . ROWNUM What is the output of SIGN function? 1 for positive value. Oracle is intelligent enough to use an index if it exists. the Oracle optimizer can run as either rule-based or cost-based. As a general rule. As we know. For example.1) in (select rowid. -1 for Negative value. consider the following query against a customer table: SELECT FROM WHERE AND AND AND customer_name CUSTOMER credit_rating = 'POOR' amount_due > 1000 state = 'IOWA' job_description like lower('%computer%'). In general. However.2) from emp). Because of the complex conditions and the use of Oracle extensions in the SQL.64 Display Odd/ Even number of records Odd number of records: select * from emp where (rowid. What is the maximum number of triggers. No_Data_Found. NEXTVAL.
we would not be able to use a multi-valued index. a concatenated or multi-column index can be used to improve performance. we create an index as follows: CREATE INDEX last_status_zip ON CUSTOMER (customer_last_name.most notable exception is the n-way join with a complex WHERE clause. either ascending or descending. 73 Now. customer_status. bad) with another column such as state_name (only 50 unique values). . SELECT * FROM CUSTOMER WHERE total_purchases > 5000*10. the columns have few unique values)—can be combined into an index that has better selectivity. and other functions will invalidate the index. Oracle supports the use of multi-valued indexes. We always need to remember that Oracle will only use an index when the index column is specified in its “pure” form. If this query were to be issued against the customer table. The rule-based optimizer will get “confused” and invoke a full-table scan on at least one of the tables. Oracle would never need to access any rows in the base table! Since all of the key values are contained in the index and the high-order key (customer_last_name) is in the ORDER BY clause. Unlike other relational databases. For example. However. Using Multi-Column Indexes When an SQL request is commonly issued using multiple columns. but there are some important limitations. Another reason for creating concatenated indexes is to speed the execution of queries that reference all of the values in the index. customer_zip_code CUSTOMER customer_last_name. Sometimes two columns—each with poor selectivity (i. we do have a few tricks to help us get around this obstacle. followed immediately by gross_pay descending. customer_status. which involves analyzing statistics for each table. customer_zip_code) ascending. Oracle can scan the index. neutral. The second query. For example. upper. The only remedy to this problem is to use the cost-based optimizer. if we needed to index on customer_last_name ascending. Oracle requires that all columns in the index be sorted in the same order. by virtue of the fact that it does not alter the index column. Consider the two equivalent SQL queries: SELECT * FROM CUSTOMER WHERE total_purchases/10 > 5000. retrieving the data without ever touching the base table.. would be able to use an index on the total_purchases column. For example. The use of the substr. even if the appropriate foreign key indexes exist for all of the tables. lower. consider the following query: SELECT FROM ORDER BY customer_last_name. thereby creating a multi-valued index that has far better selectivity than each column would have if indexed separately. we could combine a status field that has three values (good.e.
Consider the following Oracle table definition: CREATE TABLE ITEM ( item_nbr item_name item_description INITIAL 50K NEXT 50K PCTFREE 10 PCTUSED 60 FREELISTS 1 NUMBER. What options do I have when shutting down a database? Shutdown Options Administration Tips Databases can be shutdown with one of the following commands: • shutdown normal • shutdown transactional (Oracle 7. If the target block does not have enough room.0. and Privileged Actions can only be performed in Server Manager. dramatically improving performance. This condition can lead to many unnecessary I/Os when the row is retrieved. Oracle may create a very long chain until it finds a block with enough room to store the new column data. VARCHAR(50) ) 74 STORAGE ( ). if a row contains a lot of VARCHAR data types and the rows are initially inserted without values. this column could be added to the concatenated index. the PCTFREE parameter is only useful for the SQL UPDATE statement—and only when the UPDATE will cause the row to grow in size.3 and above only) • shutdown immediate • shutdown abort In Oracle 7 or 8. In 8i. If this block is also full. For static read-only tables. the savvy Oracle developer may also add columns to the end of the concatenated index so that the base table is never touched. the following guidelines apply when creating a concatenated index: • Use a composite index whenever two or more values are used in the SQL where the clause and the operators are ANDed together. For example. The rule here is simple: Determine the average row length and predicted growth for each row. if the above query also returned the value of the customer_address column. then use PCTFREE to reserve that amount of space on each block. since many database blocks must be read to retrieve the row. 75 PCTFREE tells Oracle how much space to reserve in each Oracle block for future updates and can have an important impact on the performance of an Oracle database if it is set too low. later updates of values into the VARCHAR fields will cause the row to expand on the block. VARCHAR(30). reserving only 5 percent of each database block for updates. In summary. with data items added at the end of the index. it is acceptable to set PCTFREE to a very small number in order to fully occupy each database block. Allocating Oracle Tables Several parameters can be used to ensure that all data stored within Oracle tables remains in an optimal configuration. For example. • Place the columns in the WHERE clause in the same order as in the index. Again. then PCTFREE should be set to 5.With the assistance of this feature. SQL Plus acquired the ability to perform . these commands must be issued within the Server Manager utility. because shutting down a database is a Privileged Action. If this is not the case. Oracle must fragment the row and store some row information on the next physical block in the tablespace.
if they managed to fit in a "commit". Obviously. If you've any sense. When all Users have been disconnected in this way. get out of the habit quickly! It works for Oracle 7. No data whatsoever is lost. When all uncommitted transactions are rolled back. it's functionally equivalent to a Shutdown Immediate. That means you must connect as SYS. Lots of Oracle 7 Users have got into the habit of doing "connect Internal". just as when you *do* accidentally pull the plug on the box. It's the equivalent of pulling the plug on the box. Once they do that. or weeks -all the while preventing the thing from actually shutting down. then Oracle flushes the entire Buffer Cache. issue a rollback or commit command). the database is ring-fenced from new connections. and (because of the ring-fence) they cannot re-connect. Instance Recoveries mean that all committed data is recovered. When everyone *does* finally remember to log themselves out. There's no nice flush of the Buffer Cache. As ever. Oracle flushes the entire Buffer Cache. issues a checkpoint. Well.Privileged Actions. if you have Users who forget to issue a rollback or commit command. Shutdown Immediate starts getting a bit rude. then "connect / as sysdba" will do the trick. but all uncommitted stuff is lost -so at the end of the day. Shutdown Abort is simply the nuclear option. Their session is nevertheless terminated. They can stay in there for days. and shuts down the database gracefully. don't break when you finally make that move to 9i. You still have trouble. But anybody already connected is left alone to do whatever they like. and shuts down the database gracefully. Oracle simply dismantles the Instance. a subsequent startup can take a long time -because all those transactions that were pending when the Instance disappeared now have to be recovered (and rolled back). If they are in the middle of a transaction. All uncommitted transactions are lost. however. The Instance just disappears. If you are using O/S authentication. and shuts down the database gracefully. issues a checkpoint. Again. though. No data whatsoever is lost. No committed data is lost. Note that the need to rollback pending transactions means that a shutdown immediate isn't always terribly immediate! I've seen one take 6 hours to complete because there were that many outstanding transactions pending at the time. no time to finish whatever transaction you were in the middle of. 8 and 8i. It just depends on whether you want the . you have to be a Privileged User. the database is ring-fenced. so you can use that tool instead. I've seen one take 3 hours to complete). a Shutdown Abort requires a subsequent Instance Recovery -and that can take time (again. But any existing Users are only allowed to finish their *current* transaction (that is. then it will have to be "connect sys/<whatever the password is> as sysdba". Of course. Shutdown Aborts therefore take practically no time to complete (a matter of seconds). In other words. tough. Shutdown Normal is terribly polite: it ring-fences the database (so no new connections are allowed). no nice checkpoint. they are forcibly disconected. If you are using a password file. to perform a Privileged Action. But existing Users are simply booted off the system. Shutdown Transactional is a bit more forceful. you'll start using the 'as sysdba' technique early. that data is safe. with the SYSDBA privilege. However. But it stops working in Oracle 9i. and whatever updates they had managed to perform are rolled back. so that scripts etc. issues a checkpoint. and your connection with it. Oracle flushes the entire Buffer Cache. whatever they are doing.
There's a lot of old nonsense talked about Shutdown Abort being somehow "dangerous". The various background processes in oracle are a) Data Base Writer(DBWR) :: Data Base Writer Writes Modified blocks from Database buffer cache to Data Files. This is one of the most frequently asked question. Pmon Clears and Frees resources that process were using. that. Provided your online redo logs are OK. it renders you liable to data loss. There are basically 9 Processes but in a general system we need to mention the first five background processes. or before the subsequent startup.They are a) Data Definition Language(DDL) :: The DDL statements define and maintain objects and drop objects.Instance Recovery performed before the shutdown. c) System Monitor(SMON) :: The System Monitor performs instance recovery at instance startup. As transaction commits and log buffer fills. How many types of SQL Statements are there in Oracle There are basically 6 types of sql statements. This is required since the data is not written whenever a transaction is committed. And that's probably a reasonable decision to make. c) Transaction Control Statements :: Manage change by DML d) Session Control :: Used to control the properties of current session enabling and disabling roles and changing . Nevertheless. there is a glimmer of risk with an Abort (suppose Junior DBA accidentally deletes your current redo log afterwards?). g) Recoveror(RECO) :: The Recoveror is used to resolve the distributed transaction in network h) Dispatcher (Dnnn) :: The Dispatcher is useful in Multi Threaded Architecture i) Lckn :: We can have upto 10 lock processes for inter instance locking in parallel sql.g. somehow. all modified database buffers in SGA are written to data files by DBWR at Checkpoints and Updating all data files and control files of database to indicate the most recent checkpoint f)Archieves(ARCH) :: The Archiver copies online redo log files to archival storage when they are busy.g. b)LogWriter(LGWR) :: LogWriter writes the redo log entries to disk. 76 What are the Back ground processes in Oracle and what are they.e. LGWR writes log entries into a online redo log file. Such talk is complete nonsense.e. and it is anyway considered a bit rude to be pulling the plug on your Users in such a brutal way. Oracle never loses committed data (and would be a pretty sad product if it did). and reserve Aborts for dire emergencies. They do the house keeping activities for the Oracle and are common in any system. e) CheckPoint (CKPT) :: At Specified times. Set Role e) System Control Statements :: Change Properties of Oracle Instance . Redo Log data is generated in redo log buffer of SGA.This is useful for recovery from system failure d)Process Monitor(PMON) :: The Process Monitor performs process recovery when user Process fails. b) Data Manipulation Language(DML) :: The DML statements manipulate database data.:: Alter System 77 . :: Alter statements. Most DBAs would consider a Shutdown Immediate to be acceptable.
Procedures do not Return values while Functions return one value Packages: Packages Provide a method of encapsulating and storing related procedures. functions and Packages? Procedures and functions consist of set of PL/SQL statements that are grouped together as a unit to solve a specific problem or perform set of related tasks. Database triggers have the values old and new to denote the old value in the table before it is deleted and the new indicated the new value that will be used. d) Rolling Forward: Process of applying redo log during recovery is called rolling forward. or delete from table.DML and T.78 f) Embedded SQL :: Incorporate DDL. The set of database buffers in an instance is called Database Buffer Cache. It consists of Database Buffer Cache and Redo log Buffer. variables and other Package Contents What are Database Triggers and Stored Procedures? Database Triggers: Database Triggers are Procedures that are automatically executed as a result of insert in. functions. Open. b) Rollback: A transaction that retracts any of the changes resulting from SQL statements in Transaction. What are procedures. a transaction begins with first executable statement and ends when it is explicitly committed or rolled back. According to ANSI. Savepoints can be used to divide a transaction into smaller points. DT are useful for implementing complex business rules which cannot be 79 80 81 . execute and close What is a Transaction in Oracle? A transaction is a logical unit of work that compromises one or more SQL Statements executed by a single User. j) Process: A Process is a 'thread of control' or mechanism in Operating System that executes series of steps. update to. h) Redo log Buffer: Redo log Buffer of SGA stores all the redo log entries. I) Redo Log Files: Redo log files are set of files that protect altered database data in memory that has not been written to Data Files. e) Cursor: A cursor is a handle (name or a pointer) for the memory associated with a specific statement. g) Database Buffer Cache: Database Buffer of SGA stores the most recently used blocks of database data. E. f) System Global Area (SGA): The SGA is a shared memory region allocated by the Oracle that contains Data and control information for one Oracle Instance. c) SavePoint :: For long transactions that contain many SQL statements. A cursor is basically an area allocated by Oracle for executing the SQL Statement. g) Program Global Area (PGA): The PGA is a memory buffer that contains data and control information for server process.S in Programming Language.g.: Using the SQL Statements in languages such as 'C'. Fetch.C. Oracle uses an implicit cursor statement for Single row query and Uses Explicit cursor for a multi row query. intermediate markers or savepoints are declared. They are basically used for backup when a database crashes. Key Words Used in Oracle The Key words that are used in Oracle are: a) Committing: A transaction is said to be committed when the transaction makes permanent changes resulting from the SQL statements.
'Second'Null). My_exception exception When My_exception then What is 3rd normal form? All items are atomic. When there is data in Child Tables the Master tables cannot be deleted. We can have the trigger as Before trigger or After Trigger and at Statement or Row level.after 3*2 A total of 6 combinations At statement level(once for the trigger) or row level( for every execution ) 6 * 2 A total of 12.3 Onwards. b) Isolated :: The Master can be deleted when the child is existing c) Cascading :: The child gets deleted when the Master is deleted. there are no duplicate rows. Stored Procedures: Stored Procedures are Procedures that are stored in compiled form in the database. The advantage of using the stored procedures is that many users can use the same procedure in compiled and ready to use format.'1'.g. They are a) System Exceptions e. When no_data_found. and that value must be atomic: there can be no repeating groups in a table that satisfies first normal form. Value_Error. How do u implement the If statement in the Select Statement We can implement the if statement in the select statement by using the Decode statement.enforced using the integrity rules. Thus a total of 12 combinations are there and the restriction of usage of 12 triggers has been lifted from Oracle 7.:: operations insert. update .g. How many types of Exceptions are there There are 2 types of exceptions. What is 1st normal form? Each cell must be one and only one value.delete 3 before . e. How many Integrity Rules are there and what are they There are Three Integrity Rules.Others b) User Defined Exceptions e. Dup_Val_on_index.g. What are the Various Master and Detail Relation ships. select DECODE (EMP_CAT. c) Business Integrity Rules :: The Third Integrity rule is about the complex business processes which cannot be implemented by the above 2 rules. 82 83 84 85 86 87 . The various Master and Detail Relationship are a) NonIsolated :: The Master cannot be deleted when a child is existing. all tables have a primary key. They are as follows :: a) Entity Integrity Rule :: The Entity Integrity Rule enforces that the Primary key cannot be Null b) Foreign Key Integrity Rule :: The FKIR denotes that the relationship between the foreign key and the primary key has to be enforced. e. No nonkey column depends on another nonkey column.'First'. every row is determined by its primary key. Here the Null is the else statement where null is done . When too_many_rows.'2'. every column is dependent on ONLY the primary key.g.
DBMS_UTILITY. which is usually the same tablespace as where the table is being created which can cause performance problems.88 89 What is 2nd normal form? Every nonkey column must depend on the entire primary key. What Oracle package allows you to schedule one-off or recurring jobs in your database? DBMS_JOB What packages has Oracle provided for use by developers? The DBMS_ series of packages. What is a bind variable and why is it important? A bind variable is a placeholder in a query. DBMS_TRANSACTION.. DBMS_ALERT. What is 4th normal form? Fourth normal form forbids independent one-to-many relationships between primary key columns and nonkey columns. DBMS_PIPE. Why should you care about the NLS_DATE_FORMAT? Because its' value (dd-mon-yy or dd-mon-rr) determines the results of your date arithmetic when you are dealing with years of 99 and 00. DBMS_OUTPUT. DBMS_DDL. i. What are snapshots? Snapshots are copies of remote data. In their simplest form.. Tables normalized to this extent consist of little more than the primary key. 90 91 92 93 94 95 96 97 98 99 100 101 . Create table as .. 10-20 percent at database level What is a mutating table? A mutating table is a table that is in the process of being modified by an UDPATE. DBMS_JOB. The way the Oracle shared pool (a very important shared memory data structure) operates is predicated on developers using bind variables.. Where is most tuning done? 80-90 percent at application level. DBMS_SQL. What are some methods for transferring a table from one schema to another? Export-Import. if your trigger contains a select statement or an update statement referencing the table it is triggering off of you will receive the error. DBMS_LOCK. What are cascading triggers? Executing one trigger may cause another trigger to also be executed. What is 5th normal form? Fifth normal form breaks tables into the smallest possible pieces in order to eliminate all redundancy within a table. UTL_FILE. How are reads and writes handled in Oracle that is different than almost every other database? Reads are not blocked by writes. UTL_TCP. Copy What happens if a tablespace clause is left off a primary key constraint? This results in the index automatically generated being placed in the users' default tablespace. UTL_SMTP.e. For example. Select . based upon queries. they can be thought of as a table created by a command such as: create table t as select * from z.nn. DELETE or INSERT statement. UTL_HTTP.
00. .'BCDEFGHIJ') from DUAL. In a Select statement. Their main advantage is that when relatively small tables must be constantly consulted.102 103 What is the purpose of the SUBSTR string function? To return a specified substring from a string. I follow this advice when at a client site.234567890. FSG reports in Oracle General Ledger. Is PL/SQL truly compiled when stored in the database or is it interpreted? PL/SQL on the server is run in much the same fashion as Java is run anywhere.the var v_min_bal takes on the Type of sales.balance and the value of 10. What are PL/SQL Tables (or Arrays)? This is dependent upon your Oracle version. PL/SQL is compiled into PCode and the PCode is interpreted at runtime. What's the most important 'Best Practice' guideline you follow? Ask for Help if you find yourself spending more than 30 minutes to solve a problem. End. and so individual alerts enjoy support from Oracle at the same level as. not just a field. Example: select TRANSLATE (7671234.00. performance can be enhanced.3 that dimension could be a record. Begin End.then). if they can be put in memory via a PL/SQL table. What is %TYPE used for? v_min_bal sales.if. but if the && is used the user will not be bothered with a second prompt for the value. when I'm at home. What's another Best Practice? Make code reviews a regular part of your development process.balance%TYPE := 10. I act like the Duracell bunny and just keep going and going. I have found this useful during some data migrations where special characters needed to be translated. The result would be: GFG1BCD. 104 105 106 107 108 109 110 111 112 113 114 115 . Oracle Alert is an end-user tool. Describe the PL/SQL Block structure. but after PLSQL 2. What's the difference between an equijoin and a self-join? An equijoin does an equality test between two fields in two different tables. Declare Begin Begin End. What is Oracle*Alert? Oracle*Alert is licensed as an Application but it functions as an extension of AOL in that it supplements the features of all the Applications. What is %ROWTYPE used for? Similar to %TYPE but for a record. The format is TRANSLATE(string. what is the difference between a & and &&? Both pass in values at runtime. PL/SQL Tables have only one dimension. What is the TRANSLATE function? TRANSLATE is a simple function that does an orderly character-by-character substitution in a string. a self join does the same thing on a copy of the same table. What is an anonymous block? A stored procedure without a name. for instance. Declare Begin Exception End Describe a nested PL/SQL Block.
What else may truncating a table do? It can reset the high water mark for a table if the REUSE STORAGE clause is not used. excluding attributes. Why is the high water mark important? The high water mark is used in association with each individual table and tells Oracle 1. What is the default length of the CHAR column? 1. What does truncating a table do? It deletes the data from the table. what needs to be followed with a semicolon? All SQL statements. and securing attributes to users. What is the purpose of a referential integrity constraint? Enforce the rule that a child foreign key must have a valid parent primary key. A security realm is a list of objects (item source or a category) to which a user is granted access. which character is used to pass in a value at runtime? The '&' character or the '&&' characters. how far to scan a table's information when doing a full-table scan. What are realms? Application security in Oracle Applications is maintained and managed by assigning responsibilities. In a SELECT statement. Transition 5. FTO. etc. Strategy and analysis 2. use Telnet.116 What is the purpose of the PL/SQL FETCH command? The FETCH command retrieves values returned by the cursor from the active set into the local variables. Design 3. where to start loading data during a SQL*Loader process 2. Build and document 4. What is the purpose of the SQL*Plus command GET? Get the contents of a previously saved operating system file into the buffer. all PL/SQL statements and the END clause What character do you type to execute an anonymous block? 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 . Internet Procurement 11i uses a security realm as an additional layer for application security. What occurs during the production phase of the system development cycle? Perform normal routine maintenance. A database trigger is fired automatically when what is executed? a DML statement In a PL/SQL block. What is DNS? What does it stand for and why do we care that it exists? Dynamic Name Server is what allows us to type in names instead of IP addresses to get to Web servers. Production. What does the TO_NUMBER function do? It converts VARCHAR2 values to numbers. What is the order of the stages of the system development cycle? 1.
Dept_table(15) 139 140 141 142 143 144 145 146 147 148 . 2. Can you have more than one transaction in a PL/SQL block? Yes What is common among these cursor attributes. What data type is used to store large binary objects outside the database? The BFILE data type Which variable type accepts only character strings of a specified length? CHAR Which variable type accepts any length of character up to 32767 bytes? VARCHAR2 What operator is used to assign a value to a variable that doesn't have a typical value? := What keyword is used to assign a value to a variable that has a typical value? DEFAULT How frequently are block declared variables initialized? Every time a block is executed With which symbol do you prefix a bind variable when you reference it in PL/SQL? : What are two statements that are true about the INTO clause? 1. What keyword is used when you populate a host variable from the SQL prompt? The VARIABLE keyword How do you end each SQL statement in a PL/SQL block? With a . 2. What are two true statements concerning the index in a FOR loop? 1. How do you begin defining a record type? TYPE emp_record_type IS RECORD Do PL/SQL records have a predefined data type? No. SQL %ISOPEN? They are all Boolean attributes.132 133 134 135 136 137 138 The / character. You can't reference it outside the loop. SQL%NOTFOUND. You have to specify the same number of variables in the INTO clause as the values returned by the SELECT statement. SQL%FOUND. Give an example of the correct syntax to reference a row in a PL/SQL table. The data types of the variables specified in the INTO clause need to correspond with the values returned by the SELECT statement. What does it mean when the cursor attribute SQL%FOUND returns the result TRUE? The most recent SQL statement issued affects one or more rows. You can use an expression to reference its existing value within the loop.
without having to explicitly reference the ROWID? How long does the Oracle server wait if it cannot acquire the locks on the rows it needs in a SELECT FOR UPDATE? Indefinitely Name three things about using cursors with parameters. When defining your own exceptions. 2. %NOTFOUND 3. the associated exception is raised automatically. You can use parameters to pass values to a cursor when it is open. They need to be declared and named before they can be used. when an exception occurs. PL/SQL processes only one handler before leaving the block. and the cursor is closed when all the rows have been processed. 3. What exception occurs when the conversion of a character string to a number fails? INVALID_NUMBER Name three things about user-defined exceptions. They automate processing as the cursor is automatically opened and the rows fetched for each iteration in the loop. What clause do you use to apply updates and deletes to the row currently being addressed. They individually process each row returned by a multi row SELECT statement. If you use the OTHERS clause. 1. each formal parameter in the cursor declaration must have a corresponding real parameter. 2. 2. 1. 1. They process rows in an explicit cursor. You can raise an exception explicitly by issuing the RAISE statement within the block. 1. Name two things true about cursor FOR loops. 2. They are manipulated through specific statements in the block's executable actions. Name three things true about trapping exceptions. 152 153 154 155 156 157 158 159 160 161 . What are four attributes that provide status information about a cursor? 1. You can use the explicit cursor attributes to test the success of each fetch before any further references are made to the cursor. it should be placed last of all the exception-handling clauses. Exceptions cannot appear in assignment statements or SQL statements. %ROWCOUNT Describe at least one way explicit cursor attributes are used. 1. %ISOPEN 2. 3. 2. 3. %FOUND 4. Describe two aspects about exceptions. 1. Once an Oracle error occurs. you need to declare them in the DECLARE section of a PL/SQL block. In the OPEN statement. Parameters are used in a query when it executes.149 150 151 The primary key of a PL/SQL table must be of what data type? Scalar What is the term used for the rows produced by a query? Active set Name three things that are true about explicit cursors.
It describes the storage structures and access methods used to achieve efficient access to the data. using natural objects of information and natural associations between them. How SQL is written in PL/SQL code. which are represented in the physical model as tables. and key groups. sequence. What is a pseudo-column? A pseudo-column is a "column" that yields a value when selected. 3. What are the more common pseudo-columns? sequence. A single CDM may therefore be associated with a number of PDMs targeting different DBMSs. number_string := TO_CHAR (10000). It is recommended that you use VARCHAR2 rather than VARCHAR. 3.The process of producing a description of the implementation of the database on secondary storage. A Conceptual Data Model lays the foundation for building shared databases and re-engineering the business. 'MMDDYY'). You need to reference your declared exception within the corresponding exception-handling routine. physical implementation-independent clear view of the format of the data sets and their descriptions. How the exception handling architecture is designed. respectively. Processes for code review and testing. SysDate. Most of the objects in the logical model correspond to a related object in the physical model. the logical model contains entities. The CDM thus provides a clear and succinct picture of the information system. but which is not an actual column of the table. should present to the user a simple. attributes. Physical database design . RowID. data access speed and data storage efficiency.162 2. Selection of development tools 2. How can I check for duplicates? 163 164 165 166 167 168 169 170 . UID. 1.CurrVal. The model of information is independent of a particular implementation and other physical consideration.? The CALL statement is SQL(and only understands SQL types). RowNum. What is the difference between call and execute sqlplus commands.The process of constructing a model of information used in an enterprise based on a specific data model. The conceptual level schema. e. EXEC is really shorthand for begin/end. then two different functions would be required to support conversions to character format. In a future version of Oracle. columns. Explain the relationship between a Conceptual Data Model (CDM) and a Physical Data Model (PDM). If overloading was not supported in PL/SQL (TO_CHAR is a function in the STANDARD package). The CDM allows the designer to concentrate solely on defining the objects in the information system and the relationships between them.. which is independent of the targeted DBMS. and indexes. describe conceptual vs logical vs physical designs. Conceptual database design is the process of building a model of the essential part of the enterprise business process and the used information.NextVal. Elaborating on 163. independent of all physical considerations. 4. date_string := TO_CHAR (SYSDATE. What's another Best Practice? Set standards and guidelines for your application before anyone starts writing code. They are raised explicitly with RAISE statements. VARCHAR might be a separate data type used for variable length character strings compared with different comparison semantics.g. without having to consider the numerous parameters associated with the physical implementation such as data integrity constraints. Logical database design . Give an example of overloaded Built-in functions. User What is the difference between VARCHAR and VARCHAR2? The VARCHAR data type is currently synonymous with the VARCHAR2 data type.
. If a SQL statement executes successfully. ie the first character can be any character. What is SQLCODE? A predefined symbol that contains the Oracle error status of the previously executed PL/SQL statement. Give an example of the NOT keyword. Give an example of the INTERSECT keyword. b. PLS_INTEGER is the most efficient numeric datatype because its values require less storage than INTEGER or NUMBER values. SELECT count(*). 4 CLERK 4 SALESMAN 3 MANAGER 2 ANALYST 1 PRESIDENT What is another name for ref cursors? cursor variables What data type column can not be used with INTERSECT? LONG When is the MINUS keyword used? To remove those rows which are retrieved by one SELECT from those retrieved by another SELECT statement. SELECT c FROM t WHERE c != 'x'. SELECT c FROM t WHERE NOT c = 'x'. the next two must be EU and the last must be L. c FROM t GROUP BY a. SELECT c FROM t WHERE c LIKE '_EU%L'.z. successful completion What is ROWNUM? A pseudocolumn that indicates the order of the retrieved row. b and c in a table of columns a. What are the benefits of using the PLS_INTEGER Datatype in PL/SQL? If you have a whole-number counter. for example in a loop or record counter. If a SQL statement executes without errors. The ROWNUM for the first returned row is 1. Any number of chararcters or numbers could be between the U and L. When is the INTERSECT keyword used? To return only those rows that are the result of two or more SELECT statements. List the numbers of all managers who do not hold advanced degrees. SELECT MGRNO FROM DEPT WHERE MGRNO IS NOT NULL MINUS SELECT EMPNO FROM EMP WHERE EDLEVEL >= 18. SQLCODE is equal to 0. consider using a datatype of PLS_INTEGER instead of INTEGER or NUMBER. c HAVING COUNT(*) > 1. SQLCODE is equal to 0 and SQLERRM contains the string ORA-0000: normal. Give an example of the MINUS keyword. What is SQLERRM? A PL/SQL symbol that contains the error message associated with SQLCODE. a. When declaring an integer variable.171 172 173 select count(*). job from emp group by job having count(*) > 0. ROWNUM can limit the number of rows that are returned by a query. which are represented 174 175 176 177 178 179 180 181 182 183 . List the numbers of all managers who do not hold advanced degrees. Give an example of the LIKE keyword. Write a query to find the duplicate record(s) of column a. SELECT MGRNO FROM DEPT WHERE MGRNO IS NOT NULL INTERSECT SELECT EMPNO FROM EMP WHERE EDLEVEL < 18. b.
the function will return expr3. The basic idea is to prevent concurrent access to shared data structures in the SGA. UNION returns distinct rows selected by both queries while UNION ALL returns all the rows. A process acquires and holds the latch as long as the data structure is in use. SMITH CLERK 800 1 JAMES CLERK 950 2 ADAMS CLERK 185 186 187 188 189 190 191 . PLS_INTEGER operations use machine arithmetic. SELECT ename. thereby causing extra load on the CPU.10 CLERK 1 0 0 10 MANAGER 1 0 0 10 PRESIDENT 1 0 0 10 3 0 1 20 ANALYST 2 0 0 20 CLERK 2 0 0 20 MANAGER 1 0 0 20 5 0 1 30 CLERK 1 0 0 30 MANAGER 1 0 0 30 SALESMAN 4 0 0 30 6 0 1 14 1 1 As shown in this example. NVL . This process will spin until the latch is available.---.184 internally as 22-byte Oracle numbers. The string passed as the first parameter is returned with all characters contained in the string passed as the second parameter removed from the right of the last character not found in the remove string.expr2). A dba has to monitor the latches for contention and make sure that CPU cycles are not being burnt on process spinning. What is a Latch? A Latch is a low level serialization mechanism that (released as quickly as it is acquired) protects shared data structures. Does ROLLUP work with multiple columns? The ROLLUP feature can in fact be applied to multiple columns. This causes additional spinning (looking for availability at fixed intervals of time ) of the process. the PMON process will clean up the lock on the data structure and release the latch. grouping(job) from emp group by rollup(deptno.---. as illustrated here: select deptno. If a process is not able to obtain a latch. The datatype of the return value is that of expr2.'EDATPU') --> 'ORACLE ' rtrim('ORACLE UPDATE'.If expr1 is null then return expr2 else return expr1. rownum FROM (SELECT ename. DEPTNO JOB COUNT(*) GROUPING(DEPTNO) GROUPING(JOB) ---. count(*). which use library arithmetic. or NUMBER operations. sal FROM emp ORDER BY sal) WHERE rownum <= 3. job. it must wait for the latch to be freed up by the process holding it. job). UNION will remove them. The expr1 can have any datatype and arguments expr2 and expr3 can be of any datatype other than LONG. NVL2(expr1. What does pragma mean to Oracle? A pragma is simply a compiler directive.' EDATPU') --> 'ORACL' Describe UNION and UNION ALL. we're able to count the employees by 1) department and job. job. UNION will force a sort and cause performance degradation as compared to UNION ALL. job. Jayanta Sengupta Lowell. rtrim('ORACLE UPDATE ') --> 'ORACLE UPDATE' rtrim('ORACLE UPDATE'. Describe RTRIM.---. NVL(expr1. Also.---. What is an inline view? A subquery in the from clause of your main query. Otherwise. The function removes characters from the right-hand portion of a string. 2) department. INTEGER.'set']) RTRIM is the opposite of RPAD and similar to LTRIM.expr2. Therefore. Massachusetts Explain the difference between NVL and NVL2. if the table has duplicates. RTRIM(string [. If the table has no duplicates. a method to instruct the compiler to perform some compilation option. so they are faster than BINARY_INTEGER. NVL2 . Give an example of an inline view and Top-N Query. The result is multiple levels of rollup.If expr1 is not null then the function will return expr2. The second parameter is optional and defaults to a single space. sal.expr3). In case the process dies without releasing the latch. and 3) grand total. grouping(deptno).
i. To ease administration burdens (derived from the fact that performing operations on small objects is inherently easier. and less resource intensive than performing 193 194 195 196 197 198 199 200 201 202 203 204 205 . data with few distinct values. including subselects. What are the three main reasons for partitioning a database? 1. Use of what command requires that you first run the plustrce. To increase availability (derived from the fact that partitions are independent entities). how do you write the code? scott@PO816> SELECT name. 2. age ) IN ( SELECT country. containing contestant name. What is PostgreSQL? PostgreSQL is a sophisticated Object-Relational DBMS. ATHLETES. What does SQL_TRACE do? Enables logging of all application SQL.192 1100 3 What SQL*Plus command is useful for determining whether the "N rows selected" message will appear? Feedback What SQL*Plus keyword is used for defining formats for how SQL*Plus displays column information? Set This phrase describes a query that feeds one row of results to a parent query for the purpose of selection when the exact where clause criteria is not known? Single-row subquery.sql script? Autotrace The database for an international athletic competition consists of one table. supporting almost all SQL constructs. age FROM athletes WHERE ( country. performance stats and query plan used. What is a top-n query? select * from ( select ename from emp order by sal ) where rownum <= 3. transactions.e. It is the most advanced open-source database available anywhere. What does AUTOTRACE do? Allows us to see the execution plan of the queries we've executed and the resources they used. and represented country. without having to use the EXPLAIN PLAN command. To determine the youngest athlete representing each country. What is an inline view? A subquery in a from clause used for defining an intermediate result set to query from. Commercial Support is also available. What is a single-row subquery? The main query expects the subquery to return only one value. and user-defined types and functions. What does TKPROF do? Formats the raw trace files into a readable report. min(age) FROM athletes GROUP BY country). age. In general it refers to getting the top-n rows from a result set. country. faster. What are the two main index types that Oracle uses? B*Tree and Bitmap When are Bitmap indexes appropriate? In situations of low cardinality data.
the calling procedure must be the earlier of the two.206 the same operation on a large object). 3. To enhance DML and query performance (potential to perform parallel DML). if that happens. Does the order of stored procedures in a package matter? It does if one procedure calls another. .
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.