Sunday, November 16, 2014

Oracle Concepts and Architecture Interview Questions and Answers



Interview questions and answers for Oracle Concepts and Architecture  Interview Questions and Answers
Oracle Concepts and Architecture Interview Questions and Answers includes, Physical database, structure of Oracle Database, components of Logical database, Tablespace, SYSTEM tablespace, relationship among Database, schema, Schema Objects, Table, View, Sequence, Synonym, Private Synonyms, Public Synonyms, Index, Indexes Update, Clusters, cluster Key, Index Cluster. Synonyms, Cluster

What are the components of Physical database structure of Oracle Database?
    ORACLE database is comprised of three types of files. One or more Data files, two are more Redo Log files, and one or more Control files.

2.     What are the components of Logical database structure of ORACLE database?
    Tablespaces and the Database's Schema Objects.

3.     What is a Tablespace?
    A database is divided into Logical Storage Unit called tablespaces. A tablespace is used to grouped related logical structures together.

4.     What is SYSTEM tablespace and When is it Created?
    Every ORACLE database contains a tablespace named SYSTEM, which is automatically created when the database is created. The SYSTEM tablespace always contains the data dictionary tables for the entire database.

5.     Explain the relationship among Database, Tablespace and Data file.
    Each databases logically divided into one or more tablespaces One or more data files are explicitly created for each tablespace.

6.     What is schema?
    A schema is collection of database objects of a User.

7.     What are Schema Objects ?
    Schema objects are the logical structures that directly refer to the database's data. Schema objects include tables,views,sequences,synonyms, indexes, clusters, database triggers, procedures, functions packages and database links.

8.     Can objects of the same Schema reside in different tablespaces.?
    Yes.

9.     Can a Tablespace hold objects from different Schemes ?
    Yes.

10.     what is Table ?
      A table is the basic unit of data storage in an ORACLE database. The tables of a database hold all of the user accessible data. Table data is stored in rows and columns.

11.     What is a View ?
      A view is a virtual table. Every view has a Query attached to it. (The Query is a SELECT statement that identifies the columns and rows of the table(s) the view uses.)

12.     Do View contain Data ?
      Views do not contain or store data.

13.     Can a View based on another View ?
    Yes.

14.     What are the advantages of Views ?
      •Provide an additional level of table security, by restricting access to a predetermined set of rows and columns of a table.
•Hide data complexity.
•Simplify commands for the user.
•Present the data in a different perpecetive from that of the base table.
•Store complex queries.
15.     What is a Sequence ?
    A sequence generates a serial list of unique numbers for numerical columns of a database's tables.

16.     What is a Synonym ?
    A synonym is an alias for a table, view,sequence or program unit.

17.     What are the type of Synonyms ?
    There are two types of Synonyms Private and Public.

18.     What is a Private Synonyms ?
    A Private Synonyms can be accessed only by the owner.

19.     What is a Public Synonyms ?
      A Public synonyms can be accessed by any user on the database.

20.     What are synonyms used for ?
    Synonyms are used to : 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.
Simplify the SQL statements for database users.

21.     What is an Index ?
    An Index is an optional structure associated with a table to have direct access to rows,which can be created to increase the performance of data retrieval. Index can be created on one or more columns of a table.

22.     How are Indexes Update ?
    Indexes are automatically maintained and used by ORACLE. Changes to table data are automatically incorporated into all relevant indexes.

23.     What are Clusters ?
      Clusters are groups of one or more tables physically stores together to share common columns and are often used together.

24.     What is cluster Key ?
      The related columns of the tables in a cluster is called the Cluster Key.

25.     What is Index Cluster ?
    A Cluster with an index on the Cluster Key.

26.     What is Hash Cluster ?
    A row is stored in a hash cluster based on the result of applying a hash function to the row's cluster key value. All rows with the same hash key value are stores together on disk.

27.     When can Hash Cluster used ?
    Hash clusters are better choice when a table is often queried with equality queries. For such queries the specified cluster key value is hashed. The resulting hash key value points directly to the area on disk that stores the specified rows.

