下面是从对偶表中选择100
的正常执行:
SQL> select 100 from dual;
100
----------
100
这是将 'a'
添加到数字 100
的相同执行,它只是设置列名称。对于除 d 和 f 之外的任何其他字母表,结果都是相同的。
SQL> select 100a from dual;
A
----------
100
这是将 'd'
和 'f'
添加到数字 100
SQL> select 100d from dual;
100D
----------
1.0E+002
SQL> select 100f from dual;
100F
----------
1.0E+002
它有什么用?什么意思?
最佳答案
d
和 f
用于隐式声明数字为 float 。
1.0E+002
是 scientific notation 100
100a
只是被 oracle 解释为数字值 100
别名 a
。
官方文档NUMBER and Floating-Point Literals
f or F indicates that the number is a 32-bit binary floating point number (of type BINARY_FLOAT).
d or D indicates that the number is a 64-bit binary floating point number (of type BINARY_DOUBLE)
可以在 ROUND() function 中找到此行为的示例文档
The following examples illustrate the difference between rounding NUMBER and floating-point number values. NUMBER values are rounded up (for positive values), whereas floating-point numbers are rounded toward the nearest even value:
SELECT ROUND(1.5), ROUND(2.5) FROM DUAL; ROUND(1.5) ROUND(2.5) ---------- ---------- 2 3 SELECT ROUND(1.5f), ROUND(2.5f) FROM DUAL; ROUND(1.5F) ROUND(2.5F) ----------- ----------- 2.0E+000 2.0E+000
关于sql - oracle中<number>d或<number>f是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39672695/