Join the OracleApps88 Telegram group @OracleApps88to get more information on Oracle EBS R12/Oracle Fusion applications.

If you are facing any issues while copying the Code/Script or any issues with Posts, Please send a mail to OracleApp88@Yahoo.com or message me at @apps88 or +91 905 957 4321 in telegram.

Tuesday, July 17, 2012

Oracle DBS, SQL, PL SQL FAQS


1) What are the Back ground processes in Oracle and what are they.
1) This is one of the most frequently asked question. There are basically 9 Processes but in a general system we need to mention the first five background processes. They do the house keeping activities for the Oracle and are common in any system.
The various background processes in oracle are

a) Data Base Writer(DBWR)  :: 
Data Base Writer Writes Modified blocks from Database buffer cache to Data Files. This is required since the data is not written whenever a transaction is commited.

b)LogWriter(LGWR)  :: 
LogWriter writes the redo log entries to disk. Redo Log data is generated in redo log buffer of SGA. As transaction commits and log buffer fills, LGWR writes log entries into an online redo log file.

c) System Monitor(SMON) ::
The System Monitor performs instance recovery at instance startup. This is useful for recovery from system failure.

d)Process Monitor(PMON) ::
The Process Monitor performs process recovery when user process fails. PMON Clears and Frees resources that process was using.

e)  CheckPoint(CKPT) ::
At Specified times, all modified database buffers in SGA are written to data files by DBWR at Checkpoints and Updating all data files and control files of database to indicate the most recent checkpoint

f)Archieves(ARCH) ::
The Archiver copies online redo log files to archival storal when they are busy.

g) Recoveror(RECO) ::
The Recoveror is used to resolve the distributed  transaction in network

h) Dispatcher (Dnnn) ::
The Dispatcher is useful in Multi Threaded Architecture

i) Lckn ::
We can have upto 10 lock processes for inter instance locking in parallel sql.


2) How many types of Sql Statements are there in Oracle
2) There are basically 6 types of sql statments.They are

a) Data Definition Language (DDL) ::
The DDL  statements define and maintain objects and drop objects.  Create, alter, drop, truncate

b) Data Manipulation Language (DML) ::
The DML statements manipulate database data. Eg: select, update, delete

c) Transaction Control Statements  ::
Manage change by DML eg : grant, revoke

d) Session Control Statements ::
Used to control the properties of current session enabling and disabling roles and changing .e.g   :: Alter Statements, Set Role
e) System Control Statements         :: Change Properties of Oracle Instance .e.g:: Alter System

f) Embedded Sql                               ::
Incorporate DDL,DML and TCS in Programming Language. e.g:: Using the Sql Statements in languages such as 'C', Open,Fetch, execute and close

3) What is a Transaction in Oracle
3) A transaction is a Logical unit of work that compromises one or more SQL Statements executed by a single User. According to ANSI, a transaction begins with first executable statement and ends when it is explicitly commited or rolled back.

4)  Key Words Used in Oracle
4) The Key words that are used in Oracle are ::

 a) Commit      ::
A transaction is said to be commited when the transaction makes permanent changes resulting from the SQL statements.

b)    Rollback      ::
A transaction that retracts any of the changes resulting from SQL statements in Transaction.

 c)  SavePoint      ::
For long transactions that contain many SQL statements, intermediate markers or savepoints are declared. Savepoints can be used to divide a transaction into smaller points.

d)  Rolling Forward ::
Process of applying  redo log during recovery is called rolling forward.

 e) Cursor       ::
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 Explcit cursor for a multi row query.

f) System Global Area(SGA)   ::
The SGA is a shared memory region allocated by the Oracle that contains Data and control information for one Oracle Instance. It consists of Database Buffer Cache and Redo log Buffer.

g) Program Global Area (PGA)          ::
The PGA is a memory buffer  that contains data and control information for server process.

g) Database Buffer Cache      ::
Databese Buffer of SGA stores the most recently used blocks of datatbase data. The set of database buffers in an instance is called Database Buffer Cache.

h) Redo log Buffer    ::
Redo log Buffer of SGA stores all the redo log entries.

i) Redo Log Files      ::
Redo log files are set of files that protect altered database data in memory that has not been written to Data Files. They are basically used for backup when a database crashes.

j) Process ::
A Process is a 'thread of control' or mechansim in Operating System that executes series of steps.

5) What are Procedure,functions and Packages
5) Procedures  and functions consist of set of PL/SQL statements that are grouped together as a unit to solve a specific problem or  perform set of related tasks.
 Procedures do not Return values while Functions return one One Value
Packages      :: Packages Provide a method of encapsulating and storing related procedures, functions, variables and other Package Contents

6) What are Database Triggers and Stored Procedures
6) Database Triggers :: Database Triggers are Procedures that are automatically executed as a result of insert into, update to, or delete from table.
 Database triggers have the values old and new to denote the old value in the table before it is deleted and the new indicated the new value that will be used. DT are useful for implementing complex business rules which cannot be enforced using the integrity rules. We can have the trigger as Before trigger or After Trigger and at Statement or Row level.
