sql基础语句
Posted lucky_light
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql基础语句相关的知识,希望对你有一定的参考价值。
mysql workbench
create table s(`s#` int, `sname` char(8), `grade` int, primary key(`s#`)); #不知道为什么需要 ``, 居然因为是有了 #, 表示了注释,系统有点蒙
alter table s add address char(10); #这个就不需要``括起来了
alter table s drop address;
改正:
create table s(id_s char(10), name_s char(10), grade_s float, adress char(10),
primary key(id_s)
);
alter table s add age_s int;
alter table s drop adress;
insert into s(id_s, name_s, grade_s, age_s)
values (‘001‘, ‘xiaoming‘, 90, 18),
(‘002‘, ‘xiaogang‘, 69, 17),
(‘003‘, ‘xiaohua‘ , 85, 19),
(‘004‘, ‘xiaomi‘ , 55, 19),
(‘005‘, ‘xiaofa‘ , 65, 29);
select *
from s;
delete from s
where (grade_s < 60 or age_s < 12 or age_s > 20) and id_s != ‘000‘;
select *
from s
where id_s > 0;
update s
set grade_s = grade_s * 1.09 #, id_s = id_s
where grade_s < 60 and id_s != ‘0‘;
drop table s;
以上是关于sql基础语句的主要内容,如果未能解决你的问题,请参考以下文章