28.     What is Database Link ?
    A database link is a named object that describes a "path" from one database to another.

29.     What are the types of Database Links?
    Private Database Link, Public Database Link & Network Database Link.

30.     What is Private Database Link?
    Private database link is created on behalf of a specific user. A private database link can be used only when the owner of the link specifies a global object name in a SQL statement or in the definition of the owner's views or procedures.

31.     What is Public Database Link?
    Public database link is created for the special user group PUBLIC. A public database link can be used when any user in the associated database specifies a global object name in a SQL statement or object definition.

32.     What is Network Database link?
    Network database link is created and managed by a network domain service. A network database link can be used when any user of any database in the network specifies a global object name in a SQL statement or object definition.

33.     What is Data Block?
    ORACLE database's data is stored in data blocks. One data block corresponds to a specific number of bytes of physical database space on disk.

34.     How to define Data Block size?
    A data block size is specified for each ORACLE database when the database is created. A database users and allocated free database space in ORACLE datablocks. Block size is specified in INIT.ORA file and cann't be changed latter.

35.     What is Row Chaining?
    In Circumstances, all of the data for a row in a table may not be able to fit in the same data block. When this occurs, the data for the row is stored in a chain of data block (one or more) reserved for that segment.

36.     What is an Extent?
    An Extent is a specific number of contiguous data blocks, obtained in a single allocation, used to store a specific type of information.

37.     What is a Segment?
    A segment is a set of extents allocated for a certain logical structure.

38.     What are the different types of Segments?
    Data Segment, Index Segment, Rollback Segment and Temporary Segment.

39.     What is a Data Segment?
    Each Non-clustered table has a data segment. All of the table's data is stored in the extents of its data segment. Each cluster has a data segment. The data of every table in the cluster is stored in the cluster's data segment.

40.     What is an Index Segment?
    Each Index has an Index segment that stores all of its data.

41.     What is Rollback Segment?
    A Database contains one or more Rollback Segments to temporarily store "undo" information.

42.     What are the uses of Rollback Segment?
    Rollback Segments are used:
To generate read-consistent database information during database recovery to rollback uncommitted transactions for users.

43.     What is a Temporary Segment?
    Temporary segments are created by ORACLE when a SQL statement needs a temporary work area to complete execution. When the statement finishes execution, the temporary segment extents are released to the system for future use.

44.     What is a Data File?
    Every ORACLE database has one or more physical data files. A database's data files contain all the database data. The data of logical database structures such as tables and indexes is physically stored in the data files allocated for a database.

45.     What are the Characteristics of Data Files?
    A data file can be associated with only one database.Once created a data file can't change size.
One or more data files form a logical unit of database storage called a tablespace.

46.     What is a Redo Log?
    The set of Redo Log files for a database is collectively known as the database's redo log.

47.     What is the function of Redo Log?
    The Primary function of the redo log is to record all changes made to data.

48.     What is the use of Redo Log Information?
    The Information in a redo log file is used only to recover the database from a system or media failure the prevents database data from being written to a database's data files.

49.     What does a Control file Contain?
    A Control file records the physical structure of the database. It contains the following information.
•Database Name
•Names and locations of a database's files and redolog files.
•Time stamp of database creation.

50.     What is the use of Control File?
    When an instance of an ORACLE database is started, its control file is used to identify the database and redo log files that must be opened for database operation to proceed. It is also used in database recovery.

51.     What is a Data Dictionary?
    The data dictionary of an ORACLE database is a set of tables and views that are used as a read-only reference about the database.
It stores information about both the logical and physical structure of the database, the valid users of an ORACLE database, integrity constraints defined for tables in the database and space allocated for a schema object and how much of it is being used.

52.     What is an Integrity Constrains?
    An integrity constraint is a declarative way to define a business rule for a column of a table.

53.     Can an Integrity Constraint be enforced on a table if some existing table data does not satisfy the constraint?
    No.

54.     Describe the different type of Integrity Constraints supported by ORACLE?
    •NOT NULL Constraint - Disallows NULLs in a table's column.
