GBase 8c V3.0.0数据类型——数字操作函数

l abs(x)

描述:绝对值。

返回值类型:和输入相同。

示例:

gbase=# SELECT abs(-17.4);

 abs

------

 17.4

(1 row)

l acos(x)

描述:反余弦。

返回值类型:double precision

示例:

gbase=# SELECT acos(-1);

acos

------------------

 3.14159265358979

(1 row)

l asin(x)

描述:反正弦。

返回值类型:double precision

示例:

gbase=# SELECT asin(0.5);

 asin

------------------

.523598775598299

(1 row)

l atan(x)

描述:反正切。

返回值类型:double precision

示例:

gbase=# SELECT atan(1); 

atan

------------------

.785398163397448

(1 row)

l atan2(y, x)

描述:y/x的反正切。

返回值类型:double precision

示例:

gbase=# SELECT atan2(2, 1);

 atan2

------------------

 1.10714871779409

(1 row)

l bitand(integer, integer)

描述:计算两个数字与运算(&)的结果。

返回值类型:bigint类型数字。

示例:

gbase=# SELECT bitand(127, 63);

 bitand

--------

 63

(1 row)

l cbrt(dp)

描述:立方根。

返回值类型:double precision

示例:

gbase=# SELECT cbrt(27.0);

cbrt

------

    3

(1 row)

l ceil(x)

描述:不小于参数的最小的整数。

返回值类型:整数。示例:

gbase=# SELECT ceil(-42.8);

 ceil

------

-42

(1 row)

l ceiling(dp or numeric)

描述:不小于参数的最小整数(ceil的别名)。

返回值类型:dp or numeric,不考虑隐式类型转换的情况下与输入相同。示例:

gbase=# SELECT ceiling(-95.3);

ceiling

---------

-95

(1 row)

l cos(x)

描述:余弦。

返回值类型:double precision

示例:

gbase=# SELECT cos(-3.1415927);

cos

-------------------

-.999999999999999

(1 row)

l cot(x)

描述:余切。

返回值类型:double precision

示例:

gbase=# SELECT cot(1);

cot

------------------

.642092615934331

(1 row)

l degrees(dp)

描述:把弧度转为角度。

返回值类型:double precision

示例:

gbase=# SELECT degrees(0.5);

degrees

------------------

28.6478897565412

(1 row)

l div(y numeric, x numeric)

描述:y除以x的商的整数部分。

返回值类型:numeric

示例:

gbase=# SELECT div(9,4);

div

-----

2

(1 row)

l exp(x)

描述:自然指数。

返回值类型:dp or numeric,不考虑隐式类型转换的情况下与输入相同。

示例:

gbase=# SELECT exp(1.0);

exp

--------------------

2.7182818284590452

(1 row)

l floor(x)

描述:不大于参数的最大整数。

返回值类型:与输入相同。

示例:

gbase=# SELECT floor(-42.8);

floor

-------

-43

(1 row)

l int1(in)

描述:将传入的text参数转换为int1类型值并返回。

返回值类型:int1

示例:

gbase=# SELECT int1('123');

int1

------

123

(1 row)

l int2(in)

描述:将传入参数转换为int2类型值并返回。支持的入参类型包括float4,float8,int16,numeric,text。

返回值类型:int2

示例:

gbase=# SELECT int2('1234');

int2

------

1234

(1 row)

gbase=# SELECT int2(25.3);

int2

------

25

(1 row)

l int4(in)

描述:将传入参数转换为int4类型值并返回。支持的入参类型包括bit,boolean,char,duoble precision,int16,numeric, real,smallint,text。

返回值类型:int4

示例:

gbase=# select int4('789');

int4

------

 789

(1 row)

gbase=# select int4(99.9);

int4

------

 100

(1 row)

l float4(in)

描述:将传入参数转换为float4类型值并返回。支持的入参类型包括:bigint,duoble precision,int16,  integer, numeric,smallint,text 。

返回值类型:float4

示例:

gbase=# select float4('789');

float4

--------

789

(1 row) 

gbase=# select float4(99.9);

float4

--------

 99.9

(1 row)

l float8(in)

描述:将传入参数转换为float8类型值并返回。支持的入参类型包括:bigint,int16, integer,  numeric,real,smallint,text 。

返回值类型:float8

示例:

gbase=# select float8('789');

 float8

--------

 789

(1 row) 

