Jump to content

Information schema

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Frap (talk | contribs) at 23:08, 22 July 2015 (Fixed capitalization). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In relational databases, the information schema is an ANSI standard set of read-only views which provide information about all of the tables, views, columns, and procedures in a database. It can be used as a source of the information which some databases make available through non-standard commands, such as the SHOW command of MySQL, the DESCRIBE command of Oracle, and the \d command in psql (PostgreSQL's default terminal).

 => SELECT count(table_name) FROM information_schema.tables;
  count 
 -------
     99
 (1 row)
 => SELECT column_name, data_type, column_default, is_nullable
       FROM information_schema.columns WHERE table_name='alpha';
  column_name | data_type | column_default | is_nullable 
 -------------+-----------+----------------+-------------
  foo         | integer   |                | YES
  bar         | character |                | YES
 (2 rows)
 => SELECT * FROM information_schema.information_schema_catalog_name;
  catalog_name 
 --------------
  johnd
 (1 row)

As a notable exception among major database systems, Oracle does not currently implement the information schema. There is an open source project trying to make up for that.

See also