去皮卡多 发表于 2025-4-7 11:07:32

数据库教学案例二 数据表中数据的插入、修改和删除

第1关:数据表中插入一条记录,对所有字 
use jwxt;
 #代码开始
insert into student (studentid,name,birthday,sex,nativeplace,political,interest,resume,photo) values('201221120101','王刚','1994-07-26','男','广西','团员','活动','2013年获得国家奖学金', ' ' );

 #代码结束
本关任务:在student数据表中插入一条数据
学号202312010101, 姓名李向, 出生年月2000-08-30,性别男
use jwxt;
#代码开始

 insert into student (studentid,name,birthday,sex,nativeplace,political,interest,resume,photo) values('2023120101','李向','2000-08-30','男',null,'群众',null,null,null);

 #代码结束
 select * from student;
第3关 数据表中插入多条记录,对指定字段赋值

 use jwxt;
 #代码开始
insert into student (studentid,name,birthday,sex,nativeplace,political,interest,resume,photo) values('201221120103','何丽洁','1994-08-30','女','辽宁','群众',null,null,null),('201221120105','彭悦','1993-08-19','男','湖南','群众',null,null,null),('201221120107','杨波','1994-02-20','男','山东','群众',null,null,null);
 #代码结束
 select * from student;
第4关 在数据表中修改单条数据记录的单个字段的值​​​​​​
 use jwxt;
#代码开始
update course
set credit=3
where coursename='盘算机概论';

 #代码结束
 select * from course;
第5关 在数据表中修改单条记录的多个字段的值
 use jwxt;
 #代码开始
 update course set period=16,credit=1 where coursename='英美文学';
 #代码结束
 select * from course;
第6关 修改数据表的多条记录
use jwxt;
#代码开始
update course set period=period+5 where required = '1';
#代码结束
select * from course;
第7关 删除数据表的多条记录
 use jwxt;
 #代码开始
 delete from course where department ='新影院';
 #代码结束
 select * from course;
第8关 删除数据表的所有数据
 use jwxt;
 #代码开始
 delete from course;
 #代码结束
 select * from course;

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: 数据库教学案例二 数据表中数据的插入、修改和删除