•UNIQUE Constraint - Disallows duplicate values in a column or set of columns.
•PRIMARY KEY Constraint - Disallows duplicate values and NULLs in a column or set of columns.
•FOREIGN KEY Constrain - Require each value in a column or set of columns match a value in a related table's UNIQUE or PRIMARY KEY.
•CHECK Constraint - Disallows values that do not satisfy the logical expression of the constraint.

55.     What is difference between UNIQUE constraint and PRIMARY KEY constraint?
    A column defined as UNIQUE can contain NULLs while a column defined as PRIMARY KEY can't contain Nulls.

56.     Describe Referential Integrity?
    A rule defined on a column (or set of columns) in one table that allows the insert or update of a row only if the value for the column or set of columns (the dependent value) matches a value in a column of a related table (the referenced value). It also specifies the type of data manipulation allowed on referenced data and the action to be performed on dependent data as a result of any action on referenced data.

57.     What are the Referential actions supported by FOREIGN KEY integrity constraint?
    UPDATE and DELETE Restrict - A referential integrity rule that disallows the update or deletion of referenced data.

DELETE Cascade - When a referenced row is deleted all associated dependent rows are deleted.

58.     What is self-referential integrity constraint?
    If a foreign key reference a parent key of the same table is called self-referential integrity constraint.

59.     What are the Limitations of a CHECK Constraint?
    The condition must be a Boolean expression evaluated using the values in the row being inserted or updated and can't contain subqueries, sequence, the SYSDATE,UID,USER or USERENV SQL functions, or the pseudocolumns LEVEL or ROWNUM.

60.     What is the maximum number of CHECK constraints that can be defined on a column?
    No Limit.

Oracle Reports Interview Questions and Answers



Interview questions and answers for Oracle Reports  Interview Questions and Answers
Oracle Reports Interview Questions and Answers includes, different file extensions that are created by oracle reports, designation, lexical reference, bind reference, use of command line parameter cmd file, external pl/sql library executed, default parameter, read level consistency, term, link property sheet, place holder column, hidden column, break group, anchors, matrix object, layout editor of the report writer, term panel, anchoring object, frame & repeating frame.

What are the different file extensions that are created by oracle reports?
    Rep file and Rdf file.

2.     From which designation is it preferred to send the output to the printed?
    Previewer.

3.     Is it possible to disable the parameter from while running the report?
    Yes

4.     What is lexical reference?How can it be created?
    Lexical reference is place_holder for text that can be embedded in a sql statements.A lexical reference can be created using & before the column or parameter name.

5.     What is bind reference and how can it carate?
    Bind reference are used to replace the single value in sql,pl/sql statements a bind reference can be careated using a (:) before a column or a parameter name.

6.     What use of command line parameter cmd file?
    It is a command line argument that allows you to specify a file that contain a set of arguments for r20run.

7.     Where is a procedure return in an external pl/sql library executed at the client or at the server?
    At the client.

8.     Where is the external query executed at the client or the server?
    At the server.

9.     What are the default parameter that appear at run time in the parameter screen?
    Destype and Desname.

10.     Which parameter can be used to set read level consistency across multiple queries?
    Read only.

11.     What is term?
      The term is terminal definition file that describes the terminal form which you are using r20run.

12.     What is use of term?
      The term file which key is correspond to which oracle report functions.

13.     Is it possible to insert comments into sql statements return in the data model editor?
      Yes.

14.     If the maximum record retrieved property of the query is set to 10 then a summary value will be calculated?
      Only for 10 records.

15.     What are the sql clauses supported in the link property sheet?
    Where startwith having.

16.     To execute row from being displayed that still use column in the row which property can be used?
    Format trigger.

17.     Is it possible to set a filter condition in a cross product group in matrix reports?
    No.

18.     If a break order is set on a column would it effect columns which are under the column?
    No.

19.     With which function of summary item is the compute at options required?
    percentage of total functions.

