CH 4 Indexes.

Slides:



Advertisements
Similar presentations
9 Creating and Managing Tables. Objectives After completing this lesson, you should be able to do the following: Describe the main database objects Create.
Advertisements

Data Definition Language (DDL)
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
11-1 Copyright © Oracle Corporation, All rights reserved. Different type of keys.
10 Copyright © 2004, Oracle. All rights reserved. Creating Other Schema Objects.
Copyright س Oracle Corporation, All rights reserved. 13 Other Database Objects.
A Guide to MySQL 7. 2 Objectives Understand, define, and drop views Recognize the benefits of using views Use a view to update data Grant and revoke users’
A Guide to SQL, Seventh Edition. Objectives Understand, create, and drop views Recognize the benefits of using views Grant and revoke user’s database.
SQL's Data Definition Language (DDL) – View, Sequence, Index.
Chapter 6 Additional Database Objects
Database Technical Session By: Prof. Adarsh Patel.
13 Other Database Objects Important Legal Notice:  Materials on this lecture are from a book titled “Oracle Education” by Kochhar, Gravina, and Nathan.
Objectives After completing this lesson, you should be able to do the following: Categorize the main database objects Review the table structure List.
Copyright © 2004, Oracle. All rights reserved. Lecture 3: Creating Other Schema Objects Lecture 3: Creating Other Schema Objects ORACLE.
12 Copyright © Oracle Corporation, All rights reserved. Other Database Objects.
11 Copyright © 2007, Oracle. All rights reserved. Creating Other Schema Objects.
Chapter 6 Additional Database Objects Oracle 10g: SQL.
Chapter 6 Database Administration
Lecture 2: Using DDL Statements to Create and Manage Tables & Indexes
10 Creating and Managing Tables Objectives At the end of this lesson, you will be able to: Describe the main database objects Create tables Describe.
11 Copyright © Oracle Corporation, All rights reserved. Creating Views.
10-1 Copyright  Oracle Corporation, All rights reserved. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns.
Database Programming Sections 11 & 12 – Creating, and Managing Views, Sequences, Indexes, and Synonymns.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
Chapter 2 Views. Objectives ◦ Create simple and complex views ◦ Creating a view with a check constraint ◦ Retrieve data from views ◦ Data manipulation.
Database Programming Sections 11 & 12 –Sequences, Indexes, and Synonymns.
© 2009 Punjab University College of Information Technology (PUCIT) September 8, 2009 Slide 1 (SQL) Other Database Objects Asif Sohail University of the.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
Copyright © 2004, Oracle. All rights reserved. Lecture 2: Using DDL Statements to Create and Manage Tables & Indexes ORACLE.
Session 1 Module 1: Introduction to Data Integrity
Chapter 4 Indexes. Indexes Logically represents subsets of data from one or more tables View Generates numeric valuesSequence Basic unit of storage; composed.
Altering Tables and Constraints Database Systems Objectives Add and modify columns. Add, enable, disable, or remove constraints. Drop a table. Remove.
Creating Indexes on Tables An index provides quick access to data in a table, based on the values in specified columns. A table can have more than one.
Creating and Managing Tables 14. ObjectivesObjectives After completing this lesson, you should be able to do the following: After completing this lesson,
Database Programming Sections 12 – Sequences, Indexes, and Synonymns.
Chapter 12Introduction to Oracle9i: SQL1 Chapter 12 Additional Database Objects.
Chapter Fourteen INDEX and SYNONYM Dr. Chitsaz Objectives: Create and maintain Indexes Types and applications of Indexes Create Synonym Application of.
1 Database Fundamentals Introduction to SQL. 2 SQL Overview Structured Query Language The standard for relational database management systems (RDBMS)
8 Copyright © 2005, Oracle. All rights reserved. Managing Schema Objects.
Creating Indexes Database Systems Objectives Distinguish between the indexes that are created automatically and those that are created manually.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
Fundamentals of DBMS Notes-1.
Controlling User Access
Objectives User access Create users Create roles
TABLES AND INDEXES Ashima Wadhwa.
Controlling User Access
Indexes By Adrienne Watt.
SQL Creating and Managing Tables
Creating Other Schema Objects
Other Database Objects
SQL Creating and Managing Tables
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Creating Other Schema Objects
SQL Creating and Managing Tables
Chapter 5 Sequences.
Ch 3 Synonym.
Managing Schema Objects
Ch 3 Synonym.
Chapter 4 Indexes.
CH 4 Indexes.
Chapter 2 Views.
A Guide to SQL, Eighth Edition
Chapter 2 Views.
Ch 3 Synonym.
Contents Preface I Introduction Lesson Objectives I-2
IST 318 Database Administration
Chapter 3 Synonym.
Other Database Objects
Presentation transcript:

CH 4 Indexes

Indexes Object Description Table Basic unit of storage; composed of rows View Logically represents subsets of data from one or more tables Sequence Generates numeric values Index Improves the performance of some queries Synonym Gives alternative names to objects Oracle Database 11g: SQL Fundamentals I 11 - 2

Indexes An index: Is a schema object Can be used by the Oracle server to speed up the retrieval of rows by using a pointer If you do not have an index on the column, then a full table scan occurs. Can reduce disk input/output (I/O) by using a rapid path access method to locate data quickly Is independent of the table that it indexes This means that they can be created or dropped at any time, and have no effect on the base tables or other indexes. Is used and maintained automatically by the Oracle server When you drop a table, the corresponding indexes are also dropped. Oracle Database 11g: SQL Fundamentals I 11 - 3

How Are Indexes Created? Automatically: A unique index is created automatically when you define a PRIMARY KEY or UNIQUE constraint in a table definition. Manually: Users can create nonunique indexes on columns to speed up access to the rows. You can manually create a unique index, but it is recommended that you create a unique constraint, which implicitly creates a unique index. Oracle Database 11g: SQL Fundamentals I 11 - 4

Creating an Index Create an index on one or more columns: Specify UNIQUE to indicate that the value of the column (or columns) upon which the index is based must be unique. Alternatively, you can define UNIQUE integrity constraints on the desired columns Improve the speed of query access to the LAST_NAME column in the EMPLOYEES table: CREATE [UNIQUE] INDEX indexName ON table (column[, column]...); CREATE INDEX emp_last_name_idx ON employees(last_name); Oracle Database 11g: SQL Fundamentals I 11 - 5

Index Creation Guidelines Create an index when: A column contains a wide range of values A column contains a large number of null values One or more columns are frequently used together in a WHERE clause or a join condition The table is large and most queries are expected to retrieve less than 2% to 4% of the rows in the table Do not create an index when: The columns are not often used as a condition in the query The table is small or most queries are expected to retrieve more than 2% to 4% of the rows in the table The table is updated frequently The indexed columns are referenced as part of an expression Oracle Database 11g: SQL Fundamentals I 11 - 6

More Is Not Always Better Having more indexes on a table does not produce faster queries. Each DML operation that is committed on a table with indexes means that the indexes must be updated. The more indexes that you have associated with a table, the more effort the Oracle server must make to update all the indexes after a DML operation.

Removing an Index Remove an index from the data dictionary by using the DROP INDEX command: Remove the emp_last_name_idx index To drop an index, you must be the owner of the index or have the DROP ANY INDEX privilege. You cannot modify indexes. To change an index, you must drop it and then re-create it. DROP INDEX indexName; DROP INDEX emp_last_name_idx; Oracle Database 11g: SQL Fundamentals I 11 - 8