sql - Oracle中的 "NUMBER"和 "NUMBER(*,0)"是否相同?

标签 sql oracle types oracle11g sqldatatypes

在Oracle documentation中提到

NUMBER (precision, scale)

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



但是NUMBER(没有精度和小数位数)也接受浮点数(34.30),但是根据文档,如果未指定scale,则默认情况下应为零小数位数,因此应仅允许整数,对吗?

another questions中提到

default precision is 38, default scale is zero



因此,NUMBERNUMBER(*,0)应该相等,但不相等。

我哪里错了?

最佳答案

小数位数的默认值不为零,其中没有任何值。因此,它可以接受-84 to 127之间的任何值。如果将其限制为零,则即使该值包含小数位值,它也不会接受任何精度

create table aaaaa
(
sno number(*,0),
sno1 number
);
user_tab_columns将为您提供精度和小数位数的值(value)
SQL> select column_name,data_precision,data_scale from user_tab_columns where ta
ble_name = 'AAAAA';

COLUMN_NAME                    DATA_PRECISION DATA_SCALE
------------------------------ -------------- ----------
SNO                                                    0
SNO1

SQL>

请找到以下工作方式
SQL> select * from aaaaa;

no rows selected

SQL> insert into aaaaa values (123.123123,123123.21344);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from aaaaa;

       SNO       SNO1
---------- ----------
       123 123123.213

SQL>

关于sql - Oracle中的 "NUMBER"和 "NUMBER(*,0)"是否相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28207708/

相关文章:

mysql - 如何使用sql获取满足一定条件的结果?

mysql - 如何将所有值列表添加到 mysql 数据库并继续添加,即使有重复的主键?

c - 测试.c :51:4: error: incompatible types when assigning to type ‘blk from type ‘void *’

php - MySQL 中的匿名函数?

sql - 使用 dateadd 的 CASE 表达式中的奇怪行为

C# 2010,ODP.net,调用存储过程传递数组

sql - Oracle sql - 连接所有列

sql - 为什么no_data_found ORA-01403是Oracle中的异常?

go - 为什么 typeof(method) 不返回 Reflect.Method 实例?

types - 在 Swift 中实现闭包协议(protocol)