SQL语句的进一步使用

练习二


1# 修改emp表中sal字段为salary
alter table emp change sal salary double;
2# 查找年薪在20000到30000之间的所有员工信息并按照
工资降序显示
select * from emp where salary between 20000 and 30000 order by salary desc;
3# 查找员工姓名中包含'A'的所有员工信息
select * from emp where ENAME like "%A%";
4# 查找所有员工姓名中包含'A'及'E'的员工信息
select * from emp where ENAME like "%A%" and ENAME like "%E%";
5# 查找所有的职位为SALESMAN的员工信息
select * from emp where JOB like "%SALESMAN%";
6# 将工资低于2000的员工工资涨薪200
update emp set salary=salary+200 where salary < 2000;
7# 查询没有上级领导的所有员工信息
select * from emp where MGR is null;
8# 查询没有奖金的所有员工信息
select * from emp where COMM is null;
9# 将部门表中的40部门的地址修改成'xian'
update emp set JOB = "xian" where DEPTNO = 40;
10# 假设李华的工资是2000,请查询出他的工资等级
select GRADE from salgrade where HISAL = 2000;
11# 将MILLER的入职日期修改为1982年2月23日
update emp set HIREDATE = 19820223 where ENAME = "MILLER";

练习三


1# 写一条SQL查询语句,找出所有属于"Electronics"类别的产品信息。
select * from products where category like "%Electronics%";
2# 写一条SQL查询语句,找出价格高于等于100.00的产品信息。
select * from products where price >=100.00;
3# 写一条SQL查询语句,找出价格在20.00到1000.00之间的产品信息。
select * from products where price between 20.00 and 1000.00;
4# 对于"products"表,有一个新的需求:将"category"列改名为"product_category"
alter table products change category product_category varchar(14);
5# 将"price"列的数据类型从DECIMAL(10, 2)改为 DECIMAL(12, 2)。请提供相应的SQL语句来执行这些修改。
alter table products modify price DECIMAL(12,2);
6# 对于"products"表,又有一个新的需求:由于某些原因,我们不再销售名为"Laptop"的产品,需要从表中删除该记录。

7#请提供一条SQL删除语句来执行此操作。
delete from products where product_name="LAPTOP";
8# 写一条SQL查询语句,找出商品名称包含字母"e"的商品信息。
select * from products where product_name like "%e%";
9# 如果要购买10个Mouse,请显示出最终的价格。
select price*10 from products where product_name="Mouse";
10# 将商品的名字,商品的类别全部转换成小写形式并展示所有信息。
select lower(product_name),lower(product_category) from products;
11# 将商品类别和名称拼接起来并显示其余的信息。比如:Elctronics-Mouse
select product_id,concat(product_category, product_name),price from products;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值