data type之number

SQL> create table n
2 (
3 num number(5,2)
4 );

Table created.

SQL> insert into n values (12345.12);
insert into n values (12345.12)
                      *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL>    
SQL> insert into n values (12345.1);
insert into n values (12345.1)
                      *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL> insert into n values(12345.0);
insert into n values(12345.0)
                     *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL> insert into n values(1234.12);
insert into n values(1234.12)
                     *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL> insert into n values(1234.1);
insert into n values(1234.1)
                     *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL> desc t
ERROR:
ORA-04043: object t does not exist


SQL> desc n
Name                                      Null?    Type
----------------------------------------- -------- ----------------------------
NUM                                                NUMBER(5,2)

SQL> insert into n values (123.12);

1 row created.

SQL> insert into n values (1234.1);
insert into n values (1234.1)
                      *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL> insert into n values (12.123);

1 row created.

SQL>   
SQL> select * from n;

       NUM
----------
    123.12
     12.12

SQL> commit;

Commit complete.

SQL> desc n
Name                                      Null?    Type
----------------------------------------- -------- ----------------------------
NUM                                                NUMBER(5,2)

SQL> select * from n;

       NUM
----------
    123.12
     12.12

SQL> insert into n values (1234.10000);
insert into n values (1234.10000)
                      *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL> insert into n values (12345);
insert into n values (12345)
                      *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL> insert into n values(1234);
insert into n values(1234)
                     *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL> alter table n drop column num;
alter table n drop column num
*
ERROR at line 1:
ORA-12988: cannot drop column from table owned by SYS


SQL> drop table n;

Table dropped.

SQL>  
SQL> creater table n(num number(5,-2));
SP2-0734: unknown command beginning "creater ta..." - rest of line ignored.
SQL>
SQL>
SQL> r
1* drop table n
drop table n
           *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> creater table n(num number(5,-2));
SP2-0734: unknown command beginning "creater ta..." - rest of line ignored.
SQL> creater table n(num number(5,-2));
SP2-0734: unknown command beginning "creater ta..." - rest of line ignored.
SQL> creater table n(num number(5,-2));
SP2-0734: unknown command beginning "creater ta..." - rest of line ignored.
SQL>
SQL>
SQL>
SQL>
SQL> create table n (   
2 num number(5,-2)
3 );

Table created.

SQL> desc n
Name                                      Null?    Type
----------------------------------------- -------- ----------------------------
NUM                                                NUMBER(5,-2)

SQL> insert into values(12345);
insert into values(12345)
            *
ERROR at line 1:
ORA-00903: invalid table name


SQL> insert into n values(12345);

1 row created.

SQL> insert into n values(123456);

1 row created.

SQL> insert into n values(1234567);

1 row created.

SQL> insert into n values(12345678);
insert into n values(12345678)
                     *
ERROR at line 1:
ORA-01438: value larger than specified precision allowed for this column


SQL>              
SQL>
SQL> select * from n;

       NUM
----------
     12300
    123500
   1234600

SQL> insert into n values(1);

1 row created.

SQL> insert into n values(1.11);

1 row created.

SQL> insert into n values(11.123);

1 row created.

SQL> select * from n;

       NUM
----------
     12300
    123500
   1234600
         0
         0
         0

6 rows selected.

SQL> insert into n values(111.1111);

1 row created.

SQL> select * from n;

       NUM
----------
     12300
    123500
   1234600
         0
         0
         0
       100

7 rows selected.

SQL> insert into n values(1111.1111111111111111111111);

1 row created.

SQL> select * from n;

       NUM
----------
     12300
    123500
   1234600
         0
         0
         0
       100
      1100

8 rows selected.

SQL>

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/42174/viewspace-327231/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/42174/viewspace-327231/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值