<?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-4315477689553621092</id><updated>2012-01-07T17:17:05.609+05:30</updated><title type='text'>Sql Question And Answers</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sqlqa.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sqlqa.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>expert</name><uri>http://www.blogger.com/profile/05027544102105084558</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>11</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4315477689553621092.post-4669571269865905401</id><published>2008-01-18T16:35:00.002+05:30</published><updated>2008-01-18T16:36:10.346+05:30</updated><title type='text'>Sql Question and answer 8</title><content type='html'>31. What are ORACLE PRECOMPILERS.&lt;br /&gt;&lt;br /&gt;Using ORACLE PRECOMPILERS ,SQL statements and PL/SQL blocks can be contained&lt;br /&gt;inside 3GL programs written in C,C++,COBOL,PASCAL,  FORTRAN,PL/1 AND ADA.&lt;br /&gt;&lt;br /&gt;The Precompilers are known as Pro*C,Pro*Cobol,...&lt;br /&gt;This form of PL/SQL is known as embedded pl/sql,the language in which pl/sql is&lt;br /&gt;embedded is known as the host language.&lt;br /&gt;&lt;br /&gt;The prcompiler translates the embedded SQL and pl/sql  ststements into calls to the&lt;br /&gt;precompiler runtime library.The output must be compiled and linked with  this library to&lt;br /&gt;creater an executable.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;32. What is OCI. What are its uses.&lt;br /&gt;&lt;br /&gt;Oracle Call Interface is a method of accesing database&lt;br /&gt;from a 3GL program. Uses--No precompiler is required,PL/SQL blocks are executed like&lt;br /&gt;other DML&lt;br /&gt;statements.&lt;br /&gt;                      The OCI library provides&lt;br /&gt;                     -functions to parse SQL statemets&lt;br /&gt;                     -bind input variables&lt;br /&gt;                     -bind output variables&lt;br /&gt;                     -execute statements&lt;br /&gt;                     -fetch the results&lt;br /&gt;&lt;br /&gt;33. Difference between database triggers and form triggers.&lt;br /&gt;&lt;br /&gt;a) Data base trigger(DBT) fires when a DML operation is performed on a data base table.Form trigger(FT) Fires when user presses a key or navigates between fields  on the screen&lt;br /&gt;&lt;br /&gt;b) Can be row level or statement level  No distinction between row level and statement level.&lt;br /&gt;&lt;br /&gt;c) Can manipulate data stored in Oracle tables via SQL Can manipulate data in Oracle tables as well as&lt;br /&gt;variables in forms.&lt;br /&gt;&lt;br /&gt;d) Can be fired from any session executing the triggering DML statements. Can be fired only from the form that define the trigger.&lt;br /&gt;&lt;br /&gt;e) Can cause other database triggers to fire.Can cause other database triggers to fire,but not other form triggers.&lt;br /&gt;&lt;br /&gt;34. What is an UTL_FILE.What are different procedures and functions associated                                                 with it.&lt;br /&gt;&lt;br /&gt;UTL_FILE is a package that adds the ability to read and write to operating system files &lt;br /&gt;Procedures associated with it are FCLOSE, FCLOSE_ALL  and 5 procedures to output &lt;br /&gt;data to a file PUT, PUT_LINE, NEW_LINE, PUTF, FFLUSH.PUT,  FFLUSH.PUT_LINE,FFLUSH.NEW_LINE. Functions associated with it are FOPEN, ISOPEN.&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;35.  Can you use a commit statement within a database trigger.&lt;br /&gt;          No&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;36. What is the maximum buffer size that can be specified using the DBMS_OUTPUT.ENABLE function? &lt;br /&gt;1,000,000&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4315477689553621092-4669571269865905401?l=sqlqa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlqa.blogspot.com/feeds/4669571269865905401/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4315477689553621092&amp;postID=4669571269865905401' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/4669571269865905401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/4669571269865905401'/><link rel='alternate' type='text/html' href='http://sqlqa.blogspot.com/2008/01/sql-question-and-answer-8.html' title='Sql Question and answer 8'/><author><name>expert</name><uri>http://www.blogger.com/profile/05027544102105084558</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-4315477689553621092.post-7057549784219830953</id><published>2008-01-18T16:35:00.001+05:30</published><updated>2008-01-18T16:35:29.601+05:30</updated><title type='text'>Sql Question and answer 7</title><content type='html'>31. How you were passing cursor variables in PL/SQL 2.2.&lt;br /&gt;In PL/SQL 2.2 cursor variables cannot be declared in a package.This is because the storage for a cursor variable has to be allocated using Pro*C or OCI with version 2.2,the only means of passing a cursor variable to a PL/SQL block is  via bind variable or a procedure parameter.&lt;br /&gt;&lt;br /&gt;32. Can cursor variables be stored in PL/SQL tables.If yes how.If not why.&lt;br /&gt;&lt;br /&gt;No, a cursor variable points a row which cannot be stored in a two-dimensional PL/SQL table.&lt;br /&gt;&lt;br /&gt;33. Difference between procedure and function.&lt;br /&gt;&lt;br /&gt;Functions are named PL/SQL blocks that return a value and can be called with arguments procedure a named block that can be called with parameter. A procedure all is a PL/SQL statement by itself, while a Function call is called as part of an expression.&lt;br /&gt;&lt;br /&gt;34. What are different modes of parameters used in functions and procedures.&lt;br /&gt;&lt;br /&gt;                   IN&lt;br /&gt;                   OUT&lt;br /&gt;                   INOUT&lt;br /&gt;&lt;br /&gt;35. What is difference between a formal and an actual parameter&lt;br /&gt;&lt;br /&gt;The variables declared in the procedure and which are passed, as arguments are called&lt;br /&gt; actual, the parameters in the procedure declaration. Actual parameters contain the&lt;br /&gt; values that are passed to a procedure and receive results. Formal parameters are the&lt;br /&gt; placeholders for the values of actual parameters&lt;br /&gt;&lt;br /&gt;36. Can the default values be assigned  to  actual parameters.&lt;br /&gt;      &lt;br /&gt;            Yes&lt;br /&gt;&lt;br /&gt;37. Can a function take OUT parameters.If not why.&lt;br /&gt;&lt;br /&gt;No.A function has to return a value,an OUT parameter cannot return a value.&lt;br /&gt;&lt;br /&gt;38. What is syntax for dropping a procedure and a function .Are these operations                                                 possible.&lt;br /&gt;&lt;br /&gt;               Drop Procedure procedure_name&lt;br /&gt;               Drop Function function_name&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4315477689553621092-7057549784219830953?l=sqlqa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlqa.blogspot.com/feeds/7057549784219830953/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4315477689553621092&amp;postID=7057549784219830953' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/7057549784219830953'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/7057549784219830953'/><link rel='alternate' type='text/html' href='http://sqlqa.blogspot.com/2008/01/sql-question-and-answer-7.html' title='Sql Question and answer 7'/><author><name>expert</name><uri>http://www.blogger.com/profile/05027544102105084558</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-4315477689553621092.post-3899632123419281215</id><published>2008-01-18T16:34:00.001+05:30</published><updated>2008-01-18T16:34:31.127+05:30</updated><title type='text'>Sql Question and answer 6</title><content type='html'>31. What a SELECT FOR UPDATE cursor represent.&lt;br /&gt;&lt;br /&gt;SELECT......FROM......FOR......UPDATE[OF column-reference][NOWAIT] The&lt;br /&gt;processing done in a fetch loop modifies the rows that have been retrieved by the &lt;br /&gt;cursor. &lt;br /&gt;&lt;br /&gt;A convenient way of modifying the rows is done by a method with two parts: the FOR&lt;br /&gt;UPDATE clause in the cursor declaration, WHERE CURRENT OF CLAUSE in an&lt;br /&gt;UPDATE or declaration statement.&lt;br /&gt;&lt;br /&gt;32. What 'WHERE CURRENT OF ' clause does in a cursor.&lt;br /&gt;&lt;br /&gt;LOOP&lt;br /&gt;                          SELECT  num_credits  INTO  v_numcredits  FROM classes&lt;br /&gt;                          WHERE  dept=123 and course=101;&lt;br /&gt;                          UPDATE  students&lt;br /&gt;                          SET current_credits=current_credits+v_numcredits&lt;br /&gt;                          WHERE  CURRENT OF  X;&lt;br /&gt;                          END  LOOP&lt;br /&gt;                          COMMIT;&lt;br /&gt;                          END;&lt;br /&gt;&lt;br /&gt;33. What is use of a cursor variable? How it is defined.&lt;br /&gt;&lt;br /&gt;A cursor variable is associated with different statements at run time, which can hold&lt;br /&gt;different values at run time. Static cursors can only be associated with  one run time &lt;br /&gt;query. A cursor variable is reference type(like a pointer in C).&lt;br /&gt;&lt;br /&gt;Declaring a cursor variable:&lt;br /&gt;TYPE  type_name  IS REF CURSOR RETURN  return_type  type_name is the name of&lt;br /&gt;the reference type,return_type is a record type  indicating the types of the select list&lt;br /&gt;that will eventually be returned by the cursor variable.&lt;br /&gt;&lt;br /&gt;34. What should be the return type for a cursor variable.Can we use a scalar data type as return type.&lt;br /&gt;The return type for a cursor must be a record type.It can be declared explicitly as a&lt;br /&gt;user-defined or %ROWTYPE  can be used. eg  TYPE  t_studentsref  IS  REF&lt;br /&gt;CURSOR  RETURN  students%ROWTYPE&lt;br /&gt;&lt;br /&gt;35. How you open and close a cursor variable.Why it is required.&lt;br /&gt;&lt;br /&gt;OPEN  cursor variable FOR  SELECT...Statement&lt;br /&gt;CLOSE cursor variable In order to associate a cursor variable with a particular&lt;br /&gt;SELECT statement  OPEN syntax is used.In order to free the resources used&lt;br /&gt;for the query CLOSE&lt;br /&gt;statement is used.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4315477689553621092-3899632123419281215?l=sqlqa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlqa.blogspot.com/feeds/3899632123419281215/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4315477689553621092&amp;postID=3899632123419281215' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/3899632123419281215'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/3899632123419281215'/><link rel='alternate' type='text/html' href='http://sqlqa.blogspot.com/2008/01/sql-question-and-answer-6.html' title='Sql Question and answer 6'/><author><name>expert</name><uri>http://www.blogger.com/profile/05027544102105084558</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-4315477689553621092.post-2801995830311228225</id><published>2008-01-18T16:33:00.001+05:30</published><updated>2008-01-18T16:33:56.626+05:30</updated><title type='text'>Sql Question and answer 5</title><content type='html'>PL-SQL QUESTIONS&lt;br /&gt;&lt;br /&gt;If you know pl-sql read it further otherwise better stop with sql alone and move to java at the bottom of the page (if you are a java guy), that should be sufficient.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1. What is the purpose of a cluster.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Oracle does not allow a user to specifically locate tables, since that is a part of the&lt;br /&gt;function of the RDBMS. However, for the purpose of increasing performance, oracle   allows a developer to create a CLUSTER.  A CLUSTER  provides a means for storing &lt;br /&gt;data from different tables together for faster retrieval than if the table placement were &lt;br /&gt;left to the RDBMS.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. What is a cursor.&lt;br /&gt;&lt;br /&gt;Oracle uses work area to execute SQL statements and store processing information&lt;br /&gt;PL/SQL construct called a cursor lets you name a work area  and access its stored &lt;br /&gt;information A cursor is a mechanism used to fetch more than one row in a Pl/SQl&lt;br /&gt;block.&lt;br /&gt;&lt;br /&gt;3. Difference between an implicit &amp; an explicit cursor.&lt;br /&gt;&lt;br /&gt;PL/SQL declares a cursor implicitly for all SQL data manipulation statements, including&lt;br /&gt;quries that return only one row.  However,queries that return more than one row you&lt;br /&gt;must declare an explicit  cursor or use a cursor FOR loop.&lt;br /&gt;&lt;br /&gt;Explicit cursor is a cursor in which the cursor name is explicitly assigned to a SELECT&lt;br /&gt;statement via the  CURSOR...IS statement. An implicit cursor is used for all SQL statements Declare, Open, Fetch, Close. An explicit cursors are used to process multirow SELECT statements  An implicit cursor is used to process INSERT, UPDATE,&lt;br /&gt;DELETE and single  row SELECT. .INTO  statements.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. What are cursor attributes&lt;br /&gt;&lt;br /&gt;                   %ROWCOUNT&lt;br /&gt;                   %NOTFOUND&lt;br /&gt;                   %FOUND&lt;br /&gt;                   %ISOPEN&lt;br /&gt;&lt;br /&gt;5. What is a cursor for loop.&lt;br /&gt;&lt;br /&gt;  Cursor For Loop is a loop where oracle implicitly declares a loop variable, the loop index that of the same record type as the cursor's record.&lt;br /&gt;&lt;br /&gt;6. Difference between NO DATA FOUND and %NOTFOUND&lt;br /&gt;&lt;br /&gt;  NO DATA FOUND is an exception raised only for the SELECT....INTO statements&lt;br /&gt;   when the where clause of the querydoes not  match any rows. When the where clause&lt;br /&gt;   of the explicit cursor does not match any rows the %NOTFOUND attribute is set to &lt;br /&gt;   TRUE instead.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4315477689553621092-2801995830311228225?l=sqlqa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlqa.blogspot.com/feeds/2801995830311228225/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4315477689553621092&amp;postID=2801995830311228225' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/2801995830311228225'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/2801995830311228225'/><link rel='alternate' type='text/html' href='http://sqlqa.blogspot.com/2008/01/sql-question-and-answer-5.html' title='Sql Question and answer 5'/><author><name>expert</name><uri>http://www.blogger.com/profile/05027544102105084558</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-4315477689553621092.post-6793664756966828602</id><published>2008-01-18T16:32:00.000+05:30</published><updated>2008-01-18T16:33:14.621+05:30</updated><title type='text'>Sql Question and answer</title><content type='html'>1. Suppose customer table is there having different columns&lt;br /&gt;like customer no, payments.What will be the query to select top three max payments.&lt;br /&gt;&lt;br /&gt;SELECT customer_no, payments from customer C1&lt;br /&gt;WHERE 3&lt;=(SELECT COUNT(*) from customer C2&lt;br /&gt;                     WHERE C1.payment &lt;= C2.payment)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Display the records between two range &lt;br /&gt;&lt;br /&gt;select rownum, empno, ename  from emp  where  rowid in &lt;br /&gt; (select rowid from emp where rownum &lt;=&amp;upto &lt;br /&gt; minus  select rowid from emp where rownum&lt;&amp;Start);&lt;br /&gt;&lt;br /&gt;Find out nth highest salary from emp table &lt;br /&gt; SELECT DISTINCT (a.sal) FROM EMP A WHERE &amp;N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal&lt;=b.sal); &lt;br /&gt;For Eg:-&lt;br /&gt;Enter value for n: 2 &lt;br /&gt;      SAL &lt;br /&gt;--------- &lt;br /&gt;     3700 &lt;br /&gt;&lt;br /&gt;Display the number value in Words &lt;br /&gt; SQL&gt; select sal, (to_char(to_date(sal,'j'), 'jsp')) &lt;br /&gt;from emp; &lt;br /&gt;&lt;br /&gt;the output like, &lt;br /&gt;      SAL (TO_CHAR(TO_DATE(SAL,'J'),'JSP')) &lt;br /&gt;--------- ----------------------------------------------------- &lt;br /&gt;      800 eight hundred &lt;br /&gt;     1600 one thousand six hundred &lt;br /&gt;     1250 one thousand two hundred fifty &lt;br /&gt;If you want to add some text like, &lt;br /&gt;Rs. Three Thousand only. &lt;br /&gt;SQL&gt; select sal  "Salary ", &lt;br /&gt; (' Rs. '|| (to_char(to_date(sal,'j'), 'Jsp'))|| ' only.')) &lt;br /&gt; "Sal in Words" from emp &lt;br /&gt;/ &lt;br /&gt;Salary  Sal in Words &lt;br /&gt;------- ------------------------------------------------------ &lt;br /&gt;    800  Rs. Eight Hundred only. &lt;br /&gt;   1600  Rs. One Thousand Six Hundred only. &lt;br /&gt;   1250  Rs. One Thousand Two Hundred Fifty only. &lt;br /&gt;&lt;br /&gt;14.  Display Odd/ Even number of records &lt;br /&gt; Odd number of records: &lt;br /&gt;select * from emp where (rowid,1) in (select rowid, mod(rownum,2) from emp); &lt;br /&gt;Output:- &lt;br /&gt;1 &lt;br /&gt;3 &lt;br /&gt;5 &lt;br /&gt;&lt;br /&gt;Even number of records: &lt;br /&gt;select * from emp where (rowid,0) in (select rowid, mod(rownum,2) from emp) &lt;br /&gt;Output:- &lt;br /&gt;&lt;br /&gt;2 &lt;br /&gt;4 &lt;br /&gt;6 &lt;br /&gt;&lt;br /&gt;'How do you find the numbert of rows in a Table ?'&lt;br /&gt;   A bad answer is count them (SELECT COUNT(*) FROM table_name)&lt;br /&gt;&lt;br /&gt;   A good answer is :-&lt;br /&gt;   'By generating SQL to ANALYZE TABLE table_name COUNT STATISTICS     by querying Oracle System Catalogues (e.g. USER_TABLES or ALL_TABLES).&lt;br /&gt;&lt;br /&gt;   The best answer is to refer to the utility which Oracle released which makes it&lt;br /&gt;   unnecessary to do ANALYZE TABLE for each Table individually.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;minvalue.sql&lt;br /&gt;Select the Nth lowest value from a table&lt;br /&gt;&lt;br /&gt;select level, min('col_name') from my_table where level = '&amp;n' connect by prior ('col_name') &lt; 'col_name')&lt;br /&gt;group by level;&lt;br /&gt;&lt;br /&gt; Example:&lt;br /&gt;&lt;br /&gt; Given a table called emp with the following columns:&lt;br /&gt;--   id   number&lt;br /&gt;--   name varchar2(20)&lt;br /&gt;--   sal  number&lt;br /&gt;--&lt;br /&gt;-- For the second lowest salary:&lt;br /&gt;&lt;br /&gt;-- select level, min(sal) from emp&lt;br /&gt;-- where level=2&lt;br /&gt;-- connect by prior sal &lt; sal&lt;br /&gt;-- group by level&lt;br /&gt;&lt;br /&gt;maxvalue.sql&lt;br /&gt;Select the Nth Highest value from a table&lt;br /&gt;&lt;br /&gt;select level, max('col_name') from my_table where level = '&amp;n' connect by prior ('col_name') &gt; 'col_name')&lt;br /&gt;group by level;&lt;br /&gt;&lt;br /&gt; Example:&lt;br /&gt;&lt;br /&gt; Given a table called emp with the following columns:&lt;br /&gt;--   id   number&lt;br /&gt;--   name varchar2(20)&lt;br /&gt;--   sal  number&lt;br /&gt;--&lt;br /&gt;-- For the second highest salary:&lt;br /&gt;&lt;br /&gt;-- select level, max(sal) from emp&lt;br /&gt;-- where level=2&lt;br /&gt;-- connect by prior sal &gt; sal&lt;br /&gt;-- group by level&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4315477689553621092-6793664756966828602?l=sqlqa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlqa.blogspot.com/feeds/6793664756966828602/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4315477689553621092&amp;postID=6793664756966828602' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/6793664756966828602'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/6793664756966828602'/><link rel='alternate' type='text/html' href='http://sqlqa.blogspot.com/2008/01/sql-question-and-answer.html' title='Sql Question and answer'/><author><name>expert</name><uri>http://www.blogger.com/profile/05027544102105084558</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-4315477689553621092.post-4424489609298310761</id><published>2008-01-18T16:31:00.000+05:30</published><updated>2008-01-18T16:32:03.578+05:30</updated><title type='text'>Sql Question and answer 4</title><content type='html'>1. When you use WHERE clause and when you use HAVING clause &lt;br /&gt;&lt;br /&gt;HAVING clause is used when you want to specify a condition for a group function and it&lt;br /&gt;is written after GROUP BY clause &lt;br /&gt;&lt;br /&gt;The WHERE  clause is used when you want to specify a condition for columns, single&lt;br /&gt;row functions except group functions and it is written before GROUP BY clause if it is &lt;br /&gt;used.&lt;br /&gt;&lt;br /&gt;2. Which is more faster - IN or EXISTS&lt;br /&gt;&lt;br /&gt;EXISTS is more faster than IN because EXISTS returns&lt;br /&gt;a Boolean value whereas IN  returns a value.&lt;br /&gt;&lt;br /&gt;3. What is a OUTER JOIN&lt;br /&gt;&lt;br /&gt;Outer Join--Its a join condition used where you can query all the rows of one of the&lt;br /&gt;tables in the join condition even though they don’t satisfy the join condition.&lt;br /&gt;&lt;br /&gt;4. How you will avoid your query from using indexes&lt;br /&gt;&lt;br /&gt;SELECT * FROM emp&lt;br /&gt;Where emp_no+' '=12345;&lt;br /&gt;&lt;br /&gt;i.e you have to concatenate  the column name with&lt;br /&gt;space within codes in the where condition.&lt;br /&gt;&lt;br /&gt;SELECT   /*+ FULL(a)  */  ename, emp_no from emp&lt;br /&gt;where emp_no=1234;&lt;br /&gt;i.e using  HINTS&lt;br /&gt;&lt;br /&gt;5. What is a pseudo column. Give some examples&lt;br /&gt;&lt;br /&gt;It is a column that is not an actual column in the&lt;br /&gt;table.&lt;br /&gt;&lt;br /&gt;eg USER, UID, SYSDATE, ROWNUM, ROWID, NULL, AND LEVEL&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4315477689553621092-4424489609298310761?l=sqlqa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlqa.blogspot.com/feeds/4424489609298310761/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4315477689553621092&amp;postID=4424489609298310761' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/4424489609298310761'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/4424489609298310761'/><link rel='alternate' type='text/html' href='http://sqlqa.blogspot.com/2008/01/sql-question-and-answer-4.html' title='Sql Question and answer 4'/><author><name>expert</name><uri>http://www.blogger.com/profile/05027544102105084558</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-4315477689553621092.post-3132099636535013244</id><published>2008-01-18T16:29:00.000+05:30</published><updated>2008-01-18T16:30:45.019+05:30</updated><title type='text'>Sql Question and answer 3</title><content type='html'>1. What is difference between SQL and SQL*PLUS&lt;br /&gt;&lt;br /&gt;SQL*PLUS is a command line tool where as SQL and PL/SQL language  interface and&lt;br /&gt;reporting tool. Its a command line tool that allows user to type SQL commands to be&lt;br /&gt;executed directly against an Oracle database. SQL is a language used to query the&lt;br /&gt;relational database(DML,DCL,DDL). SQL*PLUS commands are used to format query&lt;br /&gt;result, Set options, Edit SQL commands and PL/SQL.&lt;br /&gt;&lt;br /&gt;2. Which datatype is used for storing graphics and images&lt;br /&gt;&lt;br /&gt;LONG RAW data type is used for storing BLOB's (binary large objects).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. How will you delete duplicating rows from a base table&lt;br /&gt;delete from table_name where rowid not in (select max(rowid) from table group by duplicate_values_field_name); &lt;br /&gt;&lt;br /&gt;or &lt;br /&gt;&lt;br /&gt; delete duplicate_values_field_name dv from table_name ta where rowid &lt;(select min(rowid)  from table_name tb where ta.dv=tb.dv);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. What is difference between SUBSTR and INSTR&lt;br /&gt;     &lt;br /&gt;      SUBSTR returns a specified portion of a string&lt;br /&gt;      eg  SUBSTR('BCDEF',4)       output  BCDE&lt;br /&gt;          INSTR  provides character position in which a pattern&lt;br /&gt;      is found in a string.&lt;br /&gt;&lt;br /&gt;      eg  INSTR('ABC-DC-F','-',2)    output   7 (2nd occurence of '-')&lt;br /&gt;&lt;br /&gt;5. There is a string '120000 12 0 .125' ,how you will find the&lt;br /&gt;         position of the decimal place &lt;br /&gt;  &lt;br /&gt;INSTR('120000 12 0 .125',1,'.')&lt;br /&gt;output   13&lt;br /&gt;&lt;br /&gt;6. There is a '%' sign in one field of a column. What will be&lt;br /&gt;the query to find it. &lt;br /&gt;&lt;br /&gt;'\' Should be used before '%'.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4315477689553621092-3132099636535013244?l=sqlqa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlqa.blogspot.com/feeds/3132099636535013244/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4315477689553621092&amp;postID=3132099636535013244' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/3132099636535013244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/3132099636535013244'/><link rel='alternate' type='text/html' href='http://sqlqa.blogspot.com/2008/01/sql-question-and-answer-3.html' title='Sql Question and answer 3'/><author><name>expert</name><uri>http://www.blogger.com/profile/05027544102105084558</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-4315477689553621092.post-5676172781940797717</id><published>2008-01-18T16:28:00.000+05:30</published><updated>2008-01-18T16:29:45.713+05:30</updated><title type='text'>Sql Question and answer 2</title><content type='html'>1. What are different Oracle database objects&lt;br /&gt;&lt;br /&gt;TABLES&lt;br /&gt;VIEWS&lt;br /&gt;INDEXES&lt;br /&gt;SYNONYMS&lt;br /&gt;SEQUENCES&lt;br /&gt;TABLESPACES etc&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. What is difference between Rename and Alias&lt;br /&gt;&lt;br /&gt;Rename is a permanent name given to a table or column whereas Alias is a temporary&lt;br /&gt;name given to a table or column which do not exist once the  SQL statement is&lt;br /&gt;executed.&lt;br /&gt;&lt;br /&gt;3. What is a view&lt;br /&gt;&lt;br /&gt;A view is stored procedure based on one or more tables, it’s a virtual table.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What are various privileges that a user can grant to another user&lt;br /&gt;&lt;br /&gt;SELECT&lt;br /&gt;CONNECT&lt;br /&gt;RESOURCES&lt;br /&gt;&lt;br /&gt;4. What is difference between UNIQUE and PRIMARY KEY constraints&lt;br /&gt;&lt;br /&gt;A table can have only one PRIMARY KEY whereas there can be any number of UNIQUE keys.&lt;br /&gt;The columns that compose PK are automatically define NOT NULL, whereas a column that compose a UNIQUE is not automatically defined to be mandatory must also specify the column is NOT NULL.&lt;br /&gt;&lt;br /&gt;5. Can a primary key contain more than one columns&lt;br /&gt;&lt;br /&gt;       Yes&lt;br /&gt;&lt;br /&gt;6. How you will avoid duplicating records in a query&lt;br /&gt;&lt;br /&gt;       By using DISTINCT&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4315477689553621092-5676172781940797717?l=sqlqa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlqa.blogspot.com/feeds/5676172781940797717/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4315477689553621092&amp;postID=5676172781940797717' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/5676172781940797717'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/5676172781940797717'/><link rel='alternate' type='text/html' href='http://sqlqa.blogspot.com/2008/01/sql-question-and-answer-2.html' title='Sql Question and answer 2'/><author><name>expert</name><uri>http://www.blogger.com/profile/05027544102105084558</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-4315477689553621092.post-1234935797082826505</id><published>2008-01-18T16:26:00.001+05:30</published><updated>2008-01-18T16:27:03.149+05:30</updated><title type='text'>Sql Question and answer 1</title><content type='html'>1. Difference between group functions and single row functions.&lt;br /&gt;&lt;br /&gt;Group Function     Single Row Function&lt;br /&gt;A group function operates     A single row function&lt;br /&gt;on many rows  returns one and      result for one row.&lt;br /&gt;returns single result.&lt;br /&gt;&lt;br /&gt;Not allowed in Pl/sql procedural                              Allowed in Pl/Sql&lt;br /&gt;                Procedural statements&lt;br /&gt;   statements.&lt;br /&gt;eg SUM(),AVG,MIN,MAX  etc                       eg UPPER,LOWER,CHR...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. Difference between DECODE and TRANSLATE&lt;br /&gt;    &lt;br /&gt;DECODE is value by value                TRANSLATE is character by&lt;br /&gt;character  replacement.                                     replacement.&lt;br /&gt;Ex  SELECT  DECODE('ABC','A',1,'B',2,'ABC',3)   eg      SELECT&lt;br /&gt;from dual; o/p   3      TRANSLATE('ABCGH', &lt;br /&gt;'ABCDEFGHIJ', 1234567899) &lt;br /&gt; FROM DUAL;  o/p  12378&lt;br /&gt;    &lt;br /&gt;(DECODE command is used to bring IF,THEN,ELSE logic to SQL.It tests for the IF values(s) and then aplies THEN value(s) when true, the ELSE value(s) if not.)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;3. Difference between TRUNCATE and DELETE&lt;br /&gt;&lt;br /&gt;TRUNCATE deletes much faster than DELETE&lt;br /&gt;&lt;br /&gt;Truncate       Delete&lt;br /&gt;It is a DDL statement                   It is a DML statement&lt;br /&gt;It is a one way trip,cannot             One  can Rollback&lt;br /&gt;ROLLBACK&lt;br /&gt;Doesn't have selective features (where clause)   Has&lt;br /&gt;Doesn't fire database triggers    Does&lt;br /&gt;It requires disabling of referential   Does not require&lt;br /&gt;constraints.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;4. What is a CO-RELATED SUBQUERY&lt;br /&gt;&lt;br /&gt;A CO-RELATED  SUBQUERY  is one that has a correlation&lt;br /&gt;name as table or view designator in the FROM clause of the outer&lt;br /&gt;query and the same correlation name as a qualifier of a search&lt;br /&gt;condition in the WHERE clause of the subquery.&lt;br /&gt;&lt;br /&gt;eg&lt;br /&gt;     SELECT  field1 from table1 X&lt;br /&gt;     WHERE  field2&gt;(select avg(field2) from table1 Y&lt;br /&gt;                                       where&lt;br /&gt;                                       field1=X.field1);&lt;br /&gt;&lt;br /&gt;                  (The subquery in a correlated subquery is revaluated&lt;br /&gt;for every row of the table or view named in the outer query.)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;5. What are various joins used while writing SUBQUERIES&lt;br /&gt;&lt;br /&gt;Self join-Its a join foreign key of a table references the same table.&lt;br /&gt;&lt;br /&gt;Outer Join--Its a join condition used where One can query all the rows of one of the&lt;br /&gt;tables in the join condition even though they don't satisfy the join condition.&lt;br /&gt;&lt;br /&gt;Equi-join--Its a join condition that retrieves rows from one or more tables in which one&lt;br /&gt;or more columns in one table are equal to one or more columns in the second table.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;6. What are various constraints used in SQL&lt;br /&gt;&lt;br /&gt;NULL&lt;br /&gt;NOT NULL&lt;br /&gt;CHECK&lt;br /&gt;DEFAULT&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4315477689553621092-1234935797082826505?l=sqlqa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlqa.blogspot.com/feeds/1234935797082826505/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4315477689553621092&amp;postID=1234935797082826505' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/1234935797082826505'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/1234935797082826505'/><link rel='alternate' type='text/html' href='http://sqlqa.blogspot.com/2008/01/sql-question-and-answer-1.html' title='Sql Question and answer 1'/><author><name>expert</name><uri>http://www.blogger.com/profile/05027544102105084558</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-4315477689553621092.post-2753744597257877143</id><published>2008-01-18T16:23:00.001+05:30</published><updated>2008-01-18T16:25:55.394+05:30</updated><title type='text'>Discussion About Sql Question And Answers</title><content type='html'>Discussion About Sql Question And Answers&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4315477689553621092-2753744597257877143?l=sqlqa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlqa.blogspot.com/feeds/2753744597257877143/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4315477689553621092&amp;postID=2753744597257877143' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/2753744597257877143'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/2753744597257877143'/><link rel='alternate' type='text/html' href='http://sqlqa.blogspot.com/2008/01/discussion-about-sql-question-and.html' title='Discussion About Sql Question And Answers'/><author><name>expert</name><uri>http://www.blogger.com/profile/05027544102105084558</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-4315477689553621092.post-4286605747886514495</id><published>2008-01-18T16:23:00.000+05:30</published><updated>2008-01-18T16:25:27.699+05:30</updated><title type='text'>Discussion About Sql Tutorials</title><content type='html'>Discussion About Sql Tutorials&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4315477689553621092-4286605747886514495?l=sqlqa.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sqlqa.blogspot.com/feeds/4286605747886514495/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4315477689553621092&amp;postID=4286605747886514495' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/4286605747886514495'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4315477689553621092/posts/default/4286605747886514495'/><link rel='alternate' type='text/html' href='http://sqlqa.blogspot.com/2008/01/discussion-about-sql-tutorials.html' title='Discussion About Sql Tutorials'/><author><name>expert</name><uri>http://www.blogger.com/profile/05027544102105084558</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>
