ZT: Oracle 最常用功能函数经典汇总

开发者福利!热门AI工具限时免费用 购周边即赠Coding Plan Lite,Claude Code、Cursor等20+工具畅享,效率翻倍! 阅读详情
Oracle 最常用功能函数经典汇总
来源:ChinaITLab 收集整理
2004-6-14 10:58:00
  * SQL Group Function
*
s (num can be a column or ex

pression)          

  (null values are ign
*
ored, default between distin

ct and all is all)      

  ********************
***************
****************************

****************

  AVG([distinct or all] num)   
-- average value
  COUNT(distinct or all] num)  
-- number of values
  MAX([distinct or all
] num)   -- maximum value

  MAX([distinct or all] num)   
-- minimum value
  STDDEV([distinct or
all] num)  -- standard devi
ation
  SUM([distinct or all
] num)   -- sum of values

  VARIANCE([distinct o
r all] num) -- variance of v
alues
                                                                               
  ********************************
***********************
************************

  * Miscellaneaous Functions :  
*
                       

  ********************
***************
****************************

****************

  DECODE(expr, srch1,
return1 [,srch2, return2...]
, default]
      -- if no search matches t
he expression then the default is returned,
      -- otherwise,
the first search that match
es will cause
      -- the corres
ponding return value to be r
eturned
  DUMP(column_name [,fmt [,start_p
os [, length]]])
     -- returns an
column
internal oracle format, used

for getting info about a

     -- format options : 8 = oc
tal, 10 = decimel, 16 = hex, 17 = characters
     -- return type
codes : 1 = varchar2, 2 = n
umber, 8 = long, 12 = date,
     --  23 = raw,
