首先选择stusys数据库
desc student
create table student1
(
sno char(6) not null primary key comment '学号',
sname char(8) not null comment '姓名',
ssex char(2) not null default '男' comment '性别',
sbirthday date not null comment '出生日期',
speciality char(12) null comment '专业',
tc tinyint null comment '总学分'
);
这里的student1已经存在。
insert into student1
values
('196002','李茜','通信','1998-07-25','女',48);
insert into student1
values
('196004','周俊文',' ','1998-03-10',' ',52);
(这里显示重复插入)
insert into student
values
('191001','刘秀泉','男','1988-06-21','计算机',52),
('191002','张慧玲','女','1999-11-07','计算机',50),
('191003','冯涛','男','1999-08-12','计算机',52),
('196001','董明霞','女','1999-06-02','通信',50),
('196002','李茜','女','1998-07-25','通信',48),
('196004','周俊文','男','1998-03-10','通信',52);
通过上图可知数据已经被插入表格中。
replace into student1
values
('196002','李茜','女','1988-07-25','通信',48)
由上图可知student2已经存在。
delete from student1
where sno='196004';
truncate student
insert into student2
select * from student2;