Re: I do not get the point of the information_schema

From: "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: I do not get the point of the information_schema
Date: 2018-02-13 22:57:55
Message-ID: 20180213225755.hbpadizwav3ma2kn@hjp.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2018-02-12 23:01:41 +0100, Thiemo Kellner wrote:
> I try to implement SCD2 on trigger level and try to generated needed code on
> the fly. Therefore I need to read data about the objects in the database. So
> far so good. I know of the information_schema and the pg_catalog. The
> documentation for the information_schema states that it 'is defined in the
> SQL standard and can therefore be expected to be portable and remain
> stable'. I can think of a sensible meaning of portable. One cannot port it
> to MariaDB, can one?

You don't port the information schema to MariaDB. The information schema
is provided by the database.

The *use* of the information schema is portable between standard-
conforming databases, however.

You can use

select table_schema, table_name
from information_schema.tables
where table_type='BASE TABLE';

on both PostgreSQL and MariaDB to get a list of tables.

(That said, it looks like both PostgreSQL and MariaDB include additional
columns beyond those mandated by the standard - you can't rely on those,
of course. And some databases like Oracle don't even have an information
schema.)

hp

--
_ | Peter J. Holzer | we build much bigger, better disasters now
|_|_) | | because we have much more sophisticated
| | | hjp(at)hjp(dot)at | management tools.
__/ | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2018-02-13 23:06:43 Re: I do not get the point of the information_schema
Previous Message Adrian Klaver 2018-02-13 22:37:45 Re: PostgreSQL Download