當前位置:首頁 » 編程語言 » 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用春李法。

熱點內容
androidcursor遍歷 發布:2024-11-02 00:27:40 瀏覽:767
網易我的世界地皮伺服器大全 發布:2024-11-02 00:24:20 瀏覽:964
光宇國際服怎麼安卓轉ios 發布:2024-11-02 00:14:23 瀏覽:170
魔獸世界單機資料庫 發布:2024-11-01 23:37:11 瀏覽:698
配置vlan後如何配置電腦ip 發布:2024-11-01 23:21:16 瀏覽:546
中鐵盾構機密碼是多少 發布:2024-11-01 23:07:21 瀏覽:708
工規存儲 發布:2024-11-01 22:59:33 瀏覽:802
無法識別加密狗 發布:2024-11-01 22:47:03 瀏覽:599
手機怎麼給wifi改密碼怎麼辦啊 發布:2024-11-01 22:46:03 瀏覽:858
抖音賬號的密碼是由什麼組成 發布:2024-11-01 22:45:27 瀏覽:449