oracle函数,查询,事务

摘要:
函数包括:单行函数,多行函数(分组函数)数值函数:--绝对值selectabs(-12.3)fromdual;--向上取值selectceil(5.3)fromdual;--向下取值selectfloor(5.3)fromdual;--四舍五入selectround(123.4124,2)fromdual;--截取小数点之后selecttrunc(4252.04524,2)fromdual;--次

函数包括:单行函数,多行函数(分组函数)

数值函数:

oracle函数,查询,事务第1张oracle函数,查询,事务第2张
--绝对值
select abs(-12.3) fromdual;
--向上取值
select ceil(5.3) fromdual;
--向下取值
select floor(5.3 )fromdual;
--四舍五入
select round(123.4124,2)fromdual;
--截取小数点之后
select trunc(4252.04524,2) fromdual;
--次方
select power(2,3) fromdual;
--取余数
select mod(12.11,4) fromdual;
--开方
select sqrt(9) fromdual;
--判断正负  1为正 -1为负 0为0
select sign(-12) from dual;
View Code

字符函数:

lower(char) 将字符串转换为小写格式

upper(char) 将字符串转换为大写格式

length(char)返回字符串的长度

ltrim(char [,set]) 去掉set左端的字符串

oracle函数,查询,事务第3张oracle函数,查询,事务第4张
select ltrim('this','th') from dual
View Code
oracle函数,查询,事务第5张oracle函数,查询,事务第6张
--截取字符
select substr('hehe',3,2) fromdual;
--合并
select concat('h','e') fromdual;
--查找位置
select instr('he','h') fromdual;
--替换
select replace('he','e','h') from dual;
View Code

转换函数:

to_number() 转换为数字

select to_number('2000.02','999999D99') from dual;

to_char()将日期型转变为字符串

select to_char(sysdate,'yyyy-mm-dd') from dual;

to_date()转换为date类型

select to_date('2013-04-05','yyyy-mm-dd') from dual;

nvl(expr1,expr2) 将null转换为实际值

nvl2(expr1,expr2,expr3) 如果expr1不为null 这返回expr2,否则返回expr3

多表查询:

union :返回不重复行

union all:返回所有行

intersect :两个查询都检索到的行

minus:返回第一个查询检索到的行减去第二个查询检索到的行所剩余的行

事务:

commit:提交事务

rollback:回滚事务

savepoint a:设置保存点 整个事务部回滚

rollack to a :取消部分事务

rollack :取消全部事务

存储过程:

oracle函数,查询,事务第7张oracle函数,查询,事务第8张
-- 4部门名称和工资
create or replace procedure proc_sal(empo number)
asEname varchar2(30);
Sal number;
begin
    select scott.emp.job,scott.emp.sal into Ename,Sal from scott.emp where scott.emp.empno=empo;
    dbms_output.put_line(Ename|| ' '||Sal );
  end;
  begin
   proc_sal(7369);
   end;
View Code

免责声明:文章转载自《oracle函数,查询,事务》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇句子相似度计算方法安装pytest下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

高效的数据压缩编码方式 Protobuf

一. protocol buffers 是什么? Protocol buffers 是一种语言中立,平台无关,可扩展的序列化数据的格式,可用于通信协议,数据存储等。 Protocol buffers 在序列化数据方面,它是灵活的,高效的。相比于 XML 来说,Protocol buffers 更加小巧,更加快速,更加简单。一旦定义了要处理的数据的数据结构之...

Oracle-批量修改语句及相关知识点

问: 有两张表A和B,结构相同,数据量一致,比如都有x,y和z列且都有n行,x为主键,完全相等,如何把表B的y列的数据赋值给A的y列?   我写的是1 update A set A.y=B.y where A.x=B.x报错原因是表B未定义。  答: update A set A.y=(select yfrom B where B.x = A.x)wher...

【javaweb】库存物资管理系统思路与总结

题目: 1、有一个存放商品的仓库,每天都有商品出库和入库。 2、每种商品都有名称、生产厂家、型号、规格等。 3、出入库时必须填写出入库单据,单据包括商品名称、生产厂家、型号、 规格、数量、日期、时间、入库单位(或出库单位)名称、送货(或提货)人 姓名。 首先建立数据库goodsmanager table:goods记录商品信息 table:list记录出...

oracle 导入问题(imp)

oracle 导入问题(imp) 1.密码过期 [oracle @oracle ~]$ imp graph/graph@orcl file=/tmp/neo4j.dmp full=y; 解决方案: 使用plsql登陆,弹出窗口重新设置密码即可。 2.无导入权限 解决方案: [oracle @oracle ~]$ sqlplus '/as sysdba...

python3 爬虫之爬取安居客二手房资讯(第一版)

#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Author;Tsukasa import requests from bs4 import BeautifulSoup import pandas import time url_all = [] url_in = input('输入你所需...

C指针——C语言手记

近期敲代码的时候。发现自己非常多东西都開始忘了。 今天最终有机会好好总结一下指针。当做个笔记同一时候也希望对大家实用。假设有不对的地方。希望大家能帮我指正一下。然后我的实验环境是32位RHEL+eclipse。 一、指针基本属性 指针的属性主要包含指针的类型、指针所指向的类型、指针的值。以下以一个简单的样例为例 int *p; 指针的类型:int *...