MySQL关于表数据相关操作

一楼代码小宝宝来了都会做了

create database stusys;
use stusys;
create table student
(
    sno char(6) not null primary key comment '学号',
    sname char(8) not null comment '姓名',
    ssex char(20) not null default '男' comment '性别',
    sbirthdat date not null comment '出生日期',
    speciality char(12) null comment '专业',
    tc tinyint null comment  '总学分'
);

create table student1 like student;
desc student1;
insert into student1
 values
  ('196001','董明霞','女','1999-05-02','通信',50);
select *from student1;
insert into student1 (sno,sname,speciality,tc,ssex,sbirthdat)
 values
  ('196002','李茜','通信','48','女','1998-07-25');
select *from student1;
insert into student1 (sno,sname,sbirthdat,tc)
 values
  ('196004','周俊文','1998-03-10',52);

select *from student;
replace into student1
 values
  ('196002','李茜','女','1998-07-25','通信',48);
create table student2 like student;
insert into student2
select *from student;
select *from student2;

use stusys;
#安全模式更新;
set sql_safe_updates=0;
update student1
set sbirthdat ='1999-03-10'
    where sname ='周俊文';
select *from student1;
select *from student;
update student1
 set tc = tc+2;
select *from student1;
delete from student1
 where sno='196004';
delete from student1;
truncate student;
select *from student;

底楼效果图

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值