gbase=# select float8(99.9);

 float8

--------

 99.9

(1 row)

l int16(in)

描述:将传入参数转换为int16类型值并返回。支持的入参类型包括:bigint,boolean,double precision,integer,numeric,oid,real,smallint,tinyint 。

返回值类型:int16

示例:

gbase=# select int16('789');

 int16

--------

 789

(1 row) 

gbase=# select int16(99.9);

 int16

--------

 100

(1 row) 

l numeric(in)

描述:将传入参数转换为numeric类型值并返回。支持的入参类型包括:bigint,boolean,double precision,int16,integer,money,real,smallint 。

返回值类型:numeric

示例:

gbase=# select "numeric"('789');

numeric

---------

789

(1 row) 

gbase=# select "numeric"(99.9);

numeric

---------

99.9

(1 row)

l oid(in)

描述:将传入参数转换为oid类型值并返回。支持的入参类型包括:bigint,int16。

返回值类型:oid

l radians(dp)

描述:把角度转为弧度。

返回值类型:double precision

示例:

gbase=# SELECT radians(45.0);

 radians

------------------

.785398163397448

(1 row)

l random()

描述:0.0到1.0之间的随机数。

返回值类型:double precision

示例:

gbase=# SELECT random();

 random

------------------

.824823560658842

(1 row)

l multiply(x double precision or text, y double precision or text)

描述:x和y的乘积。

返回值类型:double precision

示例:

gbase=# SELECT multiply(9.0, '3.0');

 multiply

-------------------

27

(1 row)

gbase=# SELECT multiply('9.0', 3.0);

 multiply

-------------------

27

(1 row)

l ln(x)

描述:自然对数。

返回值类型:dp or numeric,不考虑隐式类型转换的情况下与输入相同。

示例:

gbase=# SELECT ln(2.0);

 ln

-------------------

.6931471805599453

(1 row)

l log(x)

描述:以10为底的对数。

返回值类型:与输入相同。

示例:

gbase=# SELECT log(100.0);

 log

--------------------

 2.0000000000000000

(1 row)

l log(b numeric, x numeric)

l 描述:以b为底的对数。

返回值类型:numeric

示例:

gbase=# SELECT log(2.0, 64.0);

 log

--------------------

 6.0000000000000000

(1 row)

l mod(x,y)

描述:x/y的余数(模)。如果x是0,则返回0。返回值类型:与参数类型相同。

示例:

gbase=# SELECT mod(9,4);

 mod

-----

 1

(1 row)

gbase=# SELECT mod(9,0);

mod

-----

9

(1 row)

l pi()

描述:“π”常量。

返回值类型:double precision

示例:

gbase=# SELECT pi();

 pi

------------------

 3.14159265358979

(1 row)

l power(a double precision, b double precision)

描述:a的b次幂。

返回值类型:double precision

示例:

gbase=# SELECT power(9.0, 3.0);

 power

----------------------

 729.0000000000000000

(1 row)

l round(x)

描述:离输入参数最近的整数。

返回值类型:与输入相同。

示例:

gbase=# SELECT round(42.4);

 round

-------

 42

(1 row) 

gbase=# SELECT round(42.6);

 round

-------

 43

(1 row)

l round(v numeric, s int)

描述:保留小数点后s位,s后一位进行四舍五入。

返回值类型:numeric

示例:

gbase=# SELECT round(42.4382, 2);

 round

-------

 42.44

(1 row)

l setseed(dp)

描述:为随后的random()调用设置种子(-1.0到1.0之间,包含)。返回值类型:void

示例:

gbase=# SELECT setseed(0.54823);

 setseed

--------- 

(1 row)

l sign(x)

描述:输出此参数的符号。

返回值类型:-1表示负数,0表示0,1表示正数。

示例:

gbase=# SELECT sign(-8.4);

sign

------

-1

(1 row)

l sin(x)

描述:正弦。

返回值类型:double precision

示例:

gbase=# SELECT sin(1.57079);

sin

------------------

.999999999979986

(1 row)

l sqrt(x)

描述:平方根。

返回值类型:dp or numeric,不考虑隐式类型转换的情况下与输入相同。

示例:

gbase=# SELECT sqrt(2.0);

 sqrt

-------------------

 1.414213562373095

(1 row)

l tan(x)

描述:正切。

返回值类型:double precision

示例:

gbase=# SELECT tan(20);

 tan