20.     What is the purpose of the product order option in the column property sheet?
    To specify the order of individual group evaluation in a cross products.

21.     Can a formula column be obtained through a select statement?
    Yes.

22.     Can a formula column refered to columns in higher group?
    Yes.

23.     How can a break order be created on a column in an existing group?
      By dragging the column outside the group.

24.     What are the types of calculated columns available?
      Summary, Formula, Placeholder column.

25.     What is the use of place holder column?
    A placeholder column is used to hold a calculated values at a specified place rather than allowing is to appear in the actual row where it has to appeared.

26.     What is the use of hidden column?
    A hidden column is used to when a column has to embedded into boilerplate text.

27.     What is the use of break group?
    A break group is used to display one record for one group ones.While multiple related records in other group can be displayed.

28..     If two groups are not linked in the data model editor, what is the hierarchy between them?
    Two group that is above are the left most rank higher than the group that is to right or below it.

29.     The join defined by the default data link is an outer join yes or no?
    Yes.

30.     How can a text file be attached to a report while creating in the report writer?
    By using the link file property in the layout boiler plate property sheet.

31.     Can a repeating frame be careated without a data group as a base?
    No.

32.     Can a field be used in a report wihtout it appearing in any data group?
    Yes.

33.     For a field in a repeating frame, can the source come from the column which does not exist in the data group which forms the base for the frame?
    Yes.

34.     Is it possible to center an object horizontally in a repeating frame that has a variable horizontal size?
    Yes.

35.     If yes,how?
    By the use anchors.
36.     What are the two repeating frame always associated with matrix object?
    One down repeating frame below one across repeating frame.

37.     Is it possible to split the printpreviewer into more than one region?
    Yes.

38.     Does a grouping done for objects in the layout editor affect the grouping done in the datamodel editor?
    No.

39.     How can a square be drawn in the layout editor of the report writer?
    By using the rectangle tool while pressing the (Constraint) key.

40.     To display the page no. for each page on a report what would be the source & logical page no. or & of physical page no.?
    & physical page no.

41.     What does the term panel refer to with regard to pages?
    A panel is the no. of physical pages needed to print one logical page.

42.     What is an anchoring object & what is its use?
    An anchoring object is a print condition object which used to explicitly or implicitly anchor other objects to itself.

43.     What is a physical page? & what is a logical page?
    A physical page is a size of a page. That is output by the printer. The logical page is the size of one page of the actual report as seen in the Previewer.

44.     What is the frame & repeating frame?
    A frame is a holder for a group of fields. A repeating frame is used to display a set of records when the no. of records that are to displayed is not known before.

PL SQl Interview Questions - Basics to Advanced Interview Questions

What is PL/SQL?    
    PL/SQL is a procedural language that has both interactive SQL and procedural programming language constructs such as iteration, conditional branching.

2.     What is the basic structure of PL/SQL?
    PL/SQL uses block structure as its basic structure. Anonymous blocks or nested blocks can be used in PL/SQL.

3.     What are the components of a PL/SQL block?
    A set of related declarations and procedural statements is called block.

4.     What are the components of a PL/SQL Block?
    Declarative part, Executable part and Execption part.

5.     What are the datatypes a available in PL/SQL?
    Some scalar data types such as
NUMBER, VARCHAR2, DATE, CHAR, LONG, BOOLEAN.
Some composite data types such as RECORD & TABLE.

6.     What are % TYPE and % ROWTYPE? What are the advantages of using these over datatypes?
    % TYPE provides the data type of a variable or a database column to that variable.
% ROWTYPE provides the record type that represents a entire row of a table or view or columns selected in the cursor.

The advantages are: I. need not know about variable's data type
ii. If the database definition of a column in a table changes, the data type of a variable changes accordingly.

7.     What is difference between % ROWTYPE and TYPE RECORD ?
    % ROWTYPE is to be used whenever query returns a entire row of a table or view.
TYPE rec RECORD is to be used whenever query returns columns of different table or views and variables.

