In Postgres
this information may be obtained from information_schema
, of a VIEW
calling for columns
.
For example, consider the tables tb_foobar
and tb_xpto
:
CREATE TABLE public.tb_foobar
(
id INTEGER,
name CHARACTER VARYING(100),
description TEXT,
moment DATE,
flag BOOLEAN,
blah INTEGER,
xpto NUMERIC(5,2)
);
CREATE TABLE public.tb_xpto
(
id INTEGER,
alpha CHARACTER VARYING(100),
beta TEXT
);
Recovering all type columns CHARACTER VARYING
and TEXT
of all the tables in the schema public
:
SELECT
table_schema,
table_name,
column_name,
data_type
FROM
information_schema.columns
WHERE
table_schema = 'public' AND
data_type IN ('text','character varying')
Exit:
| table_schema | table_name | column_name | data_type |
|--------------|------------|-------------|-------------------|
| public | tb_foobar | name | character varying |
| public | tb_foobar | description | text |
| public | tb_xpto | alpha | character varying |
| public | tb_xpto | beta | text |
Sqlfiddle: http://sqlfiddle.com/#! 17/23840/2