English 中文(简体)
甲骨质素NUMBER的比精密度要大吗?
原标题:How can an Oracle NUMBER have a Scale larger than the Precision?

文件指出:“考试范围从1到38。 比额表从-84到127。

比额表如何大于准确性? 比额表在-38至38之间是否应当如此?

最佳回答

The question could be why not ? Try the following SQL.

select cast(0.0001 as number(2,5)) num, 
       to_char(cast(0.0001 as number(2,5))) cnum,
       dump(cast(0.0001 as number(2,5))) dmp
  from dual

What you see is that you can hold small numbers is that sort of structure It might not be required very often, but I m sure somewhere there is someone who is storing very precise but very small numbers.

问题回答

据Oracle文件称:

比额表可能比精确性更强,最常用的是使用排位(精度部分可能如此大)。 如果规模大于精确度,精确性就具体指明了正确点权利的高位数。 例如,一个称为<代码>NUMBER(4,5)的栏目要求在数字点后一位数为零,并在数字点后将所有数值上乘。

这里我是如何看到的:

  • When Precision is greater than Scale (e.g NUMBER(8,5)), no problem, this is straightforward. Precision means the number will have a total of 8 digits, 5 of which are in the fractional part (.→), so the integer part (←.) will have 3 digits. This is easy.
  • 如果你看到<代码>Precision小于<编码>Scale(例如NUMBER(2,5)),这意味着:

    • The number will not have any integer part, only fractional part. So the 0 in the integer part is not counted in the calculations, you say .12345 not 0.12345. In fact, if you specify just 1 digit in the integer part, it will always return an error.
    • The Scale represents the total number of digits in the fractional part that the number will have. 5 in this case. So it can be .12345 or .00098 but no more than 5 digits in total.
    • The fractional part is divided into 2 parts, significant numbers and zeros. Significant numbers are specified by Precision, and minimum number of zeros equals (Scale - Precision). Example :

    ”/</a

    页: 1 这一数字在分数部分中至少必须达到3零。 接下来是2个大数目(也可能是零)。 因此,有3个零+2个大数 = 5个,即<代码>Scale。

简言之,当你看到<条码>NUMBER(6,9)时,这告诉我们,分部分总数为9位数,从3位强制性零开始,然后是6位数。

以下是一些例子:

SELECT CAST(.0000123 AS NUMBER(6,9)) FROM dual;   -- prints: 0.0000123; .000|012300
SELECT CAST(.000012345 AS NUMBER(6,9)) FROM dual; -- prints: 0.0000123; .000|012345
SELECT CAST(.123456 AS NUMBER(3,4)) FROM dual;    -- ERROR! must have a 1 zero (4-3=1)
SELECT CAST(.013579 AS NUMBER(3,4)) FROM dual;    -- prints: 0.0136; max 4 digits, .013579 rounded to .0136

感谢大家的答复。 看起来像精准的数字一样。

 select cast(0.000123 as number(2,5)) from dual

结果:

.00012

不适用

 select cast(0.00123 as number(2,5)) from dual

以及

 select cast(0.000999 as number(2,5)) from dual

两者都导致:

ORA-01438: value larger than specified precision allowed for this column

页: 1

据Oracle文件称:

比额表可能比精确性更强,最常用的是使用电子表示。 如果规模大于精确度,精确性就具体指明了正确点权利的高位数。 例如,一个名为NUMBER(4,5)的栏目要求,位数后位数位数的位数为零,在位数点后,将位数位数的位数与位数相重。

详细规定对投入进行额外廉正检查的固定点号码栏的大小和精确度是良好做法。 投机的规模和精确性并不迫使所有价值固定时间。 如果价值超过精确度,那么Oracle就会出现错误。 如果价值超过比额表,则Oracle会合。

比额表大于精确度的情况可以归纳如下:

数字

最低数量

--this will work 
select cast(0.123456 as number(5,5)) from dual;

页: 1

-- but this
select cast(0.123456 as number(2,5)) from dual;
--will return "ORA-1438 value too large".  
--It will not return err with at least 5-2 = 3 zeroes:
select cast(0.000123456 as number(2,5)) from dual;

页: 1

-- and of course this will work too
select cast(0.0000123456 as number(2,5)) from dual;

页: 1

Hmm as I understand the reference the precision is the count of digits.
maximum precision of 126 binary digits, which is roughly equivalent to 38 decimal digits

在你拥有NUMBER(精度、规模)类型中,精确度为数,比例为数位数。 比额表可以删除,但意味着零。 精度可以不明确(如NUMBER(*,10)——这意味着数字总数视需要而定,但是有10位数正确。

If the scale is less than zero, the value will be rounded to scale digits left the decimal point.
I think that if you reserve more numbers right of the decimal point than there can be in the whole number, this means something like 0.00000000123456 but I am not 100% sure.





相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

How to make a one to one left outer join?

I was wondering, is there a way to make a kind of one to one left outer join: I need a join that matches say table A with table B, for each record on table A it must search for its pair on table B, ...

Insert if not exists Oracle

I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: INSERT ALL ...

How can I store NULLs in NOT NULL field?

I just came across NULL values in NOT-NULL fields in our test database. How could they get there? I know that NOT-NULL constraints can be altered with NOVALIDATE clause, but that would change table s ...

Type reference scope

I m studying databases and am currently working on a object-relational DB project and I ve encountered a small problem with the number of possible constraints in an object table. I m using "Database ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

热门标签