


Parsing an SQL statement does not require access to the database and can be done very quickly. The steps used to process an SQL statement vary in the amount of database access they require and the amount of time they take. The DBMS executes the statement by running the access plan. Can an index be used to speed a search? Should the DBMS first apply a search condition to Table A and then join it to Table B, or should it begin with the join and use the search condition afterward? Can a sequential search through a table be avoided or reduced to a subset of the table? After exploring the alternatives, the DBMS chooses one of them. It explores various ways to carry out the access plan. The access plan is a binary representation of the steps that are required to carry out the statement it is the DBMS equivalent of executable code. The DBMS generates an access plan for the statement. Do all the tables named in the statement exist in the database? Do all of the columns exist and are the column names unambiguous? Does the user have the required privileges to execute the statement? Certain semantic errors can be detected in this step.

It checks the statement against the system catalog. Syntax errors and misspellings can be detected in this step. It breaks the statement up into individual words, called tokens, makes sure that the statement has a valid verb and valid clauses, and so on. To process an SQL statement, a DBMS performs the following five steps: The following illustration shows the steps involved in processing an SQL statement, which are discussed throughout the rest of this section. The steps involved are common to all three techniques, although each technique performs them at different times. Before discussing the techniques for using SQL programmatically, it is necessary to discuss how an SQL statement is processed.
