Re: [GENERAL] Column information - Mailing list pgsql-general

From Tom Lane
Subject Re: [GENERAL] Column information
Date
Msg-id 10820.1493913677@sss.pgh.pa.us
Whole thread Raw
In response to Re: [GENERAL] Column information  (Igor Korot <ikorot01@gmail.com>)
List pgsql-general
Igor Korot <ikorot01@gmail.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.columnswhere 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


pgsql-general by date:

Previous
From: Igor Korot
Date:
Subject: Re: [GENERAL] Column information
Next
From: "Feld, Michael (IMS)"
Date:
Subject: [GENERAL] initdb with ignore hidden option