Re: Column information

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Igor Korot <ikorot01(at)gmail(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, Alban Hertroys <haramrae(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Column information
Date: 2017-05-04 16:01:17
Message-ID: 10820.1493913677@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Igor Korot <ikorot01(at)gmail(dot)com> writes:
> So if I write for example:

> CREATE TABLE foo(id INTEGER PRIMARY KEY, label VARCHAR(50), price
> DOUBLE(10, 2));

> how can I get 50, 10 and 2 from those 5 fields?

(I assume you meant NUMERIC where you wrote DOUBLE, because that's
not valid syntax as given.)

Try something like this:

# select column_name,data_type,numeric_precision,numeric_precision_radix,numeric_scale,character_maximum_length from information_schema.columns where table_name = 'foo';
-[ RECORD 1 ]------------+------------------
column_name | id
data_type | integer
numeric_precision | 32
numeric_precision_radix | 2
numeric_scale | 0
character_maximum_length |
-[ RECORD 2 ]------------+------------------
column_name | label
data_type | character varying
numeric_precision |
numeric_precision_radix |
numeric_scale |
character_maximum_length | 50
-[ RECORD 3 ]------------+------------------
column_name | price
data_type | numeric
numeric_precision | 10
numeric_precision_radix | 10
numeric_scale | 2
character_maximum_length |

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Feld, Michael (IMS) 2017-05-04 16:59:31 initdb with ignore hidden option
Previous Message Igor Korot 2017-05-04 15:53:05 Re: Column information