---------- 基本查询
DDL:数据库定义语言 :create 、 drop
DML:数据库的操作语言 :insert、update、delete
DQL:数据库的查询语言:select
DCL:数据库的控制语言 :grant 、revoke
-- 基本查询
--全表查询
select*from emp;
--别名【一般都不用中文,如果是数字用双引号套起来,别名不能单引号】
select empno as员工编号,ename 员工姓名,sal "月薪",comm "123" ,hiredate "入职日期" from emp;
-- 四则运算
--查询员工的年薪
select empno,ename,sal*12as年薪 from emp;
--查询员工的年收入
-- 空值处理: nvl(v1,p1) 当v1等于空的时候,显示p1的值
select empno,ename,(sal*12)+nvl(comm,0)as年收入 from emp;
--字符串拼接
--dual 伪表:假的表,不存在的表,主要为了语法补全
-- concat只能有两个参数,拼接的两个字符串
selectconcat(concat('a','b'),'c') from dual;
-- 在oracle中使用 || 拼接
select'a'||'b'||'c'||'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' from dual;
--去重
selectdistinct job from emp;
-- 一般不这样玩
selectdistinct ename,job from emp;
-- 空值:空值永远不等于空
select*from emp where comm isnull;
-- 空值:空值永远不等于空
select*from emp where comm isnotnull;
select*from emp where comm =null;-- 不要用等于号
select*from emp where comm >0;--可以去空