Indexes and Views in MySql

INDEX
        Indexes are used to find rows with specific column values quickly. Without an index, MySQL must begin with the first row and then read through the entire table to find the relevant rows. The larger the table, the more this costs. If the table has an index for the columns in question, MySQL can quickly determine the position to seek to in the middle of the data file without having to look at all the data.

Simple Index:An index created on a single column of a table.
Syntax: create INDEX index_name ON tablename;
Composite Index:An index created on more than one column of a table .
Syntax: create INDEX index_name ON tablename(column_name,column_name);


Simple Unique Index:
Same as simple ixdex but key must be unique.
Composite Unique Index:Same as composit index but key must be unique.

DELETE INDEX:
        drop INDEX index_name ON table_name;



VIEW:

        create VIEW view_name AS select * from table_name;

        create VIEW view_name AS select column_name1,column_name2 from table_name ORDER BY column_name='expression'';

Comments

Popular posts from this blog

Error : DependencyManagement.dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: com.adobe.aem:uber-jar:jar:apis -> version 6.3.0 vs 6.4.0

Operators in Asterisk with Linux

ERROR Exception while handling event Sitecore.Eventing.Remote.PublishEndRemoteEventException: System.AggregateExceptionMessage: One or more exceptions occurred while processing the subscribers to the 'publish:end:remote'