<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1802525653898001175</id><updated>2011-12-06T07:30:43.118-08:00</updated><category term='Ebook Download'/><category term='oracle errors'/><category term='oracle dba'/><category term='tablespace'/><category term='Security'/><category term='SQL'/><category term='Trigger'/><category term='Hints'/><category term='oracle fundamental'/><category term='SQL*Plus'/><category term='PL/SQL'/><title type='text'>oracle tips &amp; tricks</title><subtitle type='html'>oracle tips &amp; tricks for database administration, database performance to optimize your oracle database</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>73</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-4863216684821910957</id><published>2008-04-25T00:59:00.002-07:00</published><updated>2008-04-25T01:03:12.958-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Invoking and Executing a Script from OEM</title><content type='html'>When including script names in OEM you must carefully include the fully-qualified path for the script: (i.e. /u01/app/oracle/scripts/myscript.sql).  Placing custom scripts within OEM is a great way to improve reporting. Here is a quick overview of script execution from OEM:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Create a "new event" from the OEM console&lt;/li&gt;&lt;li&gt;Choose "enable unsolicited event" and then "test unsolicited event"&lt;/li&gt;&lt;li&gt;Enter the script name with the full path.&lt;/li&gt;&lt;/ol&gt;You can also use the oemevent command to invoke a SQL script from OEM:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;root&gt; oemevent /u01/app/oracle/scripts/myscript.sql destination alert "Monitored destination message"&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-4863216684821910957?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/4863216684821910957/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=4863216684821910957' title='53 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/4863216684821910957'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/4863216684821910957'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/04/invoking-and-executing-script-from-oem.html' title='Invoking and Executing a Script from OEM'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>53</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-1153991199533000180</id><published>2008-04-24T17:07:00.000-07:00</published><updated>2008-04-24T17:12:04.157-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Database Link From Oracle to SQL Server</title><content type='html'>After you succeed &lt;a href="http://oracletipstricks.blogspot.com/2008/02/connect-oracle-to-sql-server.html"&gt;connecting Oracle with SQL Server&lt;/a&gt; probably you want to create database link between it. Oracle heterogeneous services allow you to define a database link between Oracle and SQL Server, as well as links to DB2 and other inferior databases.&lt;br /&gt;&lt;br /&gt;Here are complete notes in creating a database link between Oracle and SQL Server.&lt;br /&gt;&lt;br /&gt;1. Install Oracle ODBC drivers on the server (your local Oracle database) that will access the remote SQL Server database using the database link.&lt;br /&gt;2. Setup the ODBC connection on the local Oracle database using the Windows ODBC Data Source Administrator&lt;br /&gt;3. Test the ODBC drivers to ensure that connectivity is made to the SQL Server database.&lt;br /&gt;4. Ensure that your global_names parameter is set to False.&lt;br /&gt;5. Configure the Oracle Heterogeneous services by creating an initodbc.ora file within the Oracle database.&lt;br /&gt;&lt;br /&gt;6. Modify the Listener.ora file.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;        SID_NAME is the DSN for the remote database.&lt;br /&gt;        ORACLE_HOME is the actual Oracle home file path.&lt;br /&gt;        PROGRAM tells Oracle to use heterogeneous services.&lt;br /&gt;&lt;br /&gt;        SID_LIST_LISTENER =&lt;br /&gt;        (SID_LIST =&lt;br /&gt;        (SID_DESC =&lt;br /&gt;        (SID_NAME=Cas30C) -- Enter the DSN on this line&lt;br /&gt;        (ORACLE_HOME = c:\oracle10gdb) -- Enter your Oracle home on this line&lt;br /&gt;        (PROGRAM = hsodbc) ) )&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;        &lt;br /&gt;&lt;br /&gt;7. Modify the Tnsnames.ora file. This is the Oracle database installation accessed by the users to connect to the ODBC drivers&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;        (DESCRIPTION=&lt;br /&gt;        (ADDRESS_LIST=&lt;br /&gt;        (Address=(PROTOCOL=TCP)&lt;br /&gt;        (HOST=&lt;br /&gt;        -- (Server x)&lt;br /&gt;        (PORT=1521))) -- Enter the port on which the server x Oracle installation&lt;br /&gt;        -- is listening&lt;br /&gt;        (CONNECT_DATA=(SID=Cas30c)) - Enter the DSN name&lt;br /&gt;        (HS=OK) -- Enter this value. It tells Oracle to use hetergeneous services&lt;br /&gt;        )&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;8. Reload the listener on local Oracle database&lt;br /&gt;9. Create a database link on the local Oracle installation that accesses the heterogeneous connection, which, in turn, connect to SQL Server.&lt;br /&gt;10. Run a SQL Server Select statement from the Oracle installation using the database link.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-1153991199533000180?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/1153991199533000180/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=1153991199533000180' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/1153991199533000180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/1153991199533000180'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/04/database-link-from-oracle-to-sql-server.html' title='Database Link From Oracle to SQL Server'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-7679573191803727575</id><published>2008-04-24T16:57:00.000-07:00</published><updated>2008-04-24T16:59:49.143-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL*Plus'/><title type='text'>Accessing Oracle Alert Log via SQL with External Tables</title><content type='html'>Starting in Oracle9i you can map external flat files to Oracle tables.&lt;br /&gt;Mapping the Oracle alert log is easy and once defined, all you have to do is query it with standard SQL syntax:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;create directory BDUMP as '/u01/app/oracle/admin/mysid/bdump';&lt;br /&gt;&lt;br /&gt;create table&lt;br /&gt;   alert_log ( msg varchar2(80) )&lt;br /&gt;organization external (&lt;br /&gt;   type oracle_loader&lt;br /&gt;   default directory BDUMP&lt;br /&gt;   access parameters (&lt;br /&gt;      records delimited by newline&lt;br /&gt;   )&lt;br /&gt;   location('alrt_mysid.log')&lt;br /&gt;)&lt;br /&gt;reject limit 1000;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now we can easily extract important Oracle alert log information without leaving SQL*Plus:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;select msg from alert_log where msg like '%ORA-00600%';&lt;br /&gt;&lt;br /&gt;ORA-00600: internal error code, arguments: [17034], [2940981512], [0], [], [], [ ], [], []&lt;br /&gt;ORA-00600: internal error code, arguments: [18095], [0xC0000000210D8BF8], [], [], [], [], []&lt;br /&gt;ORA-00600: internal error code, arguments: [4400], [48], [], [], []&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-7679573191803727575?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/7679573191803727575/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=7679573191803727575' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/7679573191803727575'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/7679573191803727575'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/04/accessing-oracle-alert-log-via-sql-with.html' title='Accessing Oracle Alert Log via SQL with External Tables'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-6603121818024768112</id><published>2008-04-22T03:13:00.000-07:00</published><updated>2008-04-22T03:16:29.892-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL*Plus'/><title type='text'>Computing date differences</title><content type='html'>One of the confounding problems with Oracle DATE datatypes is the computation of elapsed time.&lt;br /&gt;&lt;br /&gt;Oracle supports date arithmetic and you can make expressions like "date1 - date2" to get the difference between the two dates.  Once you have the date difference, you can use simple techniques to express the difference in days, hours, minutes or seconds.&lt;br /&gt;&lt;br /&gt;To get the values for data differences, you must choose you unit of measurement, and this is done with the data format mask:&lt;br /&gt;&lt;br /&gt;It might be tempting to use sophisticated conversion functions to convert a data, but we will see that this is not the most elegant solution:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;round(to_number(end-date-start_date))– elapsed days&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;round(to_number(end-date-start_date)*24)– elapsed hours&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;round(to_number(end-date-start_date)*1440)– elapsed minutes&lt;br /&gt;&lt;br /&gt;How are elapsed time data displayed by default?  To find out, we issue a simple SQL*plus query:&lt;br /&gt;&lt;br /&gt;SQL&gt; select sysdate-(sysdate-3) from dual;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SYSDATE-(SYSDATE-3)&lt;br /&gt;&lt;br /&gt;-------------------&lt;br /&gt;&lt;br /&gt;                  3&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Here we see that elapsed times are expressed in days.  Hence, we can use easy conversion functions to convert this to hours or minutes:&lt;br /&gt;&lt;br /&gt;However, when the minutes are not a whole number, we have the problem of trailing decimal places:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;select&lt;br /&gt;&lt;br /&gt;   (sysdate-(sysdate-3.111))*1440&lt;br /&gt;&lt;br /&gt;from&lt;br /&gt;&lt;br /&gt;   dual;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;(SYSDATE-(SYSDATE-3.111))*1440&lt;br /&gt;&lt;br /&gt;------------------------------&lt;br /&gt;&lt;br /&gt;                    4479.83333&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Of course, we can overcome this with the ROUND function, remembering that we must first convert the DATE datatype to a NUMBER:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;select&lt;br /&gt;&lt;br /&gt;   round(to_number(sysdate-(sysdate-3.111))*1440)&lt;br /&gt;&lt;br /&gt;from&lt;br /&gt;&lt;br /&gt;   dual;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ROUND(TO_NUMBER(SYSDATE-(SYSDATE-3.111))*1440)&lt;br /&gt;&lt;br /&gt;----------------------------------------------&lt;br /&gt;&lt;br /&gt;                                          4480&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Hence, we can use these functions to convert an elapsed time into rounded elapsed minutes, and place the value inside an Oracle table.  In this example, we have a logoff system-level trigger that computes the elapsed session time and places it inside a Oracle STATSPACK user_log extension table:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;update&lt;br /&gt;&lt;br /&gt;   perfstat.stats$user_log&lt;br /&gt;&lt;br /&gt;set&lt;br /&gt;&lt;br /&gt;   elapsed_minutes =&lt;br /&gt;&lt;br /&gt;   round(to_number(logoff_time-logon_time)*1440)&lt;br /&gt;&lt;br /&gt;where&lt;br /&gt;&lt;br /&gt;   user = user_id&lt;br /&gt;&lt;br /&gt;and&lt;br /&gt;&lt;br /&gt;   elapsed_minutes is NULL;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-6603121818024768112?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/6603121818024768112/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=6603121818024768112' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/6603121818024768112'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/6603121818024768112'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/04/computing-date-differences.html' title='Computing date differences'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-1777397919259446951</id><published>2008-04-22T03:00:00.000-07:00</published><updated>2008-04-22T03:18:34.751-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL*Plus'/><title type='text'>Oracle SQL : Coding a matrix of display values</title><content type='html'>Oracle has a fascinating non-ANSI feature called an in-line view.  The in-line view allows for a query to be placed into the FROM clause of an SQL statement, where you would normally place a table name.&lt;br /&gt;&lt;br /&gt;By performing a SELECT in the FROM clause, we can summarize two columns, and display a third value based on two other columns.&lt;br /&gt;&lt;br /&gt;In the example below, we take the employee name (ename) and the department number (deptno) and display the salary of the employee by their department.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;prompt Display of Salary by Department&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;SELECT &lt;br /&gt;&lt;br /&gt;   *&lt;br /&gt;&lt;br /&gt;FROM  (SELECT&lt;br /&gt;&lt;br /&gt;         ename,&lt;br /&gt;&lt;br /&gt;         sum(decode(deptno,10,sal)) DEPT10,&lt;br /&gt;&lt;br /&gt;         sum(decode(deptno,20,sal)) DEPT20,&lt;br /&gt;&lt;br /&gt;         sum(decode(deptno,30,sal)) DEPT30,&lt;br /&gt;&lt;br /&gt;         sum(decode(deptno,40,sal)) DEPT40&lt;br /&gt;&lt;br /&gt;       FROM&lt;br /&gt;&lt;br /&gt;         emp&lt;br /&gt;&lt;br /&gt;       GROUP BY&lt;br /&gt;&lt;br /&gt;         ename)&lt;br /&gt;&lt;br /&gt;ORDER BY 1;&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;Display of Salary by Department&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;ENAME          DEPT10     DEPT20     DEPT30     DEPT40&lt;br /&gt;&lt;br /&gt;---------- ---------- ---------- ---------- ----------&lt;br /&gt;&lt;br /&gt;ADAMS                       1100&lt;br /&gt;&lt;br /&gt;ALLEN                                  1600&lt;br /&gt;&lt;br /&gt;BLAKE                                  2850&lt;br /&gt;&lt;br /&gt;CLARK            2450&lt;br /&gt;&lt;br /&gt;FORD                        3000&lt;br /&gt;&lt;br /&gt;JAMES                                   950&lt;br /&gt;&lt;br /&gt;JONES                       2975&lt;br /&gt;&lt;br /&gt;KING             5000&lt;br /&gt;&lt;br /&gt;MARTIN                                 1250&lt;br /&gt;&lt;br /&gt;MILLER           1300&lt;br /&gt;&lt;br /&gt;SCOTT                       3000&lt;br /&gt;&lt;br /&gt;SMITH                        800&lt;br /&gt;&lt;br /&gt;TURNER                                 1500&lt;br /&gt;&lt;br /&gt;WARD                                   1250&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This type of query is very useful for Oracle data warehouse system where you must display information from a FACT table according to the values of two other columns.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-1777397919259446951?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/1777397919259446951/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=1777397919259446951' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/1777397919259446951'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/1777397919259446951'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/04/oracle-sql-coding-matrix-of-display.html' title='Oracle SQL : Coding a matrix of display values'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-5972885263812816907</id><published>2008-03-17T23:53:00.000-07:00</published><updated>2008-03-17T23:56:30.299-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><title type='text'>Oracle Package Initialization</title><content type='html'>Did you notice that Oracle PL/SQL packages can have an initialization section? The initialization part of a package is run only once, the first time you reference the package. Here is an example:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;CREATE PACKAGE emp_actions AS&lt;br /&gt;     /* Declare externally callable subprograms. */&lt;br /&gt;     FUNCTION hire_employee (&lt;br /&gt;        ename  VARCHAR2,&lt;br /&gt;        job    VARCHAR2,&lt;br /&gt;        mgr    REAL,&lt;br /&gt;        sal    REAL,&lt;br /&gt;        comm   REAL,&lt;br /&gt;        deptno REAL) RETURN INT;&lt;br /&gt;  END emp_actions;&lt;br /&gt;&lt;br /&gt;  CREATE PACKAGE BODY emp_actions AS&lt;br /&gt;     number_hired INT;  -- visible only in this package&lt;br /&gt;&lt;br /&gt;     /* Fully define subprograms specified in package. */&lt;br /&gt;     FUNCTION hire_employee (&lt;br /&gt;        ename  VARCHAR2,&lt;br /&gt;        job    VARCHAR2,&lt;br /&gt;        mgr    REAL,&lt;br /&gt;        sal    REAL,&lt;br /&gt;        comm   REAL,&lt;br /&gt;        deptno REAL) RETURN INT IS&lt;br /&gt;        new_empno INT;&lt;br /&gt;     BEGIN&lt;br /&gt;        SELECT empno_seq.NEXTVAL INTO new_empno&lt;br /&gt;        FROM dual;&lt;br /&gt;        INSERT INTO emp VALUES (new_empno, ename, job,&lt;br /&gt;           mgr, SYSDATE, sal, comm, deptno);&lt;br /&gt;        number_hired := number_hired + 1;&lt;br /&gt;        RETURN new_empno;&lt;br /&gt;     END hire_employee;&lt;br /&gt;&lt;br /&gt;  BEGIN  -- initialization part starts here&lt;br /&gt;     INSERT INTO emp_audit&lt;br /&gt;     VALUES (SYSDATE, USER, 'EMP_ACTIONS');&lt;br /&gt;     number_hired := 0;&lt;br /&gt;  END emp_actions;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The initialization part of a package is run just once, the first time you reference the package. So, in the last example, only one row is inserted into the database table emp_audit. Likewise, the variable number_hired is initialized only once.&lt;br /&gt;&lt;br /&gt;Every time the procedure hire_employee is called, the variable number_hired is updated. However, the count kept by number_hired is session specific. That is, the count reflects the number of new employees processed by one user, not the number processed by all users.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-5972885263812816907?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/5972885263812816907/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=5972885263812816907' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/5972885263812816907'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/5972885263812816907'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/03/oracle-package-initialization.html' title='Oracle Package Initialization'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-6156361263190535395</id><published>2008-03-10T23:17:00.000-07:00</published><updated>2008-03-10T23:20:57.956-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Using rsync to Copy Oracle Home Directories</title><content type='html'>If you're using UNIX for your ORACLE database server, it is possible to copy the Oracle Database Software (the Oracle Home directory) from one server to another using rsync.&lt;br /&gt;&lt;br /&gt;Here is the example rsync syntax to copy the Oracle Home from one server (svr1) to another server (svr2). This process will ensure that all symbolic links and files owned by root get copied over correctly. Login to the source database server (svr1) as the root user account and run the following:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;[root@svr1 ~]# rsync -auvzpogl -e ssh /u01/app/oracle/product/10.2.0/db_1/ svr2:/u01/app/oracle/product/10.2.0/db_1/&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-6156361263190535395?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/6156361263190535395/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=6156361263190535395' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/6156361263190535395'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/6156361263190535395'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/03/using-rsync-to-copy-oracle-home.html' title='Using rsync to Copy Oracle Home Directories'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-7162760446591883807</id><published>2008-03-10T23:12:00.000-07:00</published><updated>2008-03-10T23:13:47.967-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><title type='text'>Sending E-Mail in PL/SQL</title><content type='html'>Here some example code you can use for sending email from within PL/SQL&lt;br /&gt;&lt;pre&gt;&lt;code&gt;CREATE OR REPLACE PROCEDURE SEND_MAIL_TCP (&lt;br /&gt;    msg_from     VARCHAR2 := 'sender@testing.com'&lt;br /&gt;  , msg_to       VARCHAR&lt;br /&gt;  , msg_subject  VARCHAR2 := 'E-Mail message from your database'&lt;br /&gt;  , msg_text     VARCHAR2 := ''&lt;br /&gt;)&lt;br /&gt;IS&lt;br /&gt;  c   UTL_TCP.CONNECTION;&lt;br /&gt;  rc  INTEGER;&lt;br /&gt;BEGIN&lt;br /&gt;  c  := UTL_TCP.OPEN_CONNECTION('localhost', 25);       -- open the SMTP port 25 on local machine&lt;br /&gt;  rc := UTL_TCP.WRITE_LINE(c, 'HELO localhost');&lt;br /&gt;  rc := UTL_TCP.WRITE_LINE(c, 'MAIL FROM: '||msg_from);&lt;br /&gt;  rc := UTL_TCP.WRITE_LINE(c, 'RCPT TO: '||msg_to);&lt;br /&gt;  rc := UTL_TCP.WRITE_LINE(c, 'DATA');                  -- Start message body&lt;br /&gt;  rc := UTL_TCP.WRITE_LINE(c, 'Subject: '||msg_subject);&lt;br /&gt;  rc := UTL_TCP.WRITE_LINE(c, '');&lt;br /&gt;  rc := UTL_TCP.WRITE_LINE(c, msg_text);&lt;br /&gt;  rc := UTL_TCP.WRITE_LINE(c, '.');                     -- End of message body&lt;br /&gt;  rc := UTL_TCP.WRITE_LINE(c, 'QUIT');&lt;br /&gt;  UTL_TCP.CLOSE_CONNECTION(c);                          -- Close the connection&lt;br /&gt;EXCEPTION&lt;br /&gt;  WHEN others THEN&lt;br /&gt;    RAISE_APPLICATION_ERROR(-20000, 'Unable to send e-mail message from PL/SQL routine.');&lt;br /&gt;END;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-7162760446591883807?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/7162760446591883807/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=7162760446591883807' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/7162760446591883807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/7162760446591883807'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/03/sending-e-mail-in-plsql.html' title='Sending E-Mail in PL/SQL'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-8940064712665052071</id><published>2008-02-19T00:49:00.000-08:00</published><updated>2008-02-19T01:02:38.453-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Another Oracle apps DBA Interview Questions (with answer)</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Questions&lt;/span&gt;:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;What happens if the ICM goes down?&lt;/li&gt;&lt;li&gt;How will you speed up the patching process?&lt;/li&gt;&lt;li&gt;How will you handle an error during patching?&lt;/li&gt;&lt;li&gt;Provide a high-level overview of the cloning process and post-clone manual steps.&lt;/li&gt;&lt;li&gt;Provide an introduction to AutoConfig. How does AutoConfig know which value from the XML file needs to be put in which file?&lt;/li&gt;&lt;li&gt;Can you tell me a few tests you will do to troubleshoot self-service login problems? Which profile options and files will you check?&lt;/li&gt;&lt;li&gt;What could be wrong if you are unable to view concurrent manager log and output files?&lt;/li&gt;&lt;li&gt;How will you change the location of concurrent manager log and output files?&lt;/li&gt;&lt;li&gt;If the user is experiencing performance issues, how will you go about finding the cause?&lt;/li&gt;&lt;li&gt;How will you change the apps password?&lt;/li&gt;&lt;li&gt;Provide the location of the DBC file and explain its significance and how applications know the name of the DBC file.&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-weight: bold;"&gt;Answers&lt;/span&gt;:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;All the other managers will keep working. ICM only takes care of the queue control requests, which means starting up and shutting down other concurrent managers.&lt;/li&gt;&lt;li&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;You can merge multiple patches.&lt;/li&gt;&lt;li&gt;You can create a response file for non-interactive patching.&lt;/li&gt;&lt;li&gt;You can apply patches with options (nocompiledb, nomaintainmrc, nocompilejsp) and run these once after applying all the patches.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Look at the log of the failed worker, identify and rectify the error and restart the worker using adctrl utility.&lt;/li&gt;&lt;li&gt;Run pre-clone on the source (all tiers), duplicate the DB using RMAN (or restore the DB from a hot or cold backup), copy the file systems and then run post-clone on the target (all tiers).&lt;br /&gt;Manual steps (there can be many more):&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Change all non-site profile option values (RapidClone only changes site-level profile options).&lt;/li&gt;&lt;li&gt;Modify workflow and concurrent manager tables.&lt;/li&gt;&lt;li&gt;Change printers.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;AutoConfig uses a context file to maintain key configuration files. A context file is an XML file in the $APPL_TOP/admin directory and is the centralized repository.&lt;br /&gt;When you run AutoConfig it reads the XML files and creates all the AutoConfig managed configuration files.&lt;br /&gt;For each configuration file maintained by AutoConfig, there exists a template file which determines which values to pick from the XML file.&lt;/li&gt;&lt;li&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Check guest user/password in the DBC file, profile option guest user/password, the DB.&lt;/li&gt;&lt;li&gt;Check whether apache/jserv is up.&lt;/li&gt;&lt;li&gt;Run IsItWorking, FND_WEB.PING, aoljtest, etc.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Most likely the FNDFS listener is down. Look at the value of OUTFILE_NODE_NAME and LOGFILE_NODE_NAME in the FND_CONCURRENT_REQUESTS table. Look at the FND_NODES table. Look at the FNDFS_ entry in tnsnames.ora.&lt;/li&gt;&lt;li&gt;The location of log files is determined by parameter $APPLCSF/$APPLLOG and that of output files by $APPLCSF/$APPLOUT.&lt;/li&gt;&lt;li&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Trace his session (with waits) and use tkprof to analyze the trace file.&lt;/li&gt;&lt;li&gt;Take a statspack report and analyze it.&lt;/li&gt;&lt;li&gt;O/s monitoring using top/iostat/sar/vmstat.&lt;/li&gt;&lt;li&gt;Check for any network bottleneck by using basic tests like ping results.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Use FNDCPASS to change APPS password.&lt;/li&gt;&lt;li&gt;Manually modify wdbsvr.app/cgiCMD.dat files.&lt;/li&gt;&lt;li&gt;Change any DB links pointing from other instances.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Location: $FND_TOP/secure directory.&lt;/li&gt;&lt;li&gt;Significance: Points to the DB server amongst other things.&lt;/li&gt;&lt;li&gt;The application knows the name of the DBC file by using profile option "Applications Database Id." &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-8940064712665052071?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/8940064712665052071/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=8940064712665052071' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/8940064712665052071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/8940064712665052071'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/02/another-oracle-apps-dba-interview.html' title='Another Oracle apps DBA Interview Questions (with answer)'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-2362559070008697399</id><published>2008-02-19T00:17:00.000-08:00</published><updated>2008-02-19T00:20:25.343-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Five DBA Best Practices</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Multiple Oracle Homes&lt;/span&gt;&lt;br /&gt;My favorite best practice is the one about multiple Oracle Homes. Here it how it goes. When applying a patch or a patchset, I recommend against applying to the existing Oracle Home. Instead, I suggest creating a new Oracle Home, and apply the patches there.&lt;br /&gt;&lt;br /&gt;I create the first Oracle Home at /app/oracle/db_1, for instance. When a patch comes out, I install the whole Oracle software in a different home -- /app/oracle/db_2 -- and then apply the patch there. During the process of installation and patch application, the database is up and running, as it runs off the home /db_1. When the outage window comes, all I have to do is to shut down Oracle; change Oracle Home to db_2 and bring the database up. If there is a problem, I can reset the Oracle Home back to the old one.&lt;br /&gt;&lt;br /&gt;So, here is the conventional approach:&lt;br /&gt;&lt;br /&gt;   1. Shut down the database&lt;br /&gt;   2. Apply patch to the Oracle Home&lt;br /&gt;   3. Start the database&lt;br /&gt;   4. In case of problems:&lt;br /&gt;   5. Shut down the database&lt;br /&gt;   6. Roll back the patch&lt;br /&gt;   7. Start the database&lt;br /&gt;&lt;br /&gt;Steps 2 and 6 could take as much as three hours depending on the amount of patching. The database is down during these times.&lt;br /&gt;&lt;br /&gt;In the new approach:&lt;br /&gt;&lt;br /&gt;   1. Install new Oracle Home&lt;br /&gt;   2. Apply the patch to the new Home&lt;br /&gt;   3. Shut down the database&lt;br /&gt;   4. Change Oracle Home to the new location&lt;br /&gt;   5. Start the database&lt;br /&gt;   6. In case of problems:&lt;br /&gt;   7. Shut down the database&lt;br /&gt;   8. Change Oracle Home to the old one&lt;br /&gt;   9. Start the database&lt;br /&gt;&lt;br /&gt;The database is down only during steps 4 and 8, which takes a couple of minutes at the most, not hours.&lt;br /&gt;&lt;br /&gt;So, here are the advantages:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;The downtime is significantly reduced, to one 60th of the original time.&lt;/li&gt;&lt;li&gt;The risk is reduced significantly, as there is no rolling back a patch; you just go to the older version.&lt;/li&gt;&lt;li&gt;You can perform a "diff" on these two homes to see what changed. You can see the differences across multiple homes as well.&lt;/li&gt;&lt;li&gt;You can take several databases running on the same server to the new Oracle Home one by one.&lt;/li&gt;&lt;li&gt;You can see the various Oracle Homes and what patch level they are on using the inventory. &lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;The only negative part is the space consumption -- you need space for two Oracle Homes. But considering a typical Oracle Home takes about 4 GB or less, this aspect of the suggestion is trivial.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Set audit trail to DB&lt;/span&gt;&lt;br /&gt;Set the audit trail to DB by placing the parameter AUDIT_TRAIL = DB in the initialization parameter file during the database creation. Setting this parameter does not start the auditing, because an explicit AUDIT command must be given on the object. But the parameter must be set to a value other than FALSE (the default) for the command to take effect. Being a non-dynamic parameter, the database must be bounced to change the value of AUDIT_TRAIL. To save the trouble and avoid an outage, always set the value to DB, even if you never intend to audit anything. It does not break anything and you will always be ready to audit when the time comes.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Don't use .log&lt;/span&gt;&lt;br /&gt;Don't use .log as the extension of redo logs. Someone may run a script to remove all the log files assuming they are redundant and you will end up losing the online redo logs as well, forcing a database recovery. Instead, name them with extension "redo" or "rdo."&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Preview RMAN Restore&lt;/span&gt;&lt;br /&gt;Preview RMAN Restore to identify all the various backup pieces that will be used in the recovery process without doing an actual recovery. This eliminates any surprises from missing pieces during an actual recovery process.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Create a new Oracle user for clients running on the same server as the DB&lt;/span&gt;&lt;br /&gt;The Oracle Database server software also contains the client piece, which allows the clients to connect to the database on the same server. But as a best practice do not use the same user or the software; use a new one. For instance, if "oracle" is the user to install Oracle software, create a new user called, say, "oraapp" and install the client-only software using that user. The user "oraapp" should not be part of the dba or the oinstall group; so this user can't log on to the database as sysdba. Create a new group called "appgrp" and assign the user oraaap to this group. All the application users on the box should also be part of the appgrp group. This way they can use the sqlplus, sqlldr and other executables on the server, but be able to connect as sysdba.&lt;br /&gt;&lt;br /&gt;The common practice is to use the client software in the same user as the database software owner; but starting with 10.2, Oracle has changed the security policy that takes away the global execution permissions from the Oracle Home. So the only option is to let app users be part of the dba group or change the permissions on Oracle Home -- both make the database extremely vulnerable.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-2362559070008697399?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/2362559070008697399/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=2362559070008697399' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/2362559070008697399'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/2362559070008697399'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/02/five-dba-best-practices.html' title='Five DBA Best Practices'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-5598719691781301717</id><published>2008-02-15T04:42:00.000-08:00</published><updated>2008-02-15T04:45:14.581-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><title type='text'>dbms_backup_restore Package</title><content type='html'>The dbms_backup_restore package is used as a PL/SQL command-line interface for replacing native RMAN commands, and it has very little documentation.&lt;br /&gt;&lt;br /&gt;The Oracle docs note how to install and configure the dbms_backup_restore package:&lt;br /&gt;&lt;br /&gt;    “The DBMS_BACKUP_RESTORE package is an internal package created by the dbmsbkrs.sql and prvtbkrs.plb scripts. This package, along with the target database version of DBMS_RCVMAN, is automatically installed in every Oracle database when the catproc.sql script is run. This package interfaces with the Oracle database server and the operating system to provide the I/O services for backup and restore operations as directed by RMAN.”&lt;br /&gt;&lt;br /&gt;The docs also note that “The DBMS_BACKUP_RESTORE package has a PL/SQL procedure to normalize filenames on Windows NT platforms.”&lt;br /&gt;&lt;br /&gt;Oracle DBA John Parker gives this example of dbms_backup_restore to recover a controlfile:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;declare&lt;br /&gt;devtype varchar2(256);&lt;br /&gt;done boolean;&lt;br /&gt;begin&lt;br /&gt;devtype:=dbms_backup_restore.deviceallocate( type=&gt;'sbt_tape',&lt;br /&gt;params=&gt;'ENV=(OB2BARTYPE=Oracle8,OB2APPNAME=rdcs,OB2BARLIST=ORA_RDCS_WEEKLY)',&lt;br /&gt;ident=&gt;'t1');&lt;br /&gt;dbms_backup_restore.restoresetdatafile;&lt;br /&gt;dbms_backup_restore.restorecontrolfileto('D:\oracle\ora81\dbs\CTL1rdcs.ORA');&lt;br /&gt;dbms_backup_restore.restorebackuppiece(&lt;br /&gt;'ORA_RDCS_WEEKLY&lt;rdcs_6222:596513521:1&gt;.dbf', DONE=&gt;done );&lt;br /&gt;dbms_backup_restore.restoresetdatafile;&lt;br /&gt;dbms_backup_restore.restorecontrolfileto('D:\DBS\RDCS\CTL2RDCS.ORA');&lt;br /&gt;dbms_backup_restore.restorebackuppiece(&lt;br /&gt;'ORA_RDCS_WEEKLY&lt;rdcs_6222:596513521:1&gt;.dbf', DONE=&gt;done );&lt;br /&gt;dbms_backup_restore.devicedeallocate('t1');&lt;br /&gt;end;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Here are some other examples of using dbms_backup_restore:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;DECLARE&lt;br /&gt;devtype varchar2(256);&lt;br /&gt;done boolean;&lt;br /&gt;BEGIN&lt;br /&gt;devtype := dbms_backup_restore.DeviceAllocate (type =&gt; '',ident =&gt; 'FUN');&lt;br /&gt;dbms_backup_restore.RestoreSetDatafile;&lt;br /&gt;dbms_backup_restore.RestoreDatafileTo(dfnumber =&gt; 1,toname =&gt; 'D:\ORACLE_BASE\datafiles\SYSTEM01.DBF');&lt;br /&gt;dbms_backup_restore.RestoreDatafileTo(dfnumber =&gt; 2,toname =&gt; 'D:\ORACLE_BASE\datafiles\UNDOTBS.DBF');&lt;br /&gt;--dbms_backup_restore.RestoreDatafileTo(dfnumber =&gt; 3,toname =&gt; 'D:\ORACLE_BASE\datafiles\MYSPACE.DBF');&lt;br /&gt;dbms_backup_restore.RestoreBackupPiece(done =&gt; done,handle =&gt; 'D:\ORACLE_BASE\RMAN_BACKUP\MYDB_DF_BCK05H2LLQP_1_1', params =&gt; null);&lt;br /&gt;dbms_backup_restore.DeviceDeallocate;&lt;br /&gt;END;&lt;br /&gt;/&lt;br /&gt;&lt;br /&gt;--restore archived redolog&lt;br /&gt;DECLARE&lt;br /&gt;devtype varchar2(256);&lt;br /&gt;done boolean;&lt;br /&gt;BEGIN&lt;br /&gt;devtype := dbms_backup_restore.DeviceAllocate (type =&gt; '',ident =&gt; 'FUN');&lt;br /&gt;dbms_backup_restore.RestoreSetArchivedLog(destination=&gt;'D:\ORACLE_BASE\achive\');&lt;br /&gt;dbms_backup_restore.RestoreArchivedLog(thread=&gt;1,sequence=&gt;1);&lt;br /&gt;dbms_backup_restore.RestoreArchivedLog(thread=&gt;1,sequence=&gt;2);&lt;br /&gt;dbms_backup_restore.RestoreArchivedLog(thread=&gt;1,sequence=&gt;3);&lt;br /&gt;dbms_backup_restore.RestoreBackupPiece(done =&gt; done,handle =&gt; 'D:\ORACLE_BASE\RMAN_BACKUP\MYDB_LOG_BCK0DH1JGND_1_1', params =&gt; null);&lt;br /&gt;dbms_backup_restore.DeviceDeallocate;&lt;br /&gt;END;&lt;br /&gt;/&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-5598719691781301717?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/5598719691781301717/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=5598719691781301717' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/5598719691781301717'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/5598719691781301717'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/02/dbmsbackuprestore-package.html' title='dbms_backup_restore Package'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-6172007215252623597</id><published>2008-02-13T16:45:00.000-08:00</published><updated>2008-02-13T16:53:06.162-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Creating Oracle Database Link</title><content type='html'>Oracle has invested heavily in distributed database technology and the creation of a database link is very straightforward.  You specify the database link name, the remote user to connect to, the password for the remote user and the TNS service name for the database link connection:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;create public database link&lt;br /&gt;  mylink&lt;br /&gt;connect to&lt;br /&gt;  remote_username&lt;br /&gt;identified by&lt;br /&gt;  mypassword&lt;br /&gt;using 'tns_name';&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You can also create a database link to non-Oracle databases,  here are steps for a database link to MySQL:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Your first step is having installed the TRANSPARENT GATEWAY (it comes in as of the options when you install Oracle).&lt;/li&gt;&lt;li&gt;You must have a user in the SQL Server.&lt;/li&gt;&lt;li&gt;In the directory &lt;oracle_home&gt;\tg4msql\admin look for the file inittg4msql.ora and have the following options:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;HS_FDS_CONNECT_INFO="SERVER=name_server;DATABASE=name_db"&lt;br /&gt;HS_FDS_TRACE_LEVEL=OFF&lt;br /&gt;HS_FDS_RECOVERY_ACCOUNT=user_sqlserver&lt;br /&gt;HS_FDS_RECOVERY_PWD=pass_user_sqlserver&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Configure the listener and add the following&lt;br /&gt;&lt;pre&gt;&lt;code&gt;(SID_DESC =&lt;br /&gt;(PROGRAM = tg4msql)&lt;br /&gt;(SID_NAME = MSQL)&lt;br /&gt;(ORACLE_HOME = C:\oracle1)&lt;br /&gt;)&lt;br /&gt;)&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;and on tnsnames.ora add the following&lt;br /&gt;&lt;pre&gt;&lt;code&gt;MSQL=&lt;br /&gt;(DESCRIPTION =&lt;br /&gt;(ADDRESS_LIST =&lt;br /&gt;(ADDRESS = (PROTOCOL = TCP)(HOST = servidor)(PORT = 1521))&lt;br /&gt;)&lt;br /&gt;(CONNECT_DATA =&lt;br /&gt;(SID = MSQL)&lt;br /&gt;)&lt;br /&gt;(HS=OK)&lt;br /&gt;)&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;where HS set up as a heterogonous service&lt;/li&gt;&lt;li&gt;Create a link to sql server.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;create database link msql connect to user_sqlserver identified by password using 'MSQL';&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;You can now use the database link to a foreign database:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;select * from table@msql&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-6172007215252623597?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/6172007215252623597/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=6172007215252623597' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/6172007215252623597'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/6172007215252623597'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/02/creating-oracle-database-link.html' title='Creating Oracle Database Link'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-2425348445399940626</id><published>2008-02-12T21:55:00.000-08:00</published><updated>2008-02-12T21:57:18.221-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Connect Oracle to SQL Server</title><content type='html'>In order to connect to SQL*Server from Oracle, you must do several things:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Install ODBC drivers for the SQL*Server database. The drivers are installed on your laptop or on the server that contains the Oracle code tree.&lt;/li&gt;&lt;li&gt;Setup the ODBC connection on your laptop using the Windows ODBC Data Source Administrator&lt;/li&gt;&lt;li&gt;Test the ODBC drivers to ensure that connectivity is made to the non-Oracle database.&lt;/li&gt;&lt;li&gt;Ensure the Global_names parameter is set to False in the Oracle database.&lt;/li&gt;&lt;li&gt;Configure the Hetergeneous services. This consists of creating an initodbc.ora file within the Oracle&lt;/li&gt;&lt;li&gt;Oracle database installation.&lt;/li&gt;&lt;li&gt;Modify the Listener.ora file on the database installation to connect to the Oracle instance and ODBC drivers.&lt;/li&gt;&lt;li&gt;Modify the Tnsnames.ora file to point to the proper code tree.&lt;/li&gt;&lt;li&gt;Reload the listener&lt;/li&gt;&lt;li&gt;Create a database link on the Oracle installation.&lt;/li&gt;&lt;li&gt;Run a Select statement for the Oracle installation using the database link.&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-2425348445399940626?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/2425348445399940626/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=2425348445399940626' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/2425348445399940626'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/2425348445399940626'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/02/connect-oracle-to-sql-server.html' title='Connect Oracle to SQL Server'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-4391369273657185608</id><published>2008-02-12T16:06:00.000-08:00</published><updated>2008-02-12T16:11:19.509-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><title type='text'>Finding Tables References Inside PL/SQL Store Procedure</title><content type='html'>The Oracle data dictionary tracks the object types referenced in PL/SQL with the dba_dependencies view.  To track the dependency among packages and tables, try this dictionary query:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;select&lt;br /&gt;  referenced_owner,&lt;br /&gt;  referenced_name,&lt;br /&gt;  referenced_type&lt;br /&gt;from&lt;br /&gt;  dba_dependencies&lt;br /&gt;where&lt;br /&gt;  name= 'MY_STORE_PROC'&lt;br /&gt;and&lt;br /&gt;  owner = 'SCOTT'&lt;br /&gt;order by&lt;br /&gt;  referenced_owner, referenced_name, referenced_type;&lt;/code&gt;&lt;/pre&gt;you can also select the referenced_type, ie. tables&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-4391369273657185608?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/4391369273657185608/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=4391369273657185608' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/4391369273657185608'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/4391369273657185608'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/02/finding-tables-references-inside-plsql.html' title='Finding Tables References Inside PL/SQL Store Procedure'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-5991484087568371140</id><published>2008-02-12T03:56:00.000-08:00</published><updated>2008-02-12T04:01:24.898-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Oracle listener lsnrctl command</title><content type='html'>Here are lsnrctl command :&lt;br /&gt;&lt;pre&gt;&lt;code&gt;C:\&gt;lsnrctl&lt;br /&gt;&lt;br /&gt;LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 12-PEB-2008 18:56:26&lt;br /&gt;&lt;br /&gt;Copyright (c) 1991, 2005, Oracle.  All rights reserved.&lt;br /&gt;&lt;br /&gt;Welcome to LSNRCTL, type "help" for information.&lt;br /&gt;&lt;br /&gt;LSNRCTL&gt; help&lt;br /&gt;The following operations are available&lt;br /&gt;An asterisk (*) denotes a modifier or extended command:&lt;br /&gt;&lt;br /&gt;start               stop                status&lt;br /&gt;services            version             reload&lt;br /&gt;save_config         trace               change_password&lt;br /&gt;quit                exit                set*&lt;br /&gt;show*&lt;br /&gt;&lt;br /&gt;LSNRCTL&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;The following commands are used to manage the listener:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;start – Starts the listener with the name specified, otherwise LISTENER will be used.  For Windows systems, the listener can also be started from the Control Panel.&lt;/li&gt;&lt;li&gt;stop – Stops the listener.  For Windows systems, the listener can also be stopped from the Control Panel.&lt;/li&gt;&lt;li&gt;status – Provides status information about the listener, including start date, uptime, and trace level.&lt;/li&gt;&lt;li&gt;services – Displays each service available, along with the connection history.&lt;/li&gt;&lt;li&gt;version – Displays the version information of the listener.&lt;/li&gt;&lt;li&gt;reload – Forces a read of the configuration file in order for new settings to take effect without stopping and starting the listener.&lt;/li&gt;&lt;li&gt;save_config – Creates a backup of the existing listener.ora file and saves changes to the current version.&lt;/li&gt;&lt;li&gt;trace – Sets the trace level to one of the following – OFF, USER, ADMIN, or SUPPORT.&lt;/li&gt;&lt;li&gt;spawn – Spawns a program that runs with an alias in the listener.ora file.&lt;/li&gt;&lt;li&gt;dbsnmp_start – Starts the DBSNMP subagent.&lt;/li&gt;&lt;li&gt;dbsnmp_stop – Stops the DBSNMP subagent.&lt;/li&gt;&lt;li&gt;dbsnmp_status – Displays the status of the DBSNMP subagent.&lt;/li&gt;&lt;li&gt;change_password – Sets a new password for the listener.&lt;/li&gt;&lt;li&gt;quit and exit – Exits the utility.&lt;/li&gt;&lt;li&gt;set – Changes the value of any parameter.  Everything that can be shown can be set.&lt;/li&gt;&lt;li&gt;show – Displays current parameter settings.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-5991484087568371140?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/5991484087568371140/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=5991484087568371140' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/5991484087568371140'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/5991484087568371140'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/02/oracle-listener-lsnrctl-command.html' title='Oracle listener lsnrctl command'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-8431075197050087014</id><published>2008-02-11T22:45:00.000-08:00</published><updated>2008-02-11T22:46:51.937-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Preventing Oracle DDL Unauthorized Schema Changes</title><content type='html'>One of the biggest problems in Oracle are "unexpected" schema changes.  In production environments changes are often allowed only during special maintenance times, and changes such as re-analyzing schema statistics and DDL to change table/index structures must be prohibited at other times.&lt;br /&gt;&lt;br /&gt;This can be tracked with an Oracle DDL trigger, but the DBA can disable DDL at the object level with a simple script to "disable table lock" syntax:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;alter table mbsdba.t_dept disable table lock;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;This script could be used to lock all tables within a schema:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;connect sys/xxx as sysdba;&lt;br /&gt;spool runme.sql&lt;br /&gt;select "alter table "||owner||"."||table_name||" disable table lock;"&lt;br /&gt;from&lt;br /&gt;dba_tables&lt;br /&gt;where&lt;br /&gt;owner = "mbsdba";&lt;br /&gt;&lt;br /&gt;spool off;&lt;br /&gt;@runme.sql&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;While locked, any attempted schema changes will be rejected&lt;br /&gt;&lt;pre&gt;&lt;code&gt;SQL&gt;ALTER TABLE mbsdba.t_dept ADD (NEWCOL NUMBER);&lt;br /&gt;&lt;br /&gt;ALTER TABLE mbsdba.t_dept&lt;br /&gt;*&lt;br /&gt;&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-00069: cannot acquire lock-- table locks disabled for mbsdba.t_dept &lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-8431075197050087014?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/8431075197050087014/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=8431075197050087014' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/8431075197050087014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/8431075197050087014'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/02/preventing-oracle-ddl-unauthorized.html' title='Preventing Oracle DDL Unauthorized Schema Changes'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-8802101651977279461</id><published>2008-02-11T17:53:00.000-08:00</published><updated>2008-02-11T17:56:58.909-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>Oracle SQL Sort Merge Join</title><content type='html'>The use of a sort merge join in Oracle SQL is quite common, especially in cases where there are missing join predicate against one of the tables or a missing index.&lt;br /&gt;In a sort merge join, Oracle must perform full scans on the target tables, sort the keys and join the rows together.&lt;br /&gt;It's important not to confuse a merge join with a merge join cartesian, which is a special case which is usually avoided.&lt;br /&gt;The Oracle docs note these hints for merge joins:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Sort merge join&lt;/span&gt; - Force a sort merge join (&lt;span style="font-style: italic;"&gt;use_merge&lt;/span&gt;) The use_merge hint forces a sort merge join.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Merge anti join&lt;/span&gt; (&lt;span style="font-style: italic;"&gt;merge_aj&lt;/span&gt;) - Transforms a NOT IN subquery into a merge anti-join.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Merge semi-join&lt;/span&gt; (&lt;span style="font-style: italic;"&gt;merge_sj&lt;/span&gt;) - The merge_sj hint is placed into an EXISTS subquery; This converts the subquery into a special type of merge join between t1 and t2 that preserves the semantics of the subquery. That is, even if there is more than one matching row in t2 for a row in t1, the row in t1 is returned only once.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Turn off sort merge join&lt;/span&gt; (&lt;span style="font-style: italic;"&gt;_sortmerge_inequality_join_off&lt;/span&gt;) - This hidden parameter will disable a sort merge join in cases where the predicate is an inequality.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-8802101651977279461?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/8802101651977279461/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=8802101651977279461' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/8802101651977279461'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/8802101651977279461'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/02/oracle-sql-sort-merge-join.html' title='Oracle SQL Sort Merge Join'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-474969835134108684</id><published>2008-02-07T19:17:00.000-08:00</published><updated>2008-02-07T19:18:11.972-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle errors'/><title type='text'>ORA-00918: column ambiguously defined</title><content type='html'>The Oracle docs note this on the ora-00918 error*:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;ORA-00918 column ambiguously defined&lt;br /&gt;&lt;br /&gt;    Cause: A column name used in a join exists in more than one table and is thus referenced ambiguously. In a join, any column name that occurs in more than one of the tables must be prefixed by its table name when referenced. The column should be referenced as TABLE.COLUMN or TABLE_ALIAS.COLUMN. For example, if tables EMP and DEPT are being joined and both contain the column DEPTNO, then all references to DEPTNO should be prefixed with the table name, as in EMP.DEPTNO or E.DEPTNO.&lt;br /&gt;    &lt;br /&gt;    Action: Prefix references to column names that exist in multiple tables with either the table name or a table alias and a period (.), as in the examples above.&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;*As a note, the ORA-00918 error does not exist in Oracle 10g, according to the Oracle documentation&lt;br /&gt;&lt;br /&gt;When ORA-00918 is thrown, you have a column which has been ambiguously defined.  If a column name in a join is referenced ambiguously, it exists in multiple tables.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Column names which occur in multiple tables should be prefixed when it is referenced by its table name.&lt;/li&gt;&lt;li&gt;Columns must be referenced as TABLE.COLUMN or TABLE_ALIAS.COLUM .  Oracle documentation which reference ORA-00918 give the following example:&lt;br /&gt;if tables EMP and DEPT are being joined and both contain the column DEPTNO, then all references to DEPTNO should be prefixed with the table name, as in EMP.DEPTNO or E.DEPTNO. &lt;/li&gt;&lt;/ul&gt;To correct ORA-00918, references should be prefixed to column names existing in multiple tables (either with the table name or table alias and a period)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-474969835134108684?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/474969835134108684/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=474969835134108684' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/474969835134108684'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/474969835134108684'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/02/ora-00918-column-ambiguously-defined.html' title='ORA-00918: column ambiguously defined'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-6531539388105795407</id><published>2008-02-07T19:00:00.000-08:00</published><updated>2008-02-07T19:08:13.266-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle errors'/><title type='text'>ORA-00904: STRING: invalid identifier tips</title><content type='html'>The Oracle docs note this on the ora-00904 error*:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;ORA-00904 string: invalid identifier&lt;br /&gt;    Cause: The column name entered is either missing or invalid.&lt;br /&gt;&lt;br /&gt;    Action: Enter a valid column name. A valid column name must begin with a letter, be less than or equal to 30 characters, and consist of only alphanumeric characters and the special characters $, _, and #. If it contains other characters, then it must be enclosed in double quotation marks. It may not be a reserved word.&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;*According to Oracle documentation, ORA-00904 does not occur in Oracle 10g&lt;br /&gt;&lt;br /&gt;When ORA-00904 occurs, you must enter a valid column name as it is either missing or the one entered is invalid.&lt;br /&gt;&lt;br /&gt;To avoid ORA-00904, column names cannot be a reserved word, and must contain these four criteria to be valid:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;begin with a letter&lt;/li&gt;&lt;li&gt;be less than or equal to twenty characters&lt;/li&gt;&lt;li&gt;consist only of alphanumeric and the special characters ($_#); other characters need double quotation marks around them&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Another important factor in correcting ORA-00904 is remembering to run catproc.sql&lt;br /&gt;&lt;br /&gt;You can also check your trace file to find the particular error which is causing the ORA-00904 to occur.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-6531539388105795407?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/6531539388105795407/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=6531539388105795407' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/6531539388105795407'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/6531539388105795407'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/02/ora-00904-string-invalid-identifier.html' title='ORA-00904: STRING: invalid identifier tips'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-4687244807176989142</id><published>2008-02-07T18:40:00.000-08:00</published><updated>2008-02-07T19:07:26.327-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle errors'/><title type='text'>ORA-00304: requested instance_number is busy</title><content type='html'>The Oracle docs note this on the ora-00304 error:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;ORA-00304: requested INSTANCE_NUMBER is busy&lt;br /&gt; Cause: An instance tried to start by using a value of the initialization parameter INSTANCE_NUMBER that is already in use.&lt;br /&gt; Action: Either a) specify another INSTANCE_NUMBER, b) shut down the running instance with this number c) wait for instance recovery to complete on the instance with this number.&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;You will see ORA 00304 if an INSTANCE_NUMBER parameter value is being used at the time of initializing an Oracle instance&lt;br /&gt;To resolve ORA-00304, you may try one of the three options:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Use a different INSTANCE_NUMBER&lt;br /&gt;In the initialization file, modify the initialization of the INSTANCE_NUMBER&lt;/li&gt;&lt;li&gt;Shut down the instance number causing the ORA-00304 error&lt;/li&gt;&lt;li&gt;On the instance with the ORA-00304, allow recovery to conclude&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-4687244807176989142?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/4687244807176989142/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=4687244807176989142' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/4687244807176989142'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/4687244807176989142'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/02/ora-00304-requested-instancenumber-is.html' title='ORA-00304: requested instance_number is busy'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-927690209563990515</id><published>2008-02-04T04:44:00.000-08:00</published><updated>2008-02-04T04:46:33.691-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle errors'/><title type='text'>ORA-00984: Column Not Allowed Here</title><content type='html'>The Oracle docs note this on the ora-00984 error *&lt;br /&gt;&lt;pre&gt;&lt;code&gt;ORA-00984 column not allowed here&lt;br /&gt;    Cause: A column name was used in an expression where it is not permitted, such as in the VALUES clause of an INSERT statement.&lt;br /&gt;    Action: Check the syntax of the statement and use column names only where appropriate.&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;An ORA-00984 will be thrown if a column name (like in the VALUES clause of an INSERT statement), is used in an expression where it is not permitted.  You may have used a column name in an expression where it is not permitted.  Typically, ORA-00984 occurs while including a column name in the VALUES clause of an INSERT statement.&lt;br /&gt;&lt;br /&gt;To correct ORA-00984, you simply need to view the syntax of the SQL statement and only use column names where they are appropriate.&lt;br /&gt;You may also find it appropriate to include a character value, in the INSERT statement, instead of the column name. &lt;br /&gt;&lt;br /&gt;*Note: ORA-00984 error does not exist in Oracle 10g, according to the Oracle documentation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-927690209563990515?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/927690209563990515/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=927690209563990515' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/927690209563990515'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/927690209563990515'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/02/ora-00984-column-not-allowed-here.html' title='ORA-00984: Column Not Allowed Here'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-1578042796505559021</id><published>2008-01-27T19:22:00.000-08:00</published><updated>2008-01-27T19:27:18.449-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL*Plus'/><title type='text'>Getting Table Details with SQL*Plus</title><content type='html'>You can use SQL*Plus to provide the following details about a table:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Column Details&lt;/li&gt;&lt;li&gt;PRIMARY KEY&lt;/li&gt;&lt;li&gt;INDEXES&lt;/li&gt;&lt;li&gt;FOREIGN KEYS&lt;/li&gt;&lt;li&gt;CONSTRAINTS&lt;/li&gt;&lt;li&gt;ROWCOUNT&lt;/li&gt;&lt;li&gt;Other Tables That REFER to this Table&lt;/li&gt;&lt;li&gt;PARTITIONED COLUMNS&lt;/li&gt;&lt;li&gt;PARTITIONS&lt;/li&gt;&lt;li&gt;TRIGGERS&lt;/li&gt;&lt;li&gt;DEPENDANTS&lt;/li&gt;&lt;/ol&gt;Use the following code in SQL*Plus to provide this information:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;pre&gt;&lt;code&gt;      SET AUTOTRACE OFF&lt;br /&gt;     SET TIMING OFF&lt;br /&gt;     COLUMN COMMENTS FORMAT A50&lt;br /&gt;     COLUMN column_name FORMAT A35&lt;br /&gt;     COLUMN Data_Type FORMAT A15&lt;br /&gt;     COLUMN DATA_DEFAULT FORMAT A20&lt;br /&gt;     COLUMN "PK Column" FORMAT A35&lt;br /&gt;     COLUMN "FK Column" FORMAT A20&lt;br /&gt;&lt;br /&gt;     UNDEF Owner&lt;br /&gt;     ACCEPT Owner PROMPT 'Enter Owner :'&lt;br /&gt;&lt;br /&gt;     UNDEF Table_Name&lt;br /&gt;     ACCEPT Table_Name PROMPT 'Enter Table Name :'&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;     SET HEADING OFF&lt;br /&gt;&lt;br /&gt;     PROMPT&lt;br /&gt;     PROMPT Comments for Table &amp;amp;Table_Name.&lt;br /&gt;     SELECT COMMENTS&lt;br /&gt;     FROM ALL_TAB_COMMENTS&lt;br /&gt;     WHERE TABLE_NAME = UPPER('&amp;amp;Table_Name.')&lt;br /&gt;     AND Owner = UPPER('&amp;amp;Owner.') ;&lt;br /&gt;&lt;br /&gt;     SET HEADING ON&lt;br /&gt;&lt;br /&gt;     PROMPT&lt;br /&gt;     PROMPT Column Details for Table &amp;amp;Table_Name.&lt;br /&gt;&lt;br /&gt;     SELECT&lt;br /&gt;     ROWNUM "Sr No", T.COLUMN_NAME , T.Data_Type , T.DATA_LENGTH,&lt;br /&gt;     DECODE(T.Nullable, 'N' , 'NOT NULL' , 'Y', ' ') NULLABLE , T.Data_Default , C.Comments&lt;br /&gt;     FROM&lt;br /&gt;     ALL_TAB_COLS T , All_Col_Comments C&lt;br /&gt;     WHERE&lt;br /&gt;     T.OWNER = C.OWNER&lt;br /&gt;     AND T.TABLE_NAME = C.TABLE_NAME&lt;br /&gt;     AND T.COLUMN_NAME = C.COLUMN_NAME&lt;br /&gt;     AND T.TABLE_NAME = UPPER('&amp;amp;Table_Name.')&lt;br /&gt;     AND T.Owner = UPPER('&amp;amp;Owner.') ;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;     PROMPT&lt;br /&gt;     PROMPT PRIMARY KEY for Table &amp;amp;Table_Name.&lt;br /&gt;&lt;br /&gt;     select COLUMN_NAME&lt;br /&gt;     FROM ALL_CONS_COLUMNS&lt;br /&gt;     WHERE TABLE_NAME = UPPER('&amp;amp;Table_Name.')&lt;br /&gt;     AND Owner = UPPER('&amp;amp;Owner.')&lt;br /&gt;     AND CONSTRAINT_NAME = ( SELECT CONSTRAINT_NAME&lt;br /&gt;     FROM ALL_CONSTRAINTS&lt;br /&gt;     WHERE TABLE_NAME = UPPER('&amp;amp;Table_Name.')&lt;br /&gt;     AND CONS! TRAINT_T YPE = 'P'&lt;br /&gt;     AND Owner = UPPER('&amp;amp;Owner.')&lt;br /&gt;     )&lt;br /&gt;     ORDER BY POSITION&lt;br /&gt;     /&lt;br /&gt;&lt;br /&gt;     PROMPT&lt;br /&gt;     PROMPT INDEXES for Table &amp;amp;Table_Name.&lt;br /&gt;&lt;br /&gt;     BREAK ON INDEX_NAME ON UNIQUENESS SKIP 1&lt;br /&gt;&lt;br /&gt;     SELECT I.INDEX_NAME , C.COLUMN_NAME , I.UNIQUENESS&lt;br /&gt;     FROM ALL_IND_COLUMNS C , ALL_INDEXES I&lt;br /&gt;     WHERE C.INDEX_NAME = I.INDEX_NAME&lt;br /&gt;     AND C.TABLE_NAME = I.TABLE_NAME&lt;br /&gt;     AND I.TABLE_NAME = UPPER('&amp;amp;Table_Name.')&lt;br /&gt;     AND I.Owner = UPPER('&amp;amp;Owner.')&lt;br /&gt;     AND C.Table_Owner = UPPER('&amp;amp;Owner.')&lt;br /&gt;     AND NOT EXISTS ( SELECT 'X'&lt;br /&gt;     FROM ALL_CONSTRAINTS&lt;br /&gt;     WHERE CONSTRAINT_NAME = I.INDEX_NAME&lt;br /&gt;     AND Owner = UPPER('&amp;amp;Owner.')&lt;br /&gt;     )&lt;br /&gt;     ORDER BY INDEX_NAME , COLUMN_POSITION&lt;br /&gt;     /&lt;br /&gt;&lt;br /&gt;     CLEAR BREAKS&lt;br /&gt;&lt;br /&gt;     PROMPT&lt;br /&gt;     PROMPT FOREIGN KEYS for Table &amp;amp;Table_Name.&lt;br /&gt;&lt;br /&gt;     BREAK ON CONSTRAINT_NAME ON TABLE_NAME ON R_CONSTRAINT_NAME SKIP 1&lt;br /&gt;     COLUMN POSITION NOPRINT&lt;br /&gt;&lt;br /&gt;     SELECT UNIQUE A.CONSTRAINT_NAME,&lt;br /&gt;     C.COLUMN_NAME "FK Column" ,&lt;br /&gt;     B.TABLE_NAME || '.' || B.COLUMN_NAME "PK Column",&lt;br /&gt;     A.R_CONSTRAINT_NAME ,&lt;br /&gt;     C.POSITION&lt;br /&gt;     FROM ALL_CONSTRAINTS A, ALL_CONS_COLUMNS B, ALL_CONS_COLUMNS C&lt;br /&gt;     WHERE A.R_CONSTRAINT_NAME=B.CONSTRAINT_NAME&lt;br /&gt;     AND B.OWNER=UPPER('&amp;amp;OWNER')&lt;br /&gt;     AND A.CONSTRAINT_NAME=C.CONSTRAINT_NAME&lt;br /&gt;     AND A.OWNER=C.OWNER&lt;br /&gt;     AND A.OWNER = B.OWNER&lt;br /&gt;     AND A.TABLE_NAME=C.TABLE_NAME&lt;br /&gt;     AND B.POSITION=C.POSITION&lt;br /&gt;     AND A.TABLE_NAME LIKE UPPER('&amp;amp;TABLE_NAME')&lt;br /&gt;     ORDER BY A.CONSTRAINT_NAME, C.POSITION&lt;br /&gt;     /&lt;br /&gt;&lt;br /&gt;     COLUMN POSITION NOPRINT&lt;br /&gt;     CLEAR BREAKS&lt;br /&gt;&lt;br /&gt;     PROMPT&lt;br /&gt;     PROMPT CONSTRAINTS for Table &amp;amp;Table_Name.&lt;br /&gt;&lt;br /&gt;     SELECT CONSTRAINT_NAME , SEARCH_CONDITION&lt;br /&gt;     FROM ALL_CONSTRAINTS&lt;br /&gt;     WHERE TABLE_NAME = UPPER('&amp;amp;Table_Name.')&lt;br /&gt;     AND Owner = UPPER('&amp;amp;Owner.')&lt;br /&gt;     AND CONSTRAINT_TYPE NOT IN ( 'P' , 'R');&lt;br /&gt;&lt;br /&gt;     PROMPT&lt;br /&gt;     PROMPT ROWCOUNT for Table &amp;amp;Table_Name.&lt;br /&gt;&lt;br /&gt;     SET FEEDBACK OFF&lt;br /&gt;     SET SERVEROUTPUT ON&lt;br /&gt;     DECLARE N NU MBER ;&lt;br /&gt;     V VARCHAR2(100) ;&lt;br /&gt;     BEGIN&lt;br /&gt;     V := 'SELECT COUNT(*) FROM ' || UPPER('&amp;amp;Table_Name.') ;&lt;br /&gt;     EXECUTE IMMEDIATE V INTO N ;&lt;br /&gt;     DBMS_OUTPUT.PUT_LINE (N);&lt;br /&gt;     END;&lt;br /&gt;     /&lt;br /&gt;&lt;br /&gt;     SET FEEDBACK ON&lt;br /&gt;&lt;br /&gt;     PROMPT&lt;br /&gt;     PROMPT Tables That REFER to Table &amp;amp;Table_Name.&lt;br /&gt;&lt;br /&gt;     BREAK ON TABLE_NAME ON CONSTRAINT_NAME skip 1&lt;br /&gt;&lt;br /&gt;     SELECT C.TABLE_NAME , C.CONSTRAINT_Name , CC.COLUMN_NAME "FK Column"&lt;br /&gt;     FROM ALL_CONSTRAINTS C&lt;br /&gt;     , All_Cons_colUMNs CC&lt;br /&gt;     WHERE C.Constraint_Name = CC.Constraint_Name&lt;br /&gt;     AND R_CONSTRAINT_NAME = ( SELECT CONSTRAINT_NAME&lt;br /&gt;     FROM ALL_CONSTRAINTS&lt;br /&gt;     WHERE TABLE_NAME = UPPER('&amp;amp;Table_Name.')&lt;br /&gt;     AND CONSTRAINT_TYPE = 'P'&lt;br /&gt;     AND Owner = UPPER('&amp;amp;Owner.')&lt;br /&gt;     )&lt;br /&gt;     AND C.Owner = UPPER('&amp;amp;Owner.')&lt;br /&gt;     /&lt;br /&gt;&lt;br /&gt;     CLEAR BREAKS&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;     PROMPT&lt;br /&gt;     PROMPT PARTITIONED COLUMNS for Table &amp;amp;Table_Name.&lt;br /&gt;&lt;br /&gt;     SELECT COLUMN_NAME , COLUMN_POSITION&lt;br /&gt;     FROM All_Part_Key_Columns&lt;br /&gt;     WHERE NAME = UPPER('&amp;amp;Table_Name.')&lt;br /&gt;     AND Owner = UPPER('&amp;amp;Owner.') ;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;     PROMPT&lt;br /&gt;     PROMPT PARTITIONS for Table &amp;amp;Table_Name.&lt;br /&gt;&lt;br /&gt;     SELECT PARTITION_NAME , NUM_ROWS&lt;br /&gt;     FROM All_Tab_Partitions&lt;br /&gt;     WHERE TABLE_NAME = UPPER('&amp;amp;Table_Name.')&lt;br /&gt;     AND Table_Owner = UPPER('&amp;amp;Owner.') ;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;     PROMPT&lt;br /&gt;     PROMPT TRIGGERS for Table &amp;amp;Table_Name.&lt;br /&gt;&lt;br /&gt;     SELECT Trigger_Name&lt;br /&gt;     FROM All_Triggers&lt;br /&gt;     WHERE TABLE_NAME = UPPER('&amp;amp;Table_Name.')&lt;br /&gt;     AND Owner = UPPER('&amp;amp;Owner.') ;&lt;br /&gt;&lt;br /&gt;     PROMPT&lt;br /&gt;     PROMPT DEPENDANTS for Table &amp;amp;Table_Name.&lt;br /&gt;&lt;br /&gt;     BREAK ON TYPE SKIP 1&lt;br /&gt;&lt;br /&gt;     SELECT TYPE , NAME&lt;br /&gt;     FROM ALL_DEPENDENCIES&lt;br /&gt;     WHERE REFERENCED_NAME = UPPER('&amp;amp;Table_Name.')&lt;br /&gt;     ORDER BY TYPE ;&lt;br /&gt;&lt;br /&gt;     CLEAR BREAKS&lt;br /&gt;&lt;br /&gt;     SET TERMOUT OFF&lt;br /&gt;     SET AUTOTRACE ON&lt;br /&gt;     SET TIMING ON&lt;br /&gt;     SET TERMOUT ON&lt;/code&gt;&lt;/pre&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-1578042796505559021?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/1578042796505559021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=1578042796505559021' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/1578042796505559021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/1578042796505559021'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/01/getting-table-details-with-sqlplus.html' title='Getting Table Details with SQL*Plus'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-273634552764703549</id><published>2008-01-21T16:25:00.000-08:00</published><updated>2008-01-21T16:35:35.710-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL*Plus'/><title type='text'>How To : Displaying Column Data Horisontally</title><content type='html'>Some time you need to create a result set where the rows need to be columns, or vice versa. This commonly requirement can be done by using pivot (or crosstab) query.&lt;br /&gt;&lt;br /&gt;1. A simple pivot query can be done by doing the following&lt;br /&gt;2. Add some kind of count or row number to your query, if necessary for the grouping&lt;br /&gt;3. Then use your (revised) original query as a sub-query&lt;br /&gt;4. Use "decode" to turn rows into columns (ie. a "sparse" matrix).&lt;br /&gt;5. Use "max" to "squash" the multiple rows you moved to columns, into single rows. Don't forget to group by.&lt;br /&gt;&lt;br /&gt;(Note: it gets more complicated if you don't know how many columns you'll need).&lt;br /&gt;&lt;br /&gt;Here is an example of a pivot query. Say you have the following set of data:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_jCDKRlOd7m8/R5U5WtaVchI/AAAAAAAAAIw/-T4r4TmhFOY/s1600-h/pivot1.JPG"&gt;&lt;img style="cursor: pointer; width: 266px; height: 289px;" src="http://bp2.blogger.com/_jCDKRlOd7m8/R5U5WtaVchI/AAAAAAAAAIw/-T4r4TmhFOY/s320/pivot1.JPG" alt="" id="BLOGGER_PHOTO_ID_5158092010532729362" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;And you would like to make DEPTNO be a column. We have 4 deptno's in EMP, 10,20,30,40.&lt;br /&gt;We can make columns dept_10, dept_20, dept_30, dept_40 that have the values that are&lt;br /&gt;currently in the count column. It would look like this:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_jCDKRlOd7m8/R5U5ndaVciI/AAAAAAAAAI4/jdyclvvophI/s1600-h/pivot2.JPG"&gt;&lt;img style="cursor: pointer; width: 398px; height: 300px;" src="http://bp1.blogger.com/_jCDKRlOd7m8/R5U5ndaVciI/AAAAAAAAAI4/jdyclvvophI/s320/pivot2.JPG" alt="" id="BLOGGER_PHOTO_ID_5158092298295538210" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;Note: don't confuse pivot queries with pivot tables. Pivot tables are a different concept, and have different uses (most typically to fill in missing data).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-273634552764703549?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/273634552764703549/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=273634552764703549' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/273634552764703549'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/273634552764703549'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/01/how-to-displaying-column-data.html' title='How To : Displaying Column Data Horisontally'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp2.blogger.com/_jCDKRlOd7m8/R5U5WtaVchI/AAAAAAAAAIw/-T4r4TmhFOY/s72-c/pivot1.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-6154879920485651613</id><published>2008-01-14T17:14:00.000-08:00</published><updated>2008-01-14T17:23:17.235-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='Trigger'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>Trigger on Insert and Delete</title><content type='html'>A friend of mine is asking, how to insert into TBL_A, but first you have to insert into TBL_B as master table (TBL_A referencing to TBL_B). We could use trigger on this. Here's two example on creating trigger while insert and delete on a table.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;create or replace trigger TBL_A_TRIG_INS&lt;br /&gt;before insert on TBL_A&lt;br /&gt;for each row&lt;br /&gt;&lt;br /&gt;begin&lt;br /&gt;   insert into TBL_B (ID ,NAME )&lt;br /&gt;      values ( :new.ID, :new.NAME );&lt;br /&gt;end;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;create or replace trigger TBL_A_TRIG_DEL&lt;br /&gt;after&lt;br /&gt;delete&lt;br /&gt;on TBL_A&lt;br /&gt; REFERENCING OLD AS OLD NEW AS NEW&lt;br /&gt; FOR EACH ROW&lt;br /&gt;begin&lt;br /&gt;   delete from TBL_B&lt;br /&gt;   where ID = :new.ID and NAME = :new.NAME&lt;br /&gt;end;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-6154879920485651613?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/6154879920485651613/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=6154879920485651613' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/6154879920485651613'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/6154879920485651613'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/01/trigger-on-insert-and-delete.html' title='Trigger on Insert and Delete'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-1673657934916474404</id><published>2008-01-08T01:35:00.000-08:00</published><updated>2008-01-08T01:43:05.704-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Hints'/><title type='text'>Oracle Optimizer Approach Hints</title><content type='html'>&lt;span style="font-weight: bold;"&gt;ALL_ROWS&lt;/span&gt;&lt;br /&gt;The ALL_ROWS hint explicitly chooses the cost-based approach to optimize a statement block with a goal of best throughput (that is, minimum total resource consumption).&lt;br /&gt;&lt;br /&gt;Syntax : /*+ ALL_ROWS */&lt;br /&gt;Example :&lt;blockquote&gt;&lt;br /&gt;conn / as sysdba&lt;br /&gt;&lt;br /&gt;set linesize 121&lt;br /&gt;col name format a30&lt;br /&gt;col value format a30&lt;br /&gt;&lt;br /&gt;SELECT name, value&lt;br /&gt;FROM gv$parameter&lt;br /&gt;WHERE name LIKE '%optimizer%';&lt;br /&gt;&lt;br /&gt;ALTER SYSTEM SET optimizer_mode=RULE SCOPE=MEMORY;&lt;br /&gt;&lt;br /&gt;set autotrace traceonly explain&lt;br /&gt;&lt;br /&gt;SELECT table_name&lt;br /&gt;FROM dba_tables&lt;br /&gt;WHERE owner = 'SYS'&lt;br /&gt;AND table_name LIKE '%$'&lt;br /&gt;ORDER BY 1;&lt;br /&gt;&lt;br /&gt;SELECT /*+ ALL_ROWS */ table_name&lt;br /&gt;FROM dba_tables&lt;br /&gt;WHERE owner = 'SYS'&lt;br /&gt;AND table_name LIKE '%$'&lt;br /&gt;ORDER BY 1;&lt;br /&gt;&lt;br /&gt;ALTER SYSTEM SET optimizer_mode=ALL_ROWS SCOPE=MEMORY;&lt;/blockquote&gt;&lt;span style="font-weight: bold;"&gt;FIRST_ROWS(n)&lt;/span&gt;&lt;br /&gt;The FIRST_ROWS hint explicitly chooses the cost-based approach to optimize a statement block with a goal of best response time (minimum resource usage to return first row).&lt;br /&gt;&lt;br /&gt;This hint causes the optimizer to make these choices:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;If an index scan is available, the optimizer may choose it over a full table scan.&lt;/li&gt;&lt;li&gt;If an index scan is available, the optimizer may choose a nested loops join over a sort-merge join whenever the associated table is the potential inner table of the nested loops.&lt;/li&gt;&lt;li&gt;If an index scan is made available by an ORDER BY clause, the optimizer may choose it to avoid a sort operation.&lt;/li&gt;&lt;li&gt;The optimizer ignores this hint in DELETE and UPDATE statement blocks and in SELECT statement blocks that contain any of the following: UNION, INTERSECT, MINUS, UNION ALL, GROUP BY, FOR UPDATE, aggregating function and the DISTINCT operator.&lt;/li&gt;&lt;/ul&gt;Syntax : /*+ FIRST_ROWS(&lt;integer&gt;) */&lt;br /&gt;Example :&lt;br /&gt;&lt;blockquote&gt;set autotrace trace exp&lt;br /&gt;SELECT table_name&lt;br /&gt;FROM dba_tables&lt;br /&gt;WHERE owner = 'SYS'&lt;br /&gt;AND table_name LIKE '%$'&lt;br /&gt;ORDER BY 1;&lt;br /&gt;SELECT /*+ FIRST_ROWS(10) */ table_name&lt;br /&gt;FROM dba_tables&lt;br /&gt;WHERE owner = 'SYS'&lt;br /&gt;AND table_name LIKE '%$'&lt;br /&gt;ORDER BY 1;&lt;/blockquote&gt;&lt;span style="font-weight: bold;"&gt;RULE&lt;/span&gt;&lt;br /&gt;Disables the use of the optimizer. This hint is not supported and should not be used.&lt;br /&gt;&lt;br /&gt;Syntax : /*+ RULE */&lt;br /&gt;Example : &lt;blockquote&gt;&lt;br /&gt;set autotrace trace exp&lt;br /&gt;&lt;br /&gt;SELECT table_name&lt;br /&gt;FROM dba_tables&lt;br /&gt;WHERE owner = 'SYS'&lt;br /&gt;AND table_name LIKE '%$'&lt;br /&gt;ORDER BY 1;&lt;br /&gt;&lt;br /&gt;SELECT /*+ RULE */ table_name&lt;br /&gt;FROM dba_tables&lt;br /&gt;WHERE owner = 'SYS'&lt;br /&gt;AND table_name LIKE '%$'&lt;br /&gt;ORDER BY 1;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-1673657934916474404?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/1673657934916474404/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=1673657934916474404' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/1673657934916474404'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/1673657934916474404'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/01/oracle-optimizer-approach-hints.html' title='Oracle Optimizer Approach Hints'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-5204087539603687748</id><published>2008-01-07T23:34:00.000-08:00</published><updated>2008-01-07T23:38:52.039-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Hints'/><title type='text'>Oracle SQL Hints</title><content type='html'>&lt;blockquote&gt;&lt;blockquote&gt;&lt;/blockquote&gt;/*+ hint */&lt;br /&gt;/*+ hint(argument) */&lt;br /&gt;/*+ hint(argument-1 argument-2) */&lt;/blockquote&gt;&lt;blockquote&gt;&lt;/blockquote&gt;All hints except /*+ rule */ cause the CBO to be used. Therefore, it is good practise to analyze the underlying tables if hints are used (or the query is fully hinted.&lt;br /&gt;There should be no schema names in hints. Hints must use aliases if alias names are used for table names. So the following is wrong:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;select /*+ index(scott.emp ix_emp) */ from scott.emp emp_alias&lt;br /&gt;&lt;/blockquote&gt;better&lt;br /&gt;&lt;blockquote&gt;select /*+ index(emp_alias ix_emp) */ ... from scott.emp emp_alias&lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;span style="font-weight: bold;"&gt;Why using hints&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It is a perfect valid question to ask why hints should be used. Oracle comes with an optimizer that promises to optimize a query's execution plan. When this optimizer is really doing a good job, no hints should be required at all.&lt;br /&gt;Sometimes, however, the characteristics of the data in the database are changing rapidly, so that the optimizer (or more accuratly, its statistics) are out of date. In this case, a hint could help.&lt;br /&gt;It must also be noted, that Oracle allows to lock the statistics when they look ideal which should make the hints meaningless again.&lt;br /&gt;&lt;blockquote&gt;&lt;/blockquote&gt;Hints can be categorized as follows:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Hints for Optimization Approaches and Goals,&lt;/li&gt;&lt;li&gt;Hints for Access Paths, Hints for Query Transformations,&lt;/li&gt;&lt;li&gt;Hints for Join Orders,&lt;/li&gt;&lt;li&gt;Hints for Join Operations,&lt;/li&gt;&lt;li&gt;Hints for Parallel Execution,&lt;/li&gt;&lt;li&gt;Additional Hints &lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-5204087539603687748?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/5204087539603687748/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=5204087539603687748' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/5204087539603687748'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/5204087539603687748'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/01/oracle-sql-hints.html' title='Oracle SQL Hints'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-8701388980508965042</id><published>2008-01-07T17:08:00.000-08:00</published><updated>2008-01-07T18:01:13.416-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Hints'/><title type='text'>Oracle 10g Release 2 Hint List</title><content type='html'>Getting a list of Oracle hints for SQL tuning is often difficult.  The Oracle hint list is inside the Oracle executable and you can extract the Oracle hint list easily with UNIX commands.&lt;br /&gt;&lt;br /&gt;You can use grep and strings to get them directly from the Oracle executable:&lt;br /&gt;&lt;br /&gt;   strings $ORACLE_HOME/bin/oracle &gt; hints.lst&lt;br /&gt;&lt;br /&gt;Here are categorized hint list :&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Optimizer Approaches&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;ALL_ROWS&lt;/li&gt;&lt;li&gt;FIRST_ROWS(n)&lt;/li&gt;&lt;li&gt;RULE&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;General&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;APPEND&lt;/li&gt;&lt;li&gt;CACHE&lt;/li&gt;&lt;li&gt;CURSOR_SHARING_EXACT&lt;/li&gt;&lt;li&gt;DRIVING_SITE&lt;/li&gt;&lt;li&gt;DYNAMIC_SAMPLING&lt;/li&gt;&lt;li&gt;MODEL_MIN_ANALYSIS&lt;/li&gt;&lt;li&gt;NOAPPEND&lt;/li&gt;&lt;li&gt;NO_CACHE&lt;/li&gt;&lt;li&gt;NO_PUSH_PRED&lt;/li&gt;&lt;li&gt;NO_PUSH_SUBQ&lt;/li&gt;&lt;li&gt;NO_PX_JOIN_FILTER&lt;/li&gt;&lt;li&gt;NO_XML_QUERY_REWRITE&lt;/li&gt;&lt;li&gt;PUSH_PRED&lt;/li&gt;&lt;li&gt;PUSH_SUBQ&lt;/li&gt;&lt;li&gt;PX_JOIN_FILTER&lt;/li&gt;&lt;li&gt;QB_NAME&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Access Method Hints&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;FULL&lt;/li&gt;&lt;li&gt;INDEX&lt;/li&gt;&lt;li&gt;INDEX_ASC&lt;/li&gt;&lt;li&gt;INDEX_COMBINE&lt;/li&gt;&lt;li&gt;INDEX_DESC&lt;/li&gt;&lt;li&gt;INDEX_FFS&lt;/li&gt;&lt;li&gt;INDEX_JOIN&lt;/li&gt;&lt;li&gt;INDEX_SS&lt;/li&gt;&lt;li&gt;INDEX_SS_ASC&lt;/li&gt;&lt;li&gt;INDEX_SS_DESC&lt;/li&gt;&lt;li&gt;NO_INDEX&lt;/li&gt;&lt;li&gt;NO_INDEX_FFS&lt;/li&gt;&lt;li&gt;NO_INDEX_SS&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Cluster Only Access Method Hints&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;CLUSTER&lt;/li&gt;&lt;li&gt;HASH&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Join Order&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;LEADING&lt;/li&gt;&lt;li&gt;ORDERED&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Join Operation&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;NO_USE_HASH (table1 table2)&lt;/li&gt;&lt;li&gt;NO_USE_MERGE (table1 table2)&lt;/li&gt;&lt;li&gt;NO_USE_NL (table1 table2)&lt;/li&gt;&lt;li&gt;USE_HASH (table1 table2)&lt;/li&gt;&lt;li&gt;USE_MERGE (table1 table2)&lt;/li&gt;&lt;li&gt;USE_NL (table1 table2)&lt;/li&gt;&lt;li&gt;USE_NL_WITH_INDEX&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Parallel Execution&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;PARALLEL&lt;/li&gt;&lt;li&gt;NO_PARALLEL&lt;/li&gt;&lt;li&gt;PQ_DISTRIBUTE&lt;/li&gt;&lt;li&gt;PARALLEL_INDEX&lt;/li&gt;&lt;li&gt;NO_PARALLEL_INDEX&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Query Transformation&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;FACT&lt;/li&gt;&lt;li&gt;NO_EXPAND&lt;/li&gt;&lt;li&gt;NO_FACT&lt;/li&gt;&lt;li&gt;NO_QUERY_TRANSFORMATION&lt;/li&gt;&lt;li&gt;NO_REWRITE&lt;/li&gt;&lt;li&gt;NO_STAR_TRANSFORMATION&lt;/li&gt;&lt;li&gt;NO_UNNEST&lt;/li&gt;&lt;li&gt;REWRITE&lt;/li&gt;&lt;li&gt;STAR_TRANSFORMATION&lt;/li&gt;&lt;li&gt;UNNEST&lt;/li&gt;&lt;li&gt;USE_CONCAT&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Others&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;ANTIJOIN       &lt;/li&gt;&lt;li&gt;BITMAP      &lt;/li&gt;&lt;li&gt;BUFFER      &lt;/li&gt;&lt;li&gt;CARDINALITY     &lt;/li&gt;&lt;li&gt;HASH_AJ      &lt;/li&gt;&lt;li&gt;INLINE      &lt;/li&gt;&lt;li&gt;MATERIALIZE      &lt;/li&gt;&lt;li&gt;MERGE&lt;/li&gt;&lt;li&gt;NO_ACCESS      &lt;/li&gt;&lt;li&gt;NO_BUFFER      &lt;/li&gt;&lt;li&gt;NO_MERGE&lt;/li&gt;&lt;li&gt;NO_MONITORING&lt;/li&gt;&lt;li&gt;NO_PUSH_GSETS      &lt;/li&gt;&lt;li&gt;NO_PUSH_JOIN_PRED&lt;/li&gt;&lt;li&gt;NO_QKN_BUFF      &lt;/li&gt;&lt;li&gt;NO_SEMIJOIN      &lt;/li&gt;&lt;li&gt;OR_EXPAND      &lt;/li&gt;&lt;li&gt;PUSH_JOIN_PRED&lt;/li&gt;&lt;li&gt;SEMIJOIN      &lt;/li&gt;&lt;li&gt;SEMIJOIN_DRIVER      &lt;/li&gt;&lt;li&gt;SWAP_JOIN_INPUTS      &lt;/li&gt;&lt;li&gt;USE_ANTI      &lt;/li&gt;&lt;li&gt;USE_SEMI&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Undocumented Optimizer Hints&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;BYPASS_RECURSIVE_CHECK       &lt;/li&gt;&lt;li&gt;BYPASS_UJVC      &lt;/li&gt;&lt;li&gt;CACHE_CB      &lt;/li&gt;&lt;li&gt;CACHE_TEMP_TABLE      &lt;/li&gt;&lt;li&gt;CIV_GB      &lt;/li&gt;&lt;li&gt;COLLECTIONS_GET_REFS      &lt;/li&gt;&lt;li&gt;CPU_COSTING      &lt;/li&gt;&lt;li&gt;CUBE_GB      &lt;/li&gt;&lt;li&gt;DEREF_NO_REWRITE      &lt;/li&gt;&lt;li&gt;DML_UPDATE      &lt;/li&gt;&lt;li&gt;DOMAIN_INDEX_NO_SORT      &lt;/li&gt;&lt;li&gt;DOMAIN_INDEX_SORT      &lt;/li&gt;&lt;li&gt;DYNAMIC_SAMPLING_EST_CDN      &lt;/li&gt;&lt;li&gt;EXPAND_GSET_TO_UNION      &lt;/li&gt;&lt;li&gt;FORCE_SAMPLE_BLOCK      &lt;/li&gt;&lt;li&gt;GBY_CONC_ROLLUP      &lt;/li&gt;&lt;li&gt;GLOBAL_TABLE_HINTS      &lt;/li&gt;&lt;li&gt;HWM_BROKERED      &lt;/li&gt;&lt;li&gt;IGNORE_ON_CLAUSE      &lt;/li&gt;&lt;li&gt;IGNORE_WHERE_CLAUSE      &lt;/li&gt;&lt;li&gt;INDEX_RRS      &lt;/li&gt;&lt;li&gt;LIKE_EXPAND      &lt;/li&gt;&lt;li&gt;LOCAL_INDEXES      &lt;/li&gt;&lt;li&gt;MV_MERGE      &lt;/li&gt;&lt;li&gt;NESTED_TABLE_GET_REFS      &lt;/li&gt;&lt;li&gt;NESTED_TABLE_SET_REFS      &lt;/li&gt;&lt;li&gt;NESTED_TABLE_SET_SETID      &lt;/li&gt;&lt;li&gt;NO_ELIMINATE&lt;/li&gt;&lt;li&gt;NO_EXPAND_GSET_TO_UNION      &lt;/li&gt;&lt;li&gt;NO_FILTERING      &lt;/li&gt;&lt;li&gt;NO_ORDER_ROLLUPS      &lt;/li&gt;&lt;li&gt;NO_PRUNE_GSETS      &lt;/li&gt;&lt;li&gt;NO_STATS_GSETS      &lt;/li&gt;&lt;li&gt;NOCPU_COSTING      &lt;/li&gt;&lt;li&gt;OB_NAME&lt;/li&gt;&lt;li&gt;OVERFLOW_NOMOVE      &lt;/li&gt;&lt;li&gt;PIV_GB      &lt;/li&gt;&lt;li&gt;PIV_SSF      &lt;/li&gt;&lt;li&gt;PQ_MAP      &lt;/li&gt;&lt;li&gt;PQ_NOMAP      &lt;/li&gt;&lt;li&gt;REMOTE_MAPPED      &lt;/li&gt;&lt;li&gt;RESTORE_AS_INTERVALS      &lt;/li&gt;&lt;li&gt;SAVE_AS_INTERVALS      &lt;/li&gt;&lt;li&gt;SCN_ASCENDING      &lt;/li&gt;&lt;li&gt;SELECTIVITY      &lt;/li&gt;&lt;li&gt;SKIP_EXT_OPTIMIZER      &lt;/li&gt;&lt;li&gt;SQLLDR      &lt;/li&gt;&lt;li&gt;SYS_DL_CURSOR      &lt;/li&gt;&lt;li&gt;SYS_PARALLEL_TXN      &lt;/li&gt;&lt;li&gt;SYS_RID_ORDER      &lt;/li&gt;&lt;li&gt;TIV_GB      &lt;/li&gt;&lt;li&gt;TIV_SSF      &lt;/li&gt;&lt;li&gt;USE_TTT_FOR_GSETS&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-8701388980508965042?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/8701388980508965042/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=8701388980508965042' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/8701388980508965042'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/8701388980508965042'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/01/oracle-10g-release-2-hint-list.html' title='Oracle 10g Release 2 Hint List'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-6502917400200078327</id><published>2008-01-07T16:22:00.001-08:00</published><updated>2008-01-07T23:33:30.543-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Hints'/><title type='text'>Oracle Optimizer Hints</title><content type='html'>Optimizer hints can be used with SQL statements to alter execution plans.Hints let you make decisions usually made by the optimizer. As an application designer, you might know information about your data that the optimizer does not know.&lt;br /&gt;&lt;br /&gt;For example, you might know that a certain index is more selective for certain queries. Based on this information, you might be able to choose a more efficient execution plan than the optimizer. In such a case, use hints to force the optimizer to use the optimal execution plan.&lt;br /&gt;&lt;br /&gt;You can use hints to specify the following:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The optimization approach for a SQL statement&lt;/li&gt;&lt;li&gt;The goal of the cost-based optimizer for a SQL statement&lt;/li&gt;&lt;li&gt;The access path for a table accessed by the statement&lt;/li&gt;&lt;li&gt;The join order for a join statement&lt;/li&gt;&lt;li&gt;A join operation in a join statement&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Note &lt;/span&gt;: The use of hints involves extra code that must be managed, checked, and controlled.&lt;br /&gt;&lt;br /&gt;Hints provide a mechanism to direct the optimizer to choose a certain query execution plan based on the following criteria:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Join order&lt;/li&gt;&lt;li&gt;Join method&lt;/li&gt;&lt;li&gt;Access path&lt;/li&gt;&lt;li&gt;Parallelization&lt;/li&gt;&lt;/ul&gt;Hints (except for the RULE hint) invoke the cost-based optimizer (CBO). If you have not gathered statistics, then defaults are used. Hints apply only to the optimization of the statement block in which they appear. A statement block is any one of the following statements or parts of statements:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;A simple SELECT, UPDATE, or DELETE statement.&lt;/li&gt;&lt;li&gt;A parent statement or subquery of a complex statement.&lt;/li&gt;&lt;li&gt;A part of a compound query.&lt;/li&gt;&lt;/ul&gt;For example, a compound query consisting of two component queries combined by the UNION operator has two statement blocks, one for each component query. For this reason, hints in the first component query apply only to its optimization, not to the optimization of the second component query.&lt;br /&gt;&lt;br /&gt;You can send hints for a SQL statement to the optimizer by enclosing them in a comment within the statement. A statement block can have only one comment containing hints. This comment can only follow the SELECT, UPDATE, or DELETE keyword.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Exception&lt;/span&gt;:&lt;br /&gt;The APPEND hint always follows the INSERT keyword, and the PARALLEL hint can follow the INSERT keyword.&lt;br /&gt;&lt;br /&gt;The following syntax shows hints contained in both styles of comments that Oracle supports within a statement block.&lt;br /&gt;&lt;br /&gt;{DELETE|INSERT|SELECT|UPDATE} /*+ hint [text] [hint[text]]... */&lt;br /&gt;&lt;br /&gt;or&lt;br /&gt;&lt;br /&gt;{DELETE|INSERT|SELECT|UPDATE} --+ hint [text] [hint[text]]...&lt;br /&gt;&lt;br /&gt;where:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;DELETE, INSERT, SELECT, and UPDATE are keywords that begin a statement block. Comments containing hints can appear only after these keywords.&lt;/li&gt;&lt;li&gt;+ causes Oracle to interpret the comment as a list of hints. The plus sign must immediately follow the comment delimiter; no space is permitted.&lt;/li&gt;&lt;li&gt;hint is one of the hints discussed in this section. If the comment contains multiple hints, then each hint must be separated from the others by at least one space.&lt;/li&gt;&lt;li&gt;text is other commenting text that can be interspersed with the hints.&lt;/li&gt;&lt;/ul&gt;If you specify hints incorrectly, then Oracle ignores them but does not return an error:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Oracle ignores hints if the comment containing them does not follow a DELETE, SELECT, or UPDATE keyword.&lt;/li&gt;&lt;li&gt;Oracle ignores hints containing syntax errors, but considers other correctly specified hints within the same comment.&lt;/li&gt;&lt;li&gt;Oracle ignores combinations of conflicting hints, but considers other hints within the same comment.&lt;/li&gt;&lt;li&gt;Oracle ignores hints in all SQL statements in those environments that use PL/SQL version 1, such as Forms version 3 triggers, Oracle Forms 4.5, and Oracle Reports 2.5. These hints can be passed to the server, but the server ignores them.&lt;/li&gt;&lt;/ul&gt;The optimizer recognizes hints only when using the cost-based approach. If you include a hint (except the RULE hint) in a statement block, then the optimizer automatically uses the cost-based approach.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-6502917400200078327?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/6502917400200078327/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=6502917400200078327' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/6502917400200078327'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/6502917400200078327'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/01/optimizer-hints.html' title='Oracle Optimizer Hints'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-3415895360654049040</id><published>2008-01-03T17:22:00.000-08:00</published><updated>2008-01-03T17:27:16.705-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Oracle, SQL, PL / SQL Technical Interview Questions</title><content type='html'>Listed here are Interview Questions for Database Interviews.&lt;br /&gt;This mainly lists Oracle, SQL, PL SQL frequently asked questions in technical Interviews&lt;br /&gt;&lt;br /&gt;1. What is DDL, DML ? How are they different?&lt;br /&gt;2. What are different types of joins in SQL?&lt;br /&gt;3. How do you select unique rows using SQL?&lt;br /&gt;4. What is the difference between DELETE and TRUNCATE ?&lt;br /&gt;5. What is the difference between a "where" clause and a "having" clause?&lt;br /&gt;6. What is the difference between "procedure" and "function"?&lt;br /&gt;7. What is the difference between "translate" and "replace" ?&lt;br /&gt;8. How to remove duplicate records from a table?&lt;br /&gt;9. What is a "trigger"?&lt;br /&gt;10.What is the difference between "translate" and "replace"?&lt;br /&gt;11.What is a VIEW?&lt;br /&gt;12.What is the difference among "dropping a table", "truncating a table"&lt;br /&gt;and "deleting all records" from a table&lt;br /&gt;13.Explain new feature of 9i Database ? Explain new feature of 10g Database ?&lt;br /&gt;14.How to use DECODE function?&lt;br /&gt;15.What is “Group by” clause?&lt;br /&gt;16.What are cursors and what are the situations you will use them?&lt;br /&gt;17.What default packages are provided by Oracle?&lt;br /&gt;18.How do you debug a oracle procedure /function?&lt;br /&gt;19.How many triggers are available?&lt;br /&gt;20.How are procedures executed?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-3415895360654049040?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/3415895360654049040/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=3415895360654049040' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/3415895360654049040'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/3415895360654049040'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/01/oracle-sql-pl-sql-technical-interview.html' title='Oracle, SQL, PL / SQL Technical Interview Questions'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-1524900952379557107</id><published>2008-01-03T17:15:00.000-08:00</published><updated>2008-01-03T17:20:25.739-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Oracle SQL, PL/SQL Interview Question List</title><content type='html'>These are some Oracle SQL, PL/SQL Interview Question List&lt;br /&gt;1. How do you convert a date to a string?&lt;br /&gt;2. What is an aggregate function?&lt;br /&gt;3. What is the dual table?&lt;br /&gt;4. What are cursors? Distinguish between implicit and explict cursors?&lt;br /&gt;5. Explain how cursors are used by Oracle?&lt;br /&gt;6. What is PL/SQL? Describe the block structure of PL/SQL?&lt;br /&gt;7. What is a nested subquery?&lt;br /&gt;8. What are the various types of queries ?&lt;br /&gt;9. Which of the following is not a schema object : Index, table, public synonym, trigger and    package ?&lt;br /&gt;10. What is dynamic sql in oracle?&lt;br /&gt;11. What is the difference between a package, procedure and function?&lt;br /&gt;12. What is the difference between delete, drop and truncating a table?&lt;br /&gt;13. How many triggers are supported in Oracle&lt;br /&gt;14. Are you aware of FLASHBACK concept ? What is it?&lt;br /&gt;15. Describe oracle’s logical and physical structure?&lt;br /&gt;16. What is data dictionary ?&lt;br /&gt;17. What is the use of control files ?&lt;br /&gt;18. How would store XML data in table ? What data type would be used for the columns?&lt;br /&gt;19. Difference between post and commit?&lt;br /&gt;20. Difference between commit and rollback?&lt;br /&gt;21. What are savepoints?&lt;br /&gt;22. What is the Difference between a View and Synonym?&lt;br /&gt;23. How would you fetch system date from oracle?&lt;br /&gt;24. What is the difference between primary key, unique key, foreign key?&lt;br /&gt;25. What is the difference between NO DATA FOUND and %NOTFOUND?&lt;br /&gt;26. What is cursor for loop?&lt;br /&gt;27. What are cursor attributes?&lt;br /&gt;28. What will you use in Query : IN or EXISTS? Why?&lt;br /&gt;29. Explain the difference between a data block, an extent and a segment.?&lt;br /&gt;30. What's the difference between logical and physical I/O?&lt;br /&gt;31. What is an anonymous block?&lt;br /&gt;32. What is a PL/SQL collection?&lt;br /&gt;33. How can you tell if an UPDATE updated no rows?&lt;br /&gt;34. How can you tell if a SELECT returned no rows?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-1524900952379557107?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/1524900952379557107/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=1524900952379557107' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/1524900952379557107'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/1524900952379557107'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/01/oracle-sql-plsql-interview-question.html' title='Oracle SQL, PL/SQL Interview Question List'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-5770514309249068831</id><published>2008-01-03T16:59:00.000-08:00</published><updated>2008-01-03T17:02:37.839-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><title type='text'>The Difference Between %TYPE and %ROWTYPE</title><content type='html'>%TYPE and %ROWTYPE are used to define variables in PL/SQL as it is defined within the database. If the datatype or precision of a column changes, the program automically picks up the new definition from the database without having to make any code changes.&lt;br /&gt;&lt;br /&gt;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.&lt;br /&gt;&lt;br /&gt;%TYPE is used to declare a field with the same type as that of a specified table's column. Example:&lt;br /&gt;&lt;blockquote&gt;DECLARE&lt;br /&gt;   v_EmpName  emp.ename%TYPE;&lt;br /&gt;BEGIN&lt;br /&gt;   SELECT ename INTO v_EmpName FROM emp WHERE ROWNUM = 1;&lt;br /&gt;   DBMS_OUTPUT.PUT_LINE('Name = ' || v_EmpName);&lt;br /&gt;END;&lt;br /&gt;/&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;%ROWTYPE is used to declare a record with the same types as found in the specified database table, view or cursor. Examples:&lt;br /&gt;&lt;blockquote&gt;DECLARE&lt;br /&gt;  v_emp emp%ROWTYPE;&lt;br /&gt;BEGIN&lt;br /&gt;  v_emp.empno := 10;&lt;br /&gt;  v_emp.ename := 'XXXXXXX';&lt;br /&gt;END;&lt;br /&gt;/&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;blockquote&gt;DECLARE&lt;br /&gt;  v_EmpRecord  emp%ROWTYPE;&lt;br /&gt;BEGIN&lt;br /&gt;  SELECT * INTO v_EmpRecord FROM emp WHERE ROWNUM = 1;&lt;br /&gt;  DBMS_OUTPUT.PUT_LINE('Name = ' || v_EmpRecord.ename);&lt;br /&gt;  DBMS_OUTPUT.PUT_LINE('Salary = ' || v_EmpRecord.sal);&lt;br /&gt;END;&lt;br /&gt;/&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-5770514309249068831?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/5770514309249068831/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=5770514309249068831' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/5770514309249068831'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/5770514309249068831'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/01/difference-between-type-and-rowtype.html' title='The Difference Between %TYPE and %ROWTYPE'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-3828777242136529346</id><published>2008-01-03T16:14:00.001-08:00</published><updated>2008-01-03T16:53:35.532-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Oracle DBA Interview Questions</title><content type='html'>Here are Oracle DBA Questions and Answers in Interview (don't expect too much on this)&lt;br /&gt;&lt;br /&gt;1. Explain database instance ?&lt;br /&gt;&lt;br /&gt;A database instance (server) is a set of memory structures and background processes that access a set of database files.&lt;br /&gt;The memory structures are used to store most queried data from database. This helps us to improve database performance by decreasing the amount of I/O performed against data file.&lt;br /&gt;The process can be shared by all users.&lt;br /&gt;&lt;br /&gt;2. What is parallel server?&lt;br /&gt;Multiple instances accessing the same database (Only in Multi-CPU environments).&lt;br /&gt;&lt;br /&gt;3. What is Schema ?&lt;br /&gt;The set of objects owned by user account is called the schema&lt;br /&gt;&lt;br /&gt;4. What is an Index ? How it is implemented in Oracle Database ?&lt;br /&gt;An index is a database structure used by the server to have direct access of a row in a table.An index is automatically created when a unique or primary key constraint clause is specified in create table command&lt;br /&gt;&lt;br /&gt;5. What is a clusters? Explain&lt;br /&gt;Group of tables physically stored together because they share common columns and are often used together is called Clusters.&lt;br /&gt;&lt;br /&gt;6. What is a cluster key ?&lt;br /&gt;The related columns of the tables are called the cluster key. The cluster key is indexed using a cluster index and its value is stores only once for multiple tables in the cluster.&lt;br /&gt;&lt;br /&gt;7. What are the basic element of an oracle Database ?&lt;br /&gt;It consists ofone or more data filesone or more control filestwo or more redo log files&lt;br /&gt;The database containsMultiple users/schemasone or more rollback segmentsone or more tablespacesData dictionary tables&lt;br /&gt;User objects (tables,indexes,views etc)&lt;br /&gt;The server that access the database consists of&lt;br /&gt;SGA (Database buffer, Dictionary Cache Buffers, redo log buffers,Shared SQL pool)&lt;br /&gt;SMON&lt;br /&gt;PMON&lt;br /&gt;LGWR&lt;br /&gt;DBWR&lt;br /&gt;ARCH&lt;br /&gt;CKPT&lt;br /&gt;RECO&lt;br /&gt;Dispatcher&lt;br /&gt;User process with associated PGA&lt;br /&gt;&lt;br /&gt;8. What is deadlock ? Explain.&lt;br /&gt;Two processes waiting to update the rows of a table which are locked by the other process then deadlock arises.&lt;br /&gt;In a database environment this will often happen because of not issuing proper row lock commands. Poor design of front-end application may cause this situation and the performance of server will reduce drastically.&lt;br /&gt;These locks will be released automatically when a commit/rollback operation performed or any one of this processes being killed externally.&lt;br /&gt;&lt;br /&gt;9. What is SGA ?&lt;br /&gt;The System Global Area in a Oracle database is the area in memory to facilitates the transfer of information between users. It holds the most recently requested structural information about the database.&lt;br /&gt;&lt;br /&gt;10. What is Shared SQL pool ?&lt;br /&gt;The data dictionary cache is stored in an area in SGA called the Shared SQL Pool. This will allow sharing of parsed SQL statements among concurrent users.&lt;br /&gt;&lt;br /&gt;11. What is meant by Program Global Area (PGA) ?&lt;br /&gt;It is area in memory that is used by a Single Oracle User process.&lt;br /&gt;&lt;br /&gt;12. What is a data segment ?&lt;br /&gt;Data segment are the physical areas within a database block in which the data associated with tables and clusters are stored.&lt;br /&gt;&lt;br /&gt;13. What are the factors causing the reparsing of SQL statements in SGA ?&lt;br /&gt;Due to insufficient Shared SQL pool size&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-3828777242136529346?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/3828777242136529346/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=3828777242136529346' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/3828777242136529346'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/3828777242136529346'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/01/oracle-dba-interview-questions.html' title='Oracle DBA Interview Questions'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-974023489739416740</id><published>2008-01-02T19:53:00.000-08:00</published><updated>2008-01-02T20:04:14.788-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>Oracle 10g UTL_COMPRESS</title><content type='html'>Oracle 10g includes many PL/SQL enhancements including: &lt;span style="font-weight: bold;"&gt;utl_compress&lt;/span&gt;&lt;br /&gt;The UTL_COMPRESS package provides an API to allow compression and decompression of binary data (RAW, BLOB and BFILE). It uses the Lempel-Ziv compression algorithm which is equivalent to functionality of the gzip utility. A simple example of it's usage would be:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;SET SERVEROUTPUT ON&lt;br /&gt;DECLARE&lt;br /&gt;l_original_blob      BLOB;&lt;br /&gt;l_compressed_blob    BLOB;&lt;br /&gt;l_uncompressed_blob  BLOB;&lt;br /&gt;BEGIN&lt;br /&gt;-- Initialize both BLOBs to something.&lt;br /&gt;l_original_blob     := TO_BLOB(UTL_RAW.CAST_TO_RAW('1234567890123456789012345678901234567890'));&lt;br /&gt;l_compressed_blob   := TO_BLOB('1');&lt;br /&gt;l_uncompressed_blob := TO_BLOB('1');&lt;br /&gt;&lt;br /&gt;-- Compress the data.&lt;br /&gt;UTL_COMPRESS.lz_compress (src =&gt; l_original_blob,&lt;br /&gt;                          dst =&gt; l_compressed_blob);&lt;br /&gt;&lt;br /&gt;-- Uncompress the data.&lt;br /&gt;UTL_COMPRESS.lz_uncompress (src =&gt; l_compressed_blob,&lt;br /&gt;                            dst =&gt; l_uncompressed_blob);&lt;br /&gt;&lt;br /&gt;-- Display lengths.&lt;br /&gt;DBMS_OUTPUT.put_line('Original Length    : ' || LENGTH(l_original_blob));&lt;br /&gt;DBMS_OUTPUT.put_line('Compressed Length  : ' || LENGTH(l_compressed_blob));&lt;br /&gt;DBMS_OUTPUT.put_line('Uncompressed Length: ' || LENGTH(l_uncompressed_blob));&lt;br /&gt;&lt;br /&gt;-- Free temporary BLOBs.           &lt;br /&gt;DBMS_LOB.FREETEMPORARY(l_original_blob);&lt;br /&gt;DBMS_LOB.FREETEMPORARY(l_compressed_blob);&lt;br /&gt;DBMS_LOB.FREETEMPORARY(l_uncompressed_blob);&lt;br /&gt;END;&lt;br /&gt;/&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-974023489739416740?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/974023489739416740/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=974023489739416740' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/974023489739416740'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/974023489739416740'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/01/oracle-10g-utlcompress.html' title='Oracle 10g UTL_COMPRESS'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-8690266460493723733</id><published>2008-01-01T16:02:00.000-08:00</published><updated>2008-01-01T21:47:26.219-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Oracle DBA : Backup on Tape Drive</title><content type='html'>For oracle DBA, here are some cases on Tape Drive Backup:&lt;br /&gt;&lt;br /&gt;You want to take backup on tape drive but rman always store the backup on a default location&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;how can we take backup on tape drive, should we have to install any extra softwares for tape drive or rman handle it itself?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You need thrid party Media managment software like veritas ,omnibackup,tivoli for backing up to tape.If you don't already have Media Management software, you can consider &lt;a href="http://www.oracle.com/technology/products/secure-backup/index.html"&gt;Oracle Secure Backup&lt;/a&gt; as a free alternative (assuming you are backing up one server to one tape drive).&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;how can we set the tape drive as our default location for backup?&lt;br /&gt;how can we take backup on specified location e.g. d:\backup and how can we set this location as default location for backup?&lt;br /&gt;&lt;/span&gt;To set the tape drive as the default, see &lt;a href="http://download.oracle.com/docs/cd/B19306_01/backup.102/b14192/setup004.htm#sthref227"&gt;Configuring the Default Device Type for Backups&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;If you want the tape drive to be the default backup location, then you'll have to allocate a disk channel to produce backups to d:\backup. You can configure the disk format as CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'd:\backups'; and then allocate a disk channel during backup (&lt;a href="http://download.oracle.com/docs/cd/B19306_01/backup.102/b14191/rcmconfg003.htm#sthref535"&gt;Manually Overriding Configured Channels&lt;/a&gt;).&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-8690266460493723733?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/8690266460493723733/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=8690266460493723733' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/8690266460493723733'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/8690266460493723733'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/01/backup-on-tape-drive.html' title='Oracle DBA : Backup on Tape Drive'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-2626020745523171012</id><published>2007-12-27T16:55:00.000-08:00</published><updated>2008-01-01T21:48:25.691-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL*Plus'/><title type='text'>SQL &amp; PL/SQL : When Your Query Takes Too Long</title><content type='html'>When your query takes too long and too slow, first of all you have to investigate the root caused of the problem, you have to know why it is slow&lt;br /&gt;&lt;br /&gt;The tools at your disposal are, among more:&lt;br /&gt;1. dbms_profiler&lt;br /&gt;2. explain plan&lt;br /&gt;3. SQL*Trace / tkprof&lt;br /&gt;4. statspack&lt;br /&gt;&lt;br /&gt;Use dbms_profiler if you want to know where time is being spent in PL/SQL code.&lt;br /&gt;Statspack is a must if you are a dba and want to know what is going on in your entire database. For a single query or a small process, explain plan and SQL*Trace and tkprof are your tools.&lt;br /&gt;&lt;br /&gt;explain plan in SQL*Plus you have to type:&lt;br /&gt;&lt;br /&gt;explain plan for [your query];&lt;br /&gt;select * from table(dbms_xplan.display);&lt;br /&gt;&lt;br /&gt;When you get error messages or a message complaining about an old version of plan_table, make sure you run the script utlxplan.sql.&lt;br /&gt;&lt;br /&gt;The output you get here basically shows you what the cost based optimizer expects. It gives you an idea on why the cost based optimizer chooses an access path.&lt;br /&gt;&lt;br /&gt;SQL*Trace/tkprof&lt;br /&gt;&lt;br /&gt;For this you have to type in SQL*Plus:&lt;br /&gt;- alter session set sql_trace true;&lt;br /&gt;- run your query&lt;br /&gt;- disconnect (this step is important, because it ensures all cursors get closed, and "row source operation" is generated)&lt;br /&gt;- identify your trace file in the server directory as specified in the parameter user_dump_dest&lt;br /&gt;- on your operating system: "tkprof [trace file] a.txt sys=no sort=prsela exeela fchela"&lt;br /&gt;&lt;br /&gt;The file a.txt will now give you valuable information on what has actually happened. No predictions but the truth.&lt;br /&gt;&lt;br /&gt;By comparing the output from explain plan with the output from tkprof, you are able to identify the possible problem areas.&lt;br /&gt;&lt;br /&gt;So before rushing into possible solutions, always post the output of explain plan and tkprof with your question and don't forget to post them between the tags [pre] and [/pre] for readability.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-2626020745523171012?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/2626020745523171012'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/2626020745523171012'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/12/when-your-query-takes-too-long.html' title='SQL &amp; PL/SQL : When Your Query Takes Too Long'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-7187589398303166337</id><published>2007-12-18T15:56:00.000-08:00</published><updated>2008-01-01T21:49:14.281-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL*Plus'/><title type='text'>SQL &amp; PL/QL : Deleting Table with Millions Rows</title><content type='html'>Here are the case:&lt;br /&gt;You have to compare 2 tables, both having around million rows, and delete data based on single column.&lt;br /&gt;&lt;br /&gt;SQL&gt;DELETE FROM TABLE_A WHERE COLUMN_A NOT IN&lt;br /&gt;(SELECT COLUMN_A FROM TABLE_B)&lt;br /&gt;&lt;br /&gt;when you execute the above command, it takes a long time. So what is the best way to achieve it?&lt;br /&gt;Here are some solutions:&lt;br /&gt;&lt;br /&gt;  1. If the rows percentage to be deleted is large then you can try the following step:&lt;br /&gt;         * Create a new table where COLUMN_A NOT IN&lt;br /&gt;           (SELECT COLUMN_A FROM TABLE_B)&lt;br /&gt;         * TRUNCATE table_A&lt;br /&gt;         * Insert in to table_A (select * from new table)&lt;br /&gt;         * If you have any constraints then may be it can be disabled.&lt;br /&gt;  2. If the query is properly indexed you might get better performance from a correlated subquery instead of NOT IN, something like&lt;br /&gt;&lt;br /&gt;     DELETE FROM TABLE_A&lt;br /&gt;     WHERE NOT EXISTS(&lt;br /&gt;     SELECT COLUMN_A&lt;br /&gt;        FROM TABLE_B&lt;br /&gt;     WHERE b.column_a = a.column_a&lt;br /&gt;     )&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-7187589398303166337?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/7187589398303166337'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/7187589398303166337'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/12/deleting-table-with-millions-rows.html' title='SQL &amp; PL/QL : Deleting Table with Millions Rows'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-9051705588539246470</id><published>2007-12-17T23:14:00.000-08:00</published><updated>2007-12-17T23:29:33.862-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Lost SYSOPER Password</title><content type='html'>Thera are several solutions to this issue, you can use one of the following methods:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Make sure that the database and listener services are started. Then open a command prompt and log in as / as sysdba. Then change the sys password.&lt;br /&gt;&lt;br /&gt;c:&gt; sqlplus /nolog&lt;br /&gt;SQL&gt; connect / as sysdba&lt;br /&gt;SQL&gt; alter user sys identified by &lt;new&gt;;&lt;br /&gt;&lt;br /&gt; If you get asked for a password when you log in as / you need to create or recreate the password file using orapw. Check the $ORACLE_HOME/database directory for a file called orapw&lt;sid&gt;. That is the password file for the database. Create (or recreate) it using:&lt;br /&gt;&lt;br /&gt;c:\&gt; orawpd file=$ORACLE_HOME/database/orapwd&lt;sid&gt; password=&lt;password&gt; entries=5&lt;br /&gt;&lt;br /&gt;Notice it is from the dos prompt&lt;/li&gt;&lt;li&gt;you may also try this method:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;login oracle user&lt;/li&gt;&lt;li&gt;cd $ORACLE_HOME/network/admin&lt;/li&gt;&lt;li&gt;ed(vi) file sqlnet.ora&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Remark by # at begining of line&lt;br /&gt;SQLNET.AUTHENTICATION_SERVICES = (NONE)&lt;br /&gt;=&gt; #SQLNET.AUTHENTICATION_SERVICES = (NONE)&lt;/li&gt;&lt;li&gt;sqlplus /nolog or (svrmgrl) command&lt;/li&gt;&lt;li&gt;connect sys as sysdba, or connect internal&lt;br /&gt;(not need input the password).&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-9051705588539246470?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/9051705588539246470/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=9051705588539246470' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/9051705588539246470'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/9051705588539246470'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/12/lost-sysoper-password.html' title='Lost SYSOPER Password'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-6657342481986231174</id><published>2007-12-17T16:12:00.002-08:00</published><updated>2007-12-17T16:24:29.218-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Oracle Data Security Tips</title><content type='html'>If you're building a client-server application, you can use these tips:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Build a three tier application, so the client is not connect to the database directly.&lt;/li&gt;&lt;li&gt;Allow only 1 IP Address (as application server) connect to the oracle database (you can use blocking IP tips).&lt;/li&gt;&lt;li&gt;Never use Oracle user ID (specially DBA user) as your Application user ID, instead create a user table with user and encrypted password in it.&lt;/li&gt;&lt;li&gt;Give your Oracle Listener a password, so when someone unauthorized send a stop message to the listener it didn't work out.&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-6657342481986231174?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/6657342481986231174/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=6657342481986231174' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/6657342481986231174'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/6657342481986231174'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/12/oracle-data-security-tips.html' title='Oracle Data Security Tips'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-2389433910348052081</id><published>2007-12-12T17:33:00.000-08:00</published><updated>2007-12-12T17:46:20.468-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>Oracle SAVEPOINT</title><content type='html'>&lt;span class="bodycopy"&gt;&lt;span style="font-size: 11pt;"&gt;A SAVEPOINT is a marker within a transaction           that allows for a partial rollback. As           changes are made in a transaction, we can           create SAVEPOINTs to mark different points           within the transaction. If we encounter an           error, we can rollback to a SAVEPOINT or all           the way back to the beginning of the           transaction.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;blockquote&gt;           &lt;p&gt;&lt;span class="bodycopy"&gt;           &lt;span style="font-size: 8pt;font-family:Courier New;" &gt;SQL&gt;           INSERT INTO AUTHOR&lt;br /&gt;2 VALUES ('X123', 'mister',            &lt;br /&gt;3 'popo', '62-274-4567',&lt;br /&gt;4 'jl sudirman', 'jakarta',           &lt;br /&gt;5 'JKBKJ','10001', '9999');&lt;br /&gt;          &lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;         SQL&gt; savepoint in_author;&lt;br /&gt;&lt;br /&gt;         Savepoint created.&lt;br /&gt;&lt;br /&gt;         SQL&gt; INSERT INTO BOOK_AUTHOR VALUES ('X123',           'B130', .20);&lt;br /&gt;1 row created.&lt;br /&gt;&lt;br /&gt;         SQL&gt; savepoint in_book_author;&lt;br /&gt;&lt;br /&gt;         Savepoint created.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;           &lt;p&gt;&lt;span class="bodycopy"&gt;           &lt;span style="font-size: 8pt;font-family:Courier New;" &gt;SQL&gt; INSERT INTO BOOK            &lt;br /&gt;2 VALUES ('B130', 'P002', 'how to make love',           &lt;br /&gt;3 'miscellaneous', 9.95, 1000, 15, 0, '',           &lt;br /&gt;4 to_date ('02-20-2007','MM-DD-YYYY'));&lt;br /&gt;1 row created.&lt;br /&gt;          &lt;br /&gt;SQL&gt; rollback to in_author;&lt;br /&gt;          &lt;br /&gt;         Rollback complete.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;span class="bodycopy"&gt;&lt;span style="font-size: 11pt;"&gt;In the example above, I inserted a row into           the AUTHOR table and created a SAVEPOINT           called in_author. Next, I inserted a row           into the book_author table and created           another SAVEPOINT called in_book_author.           Finally, I inserted a row in the BOOK table.           I then issued a ROLLBACK to in_author.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="bodycopy"&gt;&lt;span style="font-size: 11pt;"&gt;Row locks are NOT           released by SETTING a savepoint. Row locks           are release by one of three events - commit,           rollback, or rollback to savepoint. My           argument is that Oracle does not handle the           latter well.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;ol&gt;&lt;li&gt;&lt;span class="bodycopy"&gt;&lt;span style="font-size: 11pt;"&gt;If transaction A updates row 1, sets a           savepoint, and updates row 2 (but does not           as yet commit). Then transaction B wishes to           update row 2.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="bodycopy"&gt;&lt;span style="font-size: 11pt;"&gt;Transaction B will correctly block on the           commit or rollback of transaction A. &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="bodycopy"&gt;&lt;span style="font-size: 11pt;"&gt;However, if transaction A does a rollback           to savepoint, it will continue to have hold           a lock on row 1 (but not row 2). &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="bodycopy"&gt;&lt;span style="font-size: 11pt;"&gt;In fact a third transaction can now           update row 2 (as it's not locked by transaction A).&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="bodycopy"&gt;&lt;span style="font-size: 11pt;"&gt;However, our poor transaction B, is still           waiting (incorrectly) for transaction A to           commit or rollback.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;span class="bodycopy"&gt;&lt;span style="font-size: 11pt;"&gt;The problem is that Oracle provides no way           of waiting on a row - you can only wait on a           transaction - and sometimes transactions           (through the use of rollback to savepoint)           release rows WITHOUT committing or aborting.          &lt;br /&gt;&lt;br /&gt;Imagine what could happen when by issuing a           savepoint the lock of an standing           transaction would be released, and another           transaction would change 'my' row, and then           I do a full rollback.&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-2389433910348052081?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/2389433910348052081'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/2389433910348052081'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/12/oracle-savepoint.html' title='Oracle SAVEPOINT'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-3720821725812751243</id><published>2007-12-12T15:54:00.000-08:00</published><updated>2007-12-12T17:02:44.066-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Repair UNDO Log Corruption</title><content type='html'>In rare cases (usually DBA error) the Oracle UNDO tablespace can become corrupted.&lt;br /&gt;&lt;br /&gt;This manifests with this error: ORA-00376: file xx cannot be read at this time&lt;br /&gt;&lt;br /&gt;In cases of UNDO log corruption, you must:&lt;br /&gt;&lt;br /&gt;   • Change the undo_management parameter from “AUTO” to “MANUAL”&lt;br /&gt;   • Create a new UNDO tablespace&lt;br /&gt;   • Drop the old UNDO tablespace&lt;br /&gt;&lt;br /&gt;Dropping the corrupt UNDO tablespace can be tricky and you may get the message:&lt;br /&gt;&lt;br /&gt;ORA-00376: file string cannot be read at this time&lt;br /&gt;&lt;br /&gt;To drop a corrupt UNDO tablespace:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Identify the bad segment:&lt;br /&gt;&lt;blockquote&gt;             &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;select&lt;br /&gt;             segment_name,&lt;br /&gt;             status&lt;br /&gt;from&lt;br /&gt;             dba_rollback_segs&lt;br /&gt;where&lt;br /&gt;             tablespace_name='undotbs_corrupt'&lt;br /&gt;and&lt;br /&gt;             status = ‘NEEDS RECOVERY’;&lt;br /&gt; &lt;/span&gt;&lt;/p&gt;             &lt;p&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;&lt;br /&gt;SEGMENT_NAME STATUS&lt;br /&gt;----------------------------------------------&lt;br /&gt;_SYSSMU22$ NEEDS RECOVERY&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;/li&gt;&lt;li&gt;Bounce the instance with the hidden parameter “_offline_rollback_segments”,            specifying the bad segment name:&lt;br /&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;_OFFLINE_ROLLBACK_SEGMENTS=_SYSSMU22$&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Bounce database, nuke the corrupt segment and tablespace:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;font-size:85%;"&gt;SQL&gt; drop rollback segment "_SYSSMU22$";&lt;br /&gt;Rollback segment dropped.&lt;br /&gt;           &lt;br /&gt;SQL &gt; drop tablespace undotbs including contents and datafiles;&lt;br /&gt;Tablespace dropped.&lt;/span&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-3720821725812751243?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/3720821725812751243'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/3720821725812751243'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/12/repair-undo-log-corruption.html' title='Repair UNDO Log Corruption'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-5768534052044416803</id><published>2007-11-18T16:57:00.001-08:00</published><updated>2007-11-18T17:53:41.948-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL*Plus'/><title type='text'>Remarks in Script with Ttitle and Btitle</title><content type='html'>The TTITLE (top title) and BTITLE (bottom title) commands have this syntax:&lt;br /&gt;&lt;br /&gt;TTITLE option text OFF/ON&lt;br /&gt;&lt;br /&gt;where option refers to the placement of the title:&lt;br /&gt;&lt;br /&gt;   1. COLUMN n (start in some column, n)&lt;br /&gt;   2. SKIP m (skip m blank lines)&lt;br /&gt;   3. TAB x (tab x positions)&lt;br /&gt;   4. LEFT/CENTER/RIGHT (default is LEFT)&lt;br /&gt;&lt;br /&gt;The same holds for BTITLE.&lt;br /&gt;&lt;br /&gt;In addition, page numbers may be added with the extension:&lt;br /&gt;&lt;br /&gt;option text format 999 sql.pno&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-5768534052044416803?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/5768534052044416803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=5768534052044416803' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/5768534052044416803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/5768534052044416803'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/11/remarks-in-script-with-ttitle-and.html' title='Remarks in Script with Ttitle and Btitle'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-3467325719213906892</id><published>2007-11-18T16:55:00.000-08:00</published><updated>2007-11-18T16:57:05.168-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL*Plus'/><title type='text'>SQL*Plus</title><content type='html'>SQL*Plus is a tool for interfacing with the oracle database&lt;br /&gt;You can use it to&lt;br /&gt;&lt;br /&gt;   1. Execute SQL and PL/SQL in the database&lt;br /&gt;   2. Update data in your database&lt;br /&gt;   3. Perform queries on your data&lt;br /&gt;   4. Format the result sets of those queries into reports&lt;br /&gt;   5. Create, edit, retrieve, and execute SQL scripts&lt;br /&gt;   6. Administer the database&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-3467325719213906892?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/3467325719213906892/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=3467325719213906892' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/3467325719213906892'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/3467325719213906892'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/11/sqlplus.html' title='SQL*Plus'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-8271135289440395988</id><published>2007-09-19T20:51:00.001-07:00</published><updated>2007-09-19T20:57:05.619-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>Get IP Address and Hostname</title><content type='html'>There are legitimate times when you want your procedural code to gather the current host name or IP address and Oracle has several ways to do this:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The utl_inaddr procedure&lt;/span&gt;:&lt;br /&gt;SQL&gt; select utl_inaddr.get_host_address('www.detik.com')&lt;br /&gt;  2  hostname from dual;&lt;br /&gt;&lt;br /&gt;HOSTNAME&lt;br /&gt;-----------------&lt;br /&gt;203.190.241.41&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The sys_context procedure&lt;/span&gt;:&lt;br /&gt;SQL&gt; select SYS_CONTEXT('USERENV', 'IP_ADDRESS', 15) ipaddr from dual;&lt;br /&gt;&lt;br /&gt;IPADDR&lt;br /&gt;------------------&lt;br /&gt;172.16.1.78&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-8271135289440395988?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/8271135289440395988/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=8271135289440395988' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/8271135289440395988'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/8271135289440395988'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/get-ip-address-and-hostname.html' title='Get IP Address and Hostname'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-6942532783482870797</id><published>2007-09-18T18:28:00.000-07:00</published><updated>2007-09-18T18:53:59.413-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>Retrieving Only the Nth Row From a Table</title><content type='html'>How are we suppose to retrieve only the Nth row from a table?&lt;br /&gt;&lt;br /&gt;SELECT * FROM &lt;span style="font-style: italic;"&gt;table&lt;/span&gt;&lt;br /&gt;WHERE rowid = (&lt;br /&gt;        SELECT rowid FROM &lt;span style="font-style: italic;"&gt;table&lt;/span&gt;&lt;br /&gt;        WHERE rownum &lt;= N&lt;br /&gt;        MINUS&lt;br /&gt;        SELECT rowid FROM   &lt;span style="font-style: italic;"&gt;table&lt;/span&gt;&lt;br /&gt;        WHERE rownum &lt; N&lt;br /&gt;      );&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;span style="font-style: italic;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-6942532783482870797?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/6942532783482870797/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=6942532783482870797' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/6942532783482870797'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/6942532783482870797'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/retrieving-only-nth-row-from-table.html' title='Retrieving Only the Nth Row From a Table'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-7941244205647015474</id><published>2007-09-16T17:36:00.000-07:00</published><updated>2007-09-16T17:42:27.617-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>Analytic Features - Grouping Sets</title><content type='html'>Grouping Sets - Instead of a UNION ALL statement (that would require multiple table scans), define a grouping set - the new syntax will result in only a single pass over the base table.&lt;br /&gt;Grouping Sets are specified in the GROUP BY clause&lt;br /&gt;Syntax:&lt;br /&gt;&lt;br /&gt;  &lt;span style="font-size:85%;"&gt;SELECT group_function(column1), column2, group_function(column3)...&lt;br /&gt;   FROM table_list&lt;br /&gt;   [WHERE conditions]&lt;br /&gt;   &lt;span style="font-weight: bold;"&gt;GROUP BY GROUPING SETS&lt;/span&gt; (group_by_list)&lt;br /&gt;&lt;br /&gt;   SELECT group_function(column1), column2, group_function(column3)...&lt;br /&gt;   FROM table_list&lt;br /&gt;   [WHERE conditions]&lt;br /&gt;   &lt;span style="font-weight: bold;"&gt;GROUP BY CUBE&lt;/span&gt; (group_by_list)&lt;br /&gt;&lt;br /&gt;   SELECT group_function(column1), column2, group_function(column3)...&lt;br /&gt;   FROM table_list&lt;br /&gt;   [WHERE conditions]&lt;br /&gt;   GROUP BY &lt;span style="font-weight: bold;"&gt;ROLLUP&lt;/span&gt; (group_by_list)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;Examples:&lt;br /&gt;Instead of this UNION query...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   SELECT&lt;br /&gt;       manager_id, null hire_date, count(*)&lt;br /&gt;   FROM&lt;br /&gt;       employees&lt;br /&gt;   GROUP BY manager_id, 2&lt;br /&gt; UNION ALL&lt;br /&gt;   SELECT&lt;br /&gt;       null, hire_date, count(*)&lt;br /&gt;   FROM&lt;br /&gt;       employees&lt;br /&gt;   GROUP BY 1, hire_date&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;The above rewritten as a Grouping Set...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   SELECT&lt;br /&gt;       manager_id, hire_date, count(*)&lt;br /&gt;   FROM&lt;br /&gt;       employees&lt;br /&gt;   GROUP BY GROUPING SETS (manager_id, hire_date);&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;The GROUPING SET clause allows you to specify the EXACT groups.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;span style="font-size:100%;"&gt;CUBE&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:100%;"&gt;Where a large number of groupings are needed then the CUBE and ROLLUP statements extend this idea by calculating multiple groupings in a single statement.&lt;br /&gt;&lt;br /&gt;e.g. GROUP BY CUBE (hire_date, manager_id, product) will produce 2^3 =8 groupings&lt;br /&gt;1) hire_date, manager_id, product&lt;br /&gt;2) hire_date, manager_id&lt;br /&gt;3) hire_date, product&lt;br /&gt;4) manager_id, product&lt;br /&gt;5) hire_date&lt;br /&gt;6) manager_id&lt;br /&gt;7) product&lt;br /&gt;8) Grand Total&lt;br /&gt;&lt;br /&gt;GROUP BY CUBE always calculates ALL the combinations - which may be far more than needed.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;&lt;span style="font-size:100%;"&gt;ROLLUP&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:100%;"&gt;e.g. GROUP BY ROLLUP (hire_date, manager_id, product) will produce 4 groupings&lt;br /&gt;1) hire_date, manager_id, product&lt;br /&gt;2) hire_date, manager_id&lt;br /&gt;3) hire_date,&lt;br /&gt;4) Grand Total&lt;br /&gt;&lt;br /&gt;GROUP BY ROLLUP calculates all combinations for the first column listed in the ROLLUP clause.&lt;br /&gt;&lt;br /&gt;This can be further tuned by using parenthesis to remove some of the combinations&lt;br /&gt;&lt;br /&gt;e.g. GROUP BY ROLLUP (hire_date, (manager_id, product)) will produce&lt;br /&gt;1) hire_date, manager_id, product&lt;br /&gt;2) hire_date&lt;br /&gt;3) Grand Total&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Grouping function&lt;/span&gt;&lt;br /&gt;CUBE and ROLLUP will generate NULLs for each dimension at the subtotal levels.&lt;br /&gt;The Grouping() function can be used to identify these rows, which can be very useful when performing additional calculations such as Ranking within a group.&lt;br /&gt;&lt;br /&gt;The values returned by grouping() are:&lt;br /&gt;0 for NULL data values&lt;br /&gt;1 for NULL indicating a dimension subtotal&lt;br /&gt;&lt;br /&gt;The results of Grouping() can be passed into a decode() e.g.&lt;br /&gt;SELECT .. PARTITION BY GROUPING(column1) ..&lt;br /&gt;SELECT .. PARTITION BY DECODE(GROUPING(column1), 1, ‘My SubTotal’, column1)) …&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Combining (concatenating) Groupings&lt;/span&gt;&lt;br /&gt;The CUBE and ROLLUP clauses can be combined as part of a standard GROUP BY clause&lt;br /&gt;e.g. GROUP BY manager_id, ROLLUP (hire_date, product)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Notes&lt;/span&gt;&lt;br /&gt;Grouping sets are typically 80 - 90% more efficient at producing sub-totals than equivalent SQL code.&lt;br /&gt;&lt;br /&gt;ROLLUP/CUBE can be used with all aggregate functions (MAX, MIN, AVG, etc.)&lt;br /&gt;&lt;br /&gt;A HAVING clause will apply to all the data returned.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-7941244205647015474?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/7941244205647015474/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=7941244205647015474' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/7941244205647015474'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/7941244205647015474'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/analytic-features-grouping-sets.html' title='Analytic Features - Grouping Sets'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-4162849456947457802</id><published>2007-09-16T17:25:00.000-07:00</published><updated>2007-09-16T17:27:35.970-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>Oracle CASE SQL</title><content type='html'>Oracle SQL allows you to add "Boolean logic" and branching using the decode and CASE clauses.  The case statement is a more flexible extension of the Decode statement. In its simplest form the Oracle CASE function is used to return a value when a match is found:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;SELECT last_name, commission_pct,&lt;br /&gt;  (CASE commission_pct&lt;br /&gt;    WHEN 0.1 THEN ‘Low’&lt;br /&gt;    WHEN 0.15 THEN ‘Average’&lt;br /&gt;    WHEN 0.2 THEN ‘High’&lt;br /&gt;    ELSE ‘N/A’&lt;br /&gt;  END ) Commission&lt;br /&gt;FROM employees ORDER BY last_name;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;A more complex version is the Searched CASE expression where a comparison expression is used to find a match:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;SELECT last_name, job_id, salary,&lt;br /&gt;  (CASE&lt;br /&gt;    WHEN job_id LIKE 'SA_MAN' AND salary &lt; 12000 THEN '10%'&lt;br /&gt;    WHEN job_id LIKE 'SA_MAN' AND salary &gt;= 12000 THEN '15%'&lt;br /&gt;    WHEN job_id LIKE 'IT_PROG' AND salary &lt; 9000 THEN '8%'&lt;br /&gt;    WHEN job_id LIKE 'IT_PROG' AND salary &gt;= 9000 THEN '12%'&lt;br /&gt;    ELSE 'NOT APPLICABLE'&lt;br /&gt;  END ) Raise&lt;br /&gt;FROM employees;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-4162849456947457802?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/4162849456947457802/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=4162849456947457802' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/4162849456947457802'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/4162849456947457802'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/oracle-case-sql.html' title='Oracle CASE SQL'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-3965796812945861252</id><published>2007-09-16T17:00:00.000-07:00</published><updated>2007-09-16T17:23:14.849-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><title type='text'>Character Functions</title><content type='html'>Character Functions accept character input.&lt;br /&gt;The input may come from a column in a table or from any expression.&lt;br /&gt;Character Functions List&lt;br /&gt;&lt;ol&gt;&lt;li&gt;ASCII(x) returns the ASCII value of the character x.&lt;/li&gt;&lt;li&gt;CHR(x) returns the character with the ASCII value of x.&lt;/li&gt;&lt;li&gt;CONCAT(x, y) concatenates y to x and return the appended string.&lt;/li&gt;&lt;li&gt;INITCAP(x) converts the initial letter of each word in x to uppercase and returns that string.&lt;/li&gt;&lt;li&gt;INSTR(x, find_string [, start] [, occurrence]) searches for find_string in x and returns the position at which find_string occurs.&lt;/li&gt;&lt;li&gt;INSTRB(x) returns the location of a string within another string, but returns the value in bytes for a single-byte character system.&lt;/li&gt;&lt;li&gt;LENGTH(x) returns the number of characters in x.&lt;/li&gt;&lt;li&gt;LENGTHB(x) returns the length of a character string in bytes, except that the return value is in bytes for single-byte character sets.&lt;/li&gt;&lt;li&gt;LOWER(x) converts the letters in x to lowercase and returns that string.&lt;/li&gt;&lt;li&gt;LPAD(x, width [, pad_string]) pads x with spaces to left, to bring the total length of the string up to width characters.&lt;/li&gt;&lt;li&gt;LTRIM(x [, trim_string]) trims characters from the left of x.&lt;/li&gt;&lt;li&gt;NANVL(x, value) returns value if x matches the NaN special value (not a number), otherwise x is returned.&lt;/li&gt;&lt;li&gt;NLS_INITCAP(x) Same as the INITCAP function except that it can use a different sort method as specified by NLSSORT.&lt;/li&gt;&lt;li&gt;NLS_LOWER(x) Same as the LOWER function except that it can use a different sort method as specified by NLSSORT.&lt;/li&gt;&lt;li&gt;NLS_UPPER(x) Same as the UPPER function except that it can use a different sort method as specified by NLSSORT.&lt;/li&gt;&lt;li&gt;NLSSORT(x) Changes the method of sorting the characters. Must be specified before any NLS function; otherwise, the default sort will be used.&lt;/li&gt;&lt;li&gt;NVL(x, value) returns value if x is null; otherwise, x is returned.&lt;/li&gt;&lt;li&gt;NVL2(x, value1, value2) returns value1 if x is not null; if x is null, value2 is returned.&lt;/li&gt;&lt;li&gt;REPLACE(x, search_string, replace_string) searches x for search_string and replaces it with replace_string.&lt;/li&gt;&lt;li&gt;RPAD(x, width [, pad_string]) pads x to the right.&lt;/li&gt;&lt;li&gt;RTRIM(x [, trim_string]) trims x from the right.&lt;/li&gt;&lt;li&gt;SOUNDEX(x) returns a string containing the phonetic representation of x.&lt;/li&gt;&lt;li&gt;SUBSTR(x, start [, length]) returns a substring of x that begins at the position specified by start. An optional length for the substring may be supplied.&lt;/li&gt;&lt;li&gt;SUBSTRB(x) Same as SUBSTR except the parameters are expressed in bytes instead of characters to handle single-byte character systems.&lt;/li&gt;&lt;li&gt;TRIM([trim_char FROM) x) trims characters from the left and right of x.&lt;/li&gt;&lt;li&gt;UPPER(x) converts the letters in x to uppercase and returns that string.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-3965796812945861252?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/3965796812945861252/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=3965796812945861252' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/3965796812945861252'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/3965796812945861252'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/character-functions.html' title='Character Functions'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-2137282564936643884</id><published>2007-09-10T21:20:00.000-07:00</published><updated>2007-09-10T22:38:09.031-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Bigfile Tablespace</title><content type='html'>A bigfile tablespace (BFT) is a tablespace containing a single file that can have a very large size.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Bigfile Tablespace Overview&lt;/span&gt;&lt;br /&gt;The traditional tablespace is referred to as a smallfile tablespace (SFT). A smallfile tablespace contains multiple, relatively small files. The bigfile tablespace has the following characteristics:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;An Oracle database can contain both bigfile and smallfile tablespaces.&lt;/li&gt;&lt;li&gt;System default is to create the traditional smallfile tablespace.&lt;/li&gt;&lt;li&gt;The SYSTEM and SYSAUX tablespaces are always created using the system default type.&lt;/li&gt;&lt;li&gt;Bigfile tablespaces are supported only for locally managed tablespaces with automatic segment-space management.&lt;/li&gt;&lt;/ul&gt;There are two exceptions when bigfile tablespace segments are manually managed:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Locally managed undo tablespace&lt;/li&gt;&lt;li&gt;Temporary tablespace&lt;/li&gt;&lt;/ul&gt;Bigfile tablespaces are intended to be used with Automated Storage Management (ASM) (see Chapter 1) or other logical volume managers that support RAID.&lt;br /&gt;&lt;br /&gt;However, you can also use it without ASM.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Bigfile Tablespace Benefits&lt;/span&gt;&lt;br /&gt;Bigfile tablespace has the following benefits:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;It simplifies large database tablespace management by reducing the number of datafiles needed.&lt;/li&gt;&lt;li&gt;It simplifies datafile management with Oracle-managed files and Automated Storage Management (ASM) by eliminating the need for adding new datafiles and dealing with multiple files.&lt;/li&gt;&lt;li&gt;It allows you to create a bigfile tablespace of up to eight exabytes (eight million terabytes) in size, and significantly increase the storage capacity of an Oracle database.&lt;/li&gt;&lt;li&gt;It follows the concept that a tablespace and a datafile are logically equivalent.&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Maximum Database Size&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The BFT extended the maximum size of tablespace and database. Let’s take a look at the two formulas that calculate the maximum size of data file and database.&lt;br /&gt;&lt;br /&gt;The maximum data file size is calculated by:&lt;br /&gt;&lt;br /&gt;Maximum datafile size = db_block_size * maximum number of blocks&lt;br /&gt;&lt;br /&gt;The maximum amount of data in an Oracle database is calculated by:&lt;br /&gt;&lt;br /&gt;Maximum database size = maximum datafile size * maximum number of datafile&lt;br /&gt;&lt;br /&gt;The maximum number of datafiles in Oracle9i and Oracle 10g Database is 65,536. However, the maximum number of blocks in a data file increase from 4,194,304 (4 million) blocks to 4,294,967,296 (4 billion) blocks.&lt;br /&gt;&lt;br /&gt;The maximum amount of data for a 32K block size database is eight petabytes (8,192 Terabytes) in Oracle9i.&lt;br /&gt;The maximum amount of data for a 32K block size database is eight exabytes (8,388,608 Terabytes) in Oracle 10g.&lt;br /&gt;As you can see, with the new BFT addressing scheme, Oracle 10g can contain astronomical amounts of data within a single database.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-2137282564936643884?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/2137282564936643884/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=2137282564936643884' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/2137282564936643884'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/2137282564936643884'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/bigfile-tablespace.html' title='Bigfile Tablespace'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-179965021576272164</id><published>2007-09-09T21:05:00.000-07:00</published><updated>2007-09-09T21:15:35.906-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Oracle Listener security</title><content type='html'>The first thing to do is to put a password on your listener. By default the listener comes with no password, and anyone can change listener settings through the lsnrctl tool.&lt;br /&gt;To password protect your listener, perform the following as your Oracle user:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;$ lsnrctl&lt;br /&gt;LSNRCTL&gt; change_password&lt;br /&gt;Old password: &lt;press&gt;&lt;br /&gt;New password: &lt;enter&gt;&lt;br /&gt;Reenter new password: &lt;reenter&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you have done all of this correctly, you will see the following:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=&lt;hostname&gt;)(PORT=&lt;port&gt;)))&lt;br /&gt;Password changed for &lt;listener&gt;&lt;br /&gt;The command completed successfully&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Just as a note, if the listener you are protecting does not have the default name of LISTENER, you must do set cur &lt;listenername&gt; before issuing the change_password command.&lt;br /&gt;&lt;br /&gt;At this point, save the configuration of the listener to the file system. If you are on 10g, it will save with no problems:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;LSNRCTL&gt; save_config&lt;br /&gt;Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=&lt;hostname&gt;)(PORT=&lt;port&gt;)))&lt;br /&gt;Saved &lt;listener&gt; configuration parameters.&lt;br /&gt;Listener Parameter File &lt;oracle&gt;/listener.ora&lt;br /&gt;Old Parameter File &lt;oracle&gt;/listener.bak&lt;br /&gt;The command completed successfully&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;And you have a password protected listener.&lt;br /&gt;&lt;br /&gt;However, this does not happen on 9i. If you perform a save_config, you will see the following:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;LSNRCTL&gt; save_config&lt;br /&gt;Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=&lt;hostname&gt;)(PORT=&lt;port&gt;)))&lt;br /&gt;TNS-01169: The listener has not recognized the password&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The reason is this: in Oracle 10g, operating system authentication for the listener has been implemented. The listener checks to make sure you are part of the privileged dba group, and if so it will grant you access to change the password, save configuration, stop the listener, etc. In 9i, we must do the following at this point:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;LSNRCTL&gt; set password&lt;br /&gt;Password: &lt;the&gt;&lt;br /&gt;The command completed successfully&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;At this point, you can now perform a save_config.&lt;br /&gt;&lt;br /&gt;So what is the result of this? In 9i, you will now require a password whenever you wish to stop the listener or any other "destructive" listener actions. In 10g, if you are not logged into the operating system with a privileged account, you will have to enter a password as well. A typical listener stop may look like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;$ lsnrctl&lt;br /&gt;LSNRCTL&gt; stop&lt;br /&gt;Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=&lt;hostname&gt;)(PORT=&lt;port&gt;)))&lt;br /&gt;TNS-01169: The listener has not recognized the password&lt;br /&gt;LSNRCTL&gt; set password&lt;br /&gt;Password: &lt;enter&gt;&lt;br /&gt;The command completed successfully&lt;br /&gt;LSNRCTL&gt; stop&lt;br /&gt;Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=&lt;hostname&gt;)(PORT=&lt;port&gt;)))&lt;br /&gt;The command completed successfully&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You are now protected against unauthorized shutdowns of your listener. This protects you from a whole range of possible security breaches. Remember that "set password" is how you enter your password for authentication; change_password is how it is changed.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-179965021576272164?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/179965021576272164/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=179965021576272164' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/179965021576272164'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/179965021576272164'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/oracle-listener-security.html' title='Oracle Listener security'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-3293259118355124694</id><published>2007-09-09T19:45:00.000-07:00</published><updated>2007-09-09T20:19:47.192-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><title type='text'>Cursors</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Implicit cursors&lt;/span&gt;&lt;br /&gt;Whenever a SQL statement is issued the Database server opens an area of memory in which the command is parsed and executed. This area is called a cursor. Microsoft tends to refer to cursors as datasets throughout much of their databse product documentation..&lt;br /&gt;&lt;br /&gt;When the executable part of a PL/SQL block issues a SQL command, PL/SQL creates an implicit cursor which has the identifier SQL. PL/SQL manages this cursor for you.&lt;br /&gt;&lt;br /&gt;PL/SQL provides some attributes which allow you to evaluate what happened when the implicit cursor was last used. You can use these attributes in PL/SQL statements like functions but you cannot use then within SQL statements.&lt;br /&gt;The SQL cursor attributes are :&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;%ROWCOUNT&lt;/span&gt;:The number of rows processed by a SQL statement.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;%FOUND: &lt;/span&gt;TRUE if at least one row was processed.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;%NOTFOUND&lt;/span&gt;: TRUE if no rows were processed.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;%ISOPEN&lt;/span&gt;:TRUE if cursor is open or FALSE if cursor has not been opened or has been closed. Only used with explicit cursors&lt;/li&gt;&lt;/ul&gt;Example:&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;DECLARE&lt;br /&gt;ROW_DEL_NO NUMBER;&lt;br /&gt;BEGIN&lt;br /&gt;   DELETE * FROM JD11.SECTION;&lt;br /&gt;   ROW_DEL_NO := SQL%ROWCOUNT;&lt;br /&gt;END; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Explicit cursors&lt;/span&gt;&lt;br /&gt;SELECT statements that occur within PL/SQL blocks are known as embedded, they must return one row and may only return one row. To get around this you can define a SELECT statement as a cursor (an area of memory), run the query and then manipulate the returned rows within the cursor. Cursors are controlled via four command statements.&lt;br /&gt;They are :&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;DECLARE&lt;/span&gt;:Defines the name and structure of the cursor together with the SELECT statement that will populate the cursor with data. The query is validated but not executed.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;OPEN&lt;/span&gt;: Executes the query that populates the cursor with rows.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;FETCH&lt;/span&gt;:Loads the row addressed by the cursor pointer into variables and moves the cursor pointer on to the next row ready for the next fetch.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;CLOSE&lt;/span&gt;:Releases the data within the cursor and closes it. The cursor can be reopened to refresh its data.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Cursors are defined within a DECLARE section of a PL/SQL block. For example:&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;DECLARE&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;CURSOR MYCUR IS SELECT ISBN, COST FROM JD11.BOOK;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The cursor is defined by the CURSOR keyword followed by the cursor identifier (MYCUR in this case) and then the SELECT statement used to populate it, the SELECT statement can be any legal query.&lt;br /&gt;&lt;br /&gt;Cursors are opened with the OPEN statement, this populates the cursor with data.&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;DECLARE&lt;br /&gt;CURSOR MYCUR IS SELECT ISBN, COST FROM JD11.BOOK;&lt;br /&gt;BEGIN&lt;br /&gt;   OPEN MYCUR;&lt;br /&gt;END;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To access the rows of data within the cursor we use the FETCH statement.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;DECLARE&lt;br /&gt;CURSOR MYCUR IS SELECT ISBN, COST FROM JD11.BOOK;&lt;br /&gt;THISISBN NUMBER(10);&lt;br /&gt;THISCOST NUMBER(10,2);&lt;br /&gt;BEGIN&lt;br /&gt;   OPEN MYCUR;&lt;br /&gt;   FETCH MYCUR INTO THISISBN, THISCOST;&lt;br /&gt;END;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The FETCH statement reads the column values for the current cursor row and puts them into the specified variables. The cursor pointer is updated to point at the next row. If the cursor has no more rows the variables will be set to null on the first FETCH attempt, subsequent FETCH attempts will raise an exception.&lt;br /&gt;&lt;br /&gt;The CLOSE statement releases the cursor and any rows within it, you can open the cursor again to refresh the data in it.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;DECLARE&lt;br /&gt;CURSOR MYCUR IS SELECT ISBN, COST FROM JD11.BOOK;&lt;br /&gt;THISISBN NUMBER(10);&lt;br /&gt;THISCOST NUMBER(10,2);&lt;br /&gt;BEGIN&lt;br /&gt;   OPEN MYCUR;&lt;br /&gt;   FETCH MYCUR INTO THISISBN, THISCOST;&lt;br /&gt;   CLOSE MYCUR;&lt;br /&gt;END;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To process all the rows within a cursor we simply need to place the FETCH statement in a loop and check the cursor NOTFOUND attribute to see if we successfully fetched a row or not.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;DECLARE&lt;br /&gt;CURSOR MYCUR IS SELECT ISBN, COST FROM JD11.BOOK;&lt;br /&gt;THISISBN NUMBER(10);&lt;br /&gt;THISCOST NUMBER(10,2);&lt;br /&gt;BEGIN&lt;br /&gt;   OPEN MYCUR;&lt;br /&gt;   LOOP&lt;br /&gt;      FETCH MYCUR INTO THISISBN, THISCOST;&lt;br /&gt;      EXIT WHEN MYCUR%NOTFOUND;&lt;br /&gt;   END LOOP;&lt;br /&gt;   CLOSE MYCUR;&lt;br /&gt;END;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;PL/SQL records may be based on a cursor. This is very convenient for processing rows from the active data set. An example follows :&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;DECLARE&lt;br /&gt;CURSOR MYCUR IS SELECT ISBN, COST FROM JD11.BOOK;&lt;br /&gt;PARTBOOK MYCUR%ROWTYPE;&lt;br /&gt;BEGIN&lt;br /&gt;   OPEN MYCUR;&lt;br /&gt;   LOOP&lt;br /&gt;      FETCH MYCUR INTO PARTBOOK;&lt;br /&gt;      EXIT WHEN MYCUR%NOTFOUND;&lt;br /&gt;      IF PARTBOOK.ISBN = 21 THEN&lt;br /&gt;         PARTBOOK.COST = 19.10;&lt;br /&gt;      END IF;&lt;br /&gt;   END LOOP;&lt;br /&gt;   CLOSE MYCUR;&lt;br /&gt;END;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can use the WHERE CURRENT OF clause to execute DML commands against the current row of a cursor, this makes it easier to update rows. An example is below :&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;DECLARE&lt;br /&gt;CURSOR MYCUR IS SELECT ISBN, COST FROM JD11.BOOK;&lt;br /&gt;PARTBOOK MYCUR%ROWTYPE;&lt;br /&gt;BEGIN&lt;br /&gt;   OPEN MYCUR;&lt;br /&gt;   LOOP&lt;br /&gt;      FETCH MYCUR INTO PARTBOOK;&lt;br /&gt;      EXIT WHEN MYCUR%NOTFOUND;&lt;br /&gt;      IF PARTBOOK.ISBN = 21 THEN&lt;br /&gt;         DELETE FROM JD11.BOOK WHERE CURRENT OF MYCUR;&lt;br /&gt;      END IF;&lt;br /&gt;   END LOOP;&lt;br /&gt;   CLOSE MYCUR;&lt;br /&gt;END;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Note that I didn’t need to explicitly specify the row that I want deleted, PL/SQL supplies the required row identifier from the current record in the cursor ensuring that only the correct row is deleted.&lt;br /&gt;&lt;br /&gt;It’s possible to vary the returned result set by using parameters, parameters allow you to specify the query selection criteria when you open the cursor.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-size:85%;" &gt;DECLARE&lt;br /&gt;CURSOR MYCUR (PARAM1 NUMBER) IS SELECT ISBN, COST FROM JD11.BOOK WHERE ISBN = PARAM1;&lt;br /&gt;PARTBOOK MYCUR%ROWTYPE;&lt;br /&gt;BEGIN&lt;br /&gt;   OPEN MYCUR(21);&lt;br /&gt;   FETCH MYCUR INTO PARTBOOK;&lt;br /&gt;   CLOSE MYCUR;&lt;br /&gt;   OPEN MYCUR(101);&lt;br /&gt;   FETCH MYCUR INTO PARTBOOK;&lt;br /&gt;   CLOSE MYCUR;&lt;br /&gt;END;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-3293259118355124694?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/3293259118355124694/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=3293259118355124694' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/3293259118355124694'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/3293259118355124694'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/cursors.html' title='Cursors'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-5242520654059679561</id><published>2007-09-06T01:58:00.000-07:00</published><updated>2007-09-06T02:15:24.656-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Blocking Oracle access by IP Address</title><content type='html'>Now comes the fun part: keeping people out of your database! While IP-based blocking is not as suitable as a full firewall, you are able to block clients based on their IP address or hostname.&lt;br /&gt;&lt;br /&gt;The secret lies in the SQLNET.ORA file. This file can be found in your $ORACLE_HOME/network/admin directory along with your tnsnames.ora and listener.ora. Open it up and insert the following line:&lt;br /&gt;&lt;br /&gt;tcp.validnode_checking = yes&lt;br /&gt;&lt;br /&gt;This turns on the hostname/IP checking for your listeners. After this, you can supply lists of nodes to enable/disable, as such:&lt;br /&gt;&lt;br /&gt;tcp.invited_nodes = (hostname1, hostname2)&lt;br /&gt;tcp.excluded_nodes = (172.16.1.3)&lt;br /&gt;&lt;br /&gt;Note that if you only specify invited nodes, all others will be excluded, so there is really no reason to do both. The same goes for excluded nodes: exclude a list of clients, invite all others.&lt;br /&gt;&lt;br /&gt;Even though this will not protect you against advanced attacks (IP and hostname are easy to spoof) it still serves as a deterrent against hacking attempts.&lt;br /&gt;&lt;br /&gt;Here are some rules for entering invited/excluded nodes:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;You cannot use wildcards in your specifications.&lt;/li&gt;&lt;li&gt;You must put all invited               nodes in one line; likewise               for excluded nodes.&lt;/li&gt;&lt;li&gt;You should always enter              &lt;span style="font-style: italic;"&gt;              localhost&lt;/span&gt; as an               invited node.&lt;/li&gt;&lt;/ul&gt;Once you have set up your              rules and enabled valid node              checking, you must restart your              listeners to reap the benefits.Here is an example:             &lt;p&gt;PayrollDB is a database              server, accessed by Payroll&lt;br /&gt;BankingDB is a database server,              accessed by Banking&lt;br /&gt;BApp1, BApp2, andBApp3 are              application servers using the BankingDB&lt;br /&gt;           PApp1, PApp2, and PApp3 are              application servers using the              PayrollDB&lt;/p&gt;&lt;p&gt;The sqlnet.ora on PayrollDB              would look like this:&lt;/p&gt;&lt;p&gt;tcp.validnode_checking = yes&lt;br /&gt;tcp.invited_nodes = (localhost, PayrollDB, PApp1, PApp2, PApp3)&lt;br /&gt;&lt;br /&gt;The sqlnet.ora on SalesDB would look like this:&lt;br /&gt;&lt;br /&gt;tcp.validnode_checking = yes&lt;br /&gt;tcp.invited_nodes = (localhost, BankingDB, BApp1, BApp2, BApp3)&lt;br /&gt;&lt;/p&gt;Once this has been done,              restart the listener.&lt;br /&gt;&lt;br /&gt;&lt;span style=";font-family:Courier New;font-size:85%;"  &gt;             $ lsnrctl&lt;br /&gt;          &lt;br /&gt;           LSNRCTL&gt; set password&lt;br /&gt;           Password: &lt;the&gt;&lt;br /&gt;          &lt;br /&gt;           The command completed              successfully&lt;br /&gt;          &lt;br /&gt;           LSNRCTL&gt; stop&lt;br /&gt;           The command completed              successfully&lt;br /&gt;          &lt;br /&gt;           LSNRCTL&gt; start&lt;/the&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now PApp1, PApp2, and PApp3 can access PayrollDB but not BankingDB; the same goes for the Banking application servers' access to PayrollDB.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-5242520654059679561?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/5242520654059679561/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=5242520654059679561' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/5242520654059679561'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/5242520654059679561'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/blocking-oracle-access-by-ip-address.html' title='Blocking Oracle access by IP Address'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-7249117879532235632</id><published>2007-09-06T00:17:00.000-07:00</published><updated>2007-09-06T00:23:30.420-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><title type='text'>PL/SQL Records</title><content type='html'>A PL/SQL record is a variable that contains a collection of separate fields. Each field is individually addressable. You can reference the field names in both assignments and expressions. The fields within a record may have different datatypes and sizes, like the columns of a database table. Records are a convenient way of storing a complete fetched row from a database table.&lt;br /&gt;&lt;br /&gt;Use the %ROWTYPE attribute to declare a record based upon a collection of database columns from a table or view. The fields within the record take their names and datatypes from the columns of the table or view.&lt;br /&gt;&lt;br /&gt;Declare the record in the DECLARE section along with any other required variables and constants. An example follows :&lt;br /&gt;DECLARE&lt;br /&gt;REC1 JD11.BOOK%ROWTYPE;&lt;br /&gt;REC4 JD11.BOOK%ROWTYPE;&lt;br /&gt;&lt;br /&gt;The above declaration sets the object REC1 to be a record object holding fields that match the columns in the BOOK table. It doesn't hold any values until it is populated.&lt;br /&gt;&lt;br /&gt;Assign values into a PL/SQL record by naming the record after the INTO keyword of a SELECT statement. The INTO keyword defines the name specification for the storage area(s) of queried value(s).&lt;br /&gt;BEGIN&lt;br /&gt;   SELECT * FROM JD11.BOOK INTO REC1 WHERE ISBN = 21;&lt;br /&gt;END;&lt;br /&gt;&lt;br /&gt;You can assign all the record values from one record to another provided that the record definitions are the same.&lt;br /&gt;&lt;br /&gt;BEGIN&lt;br /&gt;   REC4 := REC1;&lt;br /&gt;END;&lt;br /&gt;&lt;br /&gt;Reference the field values within a PL/SQL record like this :&lt;br /&gt;&lt;br /&gt;BEGIN&lt;br /&gt;   REC4 := REC1;&lt;br /&gt;   IF REC4.COST &gt; 0 THEN&lt;br /&gt;      REC4.SECTION_ID := 10;&lt;br /&gt;   ELSE&lt;br /&gt;      REC4.SECTION_ID := 7;&lt;br /&gt;   END IF;&lt;br /&gt;END;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-7249117879532235632?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/7249117879532235632/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=7249117879532235632' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/7249117879532235632'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/7249117879532235632'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/plsql-records.html' title='PL/SQL Records'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-7167302039454416881</id><published>2007-09-06T00:11:00.000-07:00</published><updated>2007-09-06T00:12:45.574-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><title type='text'>Discovering PL/SQL Errors</title><content type='html'>PL/SQL does not always tell you about compilation errors. Instead, it gives you a cryptic message such as "procedure created with compilation errors". If you don't see what is wrong immediately, try issuing the command&lt;br /&gt;&lt;br /&gt;show errors procedure &lt;procedure_name&gt;;&lt;br /&gt;&lt;br /&gt;Alternatively, you can type, SHO ERR (short for SHOW ERRORS) to see the most recent compilation error.&lt;br /&gt;&lt;br /&gt;Note that the location of the error given as part of the error message is not always accurate!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-7167302039454416881?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/7167302039454416881/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=7167302039454416881' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/7167302039454416881'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/7167302039454416881'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/discovering-plsql-errors.html' title='Discovering PL/SQL Errors'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-8364483296301497406</id><published>2007-09-06T00:02:00.000-07:00</published><updated>2007-09-06T00:07:46.068-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><title type='text'>Control Flow in PL/SQL</title><content type='html'>PL/SQL allows you to branch and create loops in a fairly familiar way.&lt;br /&gt;An IF statement looks like:&lt;br /&gt;&lt;br /&gt;IF &lt;condition&gt; THEN &lt;statement_list&gt; ELSE &lt;statement_list&gt; END IF;&lt;br /&gt;&lt;br /&gt;The ELSE part is optional. If you want a multiway branch, use:&lt;br /&gt;&lt;br /&gt;IF &lt;condition_1&gt; THEN ...&lt;br /&gt;&lt;br /&gt;ELSIF &lt;condition_2&gt; THEN ...&lt;br /&gt;... ...&lt;br /&gt;ELSIF &lt;condition_n&gt; THEN ...&lt;br /&gt;&lt;br /&gt;ELSE ...&lt;br /&gt;&lt;br /&gt;END IF;&lt;br /&gt;&lt;br /&gt;Loops are created with the following:&lt;br /&gt;&lt;br /&gt;LOOP&lt;br /&gt;    &lt;loop_body&gt; /* A list of statements. */&lt;br /&gt;END LOOP;&lt;br /&gt;&lt;br /&gt;At least one of the statements in &lt;loop_body&gt; should be an EXIT statement of the form&lt;br /&gt;&lt;br /&gt;EXIT WHEN &lt;condition&gt;;&lt;br /&gt;&lt;br /&gt;The loop breaks if &lt;condition&gt; is true.&lt;br /&gt;Some other useful loop-forming statements are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;EXIT by itself is an unconditional loop break. Use it inside a conditional if you like.&lt;/li&gt;&lt;li&gt;A WHILE loop can be formed with&lt;br /&gt;    WHILE &lt;condition&gt; LOOP&lt;br /&gt;        &lt;loop_body&gt;&lt;br /&gt;    END LOOP;&lt;/li&gt;&lt;li&gt;A simple FOR loop can be formed with:&lt;br /&gt;    FOR &lt;var&gt; IN &lt;start&gt;..&lt;finish&gt; LOOP&lt;br /&gt;        &lt;loop_body&gt;&lt;br /&gt;    END LOOP;&lt;br /&gt;Here, &lt;var&gt; can be any variable; it is local to the for-loop and need not be declared. Also, &lt;start&gt; and &lt;finish&gt; are constants.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-8364483296301497406?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/8364483296301497406/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=8364483296301497406' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/8364483296301497406'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/8364483296301497406'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/control-flow-in-plsql.html' title='Control Flow in PL/SQL'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-6841226887232558688</id><published>2007-09-05T23:43:00.001-07:00</published><updated>2007-09-05T23:54:03.729-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><title type='text'>Variables and Types</title><content type='html'>Information is transmitted between a PL/SQL program and the database through variables. Every variable has a specific type associated with it. That type can be :&lt;br /&gt;&lt;ul&gt;&lt;li&gt;One of the types used by SQL for database columns&lt;/li&gt;&lt;li&gt;A generic type used in PL/SQL such as NUMBER&lt;/li&gt;&lt;li&gt;Declared to be the same as the type of some database column&lt;/li&gt;&lt;/ul&gt;The most commonly used generic type is NUMBER. Variables of type NUMBER can hold either an integer or a real number. The most commonly used character string type is VARCHAR(n), where n is the maximum length of the string in bytes. This length is required, and there is no default. For example, we might declare:&lt;br /&gt;&lt;br /&gt;DECLARE&lt;br /&gt;    price  NUMBER;&lt;br /&gt;    myBeer VARCHAR(20);&lt;br /&gt;&lt;br /&gt;Note that PL/SQL allows BOOLEAN variables, even though Oracle does not support BOOLEAN as a type for database columns.&lt;br /&gt;Types in PL/SQL can be tricky. In many cases, a PL/SQL variable will be used to manipulate data stored in a existing relation. In this case, it is essential that the variable have the same type as the relation column. If there is any type mismatch, variable assignments and comparisons may not work the way you expect. To be safe, instead of hard coding the type of a variable, you should use the %TYPE operator. For example:&lt;br /&gt;&lt;br /&gt;DECLARE&lt;br /&gt;    myBeer Beers.name%TYPE;&lt;br /&gt;&lt;br /&gt;gives PL/SQL variable myBeer whatever type was declared for the name column in relation Beers.&lt;br /&gt;A variable may also have a type that is a record with several fields. The simplest way to declare such a variable is to use %ROWTYPE on a relation name. The result is a record type in which the fields have the same names and types as the attributes of the relation. For instance:&lt;br /&gt;&lt;br /&gt;DECLARE&lt;br /&gt;    beerTuple Beers%ROWTYPE;&lt;br /&gt;&lt;br /&gt;makes variable beerTuple be a record with fields name and manufacture, assuming that the relation has the schema Beers(name, manufacture).&lt;br /&gt;The initial value of any variable, regardless of its type, is NULL. We can assign values to variables, using the ":=" operator. The assignment can occur either immediately after the type of the variable is declared, or anywhere in the executable portion of the program. An example:&lt;br /&gt;&lt;br /&gt;DECLARE&lt;br /&gt;    a NUMBER := 3;&lt;br /&gt;BEGIN&lt;br /&gt;    a := a + 1;&lt;br /&gt;END;&lt;br /&gt;.&lt;br /&gt;&lt;br /&gt;run;&lt;br /&gt;&lt;br /&gt;This program has no effect when run, because there are no changes to the database.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-6841226887232558688?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/6841226887232558688/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=6841226887232558688' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/6841226887232558688'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/6841226887232558688'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/variables-and-types.html' title='Variables and Types'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-5227018598369504492</id><published>2007-09-05T23:38:00.000-07:00</published><updated>2007-09-05T23:40:50.968-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><title type='text'>Scope of Block Objects</title><content type='html'>The scope of an object defines where it is visible, it is the area of the program logic that can legally refer to a given object.&lt;br /&gt;&lt;br /&gt;A variable or object's (cursor, constant Etc.) scope is determined by the block that it is declared in. It is only available until the block it is defined in ends execution. Remember that block variables are defined under the DECLARE keyword.&lt;br /&gt;&lt;br /&gt;For nested blocks an object defined in a parent block is available within all its child (nested blocks). The reverse is not true, objects defined in a child block are not visible to the parent.&lt;br /&gt;&lt;br /&gt;If a nested block defines an object with the same name as an object in its parent block then only the local object is visible. Unlike Java there is no method provided to get at the parent object in this circumstance.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-5227018598369504492?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/5227018598369504492/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=5227018598369504492' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/5227018598369504492'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/5227018598369504492'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/scope-of-block-objects.html' title='Scope of Block Objects'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-1822024087128770973</id><published>2007-09-05T23:11:00.000-07:00</published><updated>2007-09-05T23:27:32.846-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><title type='text'>Basic PL/SQL Block Structure</title><content type='html'>PL/SQL stands for Procedural Language/SQL. PL/SQL extends SQL by adding constructs found in procedural languages, resulting in a structural language that is more powerful than SQL. The basic unit in PL/SQL is a block. All PL/SQL programs are made up of blocks, which can be nested within each other. Typically, each block performs a logical action in he program. A block has the following structure:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;DECLARE&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Definition of any variables or objects that are used within the declared block.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;BEGIN&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Statements that make up the block.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;EXCEPTION&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;All exception handlers.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;END&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;example:&lt;br /&gt;DECLARE&lt;br /&gt;TEMP_COST NUMBER(10,2);&lt;br /&gt;BEGIN&lt;br /&gt;   SELECT COST FROM JD11.BOOK INTO TEMP_COST WHERE ISBN = 21;&lt;br /&gt;   IF TEMP_COST &gt; 0 THEN&lt;br /&gt;      UPDATE JD11.BOOK SET COST = (TEMP_COST*1.175) WHERE ISBN = 21;&lt;br /&gt;   ELSE&lt;br /&gt;      UPDATE JD11.BOOK SET COST = 21.32 WHERE ISBN = 21;&lt;br /&gt;   END IF;&lt;br /&gt;COMMIT;&lt;br /&gt;EXCEPTION&lt;br /&gt;   WHEN NO_DATA_FOUND THEN&lt;br /&gt;      INSERT INTO JD11.ERRORS (CODE, MESSAGE) VALUES(99, 'ISBN 21 NOT FOUND');&lt;br /&gt;END;&lt;br /&gt;&lt;br /&gt;As you can see there are several elements in the example that haven't been covered in SQL , these elements are the PL/SQL extensions. They include:&lt;br /&gt;- Variables and Constants&lt;br /&gt;- SQL Support&lt;br /&gt;- Composite Datatypes&lt;br /&gt;- Flow Control&lt;br /&gt;- Built In Functions&lt;br /&gt;- Cursor Handling&lt;br /&gt;- Exception Handling&lt;br /&gt;- Code Storage&lt;br /&gt;&lt;br /&gt;The rules of block structure are :&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Every unit of PL/SQL must constitute a block. As a minimum there must be the delimiting words BEGIN and END around the executable statements.&lt;/li&gt;&lt;li&gt;SELECT statements within PL/SQL blocks are embedded SQL (an ANSI category). As such they must return one row only. SELECT statements that return no rows or more than one row will generate an error. If you want to deal with groups of rows you must place the returned data into a cursor. The INTO clause is mandatory for SELECT statements within PL/SQL blocks (which are not within a cursor definition), you must store the returned values from a SELECT.&lt;/li&gt;&lt;li&gt;If PL/SQL variables or objects are defined for use in a block then you must also have a DECLARE section.&lt;/li&gt;&lt;li&gt;If you include an EXCEPTION section the statements within it are only processed if the condition to which they refer occurs. Block execution is terminated after an exception handling routine is executed.&lt;/li&gt;&lt;li&gt;PL/SQL blocks may be nested, nesting can occur wherever an executable statement could be placed (including the EXCEPTION section).&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-1822024087128770973?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/1822024087128770973/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=1822024087128770973' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/1822024087128770973'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/1822024087128770973'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/basic-plsql-block-structure.html' title='Basic PL/SQL Block Structure'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-4444566302593062453</id><published>2007-09-05T22:41:00.000-07:00</published><updated>2008-01-01T21:50:28.331-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Oracle DBA : Poor Oracle Performance</title><content type='html'>For an Oracle DBA, here are some reasons that was consider as the most common  root-causes of poor Oracle performance:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Bad Design&lt;/span&gt; – The number one offender to poor performance is over-normalization of Oracle tables, excessive (unused indexes) and 15-way table joins for what should be a simple fetch.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Bad disk I/O configuration&lt;/span&gt; – Inappropriate use of RAID5, disk channel bottlenecks and poor disk striping.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Object contention&lt;/span&gt; – Failing to set ASSM, freelists or freelist_groups for DML-active tables and indexes can cause very slow DML performance.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Non-reentrant SQL&lt;/span&gt; – All SQL should use host variables/cursor_sharing=force to make SQL reusable within the library cache.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Excessive nested loop joins&lt;/span&gt; – In 64-bit Oracle systems we have gigabytes available for RAM sorts and hash joins.  Failing to set pga_aggregate_target to allow the CBO to choose hash joins can result in very slow SQL performance.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Poor server optimization&lt;/span&gt; – Setting the server kernel parameters and I/O configuration (e.g. direct I/O) has a profound impact on Oracle performance.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Poor Optimizer Statistics&lt;/span&gt; – Prior to Oracle 10g (automatic statistics), a common cause of poor SQL performance was missing/stale CBO statistics and missing histograms.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Under-allocated RAM regions&lt;/span&gt; – Not allocating enough RAM for shared_pool_size, pga_aggregate_target and db_cache_size can cause an I/O-bound database.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Un-set initialization parameters&lt;/span&gt; – Many of the initialization parameters are made to be set by the DBA (db_file_multiblock_read_count, optimizer_index_caching) and failing to set these parameters properly results in poorly optimized execution plans.&lt;/li&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;Human Misfeasance&lt;/span&gt; – The DBA’s failure to monitor their database (STATSPACK/AWR), set-up exception reporting alerts (OEM) and adjusting their instance to match changing workloads is a major cause of poor performance.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-4444566302593062453?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/4444566302593062453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=4444566302593062453' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/4444566302593062453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/4444566302593062453'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/poor-oracle-performance.html' title='Oracle DBA : Poor Oracle Performance'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-2685477431430793192</id><published>2007-09-05T17:58:00.000-07:00</published><updated>2007-09-05T19:03:54.149-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tablespace'/><title type='text'>Oracle temporary tablespace groups (10g)</title><content type='html'>A temporary tablespace group consists of only temporary tablespace, and has the following properties:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;It contains one or more temporary tablespaces.&lt;/li&gt;&lt;li&gt;It contains only temporary tablespace.&lt;/li&gt;&lt;li&gt;It is not explicitly created. It is created implicitly when the first temporary tablespace is assigned to it, and is deleted when the last temporary tablespace is removed from the group.&lt;/li&gt;&lt;/ol&gt;Temporary tablespace group has the following benefits:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;It allows multiple default temporary tablespaces to be specified at the database level.&lt;/li&gt;&lt;li&gt;It allows the user to use multiple temporary tablespaces in different sessions at the same time.&lt;/li&gt;&lt;li&gt;It allows a single SQL operation to use multiple temporary tablespaces for sorting.&lt;/li&gt;&lt;/ol&gt;Using a tablespace with a temporary tablespace group will result in the following select statement. However, using a tablespace without a temporary tablespace group will not return the select statement below.&lt;br /&gt;select&lt;br /&gt;tablespace_name, group_name&lt;br /&gt;from&lt;br /&gt;DBA_TABLESPACE_GROUPS;&lt;br /&gt;TABLESPACE_NAME    GROUP_NAME&lt;br /&gt;---------------                  -----------&lt;br /&gt;TEMP01                            TEMPGROUP_A&lt;br /&gt;TEMP02                            TEMPGROUP_A&lt;br /&gt;TEMP03                            TEMPGROUP_B&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;- Create a temporary tablespace and implicitly add it to a temporary tablespace group.&lt;br /&gt;&lt;br /&gt;CREATE TEMPORARY TABLESPACE temp01&lt;br /&gt;TEMPFILE ‘/u02/oradata/temp01.dbs’ SIZE 500M&lt;br /&gt;TABLESPACE GROUP tempgroup_a;&lt;br /&gt;&lt;br /&gt;- Create a temporary tablespace without assigning it to a temporary tablespace group.&lt;br /&gt;&lt;br /&gt;The following two statements are exactly equivalent:&lt;br /&gt;&lt;br /&gt;CREATE TEMPORARY TABLESPACE temp04&lt;br /&gt;TEMPFILE ‘/u02/oradata/temp04.dbs’ SIZE 200M&lt;br /&gt;TABLESPACE GROUP ‘’;&lt;br /&gt;&lt;br /&gt;CREATE TEMPORARY TABLESPACE temp04&lt;br /&gt;TEMPFILE ‘/u02/oradata/temp04.dbs’ SIZE 200M;&lt;br /&gt;&lt;br /&gt;- Remove a temporary tablespace from a temporary tablespace group.&lt;br /&gt;&lt;br /&gt;This statement will remove temporary tablespace temp04 from its original temporary tablespace group:&lt;br /&gt;&lt;br /&gt;ALTER TABLESPACE temp04 TABLESPACE GROUP ‘‘;&lt;br /&gt;- Add a temporary tablespace to a temporary tablespace group.&lt;br /&gt;&lt;br /&gt;ALTER TABLESPACE temp03 TABLESPACE GROUP tempgroup_b;&lt;br /&gt;&lt;br /&gt;- Assign a user to a default temporary tablespace group.&lt;br /&gt;&lt;br /&gt;ALTER USER &lt;span style="font-weight: bold; font-style: italic;"&gt;USER&lt;/span&gt; TEMPORARY TABLESPACE tempgroup_A;&lt;br /&gt;&lt;br /&gt;In this case, user 'USER' will have multiple default temporary tablespaces (see Figure). A single SQL operation by 'USER' can use more than one temporary tablespace for sorting.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;img style="width: 448px; height: 237px;" src="http://img522.imageshack.us/img522/9985/temporarygroupsyf2.gif" /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-2685477431430793192?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/2685477431430793192/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=2685477431430793192' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/2685477431430793192'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/2685477431430793192'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/oracle-temporary-tablespace-groups-10g.html' title='Oracle temporary tablespace groups (10g)'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-296724382330463228</id><published>2007-09-05T17:08:00.000-07:00</published><updated>2007-09-05T17:15:30.496-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Killing Oracle Session</title><content type='html'>One of the most common mistakes are DBA's killing the wrong session.  When killing a session, carefully review the session, process and SQL associated with the offensive task.  Before killing the session, the DBA may decide to view the SQL being executed by the session.&lt;br /&gt;Killing session with Oracle can be a challenge and different procedures exist within Windows and UNIX.  Here are the steps that I use to kill an Oracle session:&lt;br /&gt;1. Gather session information from Oracle&lt;br /&gt;2. Kill the session at the OS-level&lt;br /&gt;3. Kill the session within Oracle using the "alter system kill session" command:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-size:11;"&gt;UNIX - I always locate the            Server PID (SPID) from v$process and issue the UNIX kill -9 command.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:11;"&gt;The Windows command to kill this session would be as follows:&lt;br /&gt;                           C:\oracle9i\bin&gt;orakill ORCL92 768&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;In this example, the windows thread corresponding to the Oracle session can be killed in the operating system without ever logging into the database.&lt;br /&gt;Here are the Oracle scripts example to gather information before killing a session:&lt;br /&gt;&lt;br /&gt;session.sql script&lt;br /&gt;&lt;br /&gt;rem session.sql - displays all connected sessions&lt;br /&gt;set echo off;&lt;br /&gt;set termout on;&lt;br /&gt;set linesize 80;&lt;br /&gt;set pagesize 60;&lt;br /&gt;set newpage 0;&lt;br /&gt;&lt;br /&gt;select&lt;br /&gt;rpad(c.name||':',11)||rpad(' current logons='||&lt;br /&gt;(to_number(b.sessions_current)),20)||'cumulative logons='||&lt;br /&gt;rpad(substr(a.value,1,10),10)||'highwater mark='||&lt;br /&gt;b.sessions_highwater Information&lt;br /&gt;from&lt;br /&gt;  v$sysstat a,&lt;br /&gt;  v$license b,&lt;br /&gt;  v$database c&lt;br /&gt;where&lt;br /&gt;a.name = 'logons cumulative'&lt;br /&gt;;&lt;br /&gt;&lt;br /&gt;ttitle "dbname Database|UNIX/Oracle Sessions";&lt;br /&gt;&lt;br /&gt;set heading off;&lt;br /&gt;select 'Sessions on database '||substr(name,1,8) from v$database;&lt;br /&gt;set heading on;&lt;br /&gt;&lt;br /&gt;select&lt;br /&gt;  substr(a.spid,1,9) pid,&lt;br /&gt;  substr(b.sid,1,5) sid,&lt;br /&gt;  substr(b.serial#,1,5) ser#,&lt;br /&gt;  substr(b.machine,1,6) box,&lt;br /&gt;  substr(b.username,1,10) username,&lt;br /&gt;  -- b.server,&lt;br /&gt;  substr(b.osuser,1,8) os_user,&lt;br /&gt;  substr(b.program,1,30) program&lt;br /&gt;from&lt;br /&gt;  v$session b,&lt;br /&gt;  v$process a&lt;br /&gt;where&lt;br /&gt;b.paddr = a.addr&lt;br /&gt;and type='USER'&lt;br /&gt;order by spid;&lt;br /&gt;ttitle off;&lt;br /&gt;set heading off;&lt;br /&gt;select 'To kill, enter SQLPLUS&gt; ALTER SYSTEM KILL SESSION',&lt;br /&gt;''''||'SID, SER#'||''''||';' from dual;&lt;br /&gt;spool off;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-296724382330463228?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/296724382330463228/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=296724382330463228' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/296724382330463228'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/296724382330463228'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/killing-oracle-session.html' title='Killing Oracle Session'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-773910446306681381</id><published>2007-09-05T02:46:00.000-07:00</published><updated>2007-09-05T03:01:18.973-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle errors'/><title type='text'>Oracle ORA-03113: end-of-file on communication channel</title><content type='html'>The ORA-03113: end-of-file on communication channel error is a generic error.  The ORA-03113 error when connecting suggests that the connection was established, but lost later, like a timeout.&lt;br /&gt;There are many possible causes for the ORA-03113 error.&lt;br /&gt;For example, ORA-3113 could be signaled for any of these scenarios:&lt;br /&gt;- Server machine crashed&lt;br /&gt;- Your server process was killed at O/S level&lt;br /&gt;- Network problems&lt;br /&gt;- Oracle internal errors / aborts on the server&lt;br /&gt;- Client incorrectly handling multiple connections&lt;br /&gt;- Etc&lt;br /&gt;&lt;br /&gt;It goes on to note that the ORA-03113 End-Of-File error often has additional messages:&lt;br /&gt;It is common for this error to be accompanied by other errors such as:&lt;br /&gt;- ORA-1041 internal error. hostdef extension doesn't exist&lt;br /&gt;- ORA-3114 not connected to ORACLE&lt;br /&gt;- ORA-1012 not logged on&lt;br /&gt;&lt;br /&gt;To find more details, check for a trace file in your USER_DUMP_DEST and BACKGROUND_DMP_DEST directory.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-773910446306681381?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/773910446306681381/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=773910446306681381' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/773910446306681381'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/773910446306681381'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/oracle-ora-03113-end-of-file-on.html' title='Oracle ORA-03113: end-of-file on communication channel'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-5550680570500183514</id><published>2007-09-03T17:53:00.000-07:00</published><updated>2007-09-05T03:12:15.344-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle errors'/><title type='text'>ORA-00054: resource busy and acquire with NOWAIT specified</title><content type='html'>When You get an ORA-00054, it's usually impossible to do the DDL unless You spend hours inconveniencing end-users by nuking their sessions.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;ORA-00054&lt;/span&gt;: resource busy and acquire with NOWAIT specified&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Cause&lt;/span&gt;: Resource interested is busy.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Action&lt;/span&gt;: Retry if necessary.&lt;br /&gt;&lt;br /&gt;You have choices for avoiding the ORA-00054 error:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Re-run the change late at night when the database is idle.&lt;/li&gt;&lt;li&gt;Do all DDL during a maintenance window with all end-users locked-out.&lt;/li&gt;&lt;li&gt;Kill the sessions that are preventing the exclusive lock.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Oracle has several views for showing lock status, some of which show the username:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-size:11;"&gt;DBA_BLOCKERS – Shows non-waiting sessions    holding locks being waited-on&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:11;"&gt;DBA_DDL_LOCKS – Shows all DDL locks held or being requested&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:11;"&gt;DBA_DML_LOCKS  - Shows all DML locks held or being requested&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:11;"&gt;DBA_LOCK_INTERNAL – Displays 1 row for every lock or latch held or being requested with the username of who is holding the lock&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:11;"&gt;DBA_LOCKS  - Shows all locks or latches    held or being requested&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:11;"&gt;DBA_WAITERS  - Shows all sessions waiting on, but not holding waited for locks&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt; The DBA_LOCK_INTERNAL view used to show locks for a specific user, and you can specify the query in the form:&lt;br /&gt;&lt;br /&gt;SELECT&lt;br /&gt;NVL(b.username,'SYS') username,&lt;br /&gt;session_id,lock_type,mode_held,&lt;br /&gt;mode_requested,lock_id1,lock_id2&lt;br /&gt;FROM&lt;br /&gt;sys.dba_lock_internal a,&lt;br /&gt;sys.v_$session b&lt;br /&gt;where  . . .&lt;br /&gt;&lt;br /&gt;You can also query v$access and v$locked_object to see specific locks:&lt;br /&gt;&lt;br /&gt;select s.sid, s.serial#, p.spid&lt;br /&gt;from&lt;br /&gt;v$session s,&lt;br /&gt;v$process p&lt;br /&gt;where&lt;br /&gt;s.paddr = p.addr&lt;br /&gt;and&lt;br /&gt;s.sid in (select SESSION_ID from v$locked_object);&lt;br /&gt;&lt;br /&gt;You can simply kill the session if you're sure:&lt;br /&gt;ALTER SYSTEM KILL SESSION ('sid,serial#');&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-5550680570500183514?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/5550680570500183514/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=5550680570500183514' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/5550680570500183514'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/5550680570500183514'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/ora-00054-resource-busy-and-acquire.html' title='ORA-00054: resource busy and acquire with NOWAIT specified'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-7247673415825121538</id><published>2007-09-03T17:30:00.000-07:00</published><updated>2007-09-05T03:37:03.558-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle errors'/><title type='text'>ORA-12154: TNS: could not resolve service name</title><content type='html'>The ORA-21254 is a very common error, always related to your local copy of the tnsnames.ora file, your listener configuration and your database name aliases.&lt;br /&gt;&lt;ul&gt;&lt;li&gt; Make sure that your listener is listening for the same service name that you are using.&lt;/li&gt;&lt;li&gt; Your service name might have an alias, so check for global (world) entries and local entries.  Check $ORACLE_HOME/network/admin/tnsnames.ora.&lt;/li&gt;&lt;li&gt;Check your global_name setting with this SQL:&lt;br /&gt;SQL&gt;SELECT * FROM GLOBAL_NAME;&lt;/li&gt;&lt;/ul&gt;The query value should match your init.ora parms for db_name and db_domain,  You can change the global_name with an alter database commend, as follows:&lt;br /&gt;&lt;br /&gt;SQL&gt;alter database rename global_name to xxx;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-7247673415825121538?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/7247673415825121538/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=7247673415825121538' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/7247673415825121538'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/7247673415825121538'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/ora-12154-tns-could-not-resolve-service.html' title='ORA-12154: TNS: could not resolve service name'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-3073690160244631608</id><published>2007-09-02T23:49:00.001-07:00</published><updated>2007-09-03T00:03:06.990-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle fundamental'/><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Methods for Moving Datafiles</title><content type='html'>Depending on the type of tablespace, the database administrator can move datafiles using one of the following two methods :&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The ALTER TABLESPACE Command&lt;/span&gt;&lt;br /&gt;Precondition :&lt;br /&gt;- Tablespace must be offline&lt;br /&gt;- Target datafiles must be exist&lt;br /&gt;&lt;br /&gt;Example of usage:&lt;br /&gt;ALTER TABLESPACE userdata RENAME&lt;br /&gt;DATAFILE '/u01/oradata/userdata01.dbf'&lt;br /&gt;TO '/u02/oradata/userdata01.dbf';&lt;br /&gt;&lt;br /&gt;Step to rename a datafile:&lt;br /&gt;- Take the tablespace offline&lt;br /&gt;- Use an OS command to move or copy the files&lt;br /&gt;- Execute the ALTER TABLESPACE RENAME DATAFILES command&lt;br /&gt;- Bring the tablespace online&lt;br /&gt;- Use an OS command to delete the old file if necessary&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The ALTER DATABASE Command&lt;/span&gt;&lt;br /&gt;The ALTER DATABASE command can be used to move any type of datafile&lt;br /&gt;Precondition:&lt;br /&gt;- Database must be mounted&lt;br /&gt;- Target datafile must exist&lt;br /&gt;&lt;br /&gt;Example of usage:&lt;br /&gt;ALTER DATABASE RENAME&lt;br /&gt;FILE '/u01/oradata/system01.dbf'&lt;br /&gt;TO '/u02/oradata/system01.dbf';&lt;br /&gt;&lt;br /&gt;Because of the SYSTEM tablespace cannot be taken offline, you must use this method to move datafiles in the SYSTEM tablespace.&lt;br /&gt;&lt;br /&gt;Use the following steps to rename files in tablespaces that cannot be taken offline:&lt;br /&gt;- Shut down the database.&lt;br /&gt;- Use an OS Command to move the files.&lt;br /&gt;- Mount the database.&lt;br /&gt;- Execute the ALTER DATABASE RENAME FILE command.&lt;br /&gt;- Open the database&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-3073690160244631608?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/3073690160244631608/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=3073690160244631608' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/3073690160244631608'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/3073690160244631608'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/methods-for-moving-datafiles.html' title='Methods for Moving Datafiles'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-2645426988451544321</id><published>2007-09-02T22:55:00.000-07:00</published><updated>2007-09-05T03:40:47.343-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle fundamental'/><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Delete Without Rollback ?</title><content type='html'>A few people asking me, is there a a way to delete a table record 'permanently' without using the rollback segments? In some cases if the table have 'so many records' and if there are no more space in the rollback segment, deleting records would be fail.&lt;br /&gt;Indeed there is a way ....&lt;br /&gt;Using the "TRUNCATE" command will bypass the rollback segments when&lt;br /&gt;deleting records. For example, "TRUNCATE TABLE Table_Name;" will&lt;br /&gt;delete all records.&lt;br /&gt;Note that no triggers that may exist get fired. Also, do not do this to a&lt;br /&gt;table that is a master snapshot.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-2645426988451544321?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/2645426988451544321/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=2645426988451544321' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/2645426988451544321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/2645426988451544321'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/delete-without-rollback.html' title='Delete Without Rollback ?'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-4917320032892473198</id><published>2007-09-02T22:02:00.000-07:00</published><updated>2007-09-05T03:25:18.729-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tablespace'/><title type='text'>Locally vs. Dictionary Managed Tablespaces</title><content type='html'>By declaring a tablespace as DICTIONARY managed, you are specifying that extent management     for segments in this tablespace will be managed using the following dictionary tables:     &lt;p&gt;     &lt;table border="0" cellpadding="1" cellspacing="1" width="550"&gt;     &lt;tbody&gt;&lt;tr&gt;       &lt;td valign="top"&gt;&lt;b&gt;sys.fet$&lt;/b&gt;     &lt;/td&gt;       &lt;td valign="top"&gt;Every extent for a particular segment is represented by           a row in the &lt;code&gt;sys.fet$&lt;/code&gt; dictionary table. &lt;code&gt;sys.fet$&lt;/code&gt; is           actually clustered in the &lt;code&gt;C_TS#&lt;/code&gt; cluster.&lt;/td&gt;     &lt;/tr&gt;     &lt;tr&gt;       &lt;td valign="top"&gt;&lt;b&gt;sys.uet$&lt;/b&gt;     &lt;/td&gt;       &lt;td valign="top"&gt;Data dictionary view used to store used extents. &lt;code&gt;sys.uet$&lt;/code&gt;         is actually clustered in the &lt;code&gt;C_FILE#_BLOCK#&lt;/code&gt; cluster.&lt;/td&gt;     &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt;     &lt;/p&gt;     Oracle updates the above tables in the data dictionary whenever an extent is      allocated, or freed for reuse.&lt;br /&gt;&lt;br /&gt;To Create Dictionary Managed Tablespaces you can use the following example:&lt;br /&gt;&lt;br /&gt;CREATE TABLESPACE users&lt;br /&gt;  DATAFILE '/u10/app/oradata/TESTDB/user01.dbf' SIZE 50M&lt;br /&gt;  EXTENT MANAGEMENT DICTIONARY&lt;br /&gt;  DEFAULT STORAGE (&lt;br /&gt;    INITIAL 64K&lt;br /&gt;    NEXT 64K&lt;br /&gt;    MINEXTENTS 2&lt;br /&gt;    MAXEXTENTS 121&lt;br /&gt;    PCTINCREASE 0);&lt;br /&gt;&lt;br /&gt;    A Locally Managed Tablespace is a tablespace that manages its own extents by     maintaining a bitmap in each datafile to keep track of the free or used status      of blocks in that datafile. Each bit in the bitmap corresponds to a block or     a group of blocks. When the extents are allocated or freed for reuse, Oracle simply     changes the bitmap values to show the new status of the blocks. These changes       do not generate rollback information because they do not update tables in the     data dictionary (except for tablespace quota information). Some of the benefits     of using a locally managed tablespace are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt; Reduced recursive space management.&lt;/li&gt;&lt;li&gt; Reduced contention on data dictionary tables.&lt;/li&gt;&lt;li&gt; No rollback generated.&lt;/li&gt;&lt;li&gt; No coalescing required.&lt;/li&gt;&lt;/ul&gt;The following statement creates a locally managed tablespace named USERS, where AUTOALLOCATE causes Oracle to automatically manage extent size.&lt;br /&gt;&lt;br /&gt;  CREATE TABLESPACE users&lt;br /&gt;  DATAFILE '/u10/app/oradata/TESTDB/user01.dbf' SIZE 50M&lt;br /&gt;  EXTENT MANAGEMENT LOCAL AUTOALLOCATE;&lt;br /&gt;&lt;br /&gt;Alternatively, this tablespace could be created specifying the UNIFORM clause. In this example, a 512K extent size is specified. Each 512K extent (which is equivalent to 64 Oracle blocks of 8K) is represented by a bit in the bitmap for this file.&lt;br /&gt;&lt;br /&gt;  CREATE TABLESPACE users&lt;br /&gt;  DATAFILE '/u10/app/oradata/TESTDB/user01.dbf' SIZE 50M&lt;br /&gt;  EXTENT MANAGEMENT LOCAL UNIFORM SIZE 512K;&lt;br /&gt;&lt;br /&gt;Advantages in using Locally Managed Tablespaces Over Dictionary Managed Tablespaces :&lt;br /&gt;&lt;ul&gt;&lt;li&gt; Because locally managed tablespaces do not record free space in data          dictionary, it reduces contention on these tables.&lt;/li&gt;&lt;li&gt; Local management of extents automatically tracks adjacent free space,          eliminating the need to coalesce free extents.&lt;/li&gt;&lt;li&gt; Avoids recursive space management operations, which can occur in          dictionary-managed tablespaces if consuming or releasing space in an          extent results in another operation that consumes or releases space in          a rollback segment or data dictionary table.&lt;/li&gt;&lt;li&gt; Sizes of extents that are managed locally can be determined automatically          by the system. Alternatively, all extents can have the same size in a          locally managed tablespace.&lt;/li&gt;&lt;li&gt; Changes to the extent bitmaps do not generate rollback information          because they do not update tables in the data dictionary (except for          special cases such as tablespace quota information).&lt;/li&gt;&lt;li&gt; Reduced fragmentation .&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-4917320032892473198?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/4917320032892473198/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=4917320032892473198' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/4917320032892473198'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/4917320032892473198'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/locally-vs-dictionary-managed.html' title='Locally vs. Dictionary Managed Tablespaces'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-4079505756779186835</id><published>2007-09-02T21:32:00.000-07:00</published><updated>2007-09-03T20:14:51.390-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle fundamental'/><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Oracle Database Shutdown Stages</title><content type='html'>What happens during the different Oracle shutdown options?&lt;br /&gt;&lt;br /&gt;Database Shutdown options:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;NORMAL&lt;/b&gt; - No new connections, waits for all users to disconnect, closes and             dismounts    database  before instance shutdown, no instance recovery             required upon next db startup.&lt;/li&gt;&lt;li&gt;&lt;b&gt;IMMEDIATE&lt;/b&gt; - Rolls back all current uncommitted transactions and disconnects users,            closes and dismounts database before instance shutdown, no instance             recovery required upon next db startup.&lt;/li&gt;&lt;li&gt;&lt;b&gt;TRANSACTIONAL&lt;/b&gt; -  No new connections, users disconnected when their current transaction is completed, when all "current transactions are complete shutdown immediate             is executed.&lt;/li&gt;&lt;li&gt; &lt;b&gt;ABORT&lt;/b&gt; - All transactions are terminated, no transactions are rolled back, instance terminated             without closing the data files, next startup will require instance             recovery.       &lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-4079505756779186835?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/4079505756779186835/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=4079505756779186835' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/4079505756779186835'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/4079505756779186835'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/oracle-database-shutdown-stages.html' title='Oracle Database Shutdown Stages'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-1136740663678263299</id><published>2007-09-02T20:39:00.005-07:00</published><updated>2007-09-05T03:19:12.051-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle fundamental'/><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='tablespace'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Resizing Temporary Tablespace</title><content type='html'>Sometimes, in many database configuration, the DBA will choose to allow their temporary tablespace to AUTOEXTEND. A runaway query or sort can easily chew up valuable space on the disk as the      tempfiles(s) extends to accommodate the request for space.&lt;br /&gt;If the increase in size      of the temporary tablespace (the tempfiles) gets exceedingly large because of     a particular anomaly, the DBA will often want to resize the temporary tablespace to      a more reasonable size in order to reclaim that extra space.&lt;br /&gt;The obvious action would      be to resize the tempfiles using the following statement:&lt;br /&gt;&lt;br /&gt;SQL&gt; alter database tempfile '/u02/oradata/TESTDB/temp01.dbf' resize 250M;&lt;br /&gt;alter database tempfile '/u02/oradata/TESTDB/temp01.dbf' resize 250M&lt;br /&gt;*&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-03297: file contains used data beyond requested RESIZE value&lt;br /&gt;&lt;br /&gt;The best practice are:&lt;br /&gt;- create another temporary tablespace&lt;br /&gt;- make the new temporary tablespace as the default temporary tablespace&lt;br /&gt;or if you want to use the old tablespace name&lt;br /&gt;- drop the old temporary tablespace, and recreate it, set it as the default temporary tablespace&lt;br /&gt;- drop the other temporary tablespace&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;SQL&gt; DROP TABLESPACE temp;&lt;br /&gt;drop tablespace temp&lt;br /&gt;*&lt;br /&gt;ERROR at line 1:&lt;br /&gt;ORA-12906: cannot drop default temporary tablespace&lt;br /&gt;&lt;br /&gt;SQL&gt; CREATE TEMPORARY TABLESPACE temp2&lt;br /&gt;  2  TEMPFILE '/u02/oradata/TESTDB/temp2_01.dbf' SIZE 5M REUSE&lt;br /&gt;  3  AUTOEXTEND ON NEXT 1M MAXSIZE unlimited&lt;br /&gt;  4  EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;&lt;br /&gt;&lt;br /&gt;Tablespace created.&lt;br /&gt;&lt;br /&gt;SQL&gt; ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp2;&lt;br /&gt;&lt;br /&gt;Database altered.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; DROP TABLESPACE temp INCLUDING CONTENTS AND DATAFILES;&lt;br /&gt;&lt;br /&gt;Tablespace dropped.&lt;br /&gt;&lt;br /&gt;SQL&gt; CREATE TEMPORARY TABLESPACE temp&lt;br /&gt;  2  TEMPFILE '/u02/oradata/TESTDB/temp01.dbf' SIZE 500M REUSE&lt;br /&gt;  3  AUTOEXTEND ON NEXT 100M MAXSIZE unlimited&lt;br /&gt;  4  EXTENT MANAGEMENT LOCAL UNIFORM SIZE 1M;&lt;br /&gt;&lt;br /&gt;Tablespace created.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp;&lt;br /&gt;&lt;br /&gt;Database altered.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;SQL&gt; DROP TABLESPACE temp2 INCLUDING CONTENTS AND DATAFILES;&lt;br /&gt;&lt;br /&gt;Tablespace dropped.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;NOTE&lt;/span&gt;:&lt;br /&gt;On some platforms , it is possible for the tempfile to be deleted from DBA_TEMP_FILES but not from the hard drive of the server.&lt;br /&gt;&lt;br /&gt;If this occurs, simply delete the file using regular O/S commands.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-1136740663678263299?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/1136740663678263299/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=1136740663678263299' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/1136740663678263299'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/1136740663678263299'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/resizing-temporary-tablespace.html' title='Resizing Temporary Tablespace'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-4399969389740575020</id><published>2007-09-02T19:24:00.001-07:00</published><updated>2007-09-02T20:30:42.190-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle fundamental'/><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='tablespace'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Creating Tablespace</title><content type='html'>&lt;span style="font-family:monospace;"&gt;Types of Tablespace&lt;br /&gt;1. SYSTEM Tablespace&lt;br /&gt; - Created with the database&lt;br /&gt; - Contains the data dictionary&lt;br /&gt; - Contains the SYSTEM undo segment&lt;br /&gt;2. Non-SYSTEM Tablespace&lt;br /&gt; - Separate segments&lt;br /&gt; - Eases space administration&lt;br /&gt; - Controls amount of space allocated to a user&lt;br /&gt;&lt;br /&gt;Create a tablespace with the CREATE TABLESPACE command:&lt;/span&gt;&lt;pre&gt;&lt;span style="font-family:verdana;"&gt;&lt;span style="font-family:verdana;"&gt;CREATE TABLESPACE tablespace&lt;br /&gt;[DATAFILES clause]&lt;br /&gt;[MINIMUM EXTENT integer [K|M] ]&lt;br /&gt;[BLOCKSIZE integer [K] ]&lt;br /&gt;[LOGGING | NOLOGGING]&lt;br /&gt;[DEFAULT storage_clause]&lt;br /&gt;[ONLINE | OFFLINE ]&lt;br /&gt;[PERMANENT | TEMPORARY]&lt;br /&gt;[extent_management_clause]&lt;br /&gt;[segment_management_clause]&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:monospace;"&gt;Example:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;CREATE TABLESPACE userdb&lt;br /&gt;DATAFILE '/u01/oradata/userdb01.dbf' SIZE 100M&lt;br /&gt;AUTOEXTEND ON NEXT 5M MAXSIZE 200M;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;For locally managed tablespace:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;span style="font-family:verdana;"&gt;CREATE TABLESPACE userdb&lt;br /&gt;DATAFILE '/u01/oradata/userdb01.dbf' SIZE 100M&lt;br /&gt;EXTENT MANAGEMENT LOCAL UNIFORM SIZE 128K;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;span style="font-family:verdana;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-4399969389740575020?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/4399969389740575020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=4399969389740575020' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/4399969389740575020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/4399969389740575020'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/creating-tablespace.html' title='Creating Tablespace'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-2217364955669414354</id><published>2007-09-02T18:10:00.000-07:00</published><updated>2007-09-05T03:15:59.384-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle fundamental'/><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='oracle dba'/><title type='text'>Creating Database</title><content type='html'>&lt;pre&gt;To create a database, use the following SQL command :&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;&lt;br /&gt;CREATE DATABASE [database]&lt;br /&gt; [CONTROLFILE REUSE]&lt;br /&gt; [LOGFILE [GROUP integer] filespec&lt;br /&gt; [MAXLOGFILES integer]&lt;br /&gt; [MAXLOGMEMBERS integer]&lt;br /&gt; [MAXLOGHISTORY integer]&lt;br /&gt; [MAXDATAFILES integer]&lt;br /&gt; [MAXINSTACES integer]&lt;br /&gt; [ARCHIVELOG |NOARCHIVELOG]&lt;br /&gt; [CHARACTER SET charset]&lt;br /&gt; [NATIONAL CHARACTER SET charset]&lt;br /&gt;[DATAFILES filespec [autoextend_clause]&lt;br /&gt;filespec :== 'filename' [SIZE integer] [K|M] [REUSE]&lt;br /&gt; autoextend_clause :==&lt;br /&gt; [AUTOEXTEND {OFF | ON [NEXT integer [K|M] ] [MAXSIZE {UNLIMMITED | integer [K|M] } } ]&lt;br /&gt;[DEFAULT TEMPORARY TABLESPACE tablespace filespec [temp_tablespace_extend_clause]&lt;br /&gt;temp_tablespace_extend_clause :==&lt;br /&gt;EXTENT MANAGEMENT LOCAL UNIFORM [SIZE integer] [K|M] ]&lt;br /&gt;&lt;br /&gt;[UNDO TABLESPACE tablespace DATAFILE filespec [autoextend_clause] ]&lt;br /&gt;[SET TIME_ZONE [time_zone_region] ]&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Example:&lt;br /&gt;&lt;span&gt;&lt;span style="font-family:verdana;"&gt;CREATE DATABASE userdb&lt;br /&gt; LOGFILE&lt;br /&gt;  GROUP 1 ('/$HOME/ORADATA/u01/redo1.log') SIZE 100M,&lt;br /&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span style="font-family:verdana;"&gt;GROUP 2 ('/$HOME/ORADATA/u02/redo1.log') SIZE 100M&lt;span style="font-family: monospace;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;   &lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span style="font-family:verdana;"&gt;GROUP 3 ('/$HOME/ORADATA/u03/redo1.log') SIZE 100M&lt;br /&gt; MAXLOGFILES 5&lt;br /&gt; MAXLOGMEMBERS 5&lt;br /&gt; MAXLOGHISTORY 1&lt;br /&gt; MAXDATAFILES 100&lt;br /&gt; MAXINSTANCES 1&lt;br /&gt; DATAFILE '/$HOME/ORADATA/u01/system01.dbf' SIZE 300M&lt;br /&gt; UNDO TABLESPACE undotbs&lt;br /&gt; DATAFILE '/$HOME/ORADATA/u02/undotbs01.dbf' SIZE 300M&lt;br /&gt;  AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED&lt;br /&gt; DEFAULT TEMPORARY TABLESPACE temp&lt;br /&gt; CHARACTER SET US7ASCII&lt;br /&gt; NATIONAL CHARACTER SET AL16UTF16&lt;br /&gt; SET TIME_ZONE = 'America/New_York'&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-2217364955669414354?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/2217364955669414354/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=2217364955669414354' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/2217364955669414354'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/2217364955669414354'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/creating-database.html' title='Creating Database'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-3514748325821021370</id><published>2007-09-02T17:17:00.001-07:00</published><updated>2007-09-05T03:13:03.285-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='oracle fundamental'/><category scheme='http://www.blogger.com/atom/ns#' term='PL/SQL'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL'/><title type='text'>The Dual Table</title><content type='html'>&lt;span style="font-family:monospace;"&gt;Dual Table is a table that contais a single row.&lt;br /&gt;The dual table has one VARCHAR2 column named dummy.&lt;br /&gt;Dual contains a single row with the value X.&lt;br /&gt;&lt;br /&gt;Oracle has created this since it makes some calculations more convenient.&lt;/span&gt;&lt;pre&gt;&lt;span style="font-family:verdana;"&gt;SQL&gt; describe dual;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;Name  Type        Nullable Default Comments &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;----- ----------- -------- ------- -------- &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;DUMMY VARCHAR2(1) Y&lt;br /&gt;&lt;br /&gt;SQL&gt; select * from dual;&lt;br /&gt;&lt;br /&gt;DUMMY&lt;br /&gt;-----&lt;br /&gt;X&lt;br /&gt;&lt;span style="font-family:monospace;"&gt;&lt;br /&gt;You can use it for math :&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:verdana;"&gt;SQL&gt; Select (202*44)/4 from dual;&lt;br /&gt;&lt;br /&gt;(202*44)/4&lt;br /&gt;----------&lt;br /&gt;  2222&lt;br /&gt;&lt;span style="font-family:monospace;"&gt;&lt;br /&gt;You can use it to increment sequences : &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:verdana;"&gt;SQL&gt; select seq_no_tx.nextval from dual;&lt;br /&gt;&lt;br /&gt; NEXTVAL&lt;br /&gt;----------&lt;br /&gt;    1402&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-3514748325821021370?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/3514748325821021370/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=3514748325821021370' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/3514748325821021370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/3514748325821021370'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/dual-table.html' title='The Dual Table'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-1148190652716097821</id><published>2007-09-01T20:56:00.000-07:00</published><updated>2009-03-15T17:02:43.848-07:00</updated><title type='text'>Privacy Policy</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;PRIVACY POLICY&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;If you require any more information or have any questions about our privacy policy, please feel free to contact us by email at sprpopo@yahoo.com.&lt;br /&gt;&lt;br /&gt;At oracletipstricks.blogspot.com, the privacy of our visitors is of extreme importance to us. This privacy policy document outlines the types of personal information is received and collected by oracletipstricks.blogspot.com and how it is used.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Log Files&lt;/span&gt;&lt;br /&gt;Like many other Web sites, oracletipstricks.blogspot.com makes use of log files. The information inside the log files includes internet protocol ( IP ) addresses, type of browser, Internet Service Provider ( ISP ), date/time stamp, referring/exit pages, and number of clicks to analyze trends, administer the site, track user’s movement around the site, and gather demographic information. IP addresses, and other such information are not linked to any information that is personally identifiable.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Cookies and Web Beacons&lt;/span&gt;&lt;br /&gt;oracletipstricks.blogspot.com does use cookies to store information about visitors preferences, record user-specific information on which pages the user access or visit, customize Web page content based on visitors browser type or other information that the visitor sends via their browser.&lt;br /&gt;&lt;br /&gt;Some of our advertising partners may use cookies and web beacons on our site. Our advertising partners include Google Adsense, Kontera.&lt;br /&gt;&lt;br /&gt;Oracle Tips &amp;amp; Tricks utilizes certain services from Google for ad serving and web traffic analysis. Please review Google's &lt;a href="http://www.google.com/privacy.html"&gt;privacy policy&lt;/a&gt; for more information on how Google AdSense and Google Analytics stores your personal information. These Google servies may place and read cookies on your browser, or use web beacons to collect information, in the course of ads being served on the Oracle Tips &amp;amp; Tricks website. Additionally, Google uses the DART cookie to enables it to serve ads to based on your visits to Oracle Tips &amp;amp; Tricks and other sites on the Internet. You may opt out of the use of the DART cookie by visiting the &lt;a href="http://www.google.com/privacy_ads.html"&gt;Google ad and content network privacy policy&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;These third-party ad servers or ad networks use technology to the advertisements and links that appear on oracletipstricks.blogspot.com send directly to your browsers. They automatically receive your IP address when this occurs. Other technologies ( such as cookies, JavaScript, or Web Beacons ) may also be used by the third-party ad networks to measure the effectiveness of their advertisements and / or to personalize the advertising content that you see.&lt;br /&gt;&lt;br /&gt;oracletipstricks.blogspot.com has no access to or control over these cookies that are used by third-party advertisers.&lt;br /&gt;&lt;br /&gt;You should consult the respective privacy policies of these third-party ad servers for more detailed information on their practices as well as for instructions about how to opt-out of certain practices. oracletipstricks.blogspot.com's privacy policy does not apply to, and we cannot control the activities of, such other advertisers or web sites.&lt;br /&gt;&lt;br /&gt;If you wish to disable cookies, you may do so through your individual browser options. More detailed information about cookie management with specific web browsers can be found at the browsers' respective websites.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-1148190652716097821?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/1148190652716097821/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=1148190652716097821' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/1148190652716097821'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/1148190652716097821'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2008/03/privacy-policy.html' title='Privacy Policy'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1802525653898001175.post-8414617044511431954</id><published>2007-09-01T16:58:00.000-07:00</published><updated>2008-04-23T17:43:04.167-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ebook Download'/><title type='text'>Oracle Ebook Download</title><content type='html'>&lt;ol&gt;&lt;li&gt;&lt;a href="http://www.4shared.com/file/45171536/82cdffe5/OReilly_-_Oracle_-_Advanced_Programming_With_Packages.html"&gt;Advance Oracle PL/SQL Programming with Packages&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.4shared.com/file/45172379/6026f42c/Developing_Client-Server_Applications_with_Oracle.html"&gt;Developing Client-Server Application with Oracle&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.4shared.com/file/45172867/92d0078b/High_Performance_Oracle_Database_Applications.html"&gt;High Performance Oracle Database Applications&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.4shared.com/file/45173411/8554aa78/OReilly_-_Learning_Oracle_Plsql.html"&gt;Learning Oracle PL/SQL&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.4shared.com/file/45174446/fb90f327/OReilly_-_Oracle_-_SQL_Programming.html"&gt;Oracle SQL Programming&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.4shared.com/file/45174733/c6fd2f36/performance_tuning.html"&gt;Performance Tuning Oracle Applications&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1802525653898001175-8414617044511431954?l=oracletipstricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://oracletipstricks.blogspot.com/feeds/8414617044511431954/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1802525653898001175&amp;postID=8414617044511431954' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/8414617044511431954'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1802525653898001175/posts/default/8414617044511431954'/><link rel='alternate' type='text/html' href='http://oracletipstricks.blogspot.com/2007/09/oracle-ebook-download.html' title='Oracle Ebook Download'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
