• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Sorting Table Data

A fundamental requirement of a database development environment is the capability to sort records quickly so that they appear in the desired sequence. Early desktop database managers required you to create a new copy of a table if you physically wanted to sort the table's records in a new order. Creating and specifying an index on a field let you display or print the table in the desired order. If you wanted to sort the data by two or more fields, however, you had to create a composite index on the fields, or presort the data in the order of one or more fields and then apply the single-field index.

Modern desktop database development systems, such as Access, never require you to physically sort the table. Instead, the physical location of the records in the file is the order in which the records were entered. By default, Access displays records in the order of the primary key. If your table doesn't have a primary key, the records display in the order in which you enter them. Unlike dBASE and its clones, you cannot choose a specific Access index to alter the order in which the records display in Table Datasheet view of the user interface (UI). You can, however, specify an index to speed retrieval of records of tables you manipulate with VBA code. Access uses sorting methods to display records in the desired order. If an index exists on the field in which you sort the records, the sorting process is much quicker. Access automatically uses indexes, if indexes exist, to speed the sort in a process called query optimization. Access's indexes and query optimization methods are discussed in Chapter 22, "Exploring Relational Database Design and Implementation."


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint