Vous êtes sur la page 1sur 4

Pl/Sql

What are the types of optimizer? A: Rule-based and Cost-based optimizers Which optimizer mode is the default one? A: Optimizer takes the rule based approach as default. What is explain plan? A:The sequence of steps the optimizer chooses to execute the SELECT, UPDATE, INSERT, DELETE statements. Can you force the optimizer to choose the optimal execution plan? A:Yes. By using hints option. How will you tune the following query? Select empid, ename, dno from emp where dno in(select deptno from dept) A: select empid, ename,dno from emp, dept where dno=deptno Which is faster? Using IN or EXISTS? A: EXISTS is faster compared to IN. What are the types of joins? What are they? A:Simple join, Outer join, Self join Simple join returns the common rows between two or more tables. Outer join returns the matching rows from one, and all the rows from the other table, with the unmatched rows marked as NULL. Self join is joining a table to itself. How will you fetch the first 10 records of a table? A: select * from emp where rownum<11 How many types of SQL statements are there in Oracle? A: DDL - create, alter, drop DML - select, insert, update, delete TCL - commit, savepoint, rollback DCL Grant, Revoke What are cursors? A: A cursor is a handle ( name or a pointer) for the memory associated with a specific statement. A cursor is basically an area allocated by Oracle for executing the SQL Statement. Oracle uses an implicit cursor statement for Single row query and Uses Explicit cursor for a multi row query. What are attributes of cursor? %FOUND , %NOTFOUND , %ISOPEN,%ROWCOUNT How will you identify the duplicates in a particular column? A:Select col1, count(*) from table1 group by col1 having count(*)>1 What are packages? Advantages of packages?

A:Packages Provide a method of encapsulating and storing related procedures, functions, variables and other Package Contents. How many types of parameters can be passed to a stored procedure? A:3 types: IN, OUT, INOUT Difference between Stored procedure and functions A: Function returns a value to the calling block whereas the Stored procedure does not. What are Database Triggers and Stored Procedures A: Database Triggers are Procedures that are automatically executed as a result of insert in, update to, or delete from table. What are partitions? A: Partitions are segments of a logical table split by range of key column values. Syntax of creating a partition Create table A(a varchar(1), b numeric(10)) Partition by range(b) (partition p1 values less than 10, Partition p2 values less than 20, Partition p3 values less than maxvalue) What is ER model? A: It is a conceptual data model that views the real world as entities and relationships. A basic component of the model is the Entity-Relationship diagram which is used to visually represents data objects. How many types of Exceptions are there There are 2 types of exceptions. They are a) System Exceptions e.g. When no_data_found, When too_many_rows b) User Defined Exceptions e.g. My_exception exception When My_exception then How many types of Locks are there? What are they? A: Shared, Share Update, Exclusive You are asked to model a many-many relationship given the students and teachers data. How many tables would you require to implement the same? A: 3 What is the difference between a sub query and a correlated sub query? A: Subquery is a query inside a query, where the sub query gets executed only once. In a correlated sub query, the sub query gets executed once for each row processed by the parent query.

What are the two types of synonyms? What is the difference between the two? A: Private and Public. Private synonyms are created by the database user and is available only to the user, where as public synonym is created by the database administrator and is available to all users. How many types of Exceptions are there? What are they? A: There are 2 types of exceptions. They are a) System Exceptions e.g. When no_data_found, When too_many_rows b) User Defined Exceptions e.g. My_exception exception Can you execute DDL statements inside a PL/SQL block? How? A: Yes. By using 'execute immediate' clause. What are embedded SQLs? A: Sql Statements embedded in a high level language such as 'C' are called embedded sqls. Table Emp has 3 records: A B C Sequence of 4 sql stmts are executed: Delete emp where val='A' Alter table emp modify(val varchar2(5)) Delete emp where val='B' Rollback What is the status of the table emp? A: Table emp has 2 records B & C. What are mutating tables? A: Mutating table is a table that is currently being modified by insert update or delete statement causing a trigger to fire that again tries to modify the same table What is the difference between deleting and truncating of tables A: Deleting a table will remove the rows from the table but space consumed by these rows is not released. But truncating a table deletes it completely and release the space consumed by it too. Name a few pseudocolumns. A: NEXTVAL, CURRVAL, ROWNUM etc.. What is 'on delete cascade' option? A: When a key value is deleted, if you want to also delete the references of the key, go for on delete cascade option.

How many columns can table have? A: The number of columns in a table can range from 1 to 254. What is tnsnames.ora? A tnsnames.ora file provides the ability to reference oracle databases by a simple alias. How do you generate statistics of a particular table involved in a query? A: Analyze table compute statistics What are PL/SQL tables? A: PL/SQL tables are not stored in the database, and is usually created inside a PL/SQL block with only one column. What is Oracle SID? Where do you set that? A: If Oracle is used in a UNIX server, then Oracle SID is set in the .profile file. It denotes the database. How do u implement the If statement in the Select Statement? A: Using DECODE How can you fetch the uncommon rows from the result set of 2 queries? A: Using MINUS operator What is the difference between to_char() & to_number() function/ A: To_char converts a number or date to a char. To_number converts a char or varchar to a number.