Oracle Interview Ques & Ans
Oracle Interview Ques & Ans
Oracle Interview Ques & Ans
AND ANSWER
1. SQL:- Structured query language is a specialized language
for Updating, Deleting, and Requesting information from
Database. Developed by IBM in1970s.
2. PL/SQL:- PL/SQL is a procedural language that has both
interactive SQL and procedural programming language
constructs such as interaction, conditional branching.
3. ORACLE:- The Oracle Database is an object relational Data
base management system produced and marked by Oracle
Corporation.
4. META-DATA:- Meta-data is data about data. Meta data is
structured data which describes the characteristics of a
resource.
5. Query:- To retrieve data from the data base table is called
query.
6. Attribute:- It is a particular property, which describes the
entity.
7. Field:- Every table is broken up into smaller entities called
field.
Field in the customers table consists of ID,
Name, Address, Age and Salary.
8. Table:- Table is a container that holds information about
like items.
For-Exam: - An Employee table would contain the same
basic details on each employee Name, Title, Department and
So On.
9. Table-Space:- T.S is a logical Storage structure at the
highest level that stores all the data in data files.
Two types of View:1. Simple - View:- Refer the Data from only single table.
- A simple view selects from one table.
- A simple view does not contain functions.
2. Complex - View:- Refer the Data from more than one table.
- A Complex view selects from one or more table.
- A Complex view contains function.
Types of Index:(1). Clustered Index or Normal Index:- Clustered Index is a special type of index that records the way
records in the table are physically stored.
- The leaf nodes of a clustered index contain the data page.
- Clustered Index is physically stored a table can have 1 clustered
Index.
(2). Non Clustered - Index or Bitmap Index:- Non-Clustered Index is a special type of index in which the
logical order of the index does not match the physical stored
order of the rows on disk.
- The leaf nodes of a non-clustered index do not consist of the
data page.
- Non-Clustered Index is logically stored a table can have 249
Non-Clustered Index.
(3). Functional based - Index:-They are based on expressions.
-Enable query to evaluate value returned by an expression.
(4). Domain - Index:-They are Index which are instances of an application specific
Index of type Index.
#Procedure:-
# Trigger:
# Primary key: Does not allow both null and duplicate values.
Accept only null value.
Doesnt allow null values.
Primary key create cluster index.
# TRUNCATE:
# DROP:-
Decode
Decode
Decode
Decode
#CASE: Case can work with logical operators, predicates & search
able sub queries.
Case can work as a PL/SQL construct.
Case expects data type consistency.
Case is a statement.
#In: IN is faster than EXISTS (when the subquery results is very small)
Returns true if a specified value matches any value in a
subquery or a list.
The sub query will run first and then only outer query.
SQL
SQL
SQL
SQL
%
%
%
%
Or: - SQL> Select Emp no, E name, Sal, Grade from Emp, sal
Grade;
#Four Types of Join:(1). Equi or Simple or Inner Join:- Returns the rows from two
or more tables joined together based upon a equality conditions
in the where clause.
Ex:- Select * from emp, dept where emp dep no = dept . dept no;
(2). Non - Equi Join:- Returns the rows from two or more tables
based upon a relationship other than the equality conditions in
the where clause.
Ex:- Select E. E name, E. Sal, S Grade From Emp E, Sal Grade S
where E. Sal Between S. Losal AND S.Hisal;
(3). Self - Join:- Self Join joins a table to itself. Basically it is for
the Hierarchical relationship.
Ex:- Select E1. E name, E2. E name from Emp E1, Emp E2 where
E1 . Mgr = E2. EMP no;
Syntax:- SQL> Select Columns From Table1 T1, Table1 T2 where
T1. Column 1 = T2. Column 2.
(4). Outer - Join:- Outer Join combines two or more tables
returning those rows from one table that have no direct match in
the other table.
Ex:- Select E. E name , D. Dept Name from Emp E, Dept D where
e. dept no = D. Dept no(+);
Syntax:- Select Table1. Column, Table2. Column from Table1,
Table2 where Table1. Column = Table2. Column (+);
(3). Data Definition language (DDL) statement:- It is used to create and modify the structure of database objects
in database.
- Create; Alter; Drop; Rename; Truncate Statement.
(4). Transaction Control Language (TCL) Statement:- It is used to manage different transaction occurring within a
database.
- Commit; Rollback; Save point Statement.
(5). Data Control Language (DCL) statement:- It is used to create roles, permissions and referential integrity as
well it is used to control access to database by searching it.
- Grant; Revoke Statements.
48. What are Group by, Order By, & having by?
*Group By:- The Group by clause is used along with the group functions to
retrieve data grouped according to one or more columns.
For Ex: - If U want to know the total amount of salary spent on
each department, the query would be:Syntax: - Select column1, sum (Column 2) from list of table
Group By Column list;
Ex:- Select dept, sum (Salary) from employee group by dept;
Ex: - Select Ename, sal, Job from EMP where Not Job =
MANAGER;
Union.
Union all.
Interacted.
Minus.
* Foreign Key:- A F.K is one or more column whose value must exit
in the primary key of another table
* Check Constraints:- It defines a condition that each row Must
satisfy.
- To satisfy the constraint, each row in the table must make the
condition either true or unknown.
* Default Option:- The Default option is given to maintain a
default value in a column.
- The Default value can be literal, an expression or a SQL function.
- The Default expression must match the data type of the column.
* Composite key:- The Combination of two or more than two keys
which identifies entities uniquely.
* Super Key: - All possible key which can identify entities in the
table uniquely.
* Alternate Key:- Rest of the condition key which is not the
primary key.
Ex:- To get the total salary given out to the employee the query
would be :- Select Sum (Salary) from employee.
p.product_name
p.product_id
FROM
(SELECT
product
o.product_id
p
FROM
order_items
WHERE o.product_id = p.product_id);