E.g. TYPE r_emp is RECORD (eno emp.empno% type,ename emp ename %type );
e_rec emp% ROWTYPE
Cursor c1 is select empno,deptno from emp;
e_rec c1 %ROWTYPE.

8.     What is PL/SQL table?
    Objects of type TABLE are called "PL/SQL tables", which are modelled as (but not the same as) database tables, PL/SQL tables use a primary PL/SQL tables can have one column and a primary key.

9.     What is a cursor? Why Cursor is required?
    Cursor is a named private SQL area from where information can be accessed.
Cursors are required to process rows individually for queries returning multiple rows.

10.     Explain the two types of Cursors?
      There are two types of cursors, Implict Cursor and Explicit Cursor.
PL/SQL uses Implict Cursors for queries.
User defined cursors are called Explicit Cursors. They can be declared and used.

11.     What are the PL/SQL Statements used in cursor processing?
      DECLARE CURSOR cursor name, OPEN cursor name, FETCH cursor name INTO <variable list> or Record types, CLOSE cursor name.

12.     What are the cursor attributes used in PL/SQL?
       %ISOPEN - to check whether cursor is open or not
% ROWCOUNT - number of rows featched/updated/deleted.
% FOUND - to check whether cursor has fetched any row. True if rows are featched.
% NOT FOUND - to check whether cursor has featched any row. True if no rows are featched.
These attributes are proceded with SQL for Implict Cursors and with Cursor name for Explict Cursors.

13.     What is a cursor for loop?
      Cursor for loop implicitly declares %ROWTYPE as loop index,opens a cursor, fetches rows of values from active set into fields in the record and closes when all the records have been processed.

eg. FOR emp_rec IN C1 LOOP
salary_total := salary_total +emp_rec sal;
END LOOP;

14.     What will happen after commit statement ?    
      Cursor C1 is
Select empno,
ename from emp;
Begin
open C1; loop
Fetch C1 into
eno.ename;
Exit When
C1 %notfound;-----
commit;
end loop;
end;

The cursor having query as SELECT .... FOR UPDATE gets closed after COMMIT/ROLLBACK.

The cursor having query as SELECT.... does not get closed even after COMMIT/ROLLBACK.

15.     Explain the usage of WHERE CURRENT OF clause in cursors ?
    WHERE CURRENT OF clause in an UPDATE,DELETE statement refers to the latest row fetched from a cursor.

16.     What is a database trigger ? Name some usages of database trigger ?
    Database trigger is stored PL/SQL program unit associated with a specific database table. Usages are Audit data modificateions, Log events transparently, Enforce complex business rules Derive column values automatically, Implement complex security authorizations. Maintain replicate tables.

17.     How many types of database triggers can be specified on a table? What are they?
                     Insert             Update             Delete

Before Row                 o.k.                  o.k.                o.k.

After Row                   o.k.                  o.k.                o.k.

Before Statement        o.k.                  o.k.                o.k.

After Statement           o.k.                  o.k.                o.k.

If FOR EACH ROW clause is specified, then the trigger for each Row affected by the statement.

If WHEN clause is specified, the trigger fires according to the retruned boolean value.

18.     Is it possible to use Transaction control Statements such a ROLLBACK or COMMIT in Database Trigger? Why?
    It is not possible. As triggers are defined for each table, if you use COMMIT of ROLLBACK in a trigger, it affects logical transaction processing.

19.     What are two virtual tables available during database trigger execution?
      The table columns are referred as OLD.column_name and NEW.column_name.
For triggers related to INSERT only NEW.column_name values only available.
For triggers related to UPDATE only OLD.column_name NEW.column_name values only available.
For triggers related to DELETE only OLD.column_name values only available.

20.     What happens if a procedure that updates a column of table X is called in a database trigger of the same table?
    Mutation of table occurs.

21.     Write the order of precedence for validation of a column in a table ?
    I. done using Database triggers.
ii. done using Integarity Constraints.

22.     What is an Exception? What are types of Exception?
    Exception is the error handling part of PL/SQL block. The types are Predefined and user_defined. Some of Predefined execptions are.

