当前位置:首页 » 编程语言 » oraclesql函数

oraclesql函数

发布时间: 2023-04-17 13:38:47

A. 求oracle sql函数清单以及使用说明

登录则毕这弯盯卖个网站可以查询到你要的详细清单
docs.oracle.com

下面是部分函数清单及简要说埋逗明,仅供参考
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 a string from one character set to another.
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
CURRENT_DATE
CURRENT_TIME
CURRENT_TIMESTAMP

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)
EXTRACT Extract part of a DATE (Year,Month,Day,Second,etc)

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 NULL Check for NULL (empty) values (Select * from demo Where x IS NULL;)
IS NOT NULL Check for items that contain a value (Select * from demo Where x IS NOT 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 procere
(e.g an invoker-rights procere).
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_BLOB(Raw_col) Convert LONG RAW and RAW values to BLOB
TO_CHAR Convert to a character String
TO_CLOB Convert character or NCLOB values to the database character set.
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
TO_MULTI_BYTE(char)
Convert single-byte char to multi-byte char
TO_NCHAR(expr) Convert a TEXT expression, date, or number to NTEXT in a specified format.
Mostly used to format output data.
TO_NCLOB Convert any character string (including LOBs) to the national character set.
TO_NUMBER Convert to numeric format
TO_SINGLE_BYTE(char)
Convert multi-byte char to single-byte character.
TO_TIME Convert to time value
TO_TIME_TZ Convert to time zone
TO_TIMESTAMP Convert to timestamp
TO_TIMESTAMP_TZ
TO_YMINTERVAL Convert a character string to an INTERVAL YEAR TO MONTH type
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)
Return 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) Truncate i to d decimal places (d defaults to 0)
TRUNC(date,fmt) Truncate Date to nearest fmt.
UID User id (a unique number)
UPPER(char) Return characters in uppercase
USER Return 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.

Examples
Return the left 4 characters from the column prod_code, like a left() function in other languages:
SQL> select substr(prod_code,1,4) from sales;
Return the right 3 characters from the column prod_code, like a right() function in other languages:
SQL> select substr(prod_code,-3) from sales;
Return the leftmost 2 digits of idnum:
SQL> select substr(to_char(idnum),1,2) from mytable;

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';

B. oracle里的哪个函数等于sql的year函数急

sql中的year函数即取日期类型年份,在oracle中可用to_char函数。

sql中取当前时间的年份:

selectyear(getdate())

结果:

C. oracle sql 管道函数是什么

oracle管道函数是一类特殊的函数,关键字PIPELINED表明这是一个oracle管道函数,oracle管道函数返回值类型必须为集合。
例子:
create or replace function f_pipeline_test
return MsgType
PIPELINED
as
begin
for i in 1 .. 10
loop
pipe row( 'Iteration ' || i || ' at ' || systimestamp );
dbms_lock.sleep(1);
end loop;
pipe row( 'All done!' );
return;
end;
/

D. Oracle sql函数replace和translate的区别

函数用法耐好让都不一样,昌局translate是逐个字符替换的
--包含ABC则替换为123
SELECT
REPLACE('AbCaBc','ABC','123')
FROM
al;
--将A替袜团换成1,B替换成2,C替换成3
SELECT
TRANSLATE('AbCaBc','ABC','123')
FROM
al;

E. oracle sql语句中,有没有能够将结果集中数字替换成汉字的函数

oracle sql语句中,有没有能够将结果集中数字替换成汉字的函数?

oracle sql语句中,有能够将结果集中数字替换成汉字的函数,用decode()函数。

1,SQL是Oracle数据库对SQL语句的扩展。它是一种程序语言,叫做过程化SQL语言。

2,在普通SQL语句的使用上增加了编程语言的特点,所以PL/SQL就是把数据操虚裤仔作和查询语句组织在PL/SQL代码的过程性单元中,通过逻辑判断、循环等操作实现复杂的功能或者计算的程序语言。

3,通过多条SQL语句实现功能时,每条语句都需要在客户端和服务端传递,而且每条语句的执行结果也需要在网络中进行交互,占用了大量的网络带宽,消耗了大量网络传递的时间。在网络中传输的那些结果,往往都是中间结果,而不是我们所关心的。

4,在整个过程中网络里只传输了很少的数据,减少了网络传输占用的时间,所以整体程序的执行性能会有明显的提高。

5,PL/SQL的使用,使SQL成为一种高级程序设计语言,支持高级语言的块操作,条件判断,循环语句,嵌套等,与数据库核心的数据类型集成,使SQL 的程序设计效率更高.

word 中的查找替换将数字换成汉字

先用CTRL+A把WORD全文选中,然后按“CTRL+F”打开“查找和替换”,选“替换”,然后在“查找内容”中输入你想要替换掉的数字,然后在“替换为”中输入你想换成的汉字,如果只替换一处,直接点下边的“替换差汪”就可以了,如果想把文档中所有符合条件的都替换就点“全部替换”即可。

Mysql中查询一个表,把结果中的7替换成文字,请写出sql语句

7是一个字段吗?还是一个值?值的话就case when吧 case when a=7 then '文字' else a

在sql查询中null怎么替换成汉字

假设字段名为 column
case when column is null then '空' else column end
还有更方便的
isnull(column,'空')

Mysql中查询一个表,把结果中的NULL替换成0,怎么写出sql语句?

1、MSSQL: ISNULL()

语法纯扒

ISNULL ( check_expression , replacement_value )

参数

check_expression

将被检查是否为 NULL的表达式。check_expression 可以是任何类型的。

replacement_value

