插入记录
INSERT [INTO] table_name [(col_name,…)] {VALUES|VALUE} ({expr|DEFAULT},…),(…),…
可以插入多列
INSERT [INTO] table_name [(col_name,…)] SELECT …
将查询结果插入到指定数据表
更新记录
UPDATA [LOW_PRIORITY] [IGNORE] table_reference SET col_name1={expr1|DEFAULT} [col_name2={expr2|DEFAULT}] [WHERE where_condition]
UPDATA users SET age = age + 5;
UPDATA users SET age = age -id, sex = 0;
UPDATA users SET age = age + 10, WHERE id%2=0;
删除记录
DELETE FROM tab_name [WHERE where_condition]
查询记录
SELECT select_expr[, select_expr …]
[
FROM table_references
[WHERE where_condition]
[GROUP BY {col_name | position} [ASC | DESC], …]
[HAVING where_condition]
[ORDER BY {col_name | expr | position} [ASC | DESC], …]
[LIMIT {[offset, ]row_count | row_count OFFSET offset}]
]
SELECT username AS name // as 别名