表数据操作(插入数据、修改数据、删除数据)
p79-p85
#1.【例5.1】向student1表插入一條記錄('196001','董明霞','女','1999-05-02','通信’,50)
use stusys;
create table student1 like student;
insert into student1
?values ('196001','董明霞','女','1999-05-02','通信','50');
select * from student1;
?#2.【例5.2】向student1表插入一條記錄,學號為“196002”,姓名為“李茜”,專業(yè)為“通信”,總學分48,性別為“女”,出生日期為“1998-07-25”
use stusys;
insert into student1 (sno,sname,specially,tc,ssex,birthday)
?values('196002','李茜','通信',48,'女','1998-07-25');
? ? select * from student1;
?#3.【例5.3】向student1表插入一條記錄,學號為“196004”,姓名為“周俊文”,性別為“男”、取默認值,出生日期為“1998-03-10”,專業(yè)為空值,總學分為52
use stusys;
?insert into student1(sno,sname,ssex,birthday,specially,tc)
? values('196004','周俊文','男','1998-03-10',null,52);
? ? ? ? select * from student1;
?#4.【例5.4】向student1表插入樣本數(shù)據(jù),共6條記錄
insert ignore into student1
?select * from student;
? ??
? ? select * from student1;
?#5.【例5.5】對student1表,重新插入記錄('196002','李茜','女','1998-07-25','通信’,48)
use stusys;
replace into student1
?values('196002','李茜','女','1998-07-25','通信','48');
?#6.【例5.6】向student2表插入student表的記錄
create table student2 like student;
insert into student2
?select * from student;
? ??
? ? select * from student2;
?#7.【例5.7】在student1表中,將學生周俊文的出生日期改為“1999-03-10”
use stusys;
?set sql_safe_updates=0;
? ? update student1
? set birthday='1999-03-10'
? ? ? ? where sname='周俊文';
select * from student1;
?#8.?【例5.8】在student1表中,將所有學生的學分增加2分
use stusys;
update student1
?set tc=tc+2;
select * from student1;
?#9.?【例5.9】在student1表中,刪除學號為196004的行
use stusys;
delete from student1
?where sno='196004';
select * from student1;
?#10.【例5.10】在student1表中,刪除所有行?
delete from student1;
select * from student1;
#11.【例5.11】在student2表中,刪除所有行
delete from student2;
select * from student2;
?
?
總結(jié)
以上是生活随笔為你收集整理的表数据操作(插入数据、修改数据、删除数据)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [工程经验] 机器人的控制方式与操作模式
- 下一篇: 三菱PLC程序 三菱F5U 系列PLC程