CURSOR_ALREADY_OPEN
DUP_VAL_ON_INDEX
NO_DATA_FOUND
TOO_MANY_ROWS
INVALID_CURSOR
INVALID_NUMBER
LOGON_DENIED
NOT_LOGGED_ON
PROGRAM-ERROR
STORAGE_ERROR
TIMEOUT_ON_RESOURCE
VALUE_ERROR
ZERO_DIVIDE
OTHERS.

23.     What is Pragma EXECPTION_INIT? Explain the usage?
      The PRAGMA EXECPTION_INIT tells the complier to associate an exception with an oracle error. To get an error message of a specific oracle error.

e.g. PRAGMA EXCEPTION_INIT (exception name, oracle error number)

24.     What is Raise_application_error?
      Raise_application_error is a procedure of package DBMS_STANDARD which allows to issue an user_defined error messages from stored sub-program or database trigger.

25.     What are the return values of functions SQLCODE and SQLERRM?
    SQLCODE returns the latest code of the error that has occured.
SQLERRM returns the relevant error message of the SQLCODE.

26.     Where the Pre_defined_exceptions are stored?
    In the standard package.
Procedures, Functions & Packages;

27.     What is a stored procedure?
    A stored procedure is a sequence of statements that perform specific function.

30.     What is difference between a PROCEDURE & FUNCTION?
    A FUNCTION is alway returns a value using the return statement.
A PROCEDURE may return one or more values through parameters or may not return at all.

31.     What are advantages of Stored Procedures?
    Extensibility,Modularity, Reusability, Maintainability and one time compilation.

32.     What are the modes of parameters that can be passed to a procedure?
    IN,OUT,IN-OUT parameters.

33.     What are the two parts of a procedure?
    Procedure Specification and Procedure Body.

34.     Give the structure of the procedure?
      PROCEDURE name (parameter list.....)
is
local variable declarations

BEGIN
Executable statements.
Exception.
exception handlers

end;

35.     Give the structure of the function?
      FUNCTION name (argument list .....) Return datatype is
local variable declarations
Begin
executable statements
Exception
execution handlers
End;

36.     Explain how procedures and functions are called in a PL/SQL block ?
      Function is called as part of an expression.
sal := calculate_sal ('a822');
procedure is called as a PL/SQL statement
calculate_bonus ('A822');

37.     What is Overloading of procedures?
      The Same procedure name is repeated with parameters of different datatypes and parameters in different positions, varying number of parameters is called overloading of procedures.

e.g. DBMS_OUTPUT put_line

38.     What is a package? What are the advantages of packages?
      Package is a database object that groups logically related procedures.
The advantages of packages are Modularity, Easier Applicaton Design, and Information.
Hiding,. Reusability and Better Performance.

39.     What are two parts of package?
      The two parts of package are PACKAGE SPECIFICATION & PACKAGE BODY.
Package Specification contains declarations that are global to the packages and local to the schema.
Package Body contains actual procedures and local declaration of the procedures and cursor declarations.

40.     What is difference between a Cursor declared in a procedure and Cursor declared in a package specification?
      A cursor declared in a package specification is global and can be accessed by other procedures or procedures in a package.
A cursor declared in a procedure is local to the procedure that can not be accessed by other procedures.

41.     How packaged procedures and functions are called from the following ?
a. Stored procedure or anonymous block
b. an application program such a PRC *C, PRO* COBOL
c. SQL *PLUS
      a. PACKAGE NAME.PROCEDURE NAME (parameters);
variable := PACKAGE NAME.FUNCTION NAME (arguments);
EXEC SQL EXECUTE
b.
BEGIN
PACKAGE NAME.PROCEDURE NAME (parameters)
variable := PACKAGE NAME.FUNCTION NAME (arguments);
END;
END EXEC;
c. EXECUTE PACKAGE NAME.PROCEDURE if the procedures does not have any out/in-out parameters. A function can not be called.

42.     Name the tables where characteristics of Package, procedure and functions are stored?
    User_objects, User_Source and User_error.