A simple parser for sql made using lex yacc / GNU's flex bison.
It currently supports only selected sql queries as stated below.
- go to source folder
cd src maketo build : this will generate the usual files and executes the executable file
- queries are
case-insensitive - each query ends with
semicolon - keywords cant be identifiers
UPDATE table_reference SET assignment_list [WHERE where_condition] [ORDER BY ...] [LIMIT row_count]
-
update customer set bonus = 1000; update customer set bonus = 1000, gst = 200; update customer set bonus = 1000, gst = 200, bonus_type = 'Diwali'; update customer set bonus = 1000, gst = 200, bonus_type = 'Diwali', extra = bonus + 200; update customer set bonus = 1000, gst = 2 * 10 ; update customer set bonus = 1000, gst = 2 * 5 + 5 - 10 / 2; -
update customer set bonus = 1000, gst = 20 where bonus_type = 'Diwali'; update customer set bonus = 1000, gst = 20 where bonus_type = 'Diwali' and salary >= 40000; update customer set bonus = 1000, gst = 20 where bonus_type = 'Diwali' and salary >= 40000 or salary <= 20000; update customer set bonus = 1000, gst = 20 where bonus_type = 'Diwali' and salary between 40000 and 20000; -
update customer set bonus = 1000, gst = 20 order by cid; update customer set bonus = 1000, gst = 20 order by cid asc, salary desc; -
update customer set bonus = 1000, gst = 20 limit 10; -
update customer set bonus = 1000, gst = 20 where bonus_type = 'Diwali' and salary >= 40000 or salary <= 20000 order by cid desc limit 5;
-
update items,month set items.price=month.price where items.id = month.id;
-
Lex Yacc Introduction
-
Lex yacc primer
-
Bison manual references