Re: Column information

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Igor Korot <ikorot01(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Column information
Date: 2017-05-04 14:03:53
Message-ID: db2a2f20-5e7b-7425-68a6-5119f7d4314a@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 05/03/2017 08:18 PM, Igor Korot wrote:
> Hi, ALL,
> One more question if I may.
>
> [code]
> draft=# SELECT * FROM information_schema.columns WHERE table_name =
> 'leagues' AND ordinal_position = 8;
> table_catalog | table_schema | table_name | column_name |
> ordinal_position | column_default | is_nullable | data_type |
> character_maximum_length | character_octet_length | numeric_precision
> | numeric_precision_radix | numeric_scale | datetime_precision |
> interval_type | interval_precision | character_set_catalog |
> character_set_schema | character_set_name | collation_catalog |
> collation_schema | collation_name | domain_catalog | domain_schema |
> domain_name | udt_catalog | udt_schema | udt_name | scope_catalog |
> scope_schema | scope_name | maximum_cardinality | dtd_identifier |
> is_self_referencing | is_identity | identity_generation |
> identity_start | identity_increment | identity_maximum |
> identity_minimum | identity_cycle | is_generated |
> generation_expression | is_updatable
> ---------------+--------------+------------+--------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+-------------------------+---------------+--------------------+---------------+--------------------+-----------------------+----------------------+--------------------+-------------------+------------------+----------------+----------------+---------------+-------------+-------------+------------+----------+---------------+--------------+------------+---------------------+----------------+---------------------+-------------+---------------------+----------------+--------------------+------------------+------------------+----------------+--------------+-----------------------+--------------
> draft | public | leagues | benchplayers |
> 8 | | YES | integer |
> | | 32 |
> 2 | 0 | | |
> | | |
> | | | |
> | | | draft | pg_catalog | int4
> | | | |
> | 8 | NO | NO |
> | | | |
> | | NEVER | | YES
> (1 row)
>
> [/code]
>
> In this query result field 'numeric_precision' is set to 32 and
> 'numeric_precision_radix' is set to 2.
>
> According to the documentation 'numeric_precision_radix' field should
> indicate what radix the value of 'numeric_precision' is stored.
>
> However, even though the radix is 2, the actual value is 32, which is
> not a radix 2.
>
> Could someone please shed some light?

What Postgres version?

Also the data_type is showing as integer not numeric so the numeric_*
values should be NULL.

What is the schema definition for the table?

When I run the query:

production=# select version();
version

-----------------------------------------------------------------------
PostgreSQL 9.6.2 on x86_64-pc-linux-gnu, compiled by gcc (SUSE Linux)
4.8.5, 64-bit
(1 row)

production=# \d projection

...

qty | numeric(7,2) | not null default 0

...

production=# \x
Expanded display is on.

production=# select * from information_schema.columns where table_name
='projection' and column_name='qty';

...

numeric_precision | 7
numeric_precision_radix | 10
numeric_scale | 2

....

>
> Thank you.
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2017-05-04 14:06:35 Re: Column information
Previous Message Tom Lane 2017-05-04 14:00:05 Re: Column information