You are on page 1of 4

INDEX

=====
An index is a database structure that provides quick lookup of data in a column or
columns of a table.

B-Tree Index is the default Oracle index created whenever we use the CREATE INDEX
command

Function-Based Index.
Bitmap Index is an index type used in scenarios with repetitive values

CHAR AND VARCHAR2


=====
The CHAR data type stores character values. It stores these values as a
fixed-length string. The maximum length of a CHAR value is 2000 bytes.

The VARCHAR datatype is an ANSI standard data type, which is why it is included in
Oracle. The maximum length of a CHAR value is 4000 bytes.

DELETE AND TRUNCATE


=====
DELETE: DML COMMAND. NO IMPLICIT COMMIT. WE CAN ROLLBACK DATA.
WE CAN USE WHERE CLAUSE.

TRUNCATE: DDL COMMAND. ORACLE WILL RELEASE IMPLICIT COMMIT.


WE CAN'T ROLLBACK DATA. WE CAN'T USE WHERE CLAUSE

DROP: DDL COMMAND, TOTAL TABLE WILL DROP AND DATA ALSO WILL DELETE.

NVL AND NVL2:


=====
NVL: If expr1 is null, then NVL returns expr2. If expr1 is not null, then NVL
returns expr1.

NVL2: If expr1 is null, then NVL2 returns expr3. If expr1 is not null, then NVL2
returns expr2

DECODE AND CASE DECODE:


=================
decode: Its a function, we can't call all operators

CASE: Its a statement, we can call all functions and operators,


Good performance as compared with DECODE

GLOBAL TEMPORARY TABLES Global Temporary Tables (GTTs)


=================
are the Oracle tables, having data type as private; such that data inserted by a
session can be accessed by that session only.

The session-specific rows in a GTT can be preserved for the entire session, tables
are created using ON COMMIT PRESERVE ROWS clause.

PRIMARY KEY AND UNIQUE KEY


=================
Only one primary key is allowed to use in a table. The primary key does not accept
the any duplicate and NULL values. A primary key of one table can be referenced by
foreign key of another table.

A table can have more than one unique key unlike primary key. Unique key
constraints can allow NULL values. Unique constraints are also referenced by the
foreign key of another table.
SUB QUERY AND CO RELATED SUB QUERY When a query is included inside another query,
the Outer query is known as Main Query, and Inner query is known as Subquery.

In Correlated Query,
=================
Outer query executes first and for every Outer query row Inner query is executed.
Hence, Inner query uses values from Outer query.
JOINS Oracle JOINS are used to retrieve data from multiple tables. An Oracle JOIN
is performed whenever two or more tables are joined in a SQL statement.

There are 4 different types of Oracle joins:

Oracle INNER JOIN (or sometimes called simple join)


Oracle LEFT OUTER JOIN (or sometimes called LEFT JOIN)
Oracle RIGHT OUTER JOIN (or sometimes called RIGHT JOIN)
Oracle FULL OUTER JOIN (or sometimes called FULL JOIN)

REF CURSOR:
It’s a dynamic cursor to change sql statement dynamically at run time.

example: will change columns, where clause, order by clause and tables also.

we need to declare a variable and build sql query and assign to variable
and execute that variable using ref cursor data type.

View and materialized view:


=====
Views are the logical and virtual copy of a table that is created by executing a
‘select query’ statement. The views are not stored anywhere on the disk. query has
to be executed when certain data is required. But, the query expression is stored
on the disk.

Materialized views
=================
are the snap shots. Materialized views are also a logical virtual table, but in
this case the result of the query is stored in the table. The performance of the
materialized views is better than normal views. This is because the data is stored
on the TABLE SPACE

will refersh using package


DBMS_MVIEW.REFRESH
on commit

SUBSTR and INSTR


=====
SUBSTR is used to extract a set of characters from a string
by specificing the character starting position and end
position and length of characters to be fetched

--------------------it will extract position of the string amoung given string


subtsrt(string , string posotion number of charter to displya);

---it alwas return position of the strin or position of the character

translate:trandalte is used to character to charctear.


replace are used to replace the character by character
replace :

INSTR is used to find the position of any particular


character in a word which returns numeric value.
REPLACE and TRANSLATE The Oracle TRANSLATE function replaces a sequence of
characters in a string with another sequence of characters.

It’s different to the REPLACE function as TRANSLATE replaces a single character at


a time, and REPLACE will replace the entire string.

PERFORMANCE TUNING
=================
IN SQL DEVELOPER , will get explain plan.
i will check table scan and cost of query
and will check whether it’s an index scan or full table scan
and check cardinality

second method
=============
i will generate trace file by checking check box calleD "trace"
and run the program
will get trace file and using command tk prof will convert to readable format
and will come to know which sql query is taking lot of time
and will tune that query

then will modify query


I WILL add hints, ADD indexes and co related sub query...TO IMPROVE PERFORMANCE

use bulk collect with limit option


AND SOME TIMES run schema and table gather statistics

Certain index is more selective for certain queries. Based on this information, WE
might be able to choose a more efficient execution plan than the optimizer. In such
a case, use hints to force the optimizer to use the optimal execution plan.

example:
Global hints:rule, first_rows, first_rows_n all_rows, driving_site
Table join hints: use_nl, use_hash
Index hints: Specifies an index name
Table access hints: parallel, full, cardinality
Table join hints: ordered

SET OPERATORS UNION is used to combine the results of two or more SELECT
statements. However, it will eliminate duplicate rows from its result set. In case
of union, number of columns and datatype must be same in both the tables, on which
UNION operation is being applied.

UNION ALL: This operation is similar to Union. But it also shows the duplicate
rows.
Intersect operation is used to combine two SELECT statements, but it only returns
the records which are common from both SELECT statements.

Intersect: Will return common values between two sql statements

The Minus operation combines results of two SELECT statements and return only those
in the final result, which belongs to the first set of the result.
Implicit and explicit cursors Implicit cursors are automatically created when
select statements are executed.
They are capable of fetching a single row at a time.
Closes automatically after execution.

Explicit cursors need to be defined explicitly by the user by providing a name.

Explicit cursors can fetch multiple rows.

Need to close after execution.

You might also like