gpt4 book ai didi

sql - Oracle SQL中的数字格式

转载 作者:行者123 更新时间:2023-12-02 11:24:36 25 4
gpt4 key购买 nike

我已经完成了将数据从Oracle View 导出到固定长度的文本文件的任务,但是已经指定了如何将数据导出到文本文件的规范。 IE。

quantity            NUM         (10)  
price NUM (8,2)
participant_id CHAR (3)
brokerage NUM (10,2)
cds_fees NUM (8,2)

我的困惑出现在数字类型上,当它表示为(8,2)时。如果我要使用与文字相同的文字,是否有效地意味着
10 characters (as to_char(<field name>, '9999999.99')) 

或者
8 characters (as to_char(<field name>, '99999.99')) 

在文本文件中导出到定长文本字段时?

我正在看这个 question,它提供了一个见解,但不是全部。

感谢有人可以通过一些例子启发我。

非常感谢。

最佳答案

根据Oracle docs on types

Optionally, you can also specify a precision (total number of digits) and scale (number of digits to the right of the decimal point):

If a precision is not specified, the column stores values as given. If no scale is specified, the scale is zero.



因此,在您的情况下, NUMBER(8,2)具有:
  • 总数
  • 8位数字
  • 其中2个在小数点后

  • 这为您提供了从 -999999.99999999.99的范围

    关于sql - Oracle SQL中的数字格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17715746/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com