24 = long raw, 69 = rowid,
96 = char, 106 = mlslabel
  GREATEST(expr [,expr2 [, expr3...]]       
     -- returns the largest val
ue of all expressions
  LEAST(expr [,expr2 [, expr3...]]             
     -- returns the
smallest value of all expre
ssions
  NVL(expr1 ,expr2                                             
     -- if expr1 is not null, i
t is returned, otherwise expr2 is returned
  SQLCODE                                                               
     -- returns sql error code
query,
of last error. Can not be used directly in

     -- value must
be set to local variable fir
st
  SQLERRM                                                               
     -- returns sql
in query,
error message of last error

. Can not be used directly

     -- value must be set to lo
cal variable first
  UID                                                                       
     -- returns the user id of
the user you are logged on as
     -- useful in s
electing information from lo
w level sys tables
  USER                                                                     
     -- returns the
user name of the user you a
re logged on as
  USERENV('option')                                           
     -- returns inf
ormation about the user you
are logged on as
     -- options : E
NTRYID, SESSIONID, TERMINAL,
LANGUAGE, LABEL, OSDBA
     --      (
all options not available in
all Oracle versions)
  VSIZE(expr)                                                       
     -- returns the number of b
ytes used by the expression
     -- useful in s
electing information about t
able space requirements
                                                                               
  ********************
***************
****************************

****************

  * SQL Date Functions (dt represe
*
nts oracle date and time)          

  * (functions return
*
an oracle date unless otherw

ise specified)        

  ********************************
***********************
************************

  ADD_MONTHS(dt, num)
   -- adds num months to
dt (num can be negative)
  LAST_DAY(dt)    
   -- last day of month in
month containing dt
  MONTHS_BETWEEN(dt1, dt2) -- retu
dt2
rns fractional value of months between dt1,

  NEW_TIME(dt, tz1, tz
zone 2
2)  -- dt = date in time zo

ne 1, returns date in time

  NEXT_DAY(dt, str)    -- date
etc..)
of first (str) after dt (str = 'Monday',

  SYSDATE         -- present system date
  ROUND(dt [,fmt]     -- roun
ds dt as specified by format fmt
  TRUNC(dt [,fmt]  
   -- truncates dt as spe
cified by format fmt
                                                                               
  ********************************
***********************
************************

  * Number Functions :      
*
                       

  ********************************
***********************
************************

  ABS(num)       -- absolute
value of num
  CEIL(num)      -- smallest integer > or = num

  COS(num)       -- cosine(n
um), num in radians
  COSH(num)     
 -- hyperbolic cosine(num)

  EXP(num)      
-- e raised to the num powe
r
  FLOOR(num)      -- largest
integer < or = num
  LN(num)       -- natural
logarithm of num
  LOG(num2, num1)   -- logarith
m base num2 of num1
  MOD(num2, num1)   -- remainde
r of num2 / num1
  POWER(num2, num1) 
 -- num2 raised to the num1
power
  ROUND(num1 [,num2]  -- num1 rou
nded to num2 decimel places (default 0)
  SIGN(num)      -- sign of
num * 1, 0 if num = 0
  SIN(num)      
-- sin(num), num in radians

  SINH(num)      -- hyperbolic sine(num)
  SQRT(num)      -- square root of num     
  TAN(num)       -- tangent(
num), num in radians
  TANH(num)     
 -- hyperbolic tangent(num)

  TRUNC(num1 [,num2]  -- truncate
num1 to num2 decimel places (default 0)
                                                                               
  ********************************
***********************
************************

  * String Functions,
*
String Result :      

               

  ********************************
***********************
************************

  (num)          -- ASCII
character for num
  CHR(num)      
  -- ASCII character for n
um
  CONCAT(str1, str2)   -- str1
concatenated with str2 (same as str1||str2)
  INITCAP(str)    
  -- capitalize first lett
er of each word in str
  LOWER(str)       -- str w
ith all letters in lowercase
  LPAD(str1, num [,str2]) -- left
spaces)
pad str1 to length num with str2 (default

  LTRIM(str [,set]) 
   -- remove set from left
side of str (default spaces)
  NLS_INITCAP(str [,nl
s_val]) -- same as initcap f
or different languages
  NLS_LOWER(str [,nls_
val])  -- same as lower for
different languages
  REPLACE(str1, str2 [,str3]) -- r
eplaces str2 with str3 in str1
                 --
deletes str2 from str1 if str3 is omitted
  RPAD(str1, num [,str
(default spaces)
2])   -- right pad str1 to

length num with str2

  RTRIM(str [,set]) 
spaces)
     -- remove set from

right side of str (default

  SOUNDEX(str)    
    -- phonetic represen
tation of str
  SUBSTR(str, num2 [,n
um1])  -- substring of str,
starting with num2,
                 --
omitted)
num1 characters (to end of str if num1 is

  SUBSTRB(str, num2 [,
bytes
num1]) -- same as substr bu

t num1, num2 expressed in

  TRANSLATE(str, set1,
set2) -- replaces set1 in
str with set2
                 --
truncated
if set2 is longer than set1, it will be

  UPPER(str)     
    -- str with all lett
ers in uppercase
                                                                               
  ********************
***************
****************************

****************

  * String Functions,
*
Numeric Result :      

               

  ********************************
***********************
************************

                                                                               
  ASCII(str)           
 -- ASCII value of str
  INSTR(str1, str2 [,num1 [,num2]]
) -- position of num2th occurrence of
                  
  -- str2 in str1, starting at num1
                  
  -- (num1, num2 default to 1)
  INSTRB(str1, str2 [,num1 [num2]]

) -- same as instr, byte values for num1, num2

  LENGTH(str)    
        -- number of
characters in str
  LENGTHB(str)          
 -- number of bytes in str
  NLSSORT(str [,nls_val])    
  -- nls_val byte value of str
                                                                               
  ********************************
***********************
************************

  * SQL Conversion Functions   
*
                       

  ********************************
***********************
************************

  CHARTOROWID(str)        
  -- converts str to ROWID
  CONVERT(str, chr_set2 [,chr_set1
]) -- converts str to chr_set2
            
character set
        -- chr_set1

default is the datbase

  HEXTORAW(str)   
  -- converts hex string va
lue to internal raw values
  RAWTOHEX(raw_val)   -- convert
s raw hex value to hex string value
  ROWIDTOCHAR(rowid) 
 -- converts rowid to 18 ch
aracter string format
  TO_CHAR(expr [,fmt])
fmt
 -- converts expr(date or n

umber) to format specified by

  TO_DATE(str [,fmt])
  -- converts string to dat
e
  TO_MULTI_BYTE(str)  -- convert
s single byte string to multi byte string
  TO_NUMBER(str [,fmt]) -- convert
s str to a number formatted by fmt
  TO_SINGLE_BYTE(str)
  -- converts multi byte st
ring to single byte string
                                                                               
  ********************************
***********************
************************

  * SQL Date Formats 
*
              

               

  ********************
***************
****************************

****************

                                                                               
  BC, B.C.    BC indicator                             
  AD, A.D.    AD indicator                             
  CC, SCC     Cent
ury Code (SCC includes space
or - sign)
  YYYY, SYYYY   4 digit year (SY
YYY includes space or - sign)
  IYYY      4 digit ISO year                         
  Y,YYY      4 digit year with comma         
  YYY, YY, or Y  last 3, 2, or 1
digit of year
  YEAR, SYEAR   year spelled out
(SYEAR includes space or - sign)
  RR       last 2 digits of
year in prior or next century
  Q        quarter or year, 1 to 4             
  MM       month - from 01 to 12                 
  MONTH      month spelled out                     
  MON       month 3 letter abbreviation   
  RM       roman numeral for month             
  WW       week of year, 1 to 53                 
  IW       ISO week of year
, 1 to 52 or 1 to 53
  W        week of month, 1
to 5 (week 1 begins 1st day of the month)
  D        day of week, 1 to 7                     
  DD       day of month, 1 to 31                 
  DDD       day of year, 1 to 366               
  DAY       day of week spel
led out, nine characters right padded
  DY       day abbreviation                           
  J        # of
days since Jan 1, 4712 BC

  HH, HH12    hour of day, 1 to 12             
  HH24      hour of day, 0 to 23                 
  MI       minute of hour, 0 to 59             
  SS       second of minute, 0 to 59         
  SSSSS      seco
nds past midnight, 0 to 8639
9
  AM, A.M.    am indicator                             
  PM, P.M.    pm indicator                             
  any puctuation punc
tuation between format items
, as in 'DD/MM/YY'
  any text    text between format items   
  TH       conv
erts 1 to '1st', 2 to '2nd',
and so on
  SP       converts 1 to 'o
ne', 2 to 'two', and so on
  SPTH      converts 1 to 'F
IRST', 2 to 'SECOND', and so on
  FX       fill
exact : uses exact pattern
matching
  FM       fill mode : tog
gles suppression of blanks in output
Oracle的几个Function实例 NULL 博文链接:https://shihuan830619.iteye.com/blog/952088 立即下载

相关推荐

基于深度学习的时间序列预测

深度学习在时间序列数据中应用广泛,学术界已经有很多深度学习模型来适应不同领域的时间序列数据集的多样性。那么到底有哪些基于深度学习的时间序列预测模型?他们的优缺点是什么?让我们一起来看一下。

Sharon0408的博客 6556

oracle常用函数(转)

转自:http://blog.sina.com.cn/s/blog_578bede90100020t.html********************************************************************* SQL Group Functions (num can be a column or expression)                    

dragoo1的专栏 429

配置VS Code使用Linux服务器上的Matlab

0、需求 Linux服务器上安装有Matlab 无图形界面,只能使用命令行工具,编辑文件不方便 1、VS Code插件安装 在扩展商店中搜索matlab,会出现Matlab Extension Pack,里面有整理好的matlab扩展 这里只安装了第一排的三个扩展 2、设置(Windows、Mac的设置类似,只是不同系统的文件路径不同) 安装好扩展,重启VS Code后,进行设置 打开:文件→首选项→设置(或快捷键ctrl+,),搜索matlab,结果如下图所示;直接打开完整json配置文件(图

赵彬的博客 4966

MySQL语句简要

SQL功能 DDL:数据定义语言,创建、修改、删除数据库对象(表,视图、索引) DML:数据操纵语言,主要用于查询、添加、修改或者删除存储在数据库中的数据 DCL:数据控制语言, 用于控制数据库中特定访问用于的权限,访问类型 SQL执行方式 交互式SQL:直接执行SQL语句,输出在命令行的 嵌入式SQL:嵌入到高级语言中的SQL语句 SQL关键词 数据定义: CREATE TABLE DROP TABLE ALER TABLE //修改表结构 CREATE INDEX DROP INDEX CREATE P

weixin_42065178的博客 257

oracle中ipad是什么意思,Oracle中Ipad和Rpad函数的用法

函数参数:lpad( string, padded_length, [ pad_string ] )参数说明:string:源字符串;padded_length:终结果返回的字符串的长度;如果终返回的字符串的长度比源字符串的小,那么此函数实际上对源串进行截取处理,与substr(string,number1,number2)的作用完全相同,如果padded_length比源字符串的长度长,...

weixin_32571965的博客 721

Oracle中的LPAD()函数与RPAD()函数的详细解析

字符串填充函数LPAD()和RPAD()的详细解析

weixin_52968866的博客 1643

Oracle中Ipad和Rpad函数的用法

函数参数:lpad( string, padded_length, [ pad_string ] ) 参数说明: string:源字符串; padded_length:终结果返回的字符串的长度;如果终返回的字符串的长度比源字符串的小,那么此函数实际上对源串进行截取处理,与substr(string,number1,number2)的作用完全相同,如果padded_length比源字符串的长度长,则用pad_string进行填充,确保返回的终字符串的长度为padded_leng...

zll137437479的专栏 595

oracle经典表,oracle常用经典SQL查询(zt)

.[@more@]1、查看表空间的名称及大小select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_sizefrom dba_tablespaces t, dba_data_files dwhere t.tablespace_name = d.tablespace_namegroup by t.tablespace_name;2、查...

weixin_39712611的博客 181

SQLServer和Oracle常用函数对比 (ZT

---------数学函数1.绝对值 S:select abs(-1) valueO:select abs(-1)  value from dual2.取整(大) S:select ceiling(-1.001) value   O:select ceil(-1.001)  value from dual3.取整(小) S:select floor(-1.001) value   O:

王涛的BLOG 1190

oracle function6,ORACLE函数介绍(6)-分析函数-ZT

ORACLE函数介绍第六篇著名函数之分析函数2007.8.281、AVG([DISTINCT|ALL]expr) OVER(analytic_clause)计算平均值。例如:--聚合函数SELECTcol,AVG(value)FROMtmp1GROUPBYcolORDERBYcol;--分析函数SELECTcol,AVG(value) OVER(PARTITIONBYcolORDERBYcol)F...

weixin_42122986的博客 140

oracle常用连接 ZT chinaunix

英文:http://tahiti.oracle.com (oracle资料列表,无论如何你都要记住的网站)http://metalink.oracle.com (oracle世界里好的地方了,里面有patch,docs,forum等等,关键是其搜索功能很强大!需要收费账号)http://asktom.oracle.com  http://otn.oracle.com  (Oracle 数据库下载

wupei 吃遍天下水果 953

ZT:PL/SQL单行函数和组函数详解

PL/SQL单行函数和组函数详解 函数是一种有零个或多个参数并且有一个返回值的程序。在SQL中Oracle内建了一系列函数,这些函数都可被称为SQL或PL/SQL语句,函数主要分为两大类:   单行函数   组函数   本文将讨论如何利用单行函数以及使用规则。  SQL中的单行函数  SQL和PL/SQL中自带很多类型的函数,有字符、数字、日期、转换、和混合型等多种函数用于处理单行数据,因此这些都

foreveryday007's BLOG 1694

ORACLE 常用函数 [ZT]

1.INITCAP返回字符串并将字符串的第一个字母变为大写;SQL>selectinitcap('smith')uppfromdual;UPP-----Smith2.CONCAT连接两个字符串;SQL>selectconcat('010-','88888888')||'转23'高乾竞电话fromdual;高乾竞电话----------------010-888888...

weixin_33995481的博客 63

Oracle 分析函数的使用(zt)

2/11/2005 09:43 FPOracle 分析函数使用介绍 分析函数oracle816引入的一个全新的概念,为我们分析数据提供了一种简单高效的处理方式.在分析函数出现以前,我们必须使用自联查询,子查询或者内联视图,甚至复杂的存储过程实现的语句,现在只要一条简单的sql语句就可以实现了,而且在执行效率方面也有相当大的提高.下面我将针对分析函数做一些具体的说明.基础数据 ...

hu841018的专栏 207

ZT: oracle数字转换为英文的函数

举例来说:运行select to_char(to_date(911,J),Jsp) as a from dual显示结果为:Nine Hundred Eleven而运行select to_date(911,J) as a from dual显示结果为:0000-0-0J:Julian day; the number of days since January 1, 4712

foreveryday007's BLOG 1533

OmniColor:统一多模态线稿上色框架的设计思路与工程实践

多模态生成技术正在重塑图像处理范式,而线稿上色作为创意生产中的高频任务,其核心难点在于如何将文本描述、参考图像、颜色涂鸦等异构条件统一映射到生成模型中。传统单模态方案难以兼顾语义表达与空间控制,而基于扩散模型的可控生成框架,借助CLIP等预训练模型的语义对齐能力,为多条件融合提供了可能性。理解这种统一框架的原理,有助于实现更精准的创意意图传递。从动画制作到概念设计,多模态条件上色能显著提升工作流效率,让模型从“随机填色”走向“按需上色”。本文围绕ECCV 2026的OmniColor研究方向,解析统一多模态

weixin_34268843的博客 359

ZT:Oracle常用dump命令

http://ningoo.itpub.net/post/2149/287794Oracle常用dump命令,记录一下备查。一.Memory Dumps1).Global AreaALTER SESSION SET EVENTS...

196

ORACLE函数介绍(1)-著名函数之单值函数-ZT

ORACLE函数介绍 第一篇 著名函数之单值函数 2007.8.13 注:N表示数字型,C表示字符型,D表示日期型,[]表示内中参数可被忽略,fmt表示格式。 ...

ctze5992的博客 147

PLSQL访问同一个Oracle的两个实例

文章目录服务端listener.oratnsnames.ora客户端 服务端 listener.ora 直接看配置文件,wolfdb 和ZT 是实例 # listener.ora Network Configuration File: C:\app\tao.xu\product\11.2.0\dbhome_1\network\admin\listener.ora # Generated by Oracle configuration tools. LISTENER1 = (DESCRIPTION_LI

涛涛之海 809

oracle常用经典SQL查询(zt)

.[@more@]1、查看表空间的名称及大小 select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_sizefrom dba_tablespaces t, db...

cuixie2370的博客 91
上一篇: ZT: 提高SQL性能的措施
下一篇: Delphi源程序格式书写规范
foreveryday007
博客等级 码龄25年 129粉丝 204原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值