Creating and Managing Indexes
What is and Index?
• It is a data structure associated with a table
that enables fast searching of data.
• Indexes are schema objects that are logically
and physically independent of the data in the
objects with which they are associated.
• Indexes are structures stored in the database
that users manage using SQL statements.
What is an Index?
• Primary and unique keys automatically have
indexes, but create an index on a foreign key.
• Index must be created on the most frequently
columns in the table.
• Oracle Database does not index table rows in
which all key columns are null.
What is an Index?
• An index contains a collection of keys and
pointers.
– Keys are values built from one or more columns in
the table
– Pointer stores the address of the location where a
data block stored in the memory.
What is an Index?
• Composite Index
– Index based on one or more columns is called
composite index.
– Multiple indexes can exist for the same table if the
permutation of columns differs for each index.
What is an Index?
• Unique Indexes
– Unique indexes guarantee that no two rows of a
table have duplicate values in the key column or
columns.
– The data is sorted only by key.
• Non Unique Indexes
– Nonunique indexes permit duplicates values in the
indexed column or columns.
– The rowid is included in the key in sorted order
Types of Indexes
• B-tree Indexes
• Bitwise Indexes
• Function Based Indexes
• ALL_INDEXES view is used to list all the
indexes details.
Types of Indexes
• B-tree Indexes
– These indexes are the standard (NORMAL) index
type.
– They are excellent for primary key and highly-
selective indexes.
– Order list of values divided into ranges.
CREATE INDEX indexname
ON table_name(column)list);
Types of Indexes
• Bitmap Index
– In a bitmap index, the database stores a bitmap
for each index key.
– Used for the columns when the number of distinct
values is small compared to the number of table
rows.
CREATE BITMAP INDEX index_name
ON table_name (column_name);
Value Row 1 Row 2 Row 3 Row 4 Row 5 Row 6 Row 7 Row 8
Male 1 1 0 1 0 1 0 1
Female 0 0 1 0 1 0 1 0
Function Based Index
• Function Based Index
– A function-based index computes the value of a
function or expression involving one or more
columns and stores it in the index.
– A function-based index can be either a B-tree or a
bitmap index.
CREATE INDEX index_name
ON tablename (expression(s) [, column_list]);
Function Based Index
• Function Based Index
– The database only uses the function-based index
when the function is included in a query not at
INSERT or UPDATE statement.
Index Organised Tables
• An index-organized table is a table stored in a
variation of a B-tree index structure.
• In an index-organized table, rows are stored in
an index defined on the primary key for the
table.
• An index-organized table stores all data in the
same structure and does not need to store the
rowid.
Heap Organised vs Index Organised Tables
• In heap organised table,
– the rowid uniquely identifies a row.
– Primary key constraint may optionally be defined.
• In Index organised table,
– Primary key uniquely identifies a row.
– Primary key constraint must be defined.
Heap Organised vs Index Organised Tables
• In heap organised table,
– Individual rows may be accessed directly by rowid.
• In Index organised table
– Access to individual rows may be achieved
indirectly by primary
Heap Organised vs Index Organised Tables
• In heap organised table, can contain a column
of the LONG data type and LOB data types.
• In Index organised table, can contain LOB
columns but not LONG columns.
Heap Organised vs Index Organised Tables
• Heap organised Table
Heap Organised vs Index Organised Tables
• Indexed organised Table

9. index and index organized table

  • 1.
  • 2.
    What is andIndex? • It is a data structure associated with a table that enables fast searching of data. • Indexes are schema objects that are logically and physically independent of the data in the objects with which they are associated. • Indexes are structures stored in the database that users manage using SQL statements.
  • 3.
    What is anIndex? • Primary and unique keys automatically have indexes, but create an index on a foreign key. • Index must be created on the most frequently columns in the table. • Oracle Database does not index table rows in which all key columns are null.
  • 4.
    What is anIndex? • An index contains a collection of keys and pointers. – Keys are values built from one or more columns in the table – Pointer stores the address of the location where a data block stored in the memory.
  • 5.
    What is anIndex? • Composite Index – Index based on one or more columns is called composite index. – Multiple indexes can exist for the same table if the permutation of columns differs for each index.
  • 6.
    What is anIndex? • Unique Indexes – Unique indexes guarantee that no two rows of a table have duplicate values in the key column or columns. – The data is sorted only by key. • Non Unique Indexes – Nonunique indexes permit duplicates values in the indexed column or columns. – The rowid is included in the key in sorted order
  • 7.
    Types of Indexes •B-tree Indexes • Bitwise Indexes • Function Based Indexes • ALL_INDEXES view is used to list all the indexes details.
  • 8.
    Types of Indexes •B-tree Indexes – These indexes are the standard (NORMAL) index type. – They are excellent for primary key and highly- selective indexes. – Order list of values divided into ranges. CREATE INDEX indexname ON table_name(column)list);
  • 9.
    Types of Indexes •Bitmap Index – In a bitmap index, the database stores a bitmap for each index key. – Used for the columns when the number of distinct values is small compared to the number of table rows. CREATE BITMAP INDEX index_name ON table_name (column_name); Value Row 1 Row 2 Row 3 Row 4 Row 5 Row 6 Row 7 Row 8 Male 1 1 0 1 0 1 0 1 Female 0 0 1 0 1 0 1 0
  • 10.
    Function Based Index •Function Based Index – A function-based index computes the value of a function or expression involving one or more columns and stores it in the index. – A function-based index can be either a B-tree or a bitmap index. CREATE INDEX index_name ON tablename (expression(s) [, column_list]);
  • 11.
    Function Based Index •Function Based Index – The database only uses the function-based index when the function is included in a query not at INSERT or UPDATE statement.
  • 12.
    Index Organised Tables •An index-organized table is a table stored in a variation of a B-tree index structure. • In an index-organized table, rows are stored in an index defined on the primary key for the table. • An index-organized table stores all data in the same structure and does not need to store the rowid.
  • 13.
    Heap Organised vsIndex Organised Tables • In heap organised table, – the rowid uniquely identifies a row. – Primary key constraint may optionally be defined. • In Index organised table, – Primary key uniquely identifies a row. – Primary key constraint must be defined.
  • 14.
    Heap Organised vsIndex Organised Tables • In heap organised table, – Individual rows may be accessed directly by rowid. • In Index organised table – Access to individual rows may be achieved indirectly by primary
  • 15.
    Heap Organised vsIndex Organised Tables • In heap organised table, can contain a column of the LONG data type and LOB data types. • In Index organised table, can contain LOB columns but not LONG columns.
  • 16.
    Heap Organised vsIndex Organised Tables • Heap organised Table
  • 17.
    Heap Organised vsIndex Organised Tables • Indexed organised Table

Editor's Notes

  • #7 Unique :- empno Non Unique index on first name