Here are the steps by which SQL statements are processed by the DBMS:
Step-1: Parse statement: In this step SQL statements are parsed and words are broken in to valid verb, legal clauses, etc. Syntax errors and spelling mistakes (if any) are found out. It is done in a swift manner.
Step-2: Validate statement: In this step SQL statements are validated against the system catalog for table names, columns, privileges, etc. Semantic errors (if any) are found out.
Step-3: Optimize statement: In this step SQL statements are optimized and methods are determined to find the best way to proceed with the execution of the statement. It is a slow step as many alternatives have to be checked for.
Step-4: Generate application plan: In this step an application plan is generated. Application plan is a binary executable code.
Step-5: Execute application plan: In this step the application plan is executed.