数据库
首页 > 数据库> > SQL数据更新

SQL数据更新

作者:互联网

数据更新

注意的问题
修改数据upadte与修改基本表alter
删除数据delete与删除基本表drop

插入数据

insert
into s
values ('04050','张三', '男', '1997/10/01','信息');

全部指定属性列名:属性列顺序可自定

insert
into s(sno,college,sname,ssex,sbirth)
values ('04050','信息', '张三', '男','1997/10/01');

指定部分属性列:插入的元组在其余属性列上取空值

insert
into s(sno,college,sname)
values ('04050','信息', '张三');
insert
into college_avg_age(college,avgage)
select college,avg(2021-year(sbirth)) 
from s
group by college;

修改数据

update sc
set grade=100 
where college='信息');
update sc
set grade=100 
where sno in
    (select sno
     from s
     where college='信息');

删除数据

delete
from s
where sno=‘04009’;
delete 
from sc
where sno in
(select sno
from s
where college=‘ ’);

标签:sno,into,更新,where,college,SQL,数据,属性
来源: https://blog.csdn.net/jhin_lx/article/details/122147271