1. Column Attributes (列属性)
2. Inserting a Row (插入单行)
- 按原表顺序插入一行,并对not null的字段进行赋值
- 明确字段再赋值,字段顺序不用遵循原表 (不可缺值的字段一定要赋值)
3. Inserting Mulitiple Rows(插入多行)
🌰结果:
4.Inserting hierarchical Rows (插入分层行)
🌰: orders是母表,order_items是子表,2张表互相关联
last_insert_id():mysql内置的function,表示获取最新插入的id
5. Creating a Copy of Table (创建表复制)
create table...as...
此种方法copy出来的表不带主键等信息。
6. Update a Single Row (更新单行)
7. Update Multiple Rows
8. Using Subqueries in Updates(在Update中使用子查询)
🌰中:此处子查询中points>3000查出来的customer_id 有多个,因此where customer_id 后不能用=,而应该用in
9. Deleting Rows(删除行)
🌰中也用了子查询