数据新增insert命令有两种形式
1 单一数据新增:
Inset into 表名 [(列名[,列名]...)]
Values (值[,值]...);
这种形式可以向数据库中插入一条数据,也可以利用这种形式在数据库中插入多条黄数据;
Inset into 表名 [(列名[,列名]...)]
Values (值[,值]...),(值[,值]...),(值[,值]...),(值[,值]...)...;
2 批量数据新增:
插入子查询结果中的若干条数据,待插入的数据由子查询给出;
Inset into 表名 [(列名[,列名]...)]
子查询;
示例:
新建table:st(student_id,student_name),将查询到的姓张的同学添加到该表中
INSERT INTO st (student_id, student_name) SELECT
student_id,
student_name
FROM
student
WHERE
student_name LIKE '张%' ;
注意:当新增数据时,DBMS会检查用户定义的完整性约束条件,如不符合完整性约束条件,则将不会执行新增动作。