<?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-1345851661927049938</id><updated>2011-07-28T05:58:52.424-07:00</updated><title type='text'>OracleTips</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://arunaigreens-oratips.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://arunaigreens-oratips.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Kamalabharathy</name><uri>http://www.blogger.com/profile/11176266768302801114</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>10</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1345851661927049938.post-5448456178991952885</id><published>2009-07-01T14:45:00.000-07:00</published><updated>2009-07-01T14:53:31.301-07:00</updated><title type='text'>Ref Cursor - 1</title><content type='html'>&lt;strong&gt;Is ref cursor the only light at end of the tunnel?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Consider a requirement: Based on the given condition, the base table of the query will change whereas select statement will remain intact.&lt;br /&gt;&lt;br /&gt;Say for example we need to select &lt;br /&gt;Account number, &lt;br /&gt;Dr_Cr ,&lt;br /&gt;Currency and &lt;br /&gt;Amount&lt;br /&gt;&lt;br /&gt;From Account_Posting_USD table when condition Local_Currency is True or &lt;br /&gt;From Account_Posting table when condition Local_Currency is False.&lt;br /&gt;&lt;br /&gt;In Static cursor I cannot parameterize the table name but still this &lt;br /&gt;is a simple requirement if you are aware of dynamic cursor/REF cursor!!!  Isn’t it?&lt;br /&gt;&lt;br /&gt;So let’s implement this with ref cursor.&lt;br /&gt;&lt;br /&gt;CREATE TABLE Account_Posting (&lt;br /&gt;                    Posting_Txn_Ref INTEGER,&lt;br /&gt;                    Account_Number NUMBER,&lt;br /&gt;                    Dr_Cr VARCHAR2(1),&lt;br /&gt;                    Currency  VARCHAR2(3),&lt;br /&gt;                    Amount NUMBER,&lt;br /&gt;              CONSTRAINT Account_Posting_PK PRIMARY KEY &lt;br /&gt;(Posting_Txn_Ref));&lt;br /&gt;                    &lt;br /&gt;CREATE TABLE Account_Posting as SELECT * FROM Account_Posting_Usd;&lt;br /&gt;&lt;br /&gt;CREATE OR REPLACE PROCEDURE Accounting_Refcur_Example(i_Local_Ccy BOOLEAN) AS &lt;br /&gt;    Ret_Val SYS_REFCURSOR;&lt;br /&gt;    l_Val  Account_Posting%ROWTYPE; &lt;br /&gt;BEGIN&lt;br /&gt;    -- IF local Currency is true means select from Account_Posting_Usd table.&lt;br /&gt;    IF i_Local_Ccy THEN &lt;br /&gt;        OPEN Ret_Val FOR &lt;br /&gt;            SELECT Account_Number,&lt;br /&gt;                   Dr_Cr,&lt;br /&gt;                   Currency ,&lt;br /&gt;                   Amount&lt;br /&gt;               FROM Account_Posting_Usd;&lt;br /&gt;    ELSE &lt;br /&gt;        OPEN Ret_Val FOR &lt;br /&gt;            SELECT Account_Number,&lt;br /&gt;                   Dr_Cr,&lt;br /&gt;                   Currency ,&lt;br /&gt;                   Amount&lt;br /&gt;               FROM Account_Posting;    &lt;br /&gt;    END IF; &lt;br /&gt;    LOOP&lt;br /&gt;        FETCH Ret_Val INTO l_Val;&lt;br /&gt;        EXIT WHEN Ret_Val%NOTFOUND;&lt;br /&gt;        Dbms_Output.Put_line(l_Val.Account_Number);&lt;br /&gt;    END LOOP;&lt;br /&gt;    CLOSE Ret_Val;&lt;br /&gt;END Accounting_Refcur_Example;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;Problem at hand solved. But is this implementation more efficient?&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;While looking behind the hoods of PL/SQL ref cursors are just pointers to the cursors (Query result set).  They are not parsed at “Compile Time”.  &lt;br /&gt;&lt;br /&gt;More importantly the queries are not parsed and stored in Shared Pool. This means &lt;br /&gt;each time  the query will under go hard parse (plan and row data generation will occur again).  &lt;br /&gt;&lt;br /&gt;For more details on hard/soft parse refer : &lt;br /&gt;&lt;a href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2588723819082"&gt; http://asktom.oracle.com &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Question for your thought:&lt;/strong&gt;&lt;br /&gt;1. What are the other ways to implement the same requirement?&lt;br /&gt; &lt;br /&gt;&lt;strong&gt;Word of Caution: &lt;/strong&gt;&lt;br /&gt;   Though this performance burden is there on ref cursor, it is advisable to use ref cursor to pass between procedures, between client/server applications etc..&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1345851661927049938-5448456178991952885?l=arunaigreens-oratips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://arunaigreens-oratips.blogspot.com/feeds/5448456178991952885/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1345851661927049938&amp;postID=5448456178991952885' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/5448456178991952885'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/5448456178991952885'/><link rel='alternate' type='text/html' href='http://arunaigreens-oratips.blogspot.com/2009/07/ref-cursor-1.html' title='Ref Cursor - 1'/><author><name>Kamalabharathy</name><uri>http://www.blogger.com/profile/11176266768302801114</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-1345851661927049938.post-8669227735718537145</id><published>2009-06-26T14:15:00.000-07:00</published><updated>2009-07-01T14:50:28.651-07:00</updated><title type='text'>XML in Oracle PL/SQL - Part-1</title><content type='html'>To keep abreast with new technologies oracle now integrated XML functionalities into PL/SQL. This articles describes some feautures.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;XML Type:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;Oracle 9i release 1 introduced a new datatype , XMLType, to facilitate native handling of XML data in database.&lt;br /&gt;&lt;br /&gt;Use XMLType anytime you want to use the database as a persistent storage of XML.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;XML Type data can be stored in two ways:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;1. &lt;em&gt;In Large Objects (LOBs)&lt;/em&gt; – LOB storage maintains content fidelity, &lt;br /&gt;also called document fidelity. The original XML is preserved, including whitespace. An entire XML document is stored as a whole in a LOB. For non-schema-based storage, XMLType offers a Character Large Object (CLOB) storage option.&lt;br /&gt;&lt;br /&gt;Note: Use this option only when your application requires content fidelity, since this option provides mediocre performance for DML and limited accessibility to SQL features.&lt;br /&gt;&lt;br /&gt;Unstructured storage: The content of the XMLType is persisted as XML text using a CLOB datatype. This option is available for non-schema-based and schema-based XML content. When the XML is to be stored and retrieved as complete documents, unstructured storage may be the best solution as it offers the fastest rates of throughput when storing and retrieving XML content.&lt;br /&gt;&lt;br /&gt;2. &lt;em&gt;In Structured storage (in tables and views)&lt;/em&gt; – Structured storage maintains DOM (Document Object Model) fidelity.&lt;br /&gt;&lt;br /&gt;Structured storage of XML documents is based on decomposing the content of the document into a set of SQL objects. These SQL objects are based on the SQL 1999 Type framework. When an XML schema is registered with Oracle XML DB, the required SQL type definitions are automatically generated from the XML schema.&lt;br /&gt;A SQL type definition is generated from each complexType defined by the XML schema. Each element or attribute defined by the complexType becomes a SQL attribute in the corresponding SQL type. Oracle XML DB automatically maps the &lt;strong&gt;47 scalar data types &lt;/strong&gt;defined by the XML Schema Recommendation to the &lt;strong&gt;19 scalar datatypes &lt;/strong&gt;supported by SQL. A varray type is generated for each element and this can occur multiple times.&lt;br /&gt;&lt;br /&gt;The generated SQL types allow XML content, compliant with the XML schema, to be decomposed and stored in the database as a set of objects without any loss of information. When the document is ingested the constructs defined by the XML schema are mapped directly to the equivalent SQL types. This allows Oracle XML DB to leverage the full power of Oracle Database when managing XML and can lead to significant reductions in the amount of space required to store the document. It can also reduce the amount of memory required to query and update XML content.&lt;br /&gt;&lt;br /&gt;   Annotating an XML schema allows control over the naming of the SQL objects and attributes created. Annotations can also be used to override the default mapping between the XML schema data types and SQL data types and to specify which table should be used to store the data.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Registering XML Schema:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;One of the very basic requirment will be to register XML Schema to validate XML docs.&lt;br /&gt;&lt;br /&gt;Oracle PL/SQL Package Dbms_Xmlschema have set of utilities to play around XML schema. Procedure RegisterSchema need to be used to register XML Schema.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Example:&lt;/strong&gt; &lt;br /&gt; The following example register a schema namely mt202.xsd (Xml Schema document) into&lt;br /&gt; oracle database using Dbms_Xmlschema.RegisterSchema procedure.&lt;br /&gt;&lt;br /&gt;DECLARE        &lt;br /&gt;    doc VARCHAR2(2000) :=  &lt;br /&gt;     '&amp;lt schema &lt;br /&gt;     targetNamespace="http://xmlns.oracle.com/xdb/schemas/Scott/mt202.xsd" &lt;br /&gt;     xmlns="http://www.w3.org/2001/XMLSchema"   &lt;br /&gt;     elementFormDefault="qualified"&amp;gt     &lt;br /&gt;     &amp;lt element name ="mt202"&amp;gt&lt;br /&gt;      &amp;lt complexType &amp;gt&lt;br /&gt;        &amp;lt sequence&amp;gt&lt;br /&gt;          &amp;lt element name="tag_20" type="integer" fixed="20"/&amp;gt&lt;br /&gt;            &amp;lt element name="txnref" &amp;gt&lt;br /&gt;              &amp;lt simpleType&amp;gt&lt;br /&gt;              &amp;lt restriction base="string"&amp;gt&lt;br /&gt;              &amp;lt length value="16"/&amp;gt&lt;br /&gt;              &amp;lt /restriction&amp;gt&lt;br /&gt;              &amp;lt /simpleType&amp;gt       &lt;br /&gt;            &amp;lt /element&amp;gt&lt;br /&gt;            &amp;lt element name="tag_21" type="integer" fixed="21"/&amp;gt&lt;br /&gt;            &amp;lt element name="relref" maxOccurs="1"&amp;gt  &lt;br /&gt;              &amp;lt simpleType&amp;gt&lt;br /&gt;              &amp;lt restriction base="string"&amp;gt             &lt;br /&gt;              &amp;lt length value="16"/&amp;gt&lt;br /&gt;              &amp;lt /restriction&amp;gt&lt;br /&gt;              &amp;lt /simpleType&amp;gt       &lt;br /&gt;            &amp;lt/ element&amp;gt&lt;br /&gt;          &amp;lt/ sequence&amp;gt&lt;br /&gt;        &amp;lt/ complexType&amp;gt   &lt;br /&gt;   &amp;lt /element&amp;gt &lt;br /&gt;   &amp;lt/schema&amp;gt';  &lt;br /&gt;BEGIN   &lt;br /&gt;  DBMS_XMLSCHEMA.registerSchema('mt202.xsd', doc);&lt;br /&gt;END;&lt;br /&gt;/     &lt;br /&gt;&lt;br /&gt;In the above example Variable doc carries complete xsd value. To know more about what is Xsd and syntaxes please refer W3Schools tutorial @ &lt;br /&gt;&lt;em&gt;&lt;a href="http://www.w3schools.com/schema/schema_intro.asp"&gt;http://www.w3schools.com/schema/schema_intro.asp&lt;/a&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Deleting the registered XML Schema:&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;BEGIN   &lt;br /&gt;  Dbms_XmlSchema.DeleteSchema('mt202.xsd',Dbms_Xmlschema.DELETE_CASCADE_FORCE);&lt;br /&gt;END;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1345851661927049938-8669227735718537145?l=arunaigreens-oratips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://arunaigreens-oratips.blogspot.com/feeds/8669227735718537145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1345851661927049938&amp;postID=8669227735718537145' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/8669227735718537145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/8669227735718537145'/><link rel='alternate' type='text/html' href='http://arunaigreens-oratips.blogspot.com/2009/06/xml-in-oracle-plsql-part-1.html' title='XML in Oracle PL/SQL - Part-1'/><author><name>Kamalabharathy</name><uri>http://www.blogger.com/profile/11176266768302801114</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-1345851661927049938.post-3472285626974631841</id><published>2008-03-27T12:40:00.000-07:00</published><updated>2008-03-27T12:42:07.555-07:00</updated><title type='text'>PL/SQL Questions</title><content type='html'>PL/SQL:&lt;br /&gt;&lt;br /&gt;1.what is the difference between char &amp; varchar2, number &amp; integer, binary int&amp; pls int&lt;br /&gt;2.usage of dbms_job package&lt;br /&gt;3.usage of dbms_keep package&lt;br /&gt;4.usage of dbms_pipe package&lt;br /&gt;5.which cursor is efficient explicit or implicit?&lt;br /&gt;6.how to built implicit multirow query?&lt;br /&gt;7.where is the result set of the cursor stored?&lt;br /&gt;8.what are the operations &amp; results involved with the cursors?&lt;br /&gt;9.what is dynamic cursor?&lt;br /&gt;10.what is cursor object?&lt;br /&gt;11.what is cursor expressions?&lt;br /&gt;12.what is syscursor,sysrefcursor?&lt;br /&gt;13.what is NOCOPY compiler hint?&lt;br /&gt;14.what is PL/SQL table?&lt;br /&gt;15.what is bulk collect and set back with limit clause?&lt;br /&gt;16.what is NDS? Native Dynamic Sql?&lt;br /&gt;17.how will you use NDS for multirow query?&lt;br /&gt;18.use of auth_id and importance of auth_id in NDS?&lt;br /&gt;19.bind Vs concatenation?&lt;br /&gt;20.sql query Vs pl/sql block while binding in NDS?&lt;br /&gt;21.What will happen if unexpected exception raised in called block and not handled?&lt;br /&gt;22.usage of returning clause in dml statements – during lob dml, bulk dml?&lt;br /&gt;23.exception handling in dml – transaction not rolled back only variables !!&lt;br /&gt;24.dml of records – and restrictions?&lt;br /&gt;25.bulk dml and exception handling – usage save exceptions, bulk_errors, sql%bulk_exceptions.count,error_index , usage of sqlerrm(-1*error_code)?&lt;br /&gt;26.Discuss about triggers.&lt;br /&gt;27.Pragma restrict references&lt;br /&gt;28.what is the difference between procedures and functions?&lt;br /&gt;29.what is the advantage of using package?&lt;br /&gt;30.Dependency management&lt;br /&gt;31.what is format_error_backuptrace in exception handling ?&lt;br /&gt;new feature in oracle 10g with dbms_utility package.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1345851661927049938-3472285626974631841?l=arunaigreens-oratips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://arunaigreens-oratips.blogspot.com/feeds/3472285626974631841/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1345851661927049938&amp;postID=3472285626974631841' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/3472285626974631841'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/3472285626974631841'/><link rel='alternate' type='text/html' href='http://arunaigreens-oratips.blogspot.com/2008/03/plsql-questions.html' title='PL/SQL Questions'/><author><name>Kamalabharathy</name><uri>http://www.blogger.com/profile/11176266768302801114</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-1345851661927049938.post-5402357757864179524</id><published>2008-03-27T12:39:00.000-07:00</published><updated>2008-03-27T12:40:32.581-07:00</updated><title type='text'>SQL Questions</title><content type='html'>SQL:&lt;br /&gt;1. What is the difference between in &amp; exists?&lt;br /&gt;2. What is the difference between delete &amp; truncate?&lt;br /&gt;3. what is constrained and unconstrained datatype?&lt;br /&gt;4. what is the default storage of native datatypes?&lt;br /&gt;5. What will happen when u exit out of sqlplus without commit or rollback? &lt;br /&gt;6. What will happen if u executed series of dml &amp; then a invalid ddl ?  &lt;br /&gt;7. what is temporary table?&lt;br /&gt;8. what is pctfree and pctused parameters?&lt;br /&gt;9. what is row chaining &amp; row migration?&lt;br /&gt;10. What is consistent get?&lt;br /&gt;11. Use of analytic functions?&lt;br /&gt;12. Use of advanced grouping functions rollup &amp; cube?&lt;br /&gt;13. What is scalar subquery and futures?&lt;br /&gt;14. What are the different partitioning methods and 10g enhancements?&lt;br /&gt;15. What is local index &amp; global index?&lt;br /&gt;16. what is Cluster index &lt;br /&gt;17. what is merge statement and usage of delete clause?&lt;br /&gt;18. what is multi table insert?&lt;br /&gt;19. what is parallel and direct insert?&lt;br /&gt;20. how to use sql loader? What is direct load in sql loader?&lt;br /&gt;21. What is materialized view? Usage of dbms_mview? &lt;br /&gt;22. What are the refresh option and query rewrite in mview?&lt;br /&gt;23.what is difference between remainder and mod&lt;br /&gt;24.what is index_ff hints -- index fast full scan&lt;br /&gt;25.What is sql injection?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1345851661927049938-5402357757864179524?l=arunaigreens-oratips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://arunaigreens-oratips.blogspot.com/feeds/5402357757864179524/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1345851661927049938&amp;postID=5402357757864179524' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/5402357757864179524'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/5402357757864179524'/><link rel='alternate' type='text/html' href='http://arunaigreens-oratips.blogspot.com/2008/03/sql-questions.html' title='SQL Questions'/><author><name>Kamalabharathy</name><uri>http://www.blogger.com/profile/11176266768302801114</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-1345851661927049938.post-5623923207252849037</id><published>2008-03-27T12:38:00.001-07:00</published><updated>2008-03-27T12:38:58.709-07:00</updated><title type='text'>All About Joins</title><content type='html'>What is SEMI JOIN?&lt;br /&gt;Co-related sub query with exists operator is called semi join. Optimizer may choose any one of the hash or merge semi join according to the need.&lt;br /&gt;&lt;br /&gt;What is horizontal join &amp; vertical join?&lt;br /&gt;  Queries with set operator UNION,UNION ALL, MINUS &amp; INTERSECT are called horizontal join. Normal equi joins are called vertical joins since they compare column wise.&lt;br /&gt;&lt;br /&gt;What is self join:&lt;br /&gt;   Queries that join the same tables in the join condition is known as self join.&lt;br /&gt;What is equii join:&lt;br /&gt;This is determined by join condition, when join condition relates two tables by equating the columns from the tables it is equi-join. If the join condition relates two tables by an operator other than equality it is non-equi-join.&lt;br /&gt;&lt;br /&gt;What is CROSS JOIN?&lt;br /&gt;&lt;br /&gt;The cross join is new syntax to tell explicitly we need Cartesian product.&lt;br /&gt;Select * from A cross join B;&lt;br /&gt;&lt;br /&gt;Inner join, outer join:&lt;br /&gt;AN inner join returns the row that satisfy the join condition. In outer join one of the table is optional, the operator (+)  is used in the join condition in the where clause following a field name from the optional table.&lt;br /&gt;&lt;br /&gt;Some restrictions on outer join:&lt;br /&gt;1. outer join operator can appear on only one side of an expression in the join condition.&lt;br /&gt;2. If join involves more than two tables the one table can’t be outer joined with more than one another table in the query. But this can be achieved by inline view eg:  &lt;br /&gt;3. outer join condition may not use the IN operator. Error ora-01719&lt;br /&gt;4. cannot be combined with OR operator.Error ora-01719&lt;br /&gt;5. cannot compare subquery. Error ora-01799&lt;br /&gt;&lt;br /&gt;FULL OUTER JOINS – get results from two outer join and do UNION.&lt;br /&gt;Now ANSI sql syntax also available&lt;br /&gt;&lt;br /&gt;What is ANTI JOIN?&lt;br /&gt;Outer join with coln name is null check is called anti join because select result is exactly opposite to join result set. (can be achieved by minus operation also)&lt;br /&gt;&lt;br /&gt;JOIN VIEW &amp; KEY-PRESERVED TABLES:&lt;br /&gt;&lt;br /&gt;A DML statement on a join view can modify only one base table of the view, so a join view must also have one key preserved table to be modified.&lt;br /&gt; Every primary key or unique key value in the base table must also be unique in the result set of the join.&lt;br /&gt;&lt;br /&gt;Select * from user_updatable_columns where table_name=’V_RTLR_EMP’;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1345851661927049938-5623923207252849037?l=arunaigreens-oratips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://arunaigreens-oratips.blogspot.com/feeds/5623923207252849037/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1345851661927049938&amp;postID=5623923207252849037' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/5623923207252849037'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/5623923207252849037'/><link rel='alternate' type='text/html' href='http://arunaigreens-oratips.blogspot.com/2008/03/all-about-joins.html' title='All About Joins'/><author><name>Kamalabharathy</name><uri>http://www.blogger.com/profile/11176266768302801114</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-1345851661927049938.post-1195301059860628589</id><published>2008-03-27T12:37:00.000-07:00</published><updated>2008-03-27T12:38:20.465-07:00</updated><title type='text'>ACID Properties</title><content type='html'>1.   Atomicity refers to the ability of the DBMS to guarantee that either all of the tasks of a transaction are performed or none of them are. The transfer of funds can be completed or it can fail for a multitude of reasons, but atomicity guarantees that one account won't be debited if the other is not credited as well. &lt;br /&gt;   &lt;br /&gt;2.   Consistency refers to the database being in a legal state when the transaction begins and when it ends. This means that a transaction can't break the rules, or integrity constraints, of the database. If an integrity constraint states that all accounts must have a positive balance, then any transaction violating this rule will be aborted. &lt;br /&gt;   &lt;br /&gt;3.   Isolation refers to the ability of the application to make operations in a transaction appear isolated from all other operations. This means that no operation outside the transaction can ever see the data in an intermediate state; a bank manager can see the transferred funds on one account or the other, but never on both -- even if he ran his query while the transfer was still being processed. More formally, isolation means the transaction history is serializable. &lt;br /&gt;&lt;br /&gt;Isolation level the oracle supports are 1.Read committed (default) &amp; 2. Serializable&lt;br /&gt;Set transaction Serializable –&lt;br /&gt;&lt;br /&gt;Means read or write only commited data before start of transaction and   No Phantom phenomenon. &lt;br /&gt;&lt;br /&gt;Different statements in a transactin may see datatabase in different state and this is referred as Phantom Phenomenon. (In read commited txn, say stmt at line 1 reads 100 rows,  in same time stmt at line 20 may read 120 rows that is called as phantom phenomenon)&lt;br /&gt;&lt;br /&gt;SET TRANSACTION ISOLATION LEVEL READ COMMITTED;&lt;br /&gt;SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;&lt;br /&gt;SET TRANSACTION READ ONLY;&lt;br /&gt;&lt;br /&gt;ALTER SESSION SET ISOLATION_LEVEL SERIALIZABLE;&lt;br /&gt;ALTER SESSION SET ISOLATION_LEVEL READ COMMITTED;&lt;br /&gt;&lt;br /&gt;4. Durability refers to the guarantee that once the user has been notified of success, the transaction will persist, and not be undone. This means it will survive system failure, and that the database system has checked the integrity constraints and won't need to abort the transaction. Typically, all transactions are written into a log that can be played back to recreate the system to its state right before the failure. A transaction can only be deemed committed after it is safely in the log.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1345851661927049938-1195301059860628589?l=arunaigreens-oratips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://arunaigreens-oratips.blogspot.com/feeds/1195301059860628589/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1345851661927049938&amp;postID=1195301059860628589' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/1195301059860628589'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/1195301059860628589'/><link rel='alternate' type='text/html' href='http://arunaigreens-oratips.blogspot.com/2008/03/acid-properties.html' title='ACID Properties'/><author><name>Kamalabharathy</name><uri>http://www.blogger.com/profile/11176266768302801114</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-1345851661927049938.post-2003690874314937319</id><published>2008-03-27T12:36:00.000-07:00</published><updated>2008-03-27T12:37:12.884-07:00</updated><title type='text'>IN  &amp; Exists</title><content type='html'>IN &amp; EXISTS:&lt;br /&gt;&lt;br /&gt;Select * from T1 where x in ( select y from T2 )&lt;br /&gt;is typically processed as:&lt;br /&gt;&lt;br /&gt;select * from t1, ( select distinct y from t2 ) t2&lt;br /&gt; where t1.x = t2.y;&lt;br /&gt;&lt;br /&gt;The subquery is evaluated, distinct'ed, indexed (or hashed or sorted) and then joined to the original table -- typically.&lt;br /&gt;&lt;br /&gt;As opposed to &lt;br /&gt;&lt;br /&gt;select * from t1 where exists ( select null from t2 where y = x )&lt;br /&gt;That is processed more like:&lt;br /&gt;&lt;br /&gt;   for x in ( select * from t1 )&lt;br /&gt;   loop&lt;br /&gt;      if ( exists ( select null from t2 where y = x.x )&lt;br /&gt;      then &lt;br /&gt;         OUTPUT THE RECORD&lt;br /&gt;      end if&lt;br /&gt;   end loop&lt;br /&gt;&lt;br /&gt;It always results in a full scan of T1 whereas the first query can make use of an index on T1(x).&lt;br /&gt;&lt;br /&gt;So, when is where exists appropriate and in appropriate?&lt;br /&gt;&lt;br /&gt;Lets say the result of the subquery&lt;br /&gt;    ( select y from T2 )&lt;br /&gt;&lt;br /&gt;is "huge" and takes a long time.  But the table T1 is relatively small and executing ( select null from t2 where y = x.x ) is very very fast (nice index on t2(y)).  Then the exists will be faster as the time to full scan T1 and do the index probe into T2 could be less then the time to simply full scan T2 to build the subquery we need to distinct on.&lt;br /&gt;&lt;br /&gt;Lets say the result of the subquery is small -- then IN is typicaly more appropriate.&lt;br /&gt;&lt;br /&gt;If both the subquery and the outer table are huge -- either might work as well as the other -- depends on the indexes and other factors.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1345851661927049938-2003690874314937319?l=arunaigreens-oratips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://arunaigreens-oratips.blogspot.com/feeds/2003690874314937319/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1345851661927049938&amp;postID=2003690874314937319' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/2003690874314937319'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/2003690874314937319'/><link rel='alternate' type='text/html' href='http://arunaigreens-oratips.blogspot.com/2008/03/in-exists.html' title='IN  &amp; Exists'/><author><name>Kamalabharathy</name><uri>http://www.blogger.com/profile/11176266768302801114</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-1345851661927049938.post-5046778794679523161</id><published>2008-03-27T12:35:00.000-07:00</published><updated>2008-03-27T12:36:13.775-07:00</updated><title type='text'>Temporary Tables</title><content type='html'>What is temporary table?&lt;br /&gt;&lt;br /&gt;Oracle can create temporary tables to hold session-private data that exists only for the duration of a transaction or session. Index created on the table is also temporary and it is dropped when the session exits. Views and triggers can also be created.&lt;br /&gt;&lt;br /&gt;Transaction specific temp table:&lt;br /&gt;Create global temporary table temptab&lt;br /&gt;(&lt;br /&gt; Col1 number,&lt;br /&gt; Col2 varchar2(8)&lt;br /&gt;)&lt;br /&gt;On commit delete rows   default &lt;br /&gt;&lt;br /&gt;Session specific temp table:&lt;br /&gt;Create global temporary table temptab&lt;br /&gt;(&lt;br /&gt; Col1 number,&lt;br /&gt; Col2 varchar2(8)&lt;br /&gt;)&lt;br /&gt;On commit preserve rows&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1345851661927049938-5046778794679523161?l=arunaigreens-oratips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://arunaigreens-oratips.blogspot.com/feeds/5046778794679523161/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1345851661927049938&amp;postID=5046778794679523161' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/5046778794679523161'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/5046778794679523161'/><link rel='alternate' type='text/html' href='http://arunaigreens-oratips.blogspot.com/2008/03/temporary-tables.html' title='Temporary Tables'/><author><name>Kamalabharathy</name><uri>http://www.blogger.com/profile/11176266768302801114</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-1345851661927049938.post-1423976835472582442</id><published>2008-03-27T12:34:00.001-07:00</published><updated>2008-03-27T12:34:54.055-07:00</updated><title type='text'>Normalization Principles</title><content type='html'>What is normalization and common forms?&lt;br /&gt;     Normalization is process of  removing anomalies, redundancy and retaining functional dependencies. A table should be in atleast the 3 NF or BCNF for effective design.&lt;br /&gt;&lt;br /&gt;1NF: Table should be atomic. i.e. every tuple should have only one attribute.&lt;br /&gt;   Every table should have a primary key.&lt;br /&gt;&lt;br /&gt;Fully functional dependency or irreducible dependency:&lt;br /&gt;• Let A and B are attributes of a relation &lt;br /&gt;• B is fully dependent on A, if B is functionally dependent on A but not on any subset of A.&lt;br /&gt;&lt;br /&gt;2NF: All the non candidate key should irreducibly depend only on primary key. OR Every non primary key attribute is fully functionally dependent on th primary key. (for functional dependency)&lt;br /&gt;&lt;br /&gt;If  functional dependency exists say  A -&gt; B  and B -&gt; C then A -&gt; C this is called transitive dependency.&lt;br /&gt;&lt;br /&gt;3NF: All the non candidate keys should non transitively depend on primary key. &lt;br /&gt;&lt;br /&gt;Difference between 3NF and BCNF is that for a functional dependency A -&gt; B,  3NF allows this dependency in a relation if B is primary key attribute and A is not a candidate key.&lt;br /&gt;&lt;br /&gt;BCNF: All the non candidate keys should be non transitively depend on the primary key and also there should not be transitive dependence in the candidate keys.&lt;br /&gt;Only determinants are candidate key. Arrows always out of candidate keys.&lt;br /&gt;&lt;br /&gt;MVD&lt;br /&gt;&lt;br /&gt;Dependency between attributes (forexample, A, B, and C) in a relation, such that&lt;br /&gt;for each value of A there is a set of values for B and a set of values for C. However, set of values for B and C are independent&lt;br /&gt;&lt;br /&gt;MVD between attributes A, B, and C in a relation using the following notation:&lt;br /&gt;&lt;br /&gt;A -&gt;&gt; B, &lt;br /&gt;A -&gt;&gt; C&lt;br /&gt;&lt;br /&gt;MVD can be defined as trivial or nontrivial – MVD A -&gt;&gt;B in relation R is defined&lt;br /&gt;as being trivial if:&lt;br /&gt;(a) B is a subset of A or&lt;br /&gt;(b) A U B = R&lt;br /&gt;      &lt;br /&gt;MVD is nontrivial if neither (a) nor (b)&lt;br /&gt;Trivial MVD does not specify a constraint on a relation, while a nontrivial MVD does&lt;br /&gt;&lt;br /&gt;4NF is defined as a relation that is in BCNF and contains no nontrivial MVDs&lt;br /&gt;&lt;br /&gt;4NF: In a relvar R if  exists a non trivial MVD A -&gt;&gt; B, then the candidate key should also functionally dependent on A.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;5NF: In a relvar R if exists a join dependency then all the join dependencies should be visible and all the candidate key should be visible.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1345851661927049938-1423976835472582442?l=arunaigreens-oratips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://arunaigreens-oratips.blogspot.com/feeds/1423976835472582442/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1345851661927049938&amp;postID=1423976835472582442' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/1423976835472582442'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/1423976835472582442'/><link rel='alternate' type='text/html' href='http://arunaigreens-oratips.blogspot.com/2008/03/normalization-principles.html' title='Normalization Principles'/><author><name>Kamalabharathy</name><uri>http://www.blogger.com/profile/11176266768302801114</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-1345851661927049938.post-8259212207920901150</id><published>2008-03-27T12:32:00.001-07:00</published><updated>2008-03-27T12:32:58.701-07:00</updated><title type='text'>External Tables</title><content type='html'>External Tables:&lt;br /&gt;&lt;br /&gt;CREATE TABLE emp_load (employee_number CHAR(5), employee_last_name &lt;br /&gt;   CHAR(20),employee_first_name CHAR(15), &lt;br /&gt;   employee_middle_name CHAR(15))&lt;br /&gt;ORGANIZATION EXTERNAL (TYPE ORACLE_LOADER DEFAULT DIRECTORY ext_tab_dir&lt;br /&gt;   ACCESS PARAMETERS (RECORDS FIXED 62 FIELDS &lt;br /&gt; (employee_number CHAR(2),&lt;br /&gt;  employee_dob CHAR(20),&lt;br /&gt;  employee_last_name CHAR(18),&lt;br /&gt;         employee_first_name CHAR(11),&lt;br /&gt;   employee_middle_name CHAR(11)))               &lt;br /&gt; LOCATION ('info.dat'));&lt;br /&gt;&lt;br /&gt;Type -- ORACLE_LOADER (Default) text files, ORACLE_DATADUMP binary dump&lt;br /&gt;Default Directory – The directory where data file will present&lt;br /&gt; CREATE DIRECTORY ext_tab_dir AS '/usr/apps/datafiles';&lt;br /&gt; GRANT READ ON DIRECTORY ext_tab_dir TO scott;&lt;br /&gt;&lt;br /&gt;Access Parameters – &lt;br /&gt;  Record info -&gt;&lt;br /&gt; Records fixed or delimited by newline or delimited by “,” etc&lt;br /&gt;    Badfile dirname:filename&lt;br /&gt;    logfile dirname:filename&lt;br /&gt;    discardfile dirname:filename&lt;br /&gt;    Load when empno &gt; 1000;&lt;br /&gt;  Field info -&gt;&lt;br /&gt;    Fields terminated by whitespace optionally encolsed by “(“ and “)” &lt;br /&gt;    Fields terminated by “,”&lt;br /&gt;    Fields enclosed by “’” and “’” ltrim MISSING FIELD VALUES ARE NULL&lt;br /&gt;  Field List -&gt;&lt;br /&gt;    Field_name, pos_spec,datatype_spec, init_spec&lt;br /&gt;    First_name (1:15) char(15),&lt;br /&gt;    Last_name  (*:20) ,&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Example with Scott:&lt;br /&gt;&lt;br /&gt;CREATE DIRECTORY EXT_TAB_DIR AS 'D:\';&lt;br /&gt;GRANT WRITE,READ ON DIRECTORY EXT_TAB_DIR TO SCOTT;&lt;br /&gt;&lt;br /&gt;Sample files: &lt;br /&gt;DATA.TXT -- 2002,Kamal,Cons,7566,18-FEB-2008&lt;br /&gt;Dat.txt -- 2003ABCDEFGHIJZYXWVUTSR756620-FEB-2008&lt;br /&gt;&lt;br /&gt;create table emp_ext (empno number(4) , enamE varchar2(10), job varchar2(9),mgr number(4),hiredate date)&lt;br /&gt; organization external (TYPE ORACLE_LOADER DEFAULT DIRECTORY &lt;br /&gt;           EXT_TAB_DIR &lt;br /&gt;   ACCESS PARAMETERS (RECORDS DELIMITED BY NEWLINE &lt;br /&gt;      FIELDS TERMINATED BY ","&lt;br /&gt;            )&lt;br /&gt; LOCATION('DATA.TXT'))&lt;br /&gt;      &lt;br /&gt;create table emp_ext2 (empno number(4) , enamE varchar2(10), job &lt;br /&gt;varchar2(9),mgr number(4),hiredate date)&lt;br /&gt;organization external TYPE ORACLE_LOADER DEFAULT DIRECTORY EXT_TAB_DIR &lt;br /&gt;ACCESS PARAMETERS (RECORDS DELIMITED BY NEWLINE LOGFILE 'EMP_EXT.LOG'     FIELDS(        &lt;br /&gt;    EMPNO (1:4) INTEGER EXTERNAL,&lt;br /&gt;    ENAME (*:+10)    CHAR,&lt;br /&gt;    JOB  (*:+9) CHAR,&lt;br /&gt;    MGR (*:+4) INTEGER EXTERNAL,&lt;br /&gt;    HIREDATE (*:+11) DATE 'DD-MON-YYYY'&lt;br /&gt;    )&lt;br /&gt;    )&lt;br /&gt;   LOCATION('DAT.TXT'))&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1345851661927049938-8259212207920901150?l=arunaigreens-oratips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://arunaigreens-oratips.blogspot.com/feeds/8259212207920901150/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1345851661927049938&amp;postID=8259212207920901150' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/8259212207920901150'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1345851661927049938/posts/default/8259212207920901150'/><link rel='alternate' type='text/html' href='http://arunaigreens-oratips.blogspot.com/2008/03/external-tables.html' title='External Tables'/><author><name>Kamalabharathy</name><uri>http://www.blogger.com/profile/11176266768302801114</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>
