Using Indexes
Another way, besides views, to present data in a different format than it physically exists on the disk is to use an index. In addition, indexes can also reorder the data stored on the disk (something views cannot do).
Indexes are used in a SQL database for three primary reasons:
To enforce referential integrity constraints by using the UNIQUE or PRIMARY KEY keywords
To facilitate the ordering of data based on the contents of the index's field or fields
To optimize the execution speed of queries
What Are Indexes?
Data can be retrieved from a database using two methods. The first method, often called the Sequential Access Method, requires SQL to go through each record looking for a match. This search method is inefficient, but it is ...
Get Sams Teach Yourself SQL in 21 Days, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.