sql - oracle中<number>d或<number>f是什么意思?

标签 sql database oracle

下面是从对偶表中选择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

它有什么用?什么意思?

最佳答案

df 用于隐式声明数字为 float

1.0E+002scientific notation 100

100a 只是被 oracle 解释为数字值 100 别名 a


官方文档NUMBER and Floating-Point Literals

enter image description here

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/

相关文章:

php - 为处理可变数量的质量规范的 mySQL/PHP 应用程序构建数据结构的正确方法

sql - 这种日期格式叫什么?

mysql - 根据类(class)对学生进行排名

php - 从数据库中获取一个值

mysql - 对 ID 有限制的 SQL SELECT

sql - 数据库和ERP

sql - Oracle级联删除

oracle - 查找使用用户定义函数的存储过程?

mysql - 连接Mysql中的字段

mysql - 基于单个列值的 SQL 循环和插入