2.数据库-第二章数据库数据管理
文章目录
- 2.数据库-第二章数据库数据管理
- DML
- 1.新增:
- 2.修改:
- 3.删除:
DML
1.新增:
insert into 表名[(列1,列2…)]values(值1,值2)
当出现多条插入时 使用逗号,隔开
inser into grade(GradeName) values("S1");
insert into student(LoginPwd,StudentName,Sex,
GradeId,Phone,BornDate,IdentityCard) value("123456","王士第",2,2,"15720201222","1999-0208 11:11:11",1111111133333333),(123456,"王诚如",2,2,"15720201222","1999-0208 11:11:11",1111111122222222)
2.修改:
update 表名 set 列1=值1,列2=值2…[where条件]
#修改
#update 表名 set 列1=值1,列2=值2...[where条件]
update student set loginPwd = "123456",Sex = 2
where StudentName = "王诚如";#修改学号为1006的C语言-3考试成绩
#要求成绩+20分update result set Studentresult = studentResult+20
where StudentNo = 1006 and SubjectNo = 7;#将数据表subject中ClassHour大于110
#且GradeID为1的课时都减少10
update `subject` set ClassHour = ClassHour-10
where ClassHour>110 and GradeID = 1;
3.删除:
delete from 表明[where条件]
delete from student where StudentNo = 10066;
elete from student where StudentNo = 10066;