create schema double_precision;
set current_schema to 'double_precision';
create table test(a float(20, 2), b double(20, 2), c real(20, 2), d double precision(20, 2));
\d test;
Table "double_precision.test"
Column | Type | Modifiers
--------+---------------+-----------
a | numeric(20,2) |
b | numeric(20,2) |
c | numeric(20,2) |
d | numeric(20,2) |
insert into test values(0.014, 0.014, 0.014, 0.014), (0.015, 0.015, 0.015, 0.015), (0.0151, 0.0151, 0.0151, 0.0151),(0.016, 0.016, 0.016, 0.016),
(0.024, 0.024, 0.024, 0.024), (0.025, 0.025, 0.025, 0.025), (0.0251, 0.0251, 0.0251, 0.0251), (0.026, 0.026, 0.026, 0.026);
select a, b, c, d from test;
a | b | c | d
------+------+------+------
0.01 | 0.01 | 0.01 | 0.01
0.02 | 0.02 | 0.02 | 0.02
0.02 | 0.02 | 0.02 | 0.02
0.02 | 0.02 | 0.02 | 0.02
0.02 | 0.02 | 0.02 | 0.02
0.03 | 0.03 | 0.03 | 0.03
0.03 | 0.03 | 0.03 | 0.03
0.03 | 0.03 | 0.03 | 0.03
(8 rows)
create table test1(a float(0, 0));
ERROR: precision for type float must be at least 1 bit
LINE 1: create table test1(a float(0, 0));
^
create table test1(a double(0, 0));
ERROR: precision for type float must be at least 1 bit
LINE 1: create table test1(a double(0, 0));
^
create table test1(a real(0, 0));
ERROR: precision for type float must be at least 1 bit
LINE 1: create table test1(a real(0, 0));
^
create table test1(a double precision(0, 0));
ERROR: precision for type float must be at least 1 bit
LINE 1: create table test1(a double precision(0, 0));
^
create table test1(a float(1001, 0));
ERROR: precision for type float must be less than 256 bits
LINE 1: create table test1(a float(1001, 0));
^
create table test1(a double(1001, 0));
ERROR: precision for type float must be less than 256 bits
LINE 1: create table test1(a double(1001, 0));
^
create table test1(a real(1001, 0));
ERROR: precision for type float must be less than 256 bits
LINE 1: create table test1(a real(1001, 0));
^
create table test1(a double precision(1001, 0));
ERROR: precision for type float must be less than 256 bits
LINE 1: create table test1(a double precision(1001, 0));
^
create table test1(a float(1001));
ERROR: precision for type float must be less than 54 bits
LINE 1: create table test1(a float(1001));
^
create table test1(a float(1001, 2));
ERROR: NUMERIC precision 1001 must be between 1 and 1000
LINE 1: create table test1(a float(1001, 2));
^
create table test1(a double(1001, 2));
ERROR: NUMERIC precision 1001 must be between 1 and 1000
LINE 1: create table test1(a double(1001, 2));
^
create table test1(a real(1001, 2));
ERROR: NUMERIC precision 1001 must be between 1 and 1000
LINE 1: create table test1(a real(1001, 2));
^
create table test1(a double precision(1001, 2));
ERROR: NUMERIC precision 1001 must be between 1 and 1000
LINE 1: create table test1(a double precision(1001, 2));
^
create table test1(a float(1, 2));
ERROR: NUMERIC scale 2 must be between 0 and precision 1
LINE 1: create table test1(a float(1, 2));
^
create table test1(a double(1, 2));
ERROR: NUMERIC scale 2 must be between 0 and precision 1
LINE 1: create table test1(a double(1, 2));
^
create table test1(a real(1, 2));
ERROR: NUMERIC scale 2 must be between 0 and precision 1
LINE 1: create table test1(a real(1, 2));
^
create table test1(a double precision(1, 2));
ERROR: NUMERIC scale 2 must be between 0 and precision 1
LINE 1: create table test1(a double precision(1, 2));
^
create table test1(a float(255, 30), b double(255, 30), c real(255, 30), d double precision(255, 30));
insert into test1 values(9007199254740991, 9007199254740991, 9007199254740991, 9007199254740991),
(9007199254740992, 9007199254740992, 9007199254740992, 9007199254740992),
(9007199254740993, 9007199254740993, 9007199254740993, 9007199254740993),
(9007199254740994, 9007199254740994, 9007199254740994, 9007199254740994),
(9007199254740995, 9007199254740995, 9007199254740995, 9007199254740995),
(9007199254740996, 9007199254740996, 9007199254740996, 9007199254740996);
select a, b, c, d from test1;
a | b | c | d
-------------------------------------------------+-------------------------------------------------+-------------------------------------------------+-------------------------------------------------
9007199254740991.000000000000000000000000000000 | 9007199254740991.000000000000000000000000000000 | 9007199254740991.000000000000000000000000000000 | 9007199254740991.000000000000000000000000000000
9007199254740992.000000000000000000000000000000 | 9007199254740992.000000000000000000000000000000 | 9007199254740992.000000000000000000000000000000 | 9007199254740992.000000000000000000000000000000
9007199254740993.000000000000000000000000000000 | 9007199254740993.000000000000000000000000000000 | 9007199254740993.000000000000000000000000000000 | 9007199254740993.000000000000000000000000000000
9007199254740994.000000000000000000000000000000 | 9007199254740994.000000000000000000000000000000 | 9007199254740994.000000000000000000000000000000 | 9007199254740994.000000000000000000000000000000
9007199254740995.000000000000000000000000000000 | 9007199254740995.000000000000000000000000000000 | 9007199254740995.000000000000000000000000000000 | 9007199254740995.000000000000000000000000000000
9007199254740996.000000000000000000000000000000 | 9007199254740996.000000000000000000000000000000 | 9007199254740996.000000000000000000000000000000 | 9007199254740996.000000000000000000000000000000
(6 rows)
create table test2(a float(20, 0), b double(20, 0), c real(20, 0), d double precision(20, 0));
insert into test2 values(9007199254740991, 9007199254740991, 9007199254740991, 9007199254740991),
(9007199254740992, 9007199254740992, 9007199254740992, 9007199254740992),
(9007199254740993, 9007199254740993, 9007199254740993, 9007199254740993),
(9007199254740994, 9007199254740994, 9007199254740994, 9007199254740994),
(9007199254740995, 9007199254740995, 9007199254740995, 9007199254740995),
(9007199254740996, 9007199254740996, 9007199254740996, 9007199254740996);
select a, b, c, d from test2;
a | b | c | d
------------+------------+------------+------------
9.0072e+15 | 9.0072e+15 | 9.0072e+15 | 9.0072e+15
9.0072e+15 | 9.0072e+15 | 9.0072e+15 | 9.0072e+15
9.0072e+15 | 9.0072e+15 | 9.0072e+15 | 9.0072e+15
9.0072e+15 | 9.0072e+15 | 9.0072e+15 | 9.0072e+15
9.0072e+15 | 9.0072e+15 | 9.0072e+15 | 9.0072e+15
9.0072e+15 | 9.0072e+15 | 9.0072e+15 | 9.0072e+15
(6 rows)
create table test3(a float(255, 0), b double(255, 0), c real(255, 0), d double precision(255, 0));
insert into test3 values(9007199254740991, 9007199254740991, 9007199254740991, 9007199254740991),
(9007199254740992, 9007199254740992, 9007199254740992, 9007199254740992),
(9007199254740993, 9007199254740993, 9007199254740993, 9007199254740993),
(9007199254740994, 9007199254740994, 9007199254740994, 9007199254740994),
(9007199254740995, 9007199254740995, 9007199254740995, 9007199254740995),
(9007199254740996, 9007199254740996, 9007199254740996, 9007199254740996);
select a, b, c, d from test3;
a | b | c | d
------------------+------------------+------------------+------------------
9007199254740991 | 9007199254740991 | 9007199254740991 | 9007199254740991
9007199254740992 | 9007199254740992 | 9007199254740992 | 9007199254740992
9007199254740992 | 9007199254740992 | 9007199254740992 | 9007199254740992
9007199254740994 | 9007199254740994 | 9007199254740994 | 9007199254740994
9007199254740996 | 9007199254740996 | 9007199254740996 | 9007199254740996
9007199254740996 | 9007199254740996 | 9007199254740996 | 9007199254740996
(6 rows)
\d test3
Table "double_precision.test3"
Column | Type | Modifiers
--------+------------------+-----------
a | double precision |
b | double precision |
c | double precision |
d | double precision |
create table test4(a float(100, 50), b double(100, 50),c real(100, 50), d double precision(100, 50));
insert into test4 values(99999999999999999999999999999999999999999999999999.99999999999999999999999999999999999999999999999999,
99999999999999999999999999999999999999999999999999.99999999999999999999999999999999999999999999999999,
99999999999999999999999999999999999999999999999999.99999999999999999999999999999999999999999999999999,
99999999999999999999999999999999999999999999999999.99999999999999999999999999999999999999999999999999);
select a, b, c, d from test4;
a | b | c | d
-------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------
99999999999999999999999999999999999999999999999999.99999999999999999999999999999999999999999999999999 | 99999999999999999999999999999999999999999999999999.99999999999999999999999999999999999999999999999999 | 99999999999999999999999999999999999999999999999999.99999999999999999999999999999999999999999999999999 | 99999999999999999999999999999999999999999999999999.99999999999999999999999999999999999999999999999999
(1 row)
create table test5(a float(3.6, 1.6));
ERROR: syntax error at or near "3.6"
LINE 1: create table test5(a float(3.6, 1.6));
^
create table test5(a real(3.6, 1.6));
ERROR: syntax error at or near "3.6"
LINE 1: create table test5(a real(3.6, 1.6));
^
create table test5(a double precision(3.6, 1.6));
ERROR: syntax error at or near "3.6"
LINE 1: create table test5(a double precision(3.6, 1.6));
^
create table test5(a double(3.5, 1.4));
\d test5
Table "double_precision.test5"
Column | Type | Modifiers
--------+--------------+-----------
a | numeric(4,1) |
drop schema double_precision cascade;
NOTICE: drop cascades to 6 other objects
DETAIL: drop cascades to table test
drop cascades to table test1
drop cascades to table test2
drop cascades to table test3
drop cascades to table test4
drop cascades to table test5
reset current_schema;