DB2SQL数据库函数.docx
- 文档编号:28207437
- 上传时间:2023-07-09
- 格式:DOCX
- 页数:39
- 大小:28.34KB
DB2SQL数据库函数.docx
《DB2SQL数据库函数.docx》由会员分享,可在线阅读,更多相关《DB2SQL数据库函数.docx(39页珍藏版)》请在冰豆网上搜索。
DB2SQL数据库函数
DB2-SQL数据库函数
1、ABS(exp)取绝对值5
2、ABSVAL(exp)取绝对值5
3、ACOS(exp)取反余弦5
4、ASCII(exp)取最左第一个字符ASCII码5
5、ASIN(exp)反正弦函数5
6、ATAN(exp)反正切函数5
7、ATAN2(x,y)y/x的反正切函数5
8、AVG(exp)平均数5
9、CEIL(exp)向上取整数,即取最大整数值5
10、CEILING(exp)向上取整数,同上5
11、CHAR(exp,[format])转换字符型format-取字符左起长度数5
12、CHR(char[1])返回单字符的ASCII码5
13、CONCAT(exp1,exp2)连接两个字符串,同’||’5
14、COS(exp)余弦函数5
15、COT(exp)余切函数5
16、DAY(dateexp)返回日期中的dd5
17、DAYNAME(dateexp)转换日期中的英文星期5
18、DAYOFWEEK(dateexp)返回日期中的本周星期数1-75
19、DAYOFYEAR(dateexp)返回日期中从本年年初到该日的天数1-3665
20、DEGREES(exp)返回弧度5
21、DIFFERENCE(‘exp’,’exp’)比较不同之处与SOUNDEX()使用?
5
22、DOUBLE(exp)转换为double型5
23、EXP(exp)指数函数5
24、FLOOR(exp)向下取整数,即取最小整数值5
25、INSERT(charexp1,exp2,exp3,charexp4)插入5
26、JULIAN_DAY(exp)从?
年一月开始到该日期的天数6
27、LEFT(exp1,exp2)返回exp2在exp1的最左出现的位子6
28、LOG(exp)取自然对数6
29、LOG10(exp)取对数6
30、LTRIM(exp)左去空格6
31、LCASE(exp)返回小写字符串6
32、LN(exp)ln(x)6
33、LOCATE(exp1,exp2,[exp3])查找exp1位于exp2[从第exp3位开始]6
34、MIDNIGHT_SECONDS(exp)返回当日0点到该时间的秒数6
35、MOD(exp)求模6
36、MONTHNAME(exp)月的英文名6
37、POWER(exp1,exp2)求幂6
38、QUARTER(exp)返回日期的季度数,范围1-46
39、RADIANS(exp)返回弧度6
40、RAND(exp)根据exp返回随机数,范围0-16
41、REPEAT(exp1,exp2)重复exp1,exp2次6
42、REPLACE(exp1,exp2,exp3)将exp1中出现的所有exp2字符替换成exp36
43、RIGHT(exp1,exp2)返回exp2在exp1最右边出现的位子6
44、ROUND(exp1,exp2)四舍五入6
45、RTRIM(exp)右边去空格6
46、SECOND(exp)返回时间的秒数6
47、SIGN(exp)标记exp>0return17
48、SIN(exp)正弦函数7
49、SMALLINT(exp)返回整数字范围-32769>t<327687
50、SOUNDEX(charexp)一种探测方法,返回四位的字符?
?
规律不明7
51、SPACE(exp)返回exp个空格7
52、SQLCACHE_SNAPSHOT7
53、SQRT(exp)平方根7
54、TAN(exp)正弦函数7
55、TIMESTAMP(exp)返回时间戳7
56、TIMESTAMPDIFF(exp)返回时间戳7
57、TRUNC(exp1,exp2)截断exp2>0到小数点后exp2位7
58、TRUNCATE(exp1,exp2)截断(同TRUNC)7
59、UCASE(exp)转换为大写7
60、VEBLOB_CP_LARGE强制大写7
61、VEBLOB_CP_SMALL强制小写7
62、WEEK(exp)返回该日是本年的第几个星期7
附表:
FUNCTION8
1、ABS(exp)取绝对值
2、ABSVAL(exp)取绝对值
3、ACOS(exp)取反余弦
4、ASCII(exp)取最左第一个字符ASCII码
5、ASIN(exp)反正弦函数
6、ATAN(exp)反正切函数
7、ATAN2(x,y)y/x的反正切函数
8、AVG(exp)平均数
9、CEIL(exp)向上取整数,即取最大整数值
10、CEILING(exp)向上取整数,同上
11、CHAR(exp,[format])转换字符型format-取字符左起长度数
Format=iso可以转换日期格式
12、CHR(char[1])返回单字符的ASCII码
13、CONCAT(exp1,exp2)连接两个字符串,同’||’
14、COS(exp)余弦函数
15、COT(exp)余切函数
16、DAY(dateexp)返回日期中的dd
17、DAYNAME(dateexp)转换日期中的英文星期
18、DAYOFWEEK(dateexp)返回日期中的本周星期数1-7
19、DAYOFYEAR(dateexp)返回日期中从本年年初到该日的天数1-366
20、DEGREES(exp)返回弧度
21、DIFFERENCE(‘exp’,’exp’)比较不同之处与SOUNDEX()使用?
22、DOUBLE(exp)转换为double型
23、EXP(exp)指数函数
24、FLOOR(exp)向下取整数,即取最小整数值
25、INSERT(charexp1,exp2,exp3,charexp4)插入
将exp4插入到exp1中,从第exp2位开始插入,插入覆盖exp1的长度exp3
例如:
insert(‘abcde’,1,0,’!
’)=>’!
abcde’
insert(‘abcde’,2,2,’!
’)=>’a!
de
insert(‘acbde’,2,3,’!
’)=>’a!
e’
26、JULIAN_DAY(exp)从?
年一月开始到该日期的天数
27、LEFT(exp1,exp2)返回exp2在exp1的最左出现的位子
28、LOG(exp)取自然对数
29、LOG10(exp)取对数
30、LTRIM(exp)左去空格
31、LCASE(exp)返回小写字符串
32、LN(exp)ln(x)
33、LOCATE(exp1,exp2,[exp3])查找exp1位于exp2[从第exp3位开始]
出现的位数
34、MIDNIGHT_SECONDS(exp)返回当日0点到该时间的秒数
Exp=’hh-mm-ss’
35、MOD(exp)求模
36、MONTHNAME(exp)月的英文名
37、POWER(exp1,exp2)求幂
38、QUARTER(exp)返回日期的季度数,范围1-4
39、RADIANS(exp)返回弧度
40、RAND(exp)根据exp返回随机数,范围0-1
exp相同产生的随机数亦相同
41、REPEAT(exp1,exp2)重复exp1,exp2次
42、REPLACE(exp1,exp2,exp3)将exp1中出现的所有exp2字符替换成exp3
43、RIGHT(exp1,exp2)返回exp2在exp1最右边出现的位子
44、ROUND(exp1,exp2)四舍五入
Exp2=n四舍五入后保留到小数点后n位
Round(99.12345,1)=99.1
Exp2=0不进行四舍五入
Exp2=-n四舍五入后保留到小数点前n位
Round(99876.4555,-2)=99880
45、RTRIM(exp)右边去空格
46、SECOND(exp)返回时间的秒数
47、SIGN(exp)标记exp>0return1
exp=0return0
exp<0return-1
48、SIN(exp)正弦函数
49、SMALLINT(exp)返回整数字范围-32769>t<32768
exp还可以是数字型字符串或数字但范围在
exp<32768exp>-32769否则报错
50、SOUNDEX(charexp)一种探测方法,返回四位的字符?
?
规律不明
51、SPACE(exp)返回exp个空格
Db2“valueschar(space
(2)||‘abcd’)”
52、SQLCACHE_SNAPSHOT
53、SQRT(exp)平方根
54、TAN(exp)正弦函数
55、TIMESTAMP(exp)返回时间戳
56、TIMESTAMPDIFF(exp)返回时间戳
57、TRUNC(exp1,exp2)截断exp2>0到小数点后exp2位
Exp2<0到小数点前exp2位
58、TRUNCATE(exp1,exp2)截断(同TRUNC)
59、UCASE(exp)转换为大写
60、VEBLOB_CP_LARGE强制大写
61、VEBLOB_CP_SMALL强制小写
62、WEEK(exp)返回该日是本年的第几个星期
附表:
FUNCTION
Functionname
Schema
Description
InputParameters
Returns
ABSorABSVAL
SYSFUN
Returnstheabsolutevalueoftheargument.
SMALLINT
SMALLINT
INTEGER
INTEGER
BIGINT
BIGINT
DOUBLE
DOUBLE
ACOS
SYSFUN
Returnsthearccosineoftheargumentasanangleexpressedinradians.
DOUBLE
DOUBLE
ASCII
SYSFUN
ReturnstheASCIIcodevalueoftheleftmostcharacteroftheargumentasaninteger.
CHAR
INTEGER
VARCHAR(4000)
INTEGER
CLOB(1M)
INTEGER
ASIN
SYSFUN
Returnsthearcsineoftheargumentasanangle,expressedinradians.
DOUBLE
DOUBLE
ATAN
SYSFUN
Returnsthearctangentoftheargumentasanangle,expressedinradians.
DOUBLE
DOUBLE
ATAN2
SYSFUN
Returnsthearctangentofxandycoordinates,specifiedbythefirstandsecondargumentsrespectively,asanangle,expressedinradians.
DOUBLE,DOUBLE
DOUBLE
AVG
SYSIBM
Returnstheaverageofasetofnumbers(columnfunction).
numeric-type4
numeric-type1
BIGINT
SYSIBM
Returnsa64bitintegerrepresentationofanumberorcharacterstringintheformofanintegerconstant.
numeric-type
BIGINT
VARCHAR
BIGINT
BLOB
SYSIBM
CastsfromsourcetypetoBLOB,withoptionallength.
string-type
BLOB
string-type,INTEGER
BLOB
CEILorCEILING
SYSFUN
Returnsthesmallestintegergreaterthanorequaltotheargument.
SMALLINT
SMALLINT
INTEGER
INTEGER
BIGINT
BIGINT
DOUBLE
DOUBLE
CHAR
SYSIBM
Returnsastringrepresentationofthesourcetype.
character-type
CHAR
character-type,INTEGER
CHAR(integer)
datetime-type
CHAR
datetime-type,keyword2
CHAR
SMALLINT
CHAR(6)
INTEGER
CHAR(11)
BIGINT
CHAR(20)
DECIMAL
CHAR(2+precision)
DECIMAL,VARCHAR
CHAR(2+precision)
CHAR
SYSFUN
Returnsacharacterstringrepresentationofafloating-pointnumber.
DOUBLE
CHAR(24)
CHR
SYSFUN
ReturnsthecharacterthathastheASCIIcodevaluespecifiedbytheargument.Thevalueoftheargumentshouldbebetween0and255;otherwise,thereturnvalueisnull.
INTEGER
CHAR
(1)
CLOB
SYSIBM
CastsfromsourcetypetoCLOB,withoptionallength.
character-type
CLOB
character-type,INTEGER
CLOB
COALESCE3
SYSIBM
Returnsthefirstnon-nullargumentinthesetofarguments.
any-type,any-union-compatible-type,...
any-type
CONCATor||
SYSIBM
Returnstheconcatenationof2stringarguments.
string-type,compatible-string-type
maxstring-type
CORRELATIONorCORR
SYSIBM
Returnsthecoefficientofcorrelationofasetofnumberpairs.
numeric-type,numeric-type
DOUBLE
COS
SYSFUN
Returnsthecosineoftheargument,wheretheargumentisanangleexpressedinradians.
DOUBLE
DOUBLE
COT
SYSFUN
Returnsthecotangentoftheargument,wheretheargumentisanangleexpressedinradians.
DOUBLE
DOUBLE
COUNT
SYSIBM
Returnsthecountofthenumberofrowsinasetofrowsorvalues(columnfunction).
any-builtin-type4
INTEGER
COUNT_BIG
SYSIBM
Returnsthenumberofrowsorvaluesinasetofrowsorvalues(columnfunction).Resultcanbegreaterthanthemaximumvalueofinteger.
any-builtin-type4
DECIMAL(31,0)
COVARIANCEorCOVAR
SYSIBM
Returnsthecovarianceofasetofnumberpairs.
numeric-type,numeric-type
DOUBLE
DATE
SYSIBM
Returnsadatefromasingleinputvalue.
DATE
DATE
TIMESTAMP
DATE
DOUBLE
DATE
VARCHAR
DATE
DAY
SYSIBM
Returnsthedaypartofavalue.
VARCHAR
INTEGER
DATE
INTEGER
TIMESTAMP
INTEGER
DECIMAL
INTEGER
DAYNAME
SYSFUN
Returnsamixedcasecharacterstringcontainingthenameoftheday(e.g.Friday)forthedayportionoftheargumentbasedonwhatthelocalewaswhendb2startwasissued.
VARCHAR(26)
VARCHAR(100)
DATE
VARCHAR(100)
TIMESTAMP
VARCHAR(100)
DAYOFWEEK
SYSFUN
Returnsthedayoftheweekintheargumentasanintegervalueintherange1-7,where1representsSunday.
VARCHAR(26)
INTEGER
DATE
INTEGER
TIMESTAMP
INTEGER
DAYOFWEEK_ISO
SYSFUN
Returnsthedayoftheweekintheargumentasanintegervalueintherange1-7,where1representsMonday.
VARCHAR(26)
INTEGER
DATE
INTEGER
TIMESTAMP
INTEGER
DAYOFYEAR
SYSFUN
Returnsthedayoftheyearintheargumentasanintegervalueintherange1-366.
VARCHAR(26)
INTEGER
DATE
INTEGER
TIMESTAMP
INTEGER
DAYS
SYSIBM
Returnsanintegerrepresentationofadate.
VARCHAR
INTEGER
TIMESTAMP
INTEGER
DATE
INTEGER
DBCLOB
SYSIBM
CastsfromsourcetypetoDBCLOB,withoptionallength.
graphic-type
DBCLOB
graphic-type,INTEGER
DBCLOB
DECIMALorDEC
SYSIBM
Returnsdecimalrepresentationofanumber,withoptionalprecisionandscale.
numeric-type
DECIMAL
numeric-type,INTEGER
DECIMAL
numeric-typeINTEGER,INTEGER
DECIMAL
DECIMALorDEC
SYSIBM
Returnsdecimalrepresentationofacharacterstring,withoptionalprecision,scale,anddecimal-character.
VARCHAR
DECIMAL
VARCHAR,INTEGER
DECIMAL
VARCHAR,INTEGER,INTEGER
DECIMAL
VARCHAR,INTEGER,INTEGER,VARCHAR
DECIMAL
DEGREES
SYSFUN
Returnsthenumberofdegreesconvertedfromtheargumentinexpressedinradians.
DOUBLE
DOUBLE
DEREF
SYSIBM
Returnsaninstanceofthetargettypeofthereferencetypeargument.
REF(any-structured-type)withdefinedscope
any-structured-type(sameasinputtargettype)
DIFFERENCE
SYSFUN
Returnst
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- DB2SQL 数据库 函数