• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Ora faq

Ora faq






Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds



Upload Details

Uploaded via as Microsoft Word

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Ora faq Ora faq Document Transcript

    • ORACLE------------------------------------------------------------------------------------------------------------ 1) What is Data or Information? The matter what we feed into the computer is called Data or Information. 2) What is database? The collection of interrelated data is called Database. 3) What is Oracle? Oracle is RDBMS package. 4) Communication channel between backend and front end? SQL*NET 5) Difference between Truncate and Delete? 6) Truncate commits after deleting entire table. i.e.; it can not be rolled back. Database triggers do not fire on truncate. 7) Delete allows the filtered deletion. Deleted records can be rolled back or committed. Data base triggers fire on delete. 8) What is difference between Alias and Synonym? 9) Alias is temporary and used with one query. Synonym is permanent and not used as alias. 10) What is difference between Rename and Alias? 11) Rename is permanent name given to a table or column where as 12) Alias is a temporary name given to a table or column which does not exist once the sol statement is executed. 13) What are the Special operators? 14) In (Picks required values from list of values). 15) Like (Character comparition). 16) Between (Provide range specification). 17) Is (Reffer Null values).
    • 18) What are Pseudo columns? 19) Pseudo columns are system defined columns behaves like a table columns. We can not insert, update or delete their values. Ex: currval, nextval, level, rowid, rownum, new, old, sysdate.20) What is Rownum? Represents the records number for displayed data, which is temporary.21) What is Rowid? 22) Represents uniqueness of records given by system, which are permanent. 23) Rowid holds the information in hexadecimal which consists of file id, block id, field id, record id.24) What is the fastest way of accessing a row in a table? 25) Rowid and Constraints.26) Difference between Translate and Replace? 27) This function used to translate the string character by character. Need to pass equal no of characters. Translate(S, C1, C2). 28) This function used to replace the string by string comparition. C1, C2 lengeths may or may not equal. Replace(S, C1, C2).29) Difference between Substr ( ) and Instr( )? 30) Substr ( ) will return the specific part of a string, where as Instr( ) returns the position of the specific part of the string31) Which is an effective command – Truncate or Delete? 32) Delete is the effective command. Because using this command we can delete only these records that are not really required.33) Difference between Count ( ) and count(*) ? 34) Count ( ) is count with column ignore null values. 35) But Count (*) is not ignore null values.36) What is NVL ( ) function? 37) It is a general function.
    • 38) It represents null values with specified value.39) Difference between Min ( ) and Least ( )? 40) Min ( ) is an aggregate function which takes only one column of a table as parameter where as 41) Least ( ) is a general function which can take any no of values and column names from dual and table respectively.42) Difference between Update and Alter? 43) Alter command is used to modify the database objects where as 44) The Update command is used to modify the values of a database object.45) What is the last clause and first clause in select statement? 46) Last clause: Order by 47) First clause: Where clause48) Difference between Group functions and Single row functions? 49) Group function operates on many rows returns one and returns single result. A group function will not allow in PL/SQL procedural. Ex. Sum ( ), Avg ( ). 50) Single row function result for one row. Allowed in PL/SQL procedural statements. Ex. Upper ( ), Lower ( ).51) Where clause: Used to provide required conditions on records while manipulating or retrieving records.52) Group by clause: Used to group data based on columns given in group by clause.53) Having clause: Used to provide group functions in conditions.54) Order by clause: Used to arrange data either in ascending or descending order.JOINS55) What is a join? Explain the different types of joins? Join is a query which retrieves related columns or rows from multiple tables. Equi join:: Joing two tables by equating two common columns. Non equi join:: Join two tables without common columns. Self join:: Joining the table with itself. Outer join::
    • 56) What are the minimum requirements for an Equi join? There should be atleast one common column between the joining data.57) Which is most faster – IN or EXISTS ? EXISTS is more faster than IN. Because EXISTS returns a boolean value where as IN returns a value.58) Difference between Union and Join ? Union is used to combine the o/p of select statements in one table. And must and should have same no of columns and similer datatypes in given select statements. Join is used to combine the more than one table. There is no required of same no of columns.59) What is Defficient table? In outer join which table has ‘+’ symbol that is defficient table.60) Difference between Left outer join and Right outer join? In Left outer join retrieves the all records of left side table. But only matching recors from right side table. Where as right outer join is opp to left outer join.61) How do you implement the IF statement in select statement ? By using the Decode statement.62) What is a Transaction? A Transaction is a set of SQL statements between commit and rollback.SUB QUERIES63) What is a Query? Query is a single line request for the information from the database.64) What are the Set operators? Set operators are combine the results of 2 queries into one result. ( Union, Intersect, Minus, Union all ).
    • 65) What we need, when we are using Set operators? Queries should contain the same no of columns along with data type matching.66) What is Subquery? Subquery is a query whose return values are used in filtering conditions of the main query.67) What is Correlated sub-query? Correlated sub-query is a sub-query which has reference to the main query.68) Difference between Simple sub-query and Correlated sub-query? In Simple sub-query first the inner query executed and its value is given as condition to outer query , which gets executed later. Correlated sub-query is opp to Simple sub-query.69) What are the Special operators in Sub Queries? Any / Some – Picks lowest value. All – Picks highest value. Exists – Returns True or False.CONSTRAINTS70) What are the Integrity Constraints? An Integrity constraint is a declarative way to define a business rule for a column of a table.71) What is Self-referential integrity constraint? If a foreign key reference a parent key of the same table is called Self_reference integrity constraint.72) What is a Composite primary key? A primary key created on combination of columns is called a Composite primary key. ( Max 32 columns are candidate keys can be allowed in composite primary key.73) What is a Candidate column?
    • It is a part of Composite primary key.74) What is Null? Is it constraint or default value? Default value.75) What is default value for every column of a table ? Null.76) What are limitations of CHECK constraint? In this we can not specify the pseudo columns like sysdate, rownum etc.77) What is ‘On delete cascade’? If this key word is included in the definition of a child table, whenever the records from the parent table is deleted then automatically deleted the respective values in the child table.78) How to drop parent table when it have child tables? Using with ‘cascade constraints’. Ex: Drop table <table name> cascade constraints;50. How can you cut the relation ship between parent and child table (or) How can you drop the primary key from parent table? Alter table <table name> drop constraint <const-name> cascade;79) In which order constraints are fired? Not null, Check, Primary key, Unique, Foreign key.80) Can Check constraint be used for self referential integrity? How? Yes. In Check condition for a column of a table, we can reference some other column of the same table and thus enforce self referential integrity.81) Difference between Unique and Primary key? Unique key can accept null values but Primary key can not accept null values.82) Difference between Foreign key and Reference key? Foreign key is the key. i.e; attribute which refers to another table primary key.
    • Reference key is the primary key of table reffered by another table. 83) How to add a primary key constraint to an existed table? Alter table <parent table> add constraint <constraint name>; 84) How to add a Foreign key to an existed table? Alter table <parent table> add constraint foreign key <constraint name> references < VIEWS 57. What is a View? View is virtual table. View exists logically but contains no physical data and manipulates the base table. Every view has a query attached to it. 58. Advantages of Views? View provides high security to base table while sharing. Using views we can write complicated queries into simple queries. To protect some of the columns of a table from other user.59. Which database objects are called Stored Queries? --- Views.60. Do view contain data? --- No.61. Can a trigger written for a view? --- No.62. Can you alter Synonym of view or view? --- No.63. Can you create Index on View? --- No.64. Difference between Simple view and Complex view? Simple view can be created on a table where as Complex view can be created on more than one table. Simple view can be modified where as Complex view can not be modified.65.What is an Inline view? An Inline view is just a subquery in place of a table in an insert, update, delete or select.66. How to update a Complex view? -- Using with Instead of Triggers.
    • 67. Difference between View and Force view? View created on existing table where as Force view created on without an exitsting table.68. Difference between View and Materialized view? View Materialized view 1.Data will store logically. 1.Data will be stored physically. 2.It occupies less memory. 2.Occupies huge space. 3.With user interaction it can refresh at 3.It can refresh without user the time of calling. interaction based on time interval. 4.It reduce performance at the time of 4.It improves the performance at the reports. time of reprots. 5.There is a possibility for duplicate rows. 5.We can avoid duplicate rows by assigning primary key at the time of creation.69. Non-key preserved column --- The common column used in a complex view having primary key is called as Non-key preserved column.70. Minimum requirements for creating Materialized view?-- Primary key on column of a table.SYNONYMS71. What is Synonym? A Synonym is an alias name for a table, view, sequence or program units.72. Difference between Private sysnonym and Public sysnonym? Private sysnonym can be accessed only by the owner where as Public synonym can be accessed by any user on the database.73. Advantages of Synonym-- Mask the real name and owner of an object. Provide public access to an object. Provide location transparency for tables, views or program units of a remote database. 74. Difference between View and Synonym? Synonym is just a second name of a table used for multiple link of database. View can be created with many tables and with virtual columns and with conditions.
    • SEQUENCE75. What is a Sequence? A Sequence generates a serial list of unique numbers for numarical columns of a database table.76. In Oracle database which object is operated with Pseudo columns? Sequence. ( Nextval, Currval ). Initially Sequence has to be operated with Nextval. In Sequence start value should be greater than Min value.77. Consider a Sequence whose currval is 1 and gets incremented by 1 by using the nextval the nextval reference we get the nextvalue 2. Suppose at this point we issue an rollback and again issue a nextval. What will the output be? --- 3.INDEX78. What is an Index? Index is a pointer locates the physical address of column.It provide quick access to rows in a table. These gets activated only when the indexed columns are used in where clause condition. It increases the performance of server79. How can u find out what columns have what indexs of a perticular Table? Select * from user_ind_columns where table_name=EMP;80. How to bypass(fire) the index in select statement for number datatype column and char datatype column? select * from fana where empno+0 = 7876; (number column) select * from fana where job||’’ = ’CLERK’; (character column)80. Types of Indexes? 1.Normal Index : Applied on single column. 2.Composite Index : Applied on more than one column Ex : Create index ind3 on emp(deptno, comm); 3.Functional Index : Applied on columns which are having functions. 4.Partitioning Index :These are 2 types a) Local Index b) Global Index
    • a : Applied on individual parts. b : Applied on all parts at a time.81. What is Cluster ? It is group of one or more tables physically stores together to share common columns & are often used together.82. What is Cluster Key? The related column of the tables in a cluster is called Cluster Key. Cluster Index applied on more than one table. Advantages of Clusters : 1) access time reduced for joins. Disadvantages : 1) The time for insert increases.LOCKS :83. What r the locks? Locks r used to avoid disturbances among different users how r sharing the data.84. Types of locks ? 1. Row level lock : Lock perticular columns & Records. EX : select * from emp where deptno= 10 for update; select * from emp for update of sal; 2.Table level lock : Lock entaire table. Syntax : Lock table tablename in (mode); Ex : lock table emp in exclusive mode; There r 3 types of table level locks : 85) Share mode:: If a user applies a lock, other user cannot be perform transactions. But he also can apply this lock. 2) Share update mode::If a user applies a lock, other user can perform transactions on other rows which r not used by first user. Other user can also apply this lock. 3) Exclusive mode::If a user applies a lock, other user cannot perform transactions and also cannot apply any lock.85. What is Snapshot ? These r read only copies of a master table located on a remote node which is periodically refreshed to reflect changes made to the master table.86. Difference b/t Round & Trunc ?
    • Round : Gives nearest whole number Trunc : It gives only whole number. 87. Explain Connect by prior? Sol : Retrives rows in hirerchal order. 88. What is Dead lock ? Two processes waiting to update the rows of a table which r locked by the other process then dead lock arises. 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 perfomance of server will reduce drastically. These locks will be realesed automatically when a commit/rollback operation performed or any one of this processes being killed externally. PL/SQL 1. What is PL/SQL? PL/SQL is a procedural language that has both interactive and procedural programing language constructs such as iteration, conditional branching. 2. What is PLSQL block? A set of related declarations and procedural statements is called block. 3. How many types of PLSQL blocks? Anonymous block and Named block. 4. Difference between Anonymous and Named blocks? Anonymous blocks are no reusability and stored in Operating system where as Named blocks are stored in database. Reusability is possible.5. What is DBMS_OUTPUT.PUT_LINE( ) ? It is a built in packaged procedure. Here DBMS_OUTPUT is a package andPUT_LINE is a procedure. This is used to display required messages on screen.
    • 6. What is SET SERVEROUTPUT ON? Used to active the DBMS_OUTPUT.PUT_LINE( ).7. What are Stored procedures? Named blocks are also called Stored procedures.There are 4 types. 1.Procedures 2.Functions 3. Packages 4. Triggers.8. What are Sub programs? --- 1.Procedures 2. Functions.9. Datatypes in PLSQL --- Scalar datatypes & Composite datatypes. Scalar datatypes : All SQL datatypes. Composite datatypes : %type, %rowtype, Record type, Table type, Objects, Varrays,Nested tables.. Record type, Table type are user defined temporary datatypes. Objects, varrays, nested tables are user defined permanent datatypes.10. What are %Type and %Rowtype? %Type is a column type declaration supports to declare a variable according tocolumn structure. Ex: variablename tablename.columnname%type; %Rowtype is a table type declaration supports to declare a variable according to tablestructure. Ex: variablename tablename%rowtype;11. Advantages of %Rowtype? When, we need variables for all columns of a table, no need to declare those many%Type variables what can be done by using a variable of %Rowtype.12. Difference between %Rowtype and Record type? %Rowtype is used whenever query returns a entire row of a table or view. where asRecord type is used whenever query returns columns of different tables or views and variables.13. What is default value for a numaric PL/SQL variables? --- NULL.14. Smallest PLSQL programe in Oracle? BEGIN NULL; END;
    • 15. What is a PLSQL Engine? This PLSQL Engine accepts any valid PLSQL block as input, executes the proceduralpart of the statements and sends the SQL statements to the SQL statement executor in the Oracle server.16. Difference between Simple loop and For loop? Simple loop requires declaration of variables used in it and exit condition. But Forloop does not require this.CURSORS17. What is Cursor? why cursor is required? Cursor is a named private SQL area in PLSQL. It is a pointer pointing to data , whichcan be used to manipulate more than 1 row at a time.18. How many types of Cursors are supported by Oracle? --- Implicit cursor,Explicit cursor.19. What are the PLSQL statements used in cursor processing? Declare cursor, Open cursor, Fetch cursor, Exit cursor, Close cursor.20. Difference between Implicit cursor, Explicit cursor? Explicit cursors are user defined cursors.where as Implicit cursors are created bysystem and no need of cursor operations.(declare cursor, open cursor....).21. What is a Cursor For loop? Cursor for loop is shortcut process for explicit cursors, because the cursor is open,rows are fetched and cursor is closed automatically when all the rows have been processed.22. What are Cursor attributes? %Found, %Not found, %Is open, %Rowcount.23. Is TCL commands are allowed in loops? No. Because rollback, commit are used when the transaction is completed.24. What is the use of cursor with "FOR UPDATE OF" clause?
    • This clause stop accessing of other users on the particular columns used by the cursoruntill the commit is issued.25. What is the use of " WHERE CURRENT OF " clause ?WHERE CURRENT OF clause is used with FOR UPDATE clause to point the cursor& do changes in that location only.26 . What should be the return type for a cursor variable? The return type for a cursor must be a record type. it can be declared explicitly as a userdefined or %rowtype can be used27 . Can cursor variables are stored in pl/sql tables. if yes how? No. A cursor variable points a row which cannot be stored in a two_diamentional pl/sqltable.28. Cursor parameter Cursor can accept arguments dynamically while opening it . Max 32 parameters canbe passed to a cursor.EXCEPTIONS29 . What is an Exceptions? How it is differ from error?Exceptions are used to handled errors at run time. whenever an error occurs exceptionraises.Error is a bug where as the exception is a warning or error condition30 . Types of errors? 2types of errors 1)errors at compile time(errors) Ex : Syntax error 2) errors at run time (exceptions) Ex : logical error(due to improper i/p by end user)31 . Types of exceptions? 1) user defined exceptions 2) predefined exceptions32. Difference b/t user defined & predefined exceptions? predefined exceptions gets activated automatically whenever logical error occurs
    • User defined exceptions have to be raised explicitly when ever required by programmer.33. Name some built in exceptions ? Two_many_rows, No_data_found, Zero_divide, not_logged_on, storage_error,value_error, etc--34. Predefined SQL code range:-- -1 to -2000035 . Non predefind exception ? Used to handle constraint validation errors in pl/sql block by using PRAGMAEXCEPTION_ INIT( ).PRAGMA EXCEPTION_ INIT( ) : takes 2 parameters as user exception name & sqlcode.For Non null constraint ---> -1400For Check Constraint ---> -2290For foreign key Constraint ---> -2291For Pk Constraint ---> 0001Child record found --> -229236. What is OTHERS exception?It is used to along with 1 or more exceptions handlers. This will handle all the errors notalready handled in the block.1. What is bulk collect?Bulk collect is part of PLSQL collection where data is stored/ poped up into a variable.Example:declareType sal_rec is table of number;
    • v_sal sal_rec;BeginSelect sal bulk collect into v_sal from EMP;For r in 1.. v_sal.count loopdbms_output.put_line (v_sal(r));End loop;End;What is PRAGMA EXECPTION_INIT?Ans: The PRAGMA EXECPTION_INIT tells the complier to associate an exceptionwith an oracle error. To get an error message of a specific oracle error.E.g. PRAGMA EXCEPTION_INIT (exception name, oracle error number)What is raise application error?Raise_application_error is a procedure of package DBMS_STANDARD which allowsissuing a user defined error messages from stored sub-program or database trigger.What is stored procedure?Stored procedures are subprogram’s stored in the database and can be called &executemultiple times wherein an application procedure is the one being used for a particularapplication same is the way for function.Both can be executed any number of times. Only difference is that stored procedures/functions are stored in database in complied format while the applicationprocedures/functions are not in precompiled format and at run time has to be compiled.What is WHERE CURRENT OF clause?WHERE CURRENT OF clause in an UPDATE, DELETE statement refers to the latestrow fetched from a cursor. Database TriggersWhat is pl/sql table?Objects of type TABLE are called "PL/SQL tables", which are modeled as (but not thesame as) database tables, PL/SQL tables use a primary PL/SQL tables can have onecolumn and a primary key.Cursors