Oracle和SQLServer常用函数对比

文章作者 100test 发表时间 2012:03:17 18:01:49
来源 100Test.Com百考试题网


  数学函数

  1.绝对值

  S:0select abs(-1) value

  O:0select abs(-1) value from dual

  2.取整(大)

  S:0select ceiling(-1.001) value

  O:0select ceil(-1.001) value from dual

  3.取整(小)

  S:0select floor(-1.001) value

  O:0select floor(-1.001) value from dual

  4.取整(截取)

  S:0select cast(-1.002 as int) value

  O:0select trunc(-1.002) value from dual

  5.四舍五入

  S:0select round(1.23456,4) value 1.23460

  O:0select round(1.23456,4) value from dual 1.2346

  6.e为底的幂

  S:0select Exp(1) value 2.7182818284590451

  O:0select Exp(1) value from dual 2.71828182

  7.取e为底的对数

  S:0select log(2.7182818284590451) value 1

  O:0select ln(2.7182818284590451) value from dual. 1

  8.取10为底对数

  S:0select log10(10) value 1

  O:0select log(10,10) value from dual. 1

  9.取平方

  S:0select SQUARE(4) value 16

  O:0select power(4,2) value from dual 16

  10.取平方根

  S:0select SQRT(4) value 2

  O:0select SQRT(4) value from dual 2

  11.求任意数为底的幂

  S:0select power(3,4) value 81

  O:0select power(3,4) value from dual 81

  12.取随机数

  S:0select rand() value

  O:0select sys.dbms_random.value(0,1) value from dual.

  13.取符号

  S:0select sign(-8) value -1

  O:0select sign(-8) value from dual -1

  14.圆周率

  S:SELECT PI() value 3.1415926535897931

  O:不知道

  15.sin,cos,tan 参数都以弧度为单位

  例如:0select sin(PI()/2) value 得到1(SQLServer)

  16.Asin,Acos,Atan,Atan2 返回弧度

  17.弧度角度互换(SQLServer,Oracle不知道)

  DEGREES:弧度-〉角度

  RADIANS:角度-〉弧度

  数值间比较

  18. 求集合最大值

  S:0select max(value) value from

  (0select 1 value

  union

  0select -2 value

  union

  0select 4 value

  union

  0select 3 value)a

  O:0select greatest(1,-2,4,3) value from dual

  19. 求集合最小值

  S:0select min(value) value from

  (0select 1 value

  union

  0select -2 value

  union

  0select 4 value

  union

  0select 3 value)a

  O:0select least(1,-2,4,3) value from dual

  20.如何处理null值(F2中的null以10代替)

  S:0select F1,IsNull(F2,10) value from Tbl

  O:0select F1,nvl(F2,10) value from Tbl

  21.求字符序号

  S:0select ascii(a) value

  O:0select ascii(a) value from dual

  22.从序号求字符

  S:0select char(97) value

  O:0select chr(97) value from dual

  23.连接

  S:0select 11 22 33 value

  O:0select CONCAT(11,22)  33 value from dual

  23.子串位置 --返回3

  S:0select CHARINDEX(s,sdsq,2) value

  O:0select INSTR(sdsq,s,2) value from dual

  23.模糊子串的位置 --返回2,参数去掉中间%则返回7

  S:0select patindex(%d%q%,sdsfasdqe) value

  O:oracle没发现,但是instr可以通过第四个参数控制出现次数

  0select INSTR(sdsfasdqe,sd,1,2) value from dual 返回6

  24.求子串

  S:0select substring(abcd,2,2) value

  O:0select substr(abcd,2,2) value from dual

  25.子串代替 返回aijklmnef

  S:SELECT STUFF(abcdef, 2, 3, ijklmn) value

  O:SELECT Replace(abcdef, bcd, ijklmn) value from dual



相关文章


Oracle数据库ASM功能详解
Oracle转义字符
ORACLE存储过程使用数组参数
Oracle学习的经验谈
Oracle和SQLServer常用函数对比
Oracle基本查询过滤排序实例
oracle的oci和thin区别
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