e.g:: operations insert, update, delete   3
        before ,after                                      3*2     A total of 6 combinatons
        At statment level(once for the trigger) or row level( for every execution )       6 * 2    A total of 12.
 Thus a total of 12 combinations are there and the restriction of usage of 12 triggers has been lifted from Oracle 7.3 Onwards.
Stored Procedures:: Stored Procedures are Procedures that are stored in Compiled form in the database. The advantage of using the stored procedures is that many users can use the same procedure in compiled and ready to use format.

7) How many Integrity Rules are there and what are they
7) There are Three Integrity Rules. They are as follows ::

a) Entity Integrity Rule ::
The Entity Integrity Rule  enforces that the Primary key cannot be Null

b) Foreign Key Integrity Rule ::
The FKIR denotes that the relationship between the foreign key and the primary key has to be enforced. When there is data in Child Tables the Master tables cannot be deleted.

c) Business Integrity Rules ::
The Third Intigrity rule is about the complex business processes which cannot be implemented by the above 2 rules.

8) What are the Various Master and Detail Relationships?
8) The various Master and Detail Relationship are
a) NonIsolated :: The Master cannot be deleted when a child is existing
b) Isolated        :: The Master can be deleted when the child is existing
c) Cascading    :: The child gets deleted when the Master is deleted.

9) What are the Various Block Coordination Properties
9) The various Block Coordination Properties are

a) Immediate
   Default Setting. The Detail records are shown when the Master Record is shown.

b) Deffered with Auto Query
Oracle Forms defer fetching the detail records until the operator navigates to the    detail block.

c) Deffered with No Auto Query
    The operator must navigate to the detail block and explicitly execute a query

10) What are the Different Optimisation Techniques
10) The Various Optimisation techniques are
a) Execute Plan ::
 we can see the plan of the query and change it accordingly based on the indexes         

b) Optimizer_hint : ::set_item_property('DeptBlock',OPTIMIZER_HINT,'FIRST_ROWS');
Select /*+ First_Rows */ Deptno,Dname,Loc,Rowid from dept
where (Deptno > 25)

c) Optimize_Sql ::
By setting the Optimize_Sql = No, Oracle Forms assigns a single cursor for all SQL statements. This slow downs the processing because for every time the SQL must be parsed whenever they are executed.
f45run module = my_firstform userid = scott/tiger optimize_sql = No

d) Optimize_Tp ::
 By setting the Optimize_Tp= No, Oracle Forms assigns seperate cursor only for each query SELECT  statement. All other SQL statements reuse the cursor.
f45run module = my_firstform userid = scott/tiger optimize_Tp = No

11) How do u implement the If statement in the Select Statement
11) We can implement the if statement in the select statement by using the Decode statement.
e.g select   DECODE (EMP_CAT,'1','First','2','Second'Null);
Here the Null is the else statement where null is done.

12) How many types of Exceptions are there?
12) There are 2 types of exceptions. They are
a) System defined Exceptions
e.g. WHEN NO_DATA_FOUND, WHEN TOO_MANY_ROWS
b) User Defined Exceptions
e.g. My_exception exception
When My_exception then

13) What are the inline and the precompiler directives
13) The inline and precompiler directives detect the values directly

14) How do you use the same lov for 2 columns
14) We can use the same lov for 2 columns by passing the return values in global values and using the global values in the code

15) How many minimum groups are required for a matrix report
15) The minimum number of groups in matrix report are 4

16) What is the difference between static and dynamic lov
16) The static lov contains the predetermined values while the dynamic lov contains values that come at run time

17) What are snap shots and views?
17) Snapshots are mirror or replicas of tables. Views are built using the columns from one or more tables. The Single Table View can be updated but the view with multi table cannot be updated. Views with joins or grouping expressions cannot be updated.

18) What are the OOPS concepts in Oracle.
18) Oracle does implement the OOPS concepts. The best example is the Property Classes. We can categorize the properties by setting the visual attributes and then attach the property classes for the objects. OOPS supports the concepts of objects and classes and we can consider the property classes as classes and the items as objects

19)  What is the difference between candidate key, unique key and primary key
19) Candidate keys are the columns in the table that could be the primary keys and the primary key is the key that has been selected to identify the rows. Unique key is also useful for identifying the distinct rows in the table.

20) What is concurrency
20) Cuncurrency is allowing simultaneous access of same data by different users.  Locks useful for accessing the database are
a) Exclusive
The exclusive lock is useful for locking the row when an insert, update or delete is being done. This lock should not be applied when we do only select from the row.
b) Share lock
We can do the table as Share_Lock as many share_locks can be put on the same resource.

21) Previleges and Grants
21) Previleges  are the right to execute a  particular type of SQL statements.
e.g :: Right to Connect, Right to create, Right to resource
Grants are given to objects so that the objects might be accessed accordingly. The grant has to be given by the owner of the object.

