In: Computer Science
The application of syntax analysis techniques in query processing system such as SQL plays an important role in ensuring if the syntax of the query is correct.
The syntax analyser is accepting query from users, parsing it into the tokens and then analysing tokens to ensure they comply with all the necessary rules. If any error is detected in query that is submitted, it is rejected and an error code is shown as per the specific error in the query.
Now the question is how the errors are detected!
Errors are detected by the syntax analyser by comparing the input query with the standard query rules as shown below:
QUERY: | SELECT_CLAUSE + FROM_CLAUSE + WHERE_CLAUSE |
SELECT_CLAUSE: | ‘SELECT’ + <COLUMN_LIST> |
FROM_CLAUSE : | ‘FROM’ + <TABLE_LIST> |
WHERE_CLAUSE : | ‘WHERE’ + VALUE1 OP VALUE2 |
VALUE1: | VALUE / COLUMN_NAME |
VALUE2: | VALUE / COLUMN_NAME |
OP: | +, -, /, * = |
In this way, errors are detected in the syntax analysis phase and then proper steps are taken to correct those errors accordingly.