程序如下。
declare
-- Local variables here
i integer;
a number(19,7);
b number(19,3);
c number(19,7);
begin
-- Test statements here
a := 123456789012.1234567;
b := 1.000;
c := a * b;
dbms_output.put_line(c); -- 输出123456789012.1234567
dbms_output.put_line(a * b); -- 输出123456789012.1234567 INSERT INTO AAA
(AAA) VALUES(c);
COMMIT;
end;问题是插入表中的数据就是
123456789012.1230010。
表AAA的字段AAA的类型是NUMBER(19,7)的。为什么?哪位能给解释一下。
declare
-- Local variables here
i integer;
a number(19,7);
b number(19,3);
c number(19,7);
begin
-- Test statements here
a := 123456789012.1234567;
b := 1.000;
c := a * b;
dbms_output.put_line(c); -- 输出123456789012.1234567
dbms_output.put_line(a * b); -- 输出123456789012.1234567 INSERT INTO AAA
(AAA) VALUES(c);
COMMIT;
end;问题是插入表中的数据就是
123456789012.1230010。
表AAA的字段AAA的类型是NUMBER(19,7)的。为什么?哪位能给解释一下。
解决方案 »
- 用or查询时条件多会严重影响性能?
- 新人小问题求指教
- 如何在存储过程里实现快速删除插入大量数据?
- imp的时候,报ORA-01452错误与 2437错误,求解
- 有高手知道oracle10g 的ldap如何使用吗? 有没有相关的文檔或网址,该如何学习呢?
- SQL查询问题(oracle)
- oracle 8i 超级管理员密码的问题?
- 我在oracle中创建了一个数据库,为什么在OME中可以看到,而在OMS中看不到呢?
- utl_file.fseek(fid,absolte,relitive)怎么定位到文件第一行
- nvl 和 sum group
- oracle 9i备份出现的问题
- select 'A' + a.company_id as new_id from t_pub_user a
alter table aaa add (b,number,a number(19,7),b1 number(19,3))
declare
a number;
b number;
c number;
begin
a:=123456789012.7654321;
b:=1.000;
c:=a*b;
dbms_output.put_line(c);
dbms_output.put_line(a*b);insert into aaa values (c,b,a,b);
commit;
end;
在插入数据库是a的值改变了
即使用insert into aaa (a) values (123456789012.1234567)
插入到数据库的值还是123456789012.1230010
SQL> drop table aaa;Table droppedSQL> create table aaa(aa number(19,7));Table createdSQL> insert into aaa select 123456789012.7654321 from dual;1 row insertedSQL> commit;Commit completeSQL> select * from aaa; AA
---------------------
123456789012.7650080SQL> select to_char(aa) from aaa;TO_CHAR(AA)
----------------------------------------
123456789012.7654321
declare
a number(19,7);
b number(19,3);
c number(19,7);
begin a := 123456789012.1234567;
b := 1.000;
c := a * b; insert into t7 values(9,c,'T');
insert into t7 values(10,a*b,'T');end;
/
SQL> select * from t7; F1 F2 F3
-------------------- -------------------- ----------------------------------------
9 123456789012.1234567 T
10 123456789012.1234567 T
SQL> desc t7
名前 NULL? 型
----------------------------------------- -------- ----------------------------
F1 NOT NULL NUMBER(10)
F2 NUMBER(19,7)
F3 VARCHAR2(40)