create view and indexes
1
- Chapter 10 -
Creating Views and Indexes
Objectives
ToChapter we begin to cover topics that may be new even to programmers or database users who have already had some exposure to SQL.
Days 1 through 8 covered nearly all the introductory material you need to get started using SQL and relational databases. Chapter 9,
"Creating and Manipulating Tables," was devoted to a discussion of database design, table creation, and other data manipulation commands.
The common feature of the objects discussed so far--databases, tables, records, and fields--is that they are all physical objects located on a
hard disk. ToChapter the focus shifts to two features of SQL that enable you to view or present data in a different format than it appears on
the disk. These two features are the view and the index. By the end of today, you will know the following:
• How to distinguish between indexes and views
• How to create views
• How to create indexes
• How to modify data using views
• What indexes do
A view is often referred to as a virtual table. Views are created by using the CREATE VIEW statement. After the view has been created, you
can use the following SQL commands to refer to that view:
•
SELECT
•
INSERT
•
INPUT
• UPDATE
• DELETE
An index is another way of presenting data differently than it appears on the disk. Special types of indexes reorder the record's physical
location within a table. Indexes can be created on a column within a table or on a combination of columns within a table. When an index is
used, the data is presented to the user in a sorted order, which you can control with the CREATE INDEX statement. You can usually gain
substantial performance improvements by indexing on the correct fields, particularly fields that are being joined between tables.
NOTE: Views and indexes are two totally different objects, but they have one thing in common: They are both associated with a
table in the database. Although each object's association with a table