Data Manipulation¶
Insert¶
INSERT INTO tbl_name
[(col_name,...)]
VALUES (val,...), ...
INSERT INTO tbl_name SET col_name = value, [col_name = value], ...
Where Expression¶
Support following simple expressions now only.
expr AND expr AND ...
expr:
col_name {= | > | >= | < | <= | != | <>} value
| value {= | > | >= | < | <= | != | <>} col_name
Replace¶
Select¶
SELECT {col_name | sel_expr | agg_func(col_name)} [AS as_name], ... FROM tbl_name
[WHERE expr]
[ORDER BY col_name [ASC | DESC], ...]
[LIMIT {[offset,] row_count | row_count OFFSET offset}]
sel_expr:
{val|col_name} + {val|col_name}
| {val|col_name} - {val|col_name}
| {val|col_name} * {val|col_name}
| {val|col_name} / {val|col_name}
agg_func:
COUNT({* | col_name})
| SUM(col_name)
| AVG(col_name)
| MIN(col_name)
| MAX(col_name)
Update¶
UPDATE tbl_name
SET col_name={val|set_expr}, ...
[WHERE where_expr]
[ORDER BY col_name [ASC | DESC], ...]
[LIMIT {[offset,] row_count | row_count OFFSET offset}]
set_expr:
{val|col_name} + {val|col_name}
| {val|col_name} - {val|col_name}
| {val|col_name} * {val|col_name}
| {val|col_name} / {val|col_name}
Delete¶
DELETE FROM tbl_name
[WHERE where_expr]
[ORDER BY col_name [ASC | DESC], ...]
[LIMIT {[offset,] row_count | row_count OFFSET offset}]