在 check_expression 为 NULL时将返回的表达式。replacement_value 必须与 check_expresssion 具有相同的类型。

返回类型

返回与 check_expression 相同的类型。

注释

如果 check_expression 不为 NULL,那么返回该表达式的值;否则返回 replacement_value。

2、Oracle: NVL()

语法

NVL(eExpression1, eExpression2)

参数

eExpression1, eExpression2

如果 eExpression1 的计算结果为 null 值,则 NVL() 返回 eExpression2。如果 eExpression1 的计算结果不是 null 值,则返回 eExpression1。eExpression1 和 eExpression2 可以是任意一种数据类型。如果 eExpression1 与 eExpression2 的结果皆为 null 值,则 NVL( ) 返回 NULL

WPS中如何将所有汉字替换成汉仪中宋简

首先,你的电脑系统中需要安装汉仪中宋简字体。
如果没有,可网络一下,下载安装。WIN7系统在下载的.ttf文件上点键——安装即可安装到系统中。
在WPS中,全选(按Ctrl+A),在“字体”中选择该字体。

oracle 中的instr替换成sqlserver的什么函数

Oracle:INSTR(<C1>,<C2>[,I][,J])
SQL Server:CHARINDEX(<C1>,<C2>[,I])
说明:在C2中从I开始搜索C1第1次出现的位置。I:默认1

java中数组的替换当中,如何使用fill()将数字替换成符号

当数据元素为对象时,数据的元素先要初始化,才能使用.因此,代码
a[]=new [10];
a[0].set(100);
System.out.println(a[0].num);
需要改成;
a[]=new [10];
a[0]=new ();
a[0].set(100);
System.out.println(a[0].num);

sqlite 用sql语句将结果集中的一列数据拼接成一个字符串

这个只用一个查询语句我是没有方法可以解决。
我的解决方法需要用到存储过程,可以直接使用下面代码,或者将其装入存储过程。
Declare @s varchar(200)--长度需要根据需要设定
Set @s = ''
Select @s = @s + Name from 【表】--你的表
Where 【条件】
Select @s

F. oracle sql 查询我使用自已写的函数查询很快,加了函数做条件就很慢是为什么

慢是因为
对于 几十万条记录左右,
你那个 test(a) 函数, 需要执行 很多次, 每行执行一次, 然后判断 LIKE '%123%'

至于:
select a,b, test(a) c from demo; --只这样查很快

我估计你使用的是 PLSQL Developer。
查询的时候, 默认是查询第一页, 因此很快。
因为只显示少部分行。
例如一页20行的话, 那么也就执行你那个函数 20次。

G. oracle 中有sql的 RAISERROR 函数吗

是有的,这个函数是用来在存储过程、触发器、自定义函数时跑出错误信息,在抛出错误时自培宽盯己可以定配和义错误消巧亏息和错误等级

H. oracle数据库中函数怎么使用

oracle数据库中函数较多,而且每个函数都有自己的用法,所以要根据具体的函数查询具体的使用方法,比如:
decode(条件,值1,返回值1,值2,返回值2,...值n,返回值n,缺省值)
这个函数运行的结果是,当字段或字段的运算的值等于值1时,该函数返回值2,否则返回值3
当然值1,值2,值3也可以是表达式,这个函数使得某些sql语句简单了许多
使用方法:
1、比较大小
select
decode(sign(变量1-变量2),-1,变量1,变量2)
from
al;
--取较小值
sign()函数根据某个值是0、正数还是负数,分别返回0、1、-1
例如:
变量1=10,变量2=20
则sign(变量1-变量2)返回-1,decode解码结果为“变量1”,达到了取较小值的目的。
2、此函数用在SQL语句中,功能介绍如下:
Decode函数与一系列嵌套的
IF-THEN-ELSE语句相似。base_exp与compare1,compare2等等依次进行比较。如果base_exp和
第i
个compare项匹配,就返回第i
个对应的value
。如果base_exp与任何的compare值都不匹配,则返回default。每个compare值顺次求值,如果发现一个匹配,则剩下的compare值(如果还有的话)就都不再求值。一个为NULL的base_exp被认为和NULL
compare值等价。如果需要的话,每一个compare值都被转换成和第一个compare
值相同的数据类型,这个数据类型也是返回值的类型。

I. oracle sql中count、case函数运用

count 表示的是计数,也就是说记录的条数,通常和分组函数一起使用蔽正。
sql:select userId , count(*) from tablename group by userId。
case表示的是多条件判断。
sql:select ename,
case
when sal<1000 then 'lower'
when sal>1001 and sal<2000 then 'modest'
when sal>2001 and sal<4000 then 'high'
else 'too high'
end
from emp;
以上语句就是一个简单的判断工资扒并迟等级的一个case用春李法。

热点内容
华为ftp在哪 发布:2024-11-01 22:36:33 浏览:288
java数组包含字符串 发布:2024-11-01 22:31:15 浏览:791
服务器和家用电脑质量 发布:2024-11-01 22:28:29 浏览:488
sqlserver默认实例 发布:2024-11-01 22:23:42 浏览:959
sort排序java 发布:2024-11-01 22:23:26 浏览:47
解压后的apk无法安装 发布:2024-11-01 22:22:10 浏览:666
公司的pop服务器地址 发布:2024-11-01 22:22:07 浏览:119
朵唯m30手机配置是真的吗如何 发布:2024-11-01 22:16:56 浏览:681
梦幻西游怎么清理缓存 发布:2024-11-01 22:15:52 浏览:345
如何配置fcm 发布:2024-11-01 22:08:15 浏览:854