java-(Oracle)-Oracle,plsqldev,Sql语法,Oracle函数

卸载好注册表,然后安装11g

每次在执行orderby的时候相当于是做了全排序,思考全排序的效率
会比较耗费系统的资源,因此选择在业务不太繁忙的时候进行

sql 复制代码
--给表添加注释
comment on table emp is '雇员表'
--给列添加注释;
comment on column emp.empno is '雇员工号';

select empno,ename,job
from emp
where deptno=10;

select distinct deptno from emp;

select e.empno 雇员编号,e.ename 雇员名称,e.job 雇员工作
from emp e
where e.deptno=10;

在sql中的null值必须要用is和is not来判断
between
exists
nvl(arg1,arg2),如何arg1是空,则返回arg2,如果arg1不为空,则返回arg1
dual是oracle数据库中的一张虚拟表,没有实际的数据,可以用来做测试

sql 复制代码
/*
--给表添加注释
comment on table emp is '雇员表'
--给列添加注释;
comment on column emp.empno is '雇员工号';

select empno,ename,job
from emp
where deptno=10;

select distinct deptno from emp;

select e.empno 雇员编号,e.ename 雇员名称,e.job 雇员工作
from emp e
where e.deptno=10;
*/
select * from emp where deptno <>20;
select sal from emp where sal> any(1000,1500,3000);
select sal from emp where sal> some(1000,1500,3000);
select sal from emp where sal> all(1000,1500,3000);

select * from emp where comm is null;
select * from emp where comm  is not null;
select * from emp where sal between 1500 and 3000;
select * from emp where deptno in(10,20);
select * from emp where deptno =10 or deptno= 20;
--and的优先级高于or
select *
from emp e
where exists(select deptno
                    from dept d
                    where (d.deptno=10 or d.deptno=20) and 
                    e.deptno=d.deptno)
select * from emp where ename like('S%');
select * from emp where ename like('S%T_');
select * from emp where ename like('%\%%')escape('\');
--escape转义字符
select * from emp where ename like('JO%');
select * from emp order by sal;
select * from emp order by sal desc;
select * from emp order by sal desc ,ename asc;

--计算字段
select 'my name is'||ename  from emp;
select concat('my name is',ename) from emp;
select ename,(e.sal+nvl(e.comm,0))*12 from emp e
select 100+null from dual
--并集union
--全集 union all
select * from emp where ename like('S%') minus
select * from emp where sal between 300 and 2000;

函数

组函数又称为聚合函数
输入多个值,最终只会返回一个值

sql 复制代码
select sum(sal) from emp;
select count(*) from emp;
select initcap(ename) from emp;
select upper(ename) from emp;
select lower(ename )from emp;
select lpad(ename,10,'*')from emp;
select rpad(ename,10,'*')from emp;
select trim(ename) from emp;
select ltrim(ename) from emp;
select rtrim(ename) from emp;
select instr(ename,'A') from emp;
select length(ename) from emp;
select substr(ename,0,2)from emp;
select replace('abcdefg','ab','hehe')from emp;
select round(123.129,2) from dual;
select trunc(123.128,2) from dual;
select mod(10,4)from dual;
select ceil(10.555)from dual;
select floor(1255.222)from dual;
相关推荐
马尔代夫哈哈哈3 小时前
Spring IoC&DI
数据库·sql
液态不合群5 小时前
[特殊字符] MySQL 覆盖索引详解
数据库·mysql
计算机毕设VX:Fegn08956 小时前
计算机毕业设计|基于springboot + vue蛋糕店管理系统(源码+数据库+文档)
数据库·vue.js·spring boot·后端·课程设计
瀚高PG实验室6 小时前
PostgreSQL到HighgoDB数据迁移
数据库·postgresql·瀚高数据库
打码人的日常分享6 小时前
智能制造数字化工厂解决方案
数据库·安全·web安全·云计算·制造
三水不滴6 小时前
Redis 过期删除与内存淘汰机制
数据库·经验分享·redis·笔记·后端·缓存
-孤存-7 小时前
MyBatis数据库配置与SQL操作全解析
数据库·mybatis
2301_822366358 小时前
使用Scikit-learn构建你的第一个机器学习模型
jvm·数据库·python
万邦科技Lafite9 小时前
一键获取京东商品评论信息,item_reviewAPI接口指南
java·服务器·数据库·开放api·淘宝开放平台·京东开放平台
自可乐9 小时前
Milvus向量数据库/RAG基础设施学习教程
数据库·人工智能·python·milvus