SQL语法1

-- 给表里面的某一列添加注释
comment on column emp.job is '工作';

--  DML 中的Select
-- 如果想查询表中的某一列  
select ename from emp;
-- 查询表中的多列
select empno,ename,job from  emp;
-- 将表中所有的列都查出来
select * from emp;

--给列取别名
select job "工 作" ,ename "姓名" from emp;

-- 给表取别名
select e.* from emp e;

-- 去除重复数据
--distinct 后面跟的是判断是否为重复数据的列 如果全部列重复才为重复数据 则distinct 后面加*
select distinct * from emp;

-- where 条件筛选数据
-- oracle 中判断数据是否为null 使用 is null 或者is not null
select  * from  emp where comm is null; 

-- in (list)
select ename,sal from emp where sal in (800,1250,3000,2500);
-- not in (list)
select ename,sal from emp where sal not in (800,1250,3000,2500);
-- between  and   查询一个范围内的数据
select * from emp where sal between 1500 and 3000;
-- <>  不等于
select * from emp where sal <>3000;

-- not and or

select * from emp where sal > 3000  and deptno = 10;

-- 列出来 部门为20 或者30 并且薪水大于3000 的所有员工
select * from emp where (deptno = 10 or deptno = 100)  and sal >1000;

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值