3,491
社区成员
发帖
与我相关
我的任务
分享
--这里有个测试表
SQL> create table binary_test
2 (bin_float binary_float,
3 bin_double binary_double)
--向表中添加数据并查看
SQL> insert into binary_test(
2 bin_float,bin_double)
3 values(39.5f,15.7d)
4 /
1 row inserted
SQL> insert into binary_test(bin_float,bin_double)
2 values(binary_float_infinity,binary_double_infinity);
1 row inserted
SQL> select * from binary_test;
BIN_FLOAT BIN_DOUBLE
---------- ----------
39.5 15.7
1E126 1E126
--但是当我执行下面的操作后,问题就来了
SQL> insert into binary_test(bin_float,bin_double)
2 values(binary_float_nan,binary_double_nan);
1 row inserted
SQL> select * from binary_test;
select * from binary_test
ORA-01722: 无效数字
--我明明向表中添加了3条数据,为啥查不出来呢?还显示为无效数子
--是不是我插入的binary_float_nan,binary_double_nan将前面的数字覆盖了,也认为那些数据为无效的数字呢?
--或者是数据的插入顺序其的作用?
SQL> rollback;
Rollback complete
SQL> select count(*) from binary_test;
COUNT(*)
----------
0
SQL> insert into binary_test(bin_float,bin_double)
2 values(binary_float_nan,binary_double_nan);
1 row inserted
SQL> select * from binary_test;
select * from binary_test
ORA-01722: 无效数字
SQL> insert into binary_test(bin_float,bin_double)
2 values(36.12f,564.1545d);
1 row inserted
--当我查看表中的数据时,有两条数据
SQL> select count(*) from binary_test;
COUNT(*)
----------
2
--但是我查看时,还是显示为无效数字
SQL> select * from binary_test;
select * from binary_test
ORA-01722: 无效数字
--原来是pl/sql developer的问题!
scott@YPCOST> insert into binary_test(
2 bin_float,bin_double)
3 values(39.5f,15.7d)
4 /
已创建 1 行。
scott@YPCOST> ed
已写入 file afiedt.buf
1 insert into binary_test(bin_float,bin_double)
2* values (binary_float_infinity,binary_double_infinity);
scott@YPCOST> /
values (binary_float_infinity,binary_double_infinity);
*
第 2 行出现错误:
ORA-00911: 无效字符
--解释下为什么上面的语句会报错 因为是通过ed进行编辑的 然后通过回车符进行执行
--最后一个;就是多余的了
scott@YPCOST> ed
已写入 file afiedt.buf
1 insert into binary_test(bin_float,bin_double)
2* values (binary_float_infinity,binary_double_infinity)
scott@YPCOST> /
已创建 1 行。
--例如上面把;去掉就正常了
scott@YPCOST> ed\
scott@YPCOST> ed
已写入 file afiedt.buf
1* select * from binary_test;
scott@YPCOST> /
select * from binary_test;
*
第 1 行出现错误:
ORA-00911: 无效字符
--这个也是同样的道理
--而下面的语句是直接写的语句(没有通过ed进行编辑) 用;结束 然后执行
scott@YPCOST> select * from binary_test;
BIN_FLOAT BIN_DOUBLE
---------- ----------
3.95E+001 1.57E+001
Inf Inf
SQL> create table binary_test
2 (bin_float binary_float,
3 bin_double binary_double)
4 /
Table created
SQL>
SQL> insert into binary_test(
2 bin_float,bin_double)
3 values(39.5f,15.7d)
4 /
1 row inserted
SQL>
SQL> insert into binary_test(bin_float,bin_double)
2 values(binary_float_infinity,binary_double_infinity);
1 row inserted
SQL> commit
2 /
Commit complete
SQL> select * from binary_test
2 /
BIN_FLOAT BIN_DOUBLE
---------- ----------
39.5 15.7
1E126 1E126
SQL>
SQL> insert into binary_test(bin_float,bin_double)
2 values(binary_float_nan,binary_double_nan)
3 /
1 row inserted
SQL> commit
2 /
Commit complete
SQL> select * from binary_test
2 /
select * from binary_test
ORA-01722: 无效数字
SQL> select count(*) from binary_test
2 /
COUNT(*)
----------
3
SQL>
--sqlplus 下则可以 是的如楼上说 的
scott@ORCL> select * from binary_test
2 /
BIN_FLOAT BIN_DOUBLE
---------- ----------
3.95E+001 1.57E+001
Inf Inf
Nan Nan
SQL> create table binary_test
2 (bin_float binary_float,
3 bin_double binary_double);
表已创建。
SQL> insert into binary_test (bin_float, bin_double) values (39.5f, 15.7d);
已创建 1 行。
SQL> commit;
提交完成。
SQL> insert into binary_test(bin_float,bin_double)
2 values(binary_float_infinity,binary_double_infinity);
已创建 1 行。
SQL> commit;
提交完成。
SQL> insert into binary_test(bin_float,bin_double)
2 values(binary_float_nan,binary_double_nan);
已创建 1 行。
SQL> commit;
提交完成。
SQL> select * from binary_test;
BIN_FLOAT BIN_DOUBLE
---------- ----------
3.95E+001 1.57E+001
Inf Inf
Nan Nan
SQL> select * from binary_test where bin_float is NAN;
BIN_FLOAT BIN_DOUBLE
---------- ----------
Nan Nan
SQL>
--也就是说nan影响到了整个查询了!
--那可不可一得出这样的结论呢?
--当表里面有一个binary_float或binary_double类型列时,给其赋值nan
--将会影响到所有关于此列的select * 或者select a.*的查询操作?
--也就是说nan影响到了整个查询了!
--那可不可一得出这样的结论呢?
--当表里面有一个binary_float或binary_double类型列时,给其赋值nan,将会影响到所有的查询操作?
--为何执行这句话的时候,什么也查不出来呢?是第三条数据(非数)影响到了整个查询吗?
SQL> select * from binary_test where rownum<=3;
select * from binary_test where rownum<=3
ORA-01722: invalid number
--谢谢各位的积极参与
SQL> select to_char(bin_float) cl,to_char(bin_double) c2 from binary_test where rownum<=3;
CL C2
---------------------------------------- ----------------------------------------
Nan Nan
3.61199989E+001 5.6415449999999998E+002
SQL> select * from binary_test t where t.bin_float !=binary_float_nan;
BIN_FLOAT BIN_DOUBLE
---------- ----------
39.5 15.7
1E126 1E126
SQL>
SQL> select count(*) from test_binary;
select count(*) from test_binary
ORA-00942: 表或视图不存在
SQL> select count(*) from binary_test;
COUNT(*)
----------
3
SQL> select * from binary_test where rownum<=1;
BIN_FLOAT BIN_DOUBLE
---------- ----------
39.5 15.7
SQL> select * from binary_test where rownum<=2;
BIN_FLOAT BIN_DOUBLE
---------- ----------
39.5 15.7
1E126 1E126
SQL> select * from binary_test where rownum<=3;
select * from binary_test where rownum<=3
ORA-01722: invalid number
SQL>
--你没理解我的意思,首先我的操作没有错误!嘿嘿
--我是想知道,为什么我添加到表中的两条数据怎么查不出来?
--我知道他两binary_float_nan,binary_double_nan是非binary_float和binary_double的数字,但是明明另外--还有一条数据的,怎么那条数据也不会显示出来呢?
--而我是通过PL/SQL Developer编辑的,没用到ed命令在notepad里面编辑。