`

Oracle SQL Functions

阅读更多
http://www.ss64.com/ora/

Oracle SQL Functions

Functions:

ABS(n)        Absolute value of number
ACOS(n)       arc cosine of n
ADD_MONTHS(date,num_months)
              Returns date + num_months
ASCII(char)   Converts char into a decimal ascii code
ASIN(n)       arc sine of n.
ATAN(n)       arc tangent of n.
ATAN2(n.m)    arc tangent of n and m.
AVG([DISTINCT]n)
              Averge value of 'n' ignoring NULLs

BETWEEN value AND value
              Where 'x' between 25 AND 100
BFILENAME('directory','filename')
              Get the BFILE locator associated with a physical LOB binary file.

CASE          Group the data into sub-sets.
CEIL(n)       Round n up to next whole number.
CHARTOROWID(char)
              Converts a Char into a rowid value.
CHR(n)        Character with value n
CONCAT(s1,s2) Concatenate string1 and string2
CONVERT(char_to_convert, new_char_set, old_char_set)
              Convert character sets
COS(n)        Cosine of number
COSH(n)       Hyperbolic Cosine of number
COUNT(*)      Count the no of rows returned
COUNT([DISTINCT] expr)
              Count the no of rows returned by expr

DECODE        IF x THEN return y ELSE return z
DENSE_RANK    Calculate the rank of a value in a group
DEREF(e)      Return the object reference of argument e.
DUMP(expr,fmt[,start,length])
              Convert to dec/hex/oct and display char set

EMPTY_BLOB    Return an empty LOB locator (use to empty a column or variable)
EMPTY_CLOB    Return an empty LOB locator (use to empty a column or variable)
EXISTS        Return TRUE if a subquery returns at least one row
EXP(n)        Exponential (e to 'n'th power)

FLOOR(n)      Round n down to the next whole number.

GREATEST(expression, expression...)
              Returns the largest in a list of expressions.
GROUPING      Grouping for superaggregate rows=NULL
              (see GROUP BY ROLLUP/CUBE)

HEXTORAW(char) Convert char containing hex digits to a raw value.

IN (list of comma separated values)
              Effectively a shorthand for ['x' = y OR 'x' = z...] i.e.
              Where 'x' IN ('sales','marketing','recruitment')
INITCAP(char) String with Initial Capitals
INSTR(str, chars[,s[,n]])
              Find the 'n'th occurence of 'chars' in 'str'              Starting at position 's'
              n and s default to 1
INSTRB (str, chars[,s[,n]])
              The same as INSTR, except that 's' and the return value are expressed in bytes,
              use for double-byte char sets
IS [NOT] NULL Check for NULL (empty) values
              Where 'x' IS NULL;

LAST_DAY(date)Returns the last day of month in Date
LEAST(expression, expression...)
              Returns the smallest in a list of expressions
LENGTH(char)  Returns the number of characters in char
LENGTHB(char) Returns the number of bytes in char (use for double-byte char sets)
LIKE wildcard/value
              Wildcards are [% = any chars] [ _ = any one char]
              Where 'x' LIKE 'smith%' [will find 'Smithson']
              Where 'x' LIKE 'smith_' [will find 'Smithy']
LN(n)         Natural Log of n, where n>0
LOG(b,n)      log of n, base b
LOWER(char)   Returns character string in lowercase
LPAD(char, n[,PadChar])
              Left Pad char with n spaces [or PadChars]
LTRIM(char[,set])
              Left Trim char - remove leading spaces [or char set]

MAKE_REF(table,key)
              Create a REF to a row of an OBJECT view/table
MAX([DISTINCT] expr)
              Maximum value returned by expr
MIN([DISTINCT] expr)
              Minimum value returned by expr
MOD(x,y)      Remainder of x divided by y
MONTHS_BETWEEN(end_date, start_date)
              Number of months between the 2 dates (integer)

NEW_TIME(date, zone1, zone2)
              Convert between GMT and US time zones (but not CET)
NEXT_DAY(date,day_of_week)
              '12-OCT-01','Monday' will return the next Mon after 12 Oct
NLS_CHARSET_DECL_LEN (bytecount,charset)
              Returns the declaration width (no of chars) of an NCHAR column
NLS_CHARSET_ID(varchars)
              Returns the char set ID given a charset name
NLS_CHARSET_NAME(charset_id)
              Returns the char set name given a charset id
NLS_INITCAP(char[,'NLS_SORT = sort_sequence'])
              Returns char in Initial Caps, using an NLS sort_sequence
              either the session default or specified directly
NLS_LOWER(char[,'NLS_SORT = sort_sequence'])
              Returns char in lower case, using an NLS sort_sequence
              either the session default or specified directly
NLSSORT(char[,'NLS_SORT = sort_sequence'])
              Return the string of bytes used to sort char, using an NLS sort_sequence
              either the session default or specified directly
NLS_UPPER(char[,'NLS_SORT = sort_sequence'])
              Returns char in UPPER case, using an NLS sort_sequence
              either the session default or specified directly
NVL(expression, value_if_null)
              If expression is null, returns value_if_null; if expression is not null, returns expression.
              The arguments can have any datatype (Oracle will perform implicit conversion where needed).
PERCENT_RANK  Calculate the percent rank of a value in a group.
POWER(m,n)    m raised to the nth power

RANK          Calculate the rank of a value in a group
RAWTOHEX(raw) Convert raw to a character value containing its hex equivalent
REF(table_alias)
              Returns a REF value for an object instance (bound to the variable or row.)
              The table alias (correlation variable) is associated with
              one row of an object table or an object view in an SQL statement.
REFTOHEX(ref) Convert ref (object type) to a char value containing its hex equivalent.
REPLACE(char, search_str[, replace_str])
              ANSI alternative to decode() Replace every occurrence of search_str
              with replace_str, replace_str defaults to null.
ROUND(n,d)    n rounded to d decimal places (d defaults to 0)
ROUND(date,fmt)
              date rounded to fmt
ROWIDTOCHAR(rowid)
              Convert a rowid value to VARCHAR2
ROW_NUMBER    Assign a unique number to each row of results.
RPAD(char, n[,PadChar])
              Right Pad char with n spaces [or PadChars]
RTRIM(char[,set])
              Right Trim char - remove trailing spaces [or char set]

SIGN(n)       positive = 1, zero = 0, negative = -1
SIN(n)        Sine of n in Radians
SINH(n)       Hyperbolic Sine of n in Radians
SOUNDEX(char) Returns a char value representing the sound of the words
SQRT(n)       Square Root (returns NULL for negative no's)
STDDEV([DISTINCT] n)
              Standard deviation of n
SUBSTR(char, s[,l])
              A substring of char, starting at character s, length l
SUBSTRB(char, s[,l])
              A substring of char, starting at character s, length l
              The same as SUBSTR, except that 's', 'l' and the return value are expressed in bytes,
              use for double-byte char sets
SUM([DISTINCT] n)
              Sum of values of n, ignoring NULLs
SYS_CONTEXT('namespace','attribute_name')
              Examine the package associated with the context namespace
              Possible attributes are: NLS_TERRITORY, NLS_CURRENCY, NLS_CALENDAR
              NLS_DATE_FORMAT, NLS_DATE_LANGUAGE, NLS_SORT, SESSION_USER, CURRENT_USER
              CURRENT SCHEMAID,SESSION_USERID, CURRENT_USERID, CURRENT_SCHEMA
              note: CURRENT_USER may be different from SESSION_USER within a stored procedure
              (e.g an invoker-rights procedure). 
SYS_CONTEXT ('USERENV','IP_ADDRESS')
SYS_GUID()    Returns a globally unique identifier (16 byte RAW value)
SYSDATE       The current system date & time

TAN(n)        Tangent of n in Radians
TANH(n)       Hyperbolic tangent of n in Radians
TO_CHAR       Convert to character String
TO_DATE       Convert to date value
TO_LOB(long)  Convert LONG values to CLOB or NCLOB values
              or convert LONG RAW values to BLOB values
              Use only as part of an "INSERT INTO ... SELECT..." subquery.
TO_MULTI_BYTE(char)
              Convert single-byte char to multi-byte char.
TO_NUMBER     Convert to numeric format
TO_SINGLE_BYTE(char)
              Convert multi-byte char to single-byte char.
TRANSLATE('char','search_str','replace_str')
              Replace every occurrence of search_str with replace_str
              unlike REPLACE() if replace_str is NULL the function returns NULL
TRANSLATE (text USING charset)
              Convert text into a specific character set
              Use this instead of CONVERT() if either the input or output datatype
              is NCHAR or NVARCHAR2.
TRIM(LEADING|TRAILING|BOTH trim_char FROM trim_source)
              Returns trim_source as a VARCHAR2 with leading/trailing items removed
              trim_char defaults to a space ' ' but may be numeric or char 'A'
TRUNC(i,d)    i truncated to d decimal places (d defaults to 0)
TRUNC(date,fmt)
              date truncated to nearest fmt

UID           User id - unique number
UPPER(char)   Returns Chars in uppercase
USER          Returns the current Username
USERENV('option')
              Can return any of the options: ENTRYID, SESSIONID,
              TERMINAL, LANGUAGE, ISDBA, LANG, INSTANCE, CLIENT_INFO

VALUE(correlation_variable)
              Return the object instance for a row of an object table
              as associated with the correlation_variable (table alias)
VARIANCE([DISTINCT] n)
              Variance of n, ignoring NULLs
VSIZE(expr)   Value Size - returns the number of bytes used by each row of expr.

This page is not an exhaustive list of all the functions available - to find a complete list of functions for a particular release of Oracle see docs.oracle.com or run this query:

SELECT distinct object_name
FROM all_arguments
WHERE package_name = 'STANDARD';
分享到:
评论

相关推荐

    Pro Oracle SQL

    Pro Oracle SQL unlocks the power of SQL in the Oracle Database—one of the most potent SQL implementations on the market today. To master it requires a three-pronged approach: learn the language ...

    oracle sql and pl/sql

    根据提供的文件信息,我们可以推断出本书主要关注的是Oracle SQL 和 PL/SQL 的掌握与应用。下面将基于这些信息来生成相关的知识点。 ### Oracle SQL 和 PL/SQL 知识点 #### 一、Oracle SQL 概述 1. **定义**:...

    oracle advanced sql 高级SQL教程 ORACLE官方教材

    Review of Group Functions 3-3 Review of the GROUP BY Clause 3-4 Review of the HAVING Clause 3-5 GROUP BY with ROLLUP and CUBE Operators 3-6 ROLLUP Operator 3-7 ROLLUP Operator Example 3-8 CUBE ...

    Oracle sql 语句集锦

    根据给定的文件信息,以下是对Oracle SQL语句集锦中的关键知识点的详细解析: ### Oracle SQL基础操作 #### 数据定义语言(DDL) - **创建表(Create Table)**: `CREATE TABLE`语句用于在数据库中创建一个新的表...

    Oracle 11g Functions 常用函数

    ### Oracle 11g Functions 常用函数详解 #### ABS **语法**: `ABS(n)` **用法**: 返回参数`n`的绝对值。 **参数**: `n`为数值数据类型,或者可以隐式转化为数值类型的其他数据类型。 **示例**: ```sql SELECT ABS(-...

    Oracle SQL:经典查询练手

    窗口函数(Window Functions)是Oracle SQL的一个高级特性,允许你在一组相关的行(一个“窗口”)上执行计算,而不仅仅是当前行。这包括ROW_NUMBER、RANK、DENSE_RANK、LEAD、LAG、FIRST_VALUE、LAST_VALUE和NTILE...

    Oracle SQL学习资料大全.zip

    Oracle SQL是数据库管理员和开发人员在Oracle数据库系统中进行数据查询、管理与分析的主要工具。这份"Oracle SQL学习资料大全.zip"压缩包包含了丰富的学习资源,帮助初学者和进阶者深入理解并掌握Oracle SQL的核心...

    Oracle高级sql学习与练习

    11. 分析函数(ANALYTICAL FUNCTIONS)是Oracle SQL的高级特性之一,允许在数据集上进行窗口计算,例如累计求和、移动平均等,非常适合处理时序数据。 12. ROWID的使用涉及Oracle中的行标识符,可以用来快速访问表...

    oracle-sql-the-essential-reference

    - **Aggregate Functions**(聚合函数):探讨了Oracle SQL提供的聚合函数,如SUM、AVG、COUNT等,以及这些函数如何用于对数据集进行汇总分析。 - **Grouping and Partitioning**(分组与分区):讲解了如何使用...

    oracle 常用sql语句和常见问题

    在Oracle数据库管理中,SQL(结构化查询语言)是核心工具,用于检索、更新和管理数据。本资料集主要涵盖了Oracle中的常用SQL语句以及在实际应用中可能遇到的常见问题及其解决策略。 1. **SQL基本操作**: - **...

    OracleSQL笔记

    ### Oracle SQL 笔记知识点详解 #### 一、SQLPlus 命令及环境变量 Oracle_sid - **SQLPlus 命令位置**:在 Oracle 安装目录下的 `bin` 文件夹中,可以通过 SQLPlus 来执行 SQL 命令。 - **Oracle_sid 环境变量**:...

    oracle functions

    ### Oracle Functions:介绍与示例 Oracle 数据库提供了丰富的内置函数,这些函数可以帮助开发者和数据库管理员执行各种数据处理任务,从而提高工作效率并简化查询过程。本文将详细介绍几个常用的 Oracle 函数,并...

    oracle常用经典sql查询.rar

    Oracle还提供了一些高级特性,如窗口函数(Window Functions),这些函数允许我们在数据集上执行计算,同时考虑行的相对位置。例如,RANK()、DENSE_RANK()和ROW_NUMBER()可以为数据行分配排名,LEAD()和LAG()则可以...

    oracle sql program

    Oracle SQL是Oracle数据库管理系统中的结构化查询语言,用于管理和操作数据。它允许用户查询、更新、插入和删除数据库中的信息,以及创建和修改数据库结构。本篇将深入探讨Oracle SQL的相关知识点。 一、SQL基础 ...

    Apress.Pro.Oracle.SQL

    SQL语句能够执行各种复杂的数据查询,包括简单的SELECT语句到复杂的联接(JOIN)、子查询(Subquery)和聚集函数(Aggregate Functions)。此外,窗口函数如ROW_NUMBER()、RANK()和DENSE_RANK()等允许对结果集进行更...

    oracle生成拼音、五笔首字母的functions方法

    本文将详细介绍如何在Oracle中实现这一功能,主要基于提供的两个SQL脚本文件:`oracle生成五笔首字母的functions方法.sql`和`oracle生成拼音首字母的functions方法.sql`。 首先,我们来探讨拼音首字母的生成。在...

    高级oracle sql

    ### 高级Oracle SQL知识点解析 #### 一、Oracle SQL概览 在IT行业中,数据库技术一直是企业数据管理和处理的核心工具之一。Oracle作为全球领先的数据库管理系统之一,其SQL(Structured Query Language)语言更是...

    Oracle 10g中的高级SQL函数

    在Oracle 10g数据库系统中,高级SQL函数是开发者不可或缺的工具,它们极大地扩展了标准SQL的功能,使得数据查询和...《Advanced SQL Functions in Oracle 10g》这本书会深入讲解这些主题,是进一步提升技能的宝贵资源。

Global site tag (gtag.js) - Google Analytics