22)Table Space, Data Files, Parameter File, Control Files
22)Table Space :: The table space is useful for storing the data in the database.
When a database is created two table spaces are created.

a) System Table space  :: This data file stores all the tables related to the system and dba tables

b) User Table space      :: This data file stores all the user related tables
We should have seperate table spaces for storing the tables and indexes so that the access is fast.
Data Files :: Every Oracle Data Base has one or more physical data files. They store the data for the database. Every datafile is associated with only one database. Once the Data file is created the size cannot change. To increase the size of the database to store more data we have to add data file.
Parameter Files :: Parameter file is needed to start an instance. A parameter file contains the list of instance configuration parameters e.g.::
db_block_buffers = 500
db_name = ORA7
db_domain = u.s.acme lang
Control Files  :: Control files record the physical structure of the data files and redo log files. They contain the Db name, name and location of dbs, data files ,redo log files and time stamp.

23) Physical Storage of the Data
23) The finest level of granularity of the data base are the data blocks.
Data Block :: One Data Block correspond  to specific number of physical database space
Extent   :: Extent is the number of specific number of contiguous data blocks.
Segments :: Set of Extents allocated for Extents. There are three types of  Segments
a) Data Segment :: Non Clustered Table has data segment data of every table is  stored in cluster data segment.
b) Index Segment :: Each Index has index segment that stores data
c) Roll Back Segment :: Temporarily stores 'undo' information

24) What are the Pct Free and Pct Used
24) Pct Free is used to denote the percentage of the free space that is to be left when creating a table. Similarly Pct Used is used to denote the percentage of the used space that is to be used when creating a table
eg.:: Pctfree 20, Pctused 40

25) What is Row Chaining
25) The data of a row in a table may not be able to fit in the same data block. Data for row is stored in a chain of data blocks.

26) What is a 2 Phase Commit
26) Two Phase commit is used in distributed data base systems. This is useful to maintain the integrity of the database so that all the users see the same values. It contains DML statements or Remote Procedural calls that reference a remote object. There are basically 2 phases in a 2 phase commit.
a) Prepare Phase :: Global coordinator asks participants to prepare
b) Commit Phase :: Commit all participants to coordinator to Prepared, Read only or abort Reply

27)  What is the difference between deleting and truncating of tables
27)  Deleting a table will not remove the rows from the table but entry is there in the database dictionary and it can be retrieved But truncating a table deletes it completely and it cannot be retrieved.

28) What are mutating tables?
28) When a table is in state of transition it is said to be mutating. eg :: If a row has been deleted then the table is said to be mutating and no operations can be done on the table except select.

29)  What are Codd Rules
29) Codd Rules describe the ideal nature of a RDBMS. No RDBMS satisfies all the 12 codd rules and Oracle Satisfies 11 of the 12 rules and is the only Rdbms to satisfy the maximum number of rules.

30) What is Normalisation
30) Normalisation is the process of organising the tables to remove the redundancy.There are mainly 5 Normal rules/forms.
a) 1 Normal Form ::  A table is said to be in 1st Normal Form when the attributes are atomic.
b) 2 Normal Form ::  A table is said to be in 2nd Normal Form when all the candidate keys are dependant on the primary key
c) 3rd Normal Form :: A table is said to be third Normal form when it is not dependant transitively

31) What is the Difference between a post query and a pre query
31) A post query will fire for every row that is fetched but the pre query will fire only once.

32) Deleting the Duplicate rows in the table
32) We can delete the duplicate rows in the table by using the Rowid

33) Can U disable database trigger? How?
 33) Yes. With respect to table
     ALTER TABLE TABLE
     [   DISABLE all_trigger ]

34) What is pseudo columns ? Name them?
 34) A pseudocolumn behaves like a table column, but is not actually stored in the table.    You can select from pseudocolumns, but you cannot insert, update, or delete their values.  This section describes these pseudocolumns:
   * CURRVAL
    * NEXTVAL
    * LEVEL
    * ROWID
    * ROWNUM

35) How many columns can table have?
      The number of columns  in a table can range from 1 to 254.

36) Is space acquired in blocks or extents?
     In extents

37) What is clustered index?
      In an indexed cluster, rows are stored together based on their cluster key values.
      Can not applied for HASH.

38) what are the datatypes supported By oracle (INTERNAL)?
      Varchar2, Number,Char , MLSLABEL.

39 ) What are attributes of cursor?
      %FOUND , %NOTFOUND , %ISOPEN,%ROWCOUNT

40) Can you use select in FROM clause of SQL select ?
      Yes.

No comments:

Post a Comment

If you are facing any issues while copying the Code/Script or any issues with Posts, Please send a mail to OracleApp88@Yahoo.com or message me at @apps88 or +91 905 957 4321 in telegram.
Best Blogger TipsGet Flower Effect