1014课后作业

1、创建 产品信息表(产品编号, 产品名称, 生产日期, 销售价格) 主键:产品编号
方式一:先建表,再设置主键

create table product_info 
(
  product_id   varchar2(10) 
 ,product_name varchar2(100)
 ,made_date    date
 ,price        number(10) 
);
alter table product_info add constraint pk_product_info primary key(product_id);

方式二:建表时,直接设置主键

create table product_info 
(
  product_id   varchar2(10) primary key 
 ,product_name varchar2(100)
 ,made_date    date
 ,price        number(10) 
);

2、往 1 中创建的表插入数据

insert into product_info 
values('p1234','苹果14手机',to_date('20221013','yyyymmdd'),9000);

insert into product_info 
values('p1235','huawei-p50',to_date('20221013','yyyymmdd'),9000);

commit;

3、修改产品信息表

update product_info t 
set t.price = 1000
where t.product_id = 'p1235';

commit;

4、删除表中的数据

delete from product_info t 
where t.product_id = 'p1234';

commit;

select * from product_info;

5、emp 表练习
查询出30部门中工资大于1500的员工的工号,姓名,工资,部门编号

select t.empno
      ,t.ename
      ,t.sal 
      ,t.deptno
from emp t 
where t.deptno = 30 
      and t.sal > 1500;

查询 salesman 这个岗位中,入职日期早于1982年1月1号的员工的工号,姓名,岗位名称,入职日期

select t.empno
      ,t.ename
      ,t.job
      ,t.hiredate
from emp t 
where t.job = 'salesman'
      and t.hiredate < to_date('19820101','yyyymmdd');

找出30部门中入职日期早于1982年1月1号的员工的所有信息或者岗位是 manager 的员工中工资大于2900 的员工的所有信息

select t.empno
      ,t.ename
      ,t.job
      ,t.mgr
      ,t.hiredate
      ,t.sal
      ,t.comm
      ,t.deptno
from emp t 
where (t.deptno = 30 and t.hiredate <  to_date('19820101','yyyymmdd'))
      or (t.job = 'manager' and t.sal > 2900);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

只会HelloWorld的华娃

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值