------------------

 2.23716094422474

(1 row)

l trunc(x)

描述:截断(取整数部分)。

返回值类型:与输入相同。

示例:

gbase=# SELECT trunc(42.8);

 trunc

-------

 42

(1 row)

l trunc(v numeric, s int)

描述:截断为s位小数。

返回值类型:numeric

示例:

gbase=# SELECT trunc(42.4382, 2);

 trunc

-------

 42.43

(1 row)

l smgrne(a smgr, b smgr)

描述:比较两个smgr类型整数是否不相等。

返回值类型:bool

l smgreq(a smgr, b smgr)

描述:比较两个smgr类型整数是否相等。

返回值类型:bool

l int1abs

描述:返回uint8类型数据的绝对值。

参数:tinyint

返回值类型:tinyint

l int1and

描述:返回两个uint8类型数据按位与的结果。

参数:tinyint, tinyint

返回值类型:tinyint

l int1cmp

描述:返回两个uint8类型数据比较的结果,若第一个参数大,则返回1;若第二个参数大,则返回-1;若相等,则返回0。

参数:tinyint, tinyint

返回值类型:integer

l int1div

描述:返回两个uint8类型数据相除的结果,结果为float8类型。

参数:tinyint, tinyint

返回值类型:tinyint

l int1eq

描述:比较两个uint8类型数据是否相等。

参数:tinyint, tinyint

返回值类型:boolean

l int1ge

描述:判断两个uint8类型数据是否第一个参数大于等于第二个参数。

参数:tinyint, tinyint

返回值类型:boolean

l int1gt

描述:无符号1字节整数做大于运算。

参数:tinyint, tinyint

返回值类型:boolean

l int1larger

描述:无符号1字节整数求最大值。

参数:tinyint, tinyint

返回值类型:tinyint

l int1le

描述:无符号1字节整数做小于等于运算。

参数:tinyint, tinyint

返回值类型:boolean

l int1lt

描述:无符号1字节整数做小于运算。

参数:tinyint, tinyint

返回值类型:boolean

l int1smaller

描述:无符号1字节整数求最小算。

参数:tinyint, tinyint

返回值类型:tinyint

l int1inc

描述:无符号1字节整数加一。

参数:tinyint

返回值类型:tinyint

l int1mi

描述:无符号一字节整数做差运算。

参数:tinyint, tinyint

返回值类型:tinyint

l int1mod

描述:无符号一字节整数做取余运算。

参数:tinyint, tinyint

返回值类型:tinyint

l int1mul

描述:无符号一字节整数做乘法运算。

参数:tinyint, tinyint

返回值类型:tinyint

l int1ne

描述:无符号一字节整数不等于运算。

参数:tinyint, tinyint

返回值类型:boolean

l int1pl

描述:无符号一字节整数加法。

参数:tinyint, tinyint

返回值类型:tinyint

l int1um

描述:无符号一字节数去相反数并返回有符号二字节整数。

参数:tinyint

返回值类型:smallint

l int1xor

描述:无符号一字节整数异或操作。

参数:tinyint, tinyint

返回值类型:tinyint

l cash_div_int1

描述:对money类型进行除法运算。

参数:money, tinyint

返回值类型:money

l cash_mul_int1

描述:对money类型进行乘法运算。

参数:money, tinyint

返回值类型:money

l int1not

描述:无符号一字节整数二进制位翻转。

参数:tinyint

返回值类型:tinyint

l int1or

描述:无符号一字节整数或运算。

参数:tinyint, tinyint

返回值类型:tinyint

l int1shl

描述:无符号一字节整数左移指定位数。

参数:tinyint, integer

返回值类型:tinyint

l width_bucket(op numeric, b1 numeric, b2 numeric, count int)

描述:返回一个桶,这个桶是在一个有count个桶,上界为b1下界为b2的等深柱 图中operand将被赋予的那个桶。

返回值类型:int

示例:

gbase=# SELECT width_bucket(5.35, 0.024, 10.06, 5);

width_bucket

--------------

3

(1 row)

l width_bucket(op dp, b1 dp, b2 dp, count int)

描述:返回一个桶,这个桶是在一个有count个桶,上界为b1下界为b2的等深柱 图中operand将被赋予的那个桶。

返回值类型:int

示例:

gbase=# SELECT width_bucket(5.35, 0.024, 10.06, 5);

width_bucket

--------------

3

(1 row)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值