Oracle number data type

Source: Internet
Author: User

Oracle number data type number (p, s) p: Total number of digits s: number of decimal places, for example, number (5, 2), indicates that the number of digits in an integer is 3 digits, and the number of decimal places is 2 digits and 1 digit. number (5, 2): the maximum number of digits of an integer is three digits, and the number of decimal places can exceed two digits. The value is scott @ ORA10G> create table tt (msg varchar2 (10 ), num_col number (5, 2); Table created. scott @ ORA10G> insert into tt values ('2017. 45', 123.45); 1 row created. the number of decimal places is rounded to: scott @ ORA10G> insert into tt values ('2017. 456 ', 123.456); 1 row created. scott @ ORA10G> select * from tt; MSG NUM_COL ---------- 123.45 123.45123.456 123.46 integer digits can be up to three digits: scott @ ORA10G> insert into tt values ('123', 1234 ); insert into tt values ('20170101', 1234) * ERROR at line 1: ORA-01438: value larger than specified precision allowed for this column 2. number (5,-2): The number of digits in the integer is rounded to 100, and the number of decimal places is not inserted. scott @ ORA10G> create table t 2 (msg varchar (10 ), 3 num_col number (5,-2) 4); Table created. scott @ ORA10G> insert into t values ('2017. 45', 123.45); 1 row created. scott @ ORA10G> insert into t values ('2017. 456 ', 123.456); 1 row created. scott @ ORA10G> select * from t; MSG NUM_COL ---------- 123.45 100123.456 100scott @ ORA10G> insert into t values ('2017. 123. 4567 ', 123.4567); 1 row created. scott @ ORA10G> insert into t values ('2017. 4567 ', 223.4567); 1 row created. scott @ ORA10G> insert into t values ('2017. 4567 ', 323.4567); 1 row created. scott @ ORA10G> select * from t; MSG NUM_COL ---------- 123.45 100123.456 100123.4567 100223.4567 200323.4567 scott @ ORA10G> commit; Commit complete. scott @ ORA10G> scott @ ORA10G> scott @ ORA10G> select * from t; MSG NUM_COL ---------- 123.45 100123.456 100123.4567 100223.4567 200323.4567 300 integer digits can be up to 7 digits, if the number of digits exceeds 7, you cannot insert scott @ ORA10G> insert into t values ('000000', 1234567); 1 row created. scott @ ORA10G> select * from t; MSG NUM_COL ---------- 123.45 100123.456 100123.4567 100223.4567 200323.4567 3001234567 rows selected. scott @ ORA10G> insert into t values ('20140901', 12345678); insert into t values ('20160901', 12345678) * ERROR at line 1: ORA-01438: value larger than specified precision allowed for this column scott @ ORA10G> insert into t values ('2017. 23 ', 1234567.23); 1 row created. scott @ ORA10G> select * from t; MSG NUM_COL ---------- 123.45 100123.456 100123.4567 100223.4567 200323.4567 3001234567 12346001234567.23 rows selected.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.