• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
Common Questions in Oracle
-----------------------------------------------
NOT NECESSARYIMPORTANT1. Difference between procedure, function & package.Procedure:
It is a type of subprogram that performs an action.It can be stored in the database, as a schema object, for repeated execution.Execute as a PL/SQL statementDo not contain RETURN clause in the headerCan return none, one, or many valuesCan contain a RETURN statement
Functions:
 It is a named PL/SQL block that returns a value.It can be stored in the database as a schema object for repeated execution.Invoke as part of an expressionMust contain a RETURN clause in the headerMust return a single valueMust contain at least one
Package:
It is a database object that groups logically related PL/SQL types, objects, and subprograms.Packages usually have two parts, a specification and a body, but body is optional.The specification is the interface to the applicationsIt declares the types, variables, constants, exceptions, cursors, and subprograms available for use.The body fully defines cursors and subprograms, and so implements the specification.
Advantages:
Packages offer several advantages:
Modularity:
Each package is easy to understand, and the interfaces between packages are simple,clear, and well defined. This aids application development.
Easier application design:
When designing an application, all we need initially is the interfaceinformation in the package specifications. We can code and compile a specification without itsbody. Once the specification has been compiled, stored subprograms that reference the packagecan be compiled as well. We need not define the package bodies fully until you are ready tocomplete the application.
Information hiding:
With packages, you can specify which types, objects, and subprograms arepublic (visible and accessible) or private (hidden and inaccessible). For example, if a packagecontains four subprograms, three might be public and one private. The package hides thedefinition of the private subprogram so that only the package (not your application) is affected if the definition changes. This simplifies maintenance and enhancement. Also, by hidingimplementation details from users, you protect the integrity of the package.
Added functionality:
Packaged public variables and cursors persist for the duration of a session.So, they can be shared by all subprograms that execute in the environment. Also, they allow youto maintain data across transactions without having to store it in the database.
Better performance:
When you call a packaged subprogram for the first time, the whole packageis loaded into memory. Therefore, subsequent calls to related subprograms in the package requireno disk I/O.
 
In addition, packages stop cascading dependencies and so avoid unnecessary recompiling. Forexample, if you change the definition of a standalone function, Oracle must recompile all storedsubprograms that call the function. However, if you change the definition of a packaged function,Oracle need not recompile the calling subprograms because they do not depend on the packagebody.
2. How 2 migrate a Oracle Db from one version to another?
There are several ways:1) Use the Database Migrations Assistant (DBMA).2) Export the data from the old system, then import it into the new system.3) Copy the data across over database links.4) Copy the data over using the SQL*Plus COPY command.5) Output all the data to flat files and load it into the new system using SQL*Loader.
3. Maximum no of cols allowed in a table in 9i.
1000
4. How could you restrict the use of a function in a SQL? What is purity level?
Functions called from SQL expressions cannot contain DML statements.Functions called from UPDATE/DELETE statements on a table, cannot contain DML on the same table.Functions called from an UPDATE or a DELETE statement on a table cannot query the same table.Functions called from SQL statements cannot contain statements that end the transactions.Calls to subprograms that break the previous restriction are not allowed in the function.The function purity level defines what structures the function reads or modifies.Following are the purity levelsWNDS - Writes No Database State i.e. Function does not modify any database tables (No DML)RNDS - Reads No Database State i.e. Function does not read any tables (No select)WNPS - Writes No Package State i.e. Function does not modify any packaged variables (packagedvariables are variables declared in a package specification)RNPS - Reads No Package State i.e. Function does not read any packaged variables
5. What is referential integrity? When inserting, where will you insert first- child or parent?
Referential integrity is a database concept that ensures that relationships between tables remain consistent.When one table has a foreign key to another table, the concept of referential integrity states that you maynot add a record to the table that contains the foreign key unless there is a corresponding record in thelinked table.It also includes the techniques known as cascading update and cascading delete, which ensure that changesmade to the linked table, are reflected in the primary table.While inserting, we should insert into the parent table first.
6. What is a Null statement in Oracle?
The NULL statement is a no-op: it passes control to the next statement without doing anything.In the body of an IF-THEN clause, a loop, or a procedure, the NULL statement serves as a placeholder.
 
7. What is the difference between Union & Union All?UNION:Combine the unique rows returned by 2 SELECT statements.The number of columns and the data types of the columns being selected must be identical in all theSELECT statements used in the query. The names of the columns need not be identical.UNION operates over all of the columns being selected.NULL values are not ignored during duplicate checking.The IN operator has a higher precedence than the UNION operator.By default, the output is sorted in ascending order of the first column of the SELECT clause.UNION ALL:Combine the rows returned by 2 SELECT statements (including all duplicates)Unlike UNION, duplicate rows are not eliminated and the output is not sorted by default.The DISTINCT keyword cannot be used.
8. What is explicit and implicit commit?Explicit Commit:
Occurs by executing COMMIT;
Implicit Commit:
Occurs when DDL command is executed or user properly exits system.9. What is Normalization? Explain with an example the diff stages.Normalization is a design technique that is widely used as a guide in designing relational databases.Normalization is essentially a two-step process that puts data into tabular form by removing repeatinggroups and then removes duplicated data from the relational tables. Normalization theory is based on theconcepts of normal forms. A relational table is said to be a particular normal form if it satisfied a certain setof constraints.First Normal Form: A relational table, by definition, is in first normal form. All values of the columns areatomic. That is, they contain no repeating values.Although the table FIRST is in 1NF it contains redundant data. For example, information about the
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...