Index (learning notes), index learning notes

Source: Internet
Author: User

Index (learning notes), index learning notes

The tablespace can be omitted.

B-Tree Index

Reverse Key Index

Function Index

Bitmap Index

Delete Index

 

B-Tree Index

Example 1,Create a table and use the PL/SQL data generator to import 0.1 million records

-- Create table depositor (actid INTEGER not null, identify INTEGER not null, lastname VARCHAR2 (10) not null, firstname VARCHAR2 (10) not null, address1 VARCHAR2 (200) not null, address2 VARCHAR2 (200), address3 VARCHAR2 (200), account NUMBER () not null, constraint PK_DEPOSITOR primary key (actid); -- Query SELECT * FROM depositor;

Use a data generator to import 0.1 million records

Execute query in explain Plan window

select identify  from depositor WHERE identify BETWEEN 10000 AND 30000;

273 of system resources consumed

Add an index for the identify column

 

CREATE INDEX deptor_index ON depositor(identify) TABLESPACE tbs_test;

 

Execute the query again in the explain Plan window.

Consumption has decreased significantly

Example 2: Create a composite index

-- No composite index query SELECT d. identify FROM depositor d WHERE d. identify> 5000 AND d. actid> 100500;

-- Create index dp_complex_index ON depositor (identify, actid) TABLESPACE tbs_test;

Return

 Reverse Key Index

Reverse key index,

The reverse key index is mainly used in large-scale cluster systems and is updated by multiple users at the same time.

Reverse key index syntax

 

Query when no index is available

Create reverse key index

-- Create index dpt_reverse_index ON depositor (identify) reverse tablespace tbs_test;

 Return

Function Index,

 

Run the following query:

-- Query all firsetnames and convert them to all lowercase select lower (d. firstname) FROM depositor d;

Create a lower Function Index

-- Create index dpt_lowerfirstname_index ON depositor (lower (firstname) TABLESPACE tbs_test;

Execute the preceding query again

Return

Bitmap index:

 

Execute statistics Query

-- Select count (*) FROM depositor d WHERE d. firstname = 'luke ';

Create a bitmap Index

-- Create bitmap index dpt_bitmap_index ON depositor (firstname) TABLESPACE tbs_test;

 

Return

Delete Index
Drop index name

Delete the previous index

-- Delete the index drop index deptor_index; drop index dp_complex_index;

 

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.