Fact-checked by Grok 2 weeks ago

Information schema

The Information Schema, formally known as INFORMATION_SCHEMA, is a standardized within management systems (RDBMS) that consists of a set of read-only views providing about the database's structure and contents, including details on tables, columns, constraints, privileges, routines, and other objects, as specified in Part 11 (SQL/Schemata) of the ISO/IEC 9075 SQL standard. This schema enables users and applications to query database in a consistent, portable manner across compliant systems, without relying on vendor-specific system tables that may change between implementations. Introduced as part of the standard (ISO/IEC 9075:1992), the Information Schema was designed to promote interoperability by offering a uniform interface to information, separate from the underlying structures used internally by database engines. Its purpose extends beyond basic structure description to include integrity constraints, security specifications (such as grants and roles), and details on SQL feature support within the implementation, allowing developers to introspect databases dynamically for tasks like validation, reporting, or automated migrations. The is defined as a collection of virtual tables (views) that conform to the three-part of catalog..object, ensuring compatibility with the broader SQL . Key components of the Information Schema include core views such as TABLES (listing tables and views with their types and creation details), COLUMNS (detailing column names, data types, nullability, and defaults), CONSTRAINTS (covering primary keys, s, unique, and check constraints), REFERENTIAL_CONSTRAINTS (mapping relationships), and SCHEMATA (providing schema-level information). Additional views address privileges (TABLE_PRIVILEGES, COLUMN_PRIVILEGES), routines (ROUTINES, PARAMETERS), triggers (TRIGGERS), and implementation specifics (SQL_FEATURES, DATA_TYPES), totaling around 60-70 views depending on the standard edition and vendor extensions. These views are populated from the database's system catalogs but present data in a standardized format, with visibility limited to objects for which the querying has appropriate permissions. The Information Schema is widely supported in major RDBMS, including (compliant since SQL Server 2005), (fully implemented per the SQL:2016 standard), (approximating SQL:2003 with extensions), and others like and , facilitating cross-database portability. While provides equivalent functionality through its views (e.g., ALL_TABLES, ALL_TAB_COLUMNS), it does not implement the exact Information Schema structure, opting instead for a proprietary but SQL-standard-inspired approach. This adoption has made the Information Schema a foundational tool for database administration, application development, and compliance with international SQL standards, with ongoing updates in revisions like ISO/IEC 9075-11:2023.

Overview

Definition

The Information Schema is a standardized collection of read-only views within management systems (RDBMS) that provide about the database's structure and contents, including details on tables, columns, data types, constraints, privileges, and other elements. Defined in Part 11 of the ISO/IEC 9075 SQL standard (SQL/Schemata), it enables users and applications to query descriptive information about SQL-data in a portable, implementation-independent manner. This schema acts as a uniform interface for accessing database introspection data without relying on vendor-specific mechanisms. Key characteristics of the Information Schema include its full compliance with the ANSI/ISO SQL , ensuring consistency across conforming RDBMS implementations. It consists of virtual views—meaning they do not maintain their own physical storage but are dynamically generated from underlying system data upon query execution—allowing for efficient, on-demand retrieval. These views are accessible exclusively through standard SQL SELECT statements, typically requiring qualified naming (e.g., INFORMATION_SCHEMA.TABLES), and their contents are scoped to the current database while respecting user permissions for metadata visibility. Unlike database , which often refer to the proprietary system tables or catalogs maintained by individual RDBMS vendors for internal storage, the Information Schema serves as a logical . This shields applications from changes in the underlying catalog structures, promoting portability and long-term across different SQL environments.

Purpose and Benefits

The information schema serves as a standardized for querying database in a portable way across SQL-compliant database management systems (DBMS), allowing users to access details about database structures such as tables, columns, and constraints without relying on vendor-specific system catalogs. This enables consistent retrieval that functions independently of changes to underlying mechanisms in the DBMS. A primary purpose is to support dynamic SQL generation by providing introspection capabilities, which allow applications to construct queries based on current details. It also facilitates analysis, enabling the examination of elements for purposes like documentation or , all through standard SQL without extensions. These functions promote in environments involving multiple DBMS vendors. Key benefits include enhanced portability for applications operating in multi-vendor settings, where metadata queries can remain unchanged across systems like SQL Server, , and . It improves security by abstracting access to sensitive system tables, exposing only permitted metadata based on user privileges and avoiding direct manipulation risks. Additionally, it supports automation in tools such as object-relational mappers (ORMs) and migration scripts, streamlining schema comparisons and code generation. In database administration, the information schema simplifies schema validation by allowing queries to check structural consistency against design specifications, impact analysis for modifications by revealing dependencies, and compliance auditing through standardized metadata inspection for policy adherence. These features reduce administrative overhead and minimize errors in complex, evolving database ecosystems.

History and Standardization

Origins in SQL Standards

The Information Schema was formally introduced in the standard, designated as ANSI X3.135-1992 and equivalently ISO/IEC 9075:1992, as a standardized mechanism for accessing database within management systems (RDBMS). This schema, named INFORMATION_SCHEMA, resides in each catalog and comprises a collection of views, domains, and descriptors derived from base tables in the supporting DEFINITION_SCHEMA, enabling users to query information about SQL data structures, integrity constraints, and related elements in a consistent manner. The introduction marked a significant advancement in SQL , replacing the more limited metadata provisions of prior versions like SQL-89, by establishing a uniform interface that promotes across diverse implementations. The development of the Information Schema was spearheaded by the ISO/IEC JTC1/SC32 working group on database languages (WG3), under the broader Joint Technical Committee 1 (JTC1) for information technology, in collaboration with the American National Standards Institute (ANSI) Technical Committee X3H2. This effort addressed the growing need for portability in SQL applications, as early commercial RDBMS such as Oracle and IBM DB2 employed proprietary catalog structures that hindered cross-system compatibility and metadata querying. By defining the Information Schema in Clause 21 of the standard, the committee aimed to provide a vendor-neutral view of schema objects, allowing developers to inspect database structures without relying on implementation-specific commands or tools. In its initial scope, the Information Schema was confined to fundamental metadata views, focusing primarily on tables, columns, schemata, domains, views, and basic constraints, with accessibility governed by user privileges and conformance levels (Entry, , or Full SQL). Key views included TABLES (detailing table catalogs, schemas, names, and types) and COLUMNS (specifying column names, positions, and data types), alongside others like SCHEMATA, DOMAINS, and CONSTRAINTS for intermediate-level support. Notably, it offered no provisions for advanced features such as stored routines or triggers, which were absent from the core and thus not reflected in the schema's metadata capabilities; these elements would emerge in later standards. This delimited design ensured a foundational, portable metadata layer while leaving room for vendor extensions.

Evolution Across SQL Versions

The Information Schema, initially introduced in SQL-92 as a set of views providing basic about database structures, underwent significant enhancements starting with SQL:1999 to support more advanced database features. In SQL:1999, the standard expanded the schema to include views for user-defined types and routines, enabling better of procedural elements and custom data types. These additions addressed the growing need for support in object-relational extensions, allowing queries to describe structured user-defined types (UDTs) and SQL-invoked routines without relying on vendor-specific catalogs. The schema information tables were separated into a dedicated Part 11 (SQL/Schemata) in SQL:2003 for improved modularity. SQL:2003 further refined the Information Schema by incorporating views for assertions, which describe declarative constraints, and introducing XML-related views to handle XML data types and document storage as part of Part 14 (SQL/XML). Additionally, support for was added through new views in the schemata, facilitating access for auto-incrementing identifiers and ordered data generation. These updates aligned the with emerging data interchange standards, ensuring that XML schemas and sequence objects could be queried uniformly across compliant systems. From SQL:2008 onward, the evolution continued with expansions to accommodate advanced features like refined support for collations and referential constraints, providing dedicated views to expose character set and collation metadata, and foreign key relationships for enhanced integrity management; trigger support had been introduced earlier in SQL:1999. SQL:2011 and subsequent revisions emphasized temporal features and internationalization, adding views for system-versioned tables to track historical data changes and internationalization elements such as locale-specific collations and time zones. By SQL:2016, the standard defined full conformance levels for the Information Schema in Part 11, specifying 338 pages of detailed views and base tables to ensure comprehensive metadata portability. The most recent revision, ISO/IEC 9075-11:2023, includes further improvements and corrections (320 pages), with ongoing maintenance by ISO/IEC JTC1/SC32 continuing to refine these elements for evolving database paradigms.

Standard Views and Structure

Core Views

The core views of the Information Schema, as defined in the SQL standard, provide standardized access to essential about database objects, ensuring portability across compliant systems. These mandatory views focus on fundamental elements such as tables, columns, and constraints, forming the basis for querying schema information without relying on vendor-specific catalogs. The TABLES view contains rows describing each table accessible to the current user, including base tables, views, and temporary tables. Key attributes include TABLE_CATALOG (the catalog name), TABLE_SCHEMA (the schema name), TABLE_NAME (the table identifier), TABLE_TYPE (specifying 'BASE TABLE', 'VIEW', 'GLOBAL TEMPORARY', or 'LOCAL TEMPORARY'), IS_INSERTABLE_INTO (indicating if the table supports insertions, with values 'YES' or 'NO'), and SELF_REFERENCING_COLUMN_NAME (the column used for self-referential constraints, if any). Additional attributes cover user-defined type details, such as USER_DEFINED_TYPE_CATALOG, USER_DEFINED_TYPE_SCHEMA, and USER_DEFINED_TYPE_NAME, which link to structured types if applicable. This view enables users to identify table structures and types systematically. The COLUMNS view provides detailed information on each column within tables or views accessible to the user. Essential attributes encompass TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, ORDINAL_POSITION (the column's position in the table, starting from 1), DATA_TYPE (the SQL data type, such as 'CHARACTER' or 'INTEGER'), IS_NULLABLE ('YES' or 'NO' for null allowance), COLUMN_DEFAULT (the default value expression), and length-related fields like CHARACTER_MAXIMUM_LENGTH (maximum characters for string types), NUMERIC_PRECISION (significant digits for numeric types), and NUMERIC_SCALE (decimal places). It also includes collation and domain details, such as CHARACTER_SET_CATALOG, COLLATION_NAME, DOMAIN_CATALOG, and DOMAIN_SCHEMA, supporting comprehensive column metadata retrieval. The TABLE_CONSTRAINTS view lists all table constraints defined on tables owned by or accessible to the user. Core attributes are CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME (the unique constraint identifier), TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, CONSTRAINT_TYPE (e.g., '', '', '', or ''), IS_DEFERRABLE ('YES' or 'NO' for deferrability), and INITIALLY_DEFERRED ('YES' or 'NO' for initial deferral status). This view facilitates inspection of constraints like primary keys and unique constraints. The REFERENTIAL_CONSTRAINTS view describes referential (foreign key) constraints, detailing relationships between tables. Key attributes include CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME, UNIQUE_CONSTRAINT_CATALOG, UNIQUE_CONSTRAINT_SCHEMA, UNIQUE_CONSTRAINT_NAME (linking to the referenced primary or unique constraint), MATCH_OPTION ('FULL', 'PARTIAL', or 'NONE' for match rules), UPDATE_RULE (actions like 'CASCADE', 'SET NULL', 'SET DEFAULT', 'RESTRICT', or 'NO ACTION' on updates), and DELETE_RULE (similar actions on deletes). It supports analysis of inter-table dependencies. The CHECK_CONSTRAINTS view outlines CHECK constraints applied to tables, columns, domains, or assertions owned by the user. Primary attributes are CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME, and CHECK_CLAUSE (the search condition defining the constraint, such as a ). This view aids in reviewing rules. Per the SQL standard, all Information Schema views, including these core ones, are defined as read-only viewed tables, with SELECT privileges granted to and GRANT OPTION enabled, but no INSERT, UPDATE, or DELETE operations permitted to maintain (as per Clause 20 and feature F021). These views must be accessible within the INFORMATION_SCHEMA schema in conforming implementations.

View Relationships and Metadata Access

The Information Schema views in the SQL standard are designed to interconnect through standardized keys, enabling comprehensive metadata retrieval across database structures. For instance, the COLUMNS view links to the TABLES view via the consisting of TABLE_CATALOG, TABLE_SCHEMA, and TABLE_NAME, allowing users to assemble complete table definitions by combining table-level details with column-specific attributes such as data types and nullability. Similarly, the REFERENTIAL_CONSTRAINTS view connects to the TABLE_CONSTRAINTS view using CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, and CONSTRAINT_NAME, which facilitates the mapping of relationships to their corresponding primary or unique constraints on referenced tables. These linkages ensure that metadata about can be queried relationally without direct access to underlying system catalogs. Metadata access patterns in the Information Schema leverage these inter-view relationships for hierarchical exploration, starting from higher-level constructs like schemas and progressing to detailed dependencies. Users can query from the SCHEMATA view to identify available schemas, then join to TABLES to list tables within those schemas, and further connect to constraint views to uncover dependencies such as cascades that enforce across tables. This approach supports discovery of complex relationships, like how a in one table references a in another, by chaining joins across views to reveal the full without proprietary system tables. Access to Information Schema views is inherently filtered by the querying user's , ensuring that only authorized is exposed. For example, the views return rows only for schemas and objects where the user holds USAGE or equivalent , with schema-level filtering applied to prevent visibility of restricted elements. This -based scoping aligns with SQL standards for security, as defined in ISO/IEC 9075, where the Information Schema acts as a portable, user-contextual to .

Implementations in Database Systems

Compliance in Major RDBMS

provides approximate compliance with the INFORMATION_SCHEMA as defined in the ANSI/ISO SQL:2003 Part 11 Schemata, introduced in version 5.0 released in 2005. This implementation serves as the default catalog for accessing database , including comprehensive coverage of standard views such as TABLES, COLUMNS, and VIEWS, enabling portable queries across compliant systems. PostgreSQL introduced support for the INFORMATION_SCHEMA in version 7.4, released in 2003, aligning closely with the SQL standard for access. It offers high compliance by implementing all core standard views, such as those for tables, columns, and constraints, while integrating with the native pg_catalog for additional PostgreSQL-specific details without deviating from baseline portability. The schema supports routines and other extended elements mandated by later SQL standards, ensuring broad adherence for cross-database compatibility. SQL Server includes partial support for INFORMATION_SCHEMA views, introduced in version 7.0 in 1998 and enhanced in version 2005, providing a system-table-independent layer for like tables and columns. However, it relies primarily on the sys for comprehensive details, with INFORMATION_SCHEMA mapping to only a of views—such as INFORMATION_SCHEMA.TABLES—while excluding advanced features like full metadata, limiting its standalone use for complete standard compliance. Oracle Database offers limited native support for INFORMATION_SCHEMA, lacking a direct implementation of the SQL standard's views in favor of its proprietary , including ALL_, USER_, and DBA_ views for metadata access. While some third-party tools and extensions emulate INFORMATION_SCHEMA for compatibility, Oracle's core system does not provide standard-compliant access, requiring custom queries against dictionary views for equivalent functionality. CockroachDB implements the INFORMATION_SCHEMA as a set of read-only views providing metadata about database objects such as tables, columns, indexes, and views, in conformance with the SQL standard. Snowflake's Information Schema is based on the ANSI standard, with additional views and functions specific to Snowflake features, automatically created in every database for metadata access.

Vendor-Specific Extensions

MySQL extends the standard INFORMATION_SCHEMA with proprietary views that provide additional metadata not covered by SQL standards. The VIEWS table includes a CHECK_OPTION column that specifies the check option attribute for updatable views, with possible values of NONE (no check), LOCAL (check only the view itself), or (recursive check on underlying views), enabling developers to query view update constraints directly. Additionally, the PLUGINS table offers details on plugins, including engines, listing attributes such as PLUGIN_NAME, PLUGIN_TYPE (e.g., ), PLUGIN_STATUS (e.g., ACTIVE), and PLUGIN_LIBRARY, which aids in monitoring and managing pluggable components like or . PostgreSQL enhances the INFORMATION_SCHEMA with support for collations and domains, reflecting its advanced . The COLLATIONS view lists all available collations in the database, including columns like COLLATION_NAME, COLLATION_SCHEMA, and PAD_ATTRIBUTE (always NO PAD in PostgreSQL), allowing queries for locale-specific and rules. For domains, the DOMAINS view provides on user-defined domains, such as DOMAIN_NAME, DOMAIN_SCHEMA, DATA_TYPE, and DOMAIN_DEFAULT, detailing constraints and underlying types for custom data domains like constrained integers or text. The SCHEMATA view includes PostgreSQL-specific details, such as SCHEMA_OWNER to identify schema ownership, facilitating and organization in multi-schema environments. In SQL Server, the INFORMATION_SCHEMA is limited to basic standard views, prompting reliance on proprietary sys catalog views for comprehensive metadata. sys.objects serves as a functional equivalent for object details, containing rows for schema-scoped objects like tables, views, and procedures, with columns including name, type (e.g., U for user table), and create_date, offering deeper insights than the standard TABLES or VIEWS. Similarly, sys.columns provides detailed column information for tables and views, including is_nullable, max_length, and user_type_id, surpassing the granularity of INFORMATION_SCHEMA.COLUMNS. Trigger metadata in INFORMATION_SCHEMA.TRIGGERS is incomplete, covering only basic DML trigger details without support for DDL triggers or advanced properties, necessitating sys.triggers for full enumeration. Oracle deviates significantly from the standard by not implementing a full INFORMATION_SCHEMA, instead depending on its views for access. DBA_TABLES, accessible to administrators, describes all relational tables in the database, including columns like OWNER, TABLE_NAME, TABLESPACE_NAME, and NUM_ROWS for row counts, providing and storage details absent in a standard . This approach, rooted in Oracle's , lacks the portable views of INFORMATION_SCHEMA, requiring custom queries against views like ALL_TABLES or USER_TABLES for user-specific or accessible .

Usage and Examples

Querying Database Metadata

The Information Schema enables retrieval of database metadata through standard SQL queries against its views, offering a vendor-independent to inspect schema details such as tables, columns, and constraints. Defined in the SQL standard, these views populate dynamically based on the database's current state and the user's privileges, ensuring portable access across compliant systems. Basic query patterns involve simple SELECT statements on key views like TABLES and COLUMNS to fetch comprehensive metadata. For example, to list all base tables, the following query can be used:
sql
SELECT * FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_TYPE = 'BASE TABLE';
This returns rows with columns including TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, and TABLE_TYPE, describing accessible tables in the database. To retrieve column details for tables, query the COLUMNS view, which includes attributes like COLUMN_NAME, DATA_TYPE, and IS_NULLABLE. Joining these views provides combined insights, such as:
sql
SELECT t.TABLE_NAME, c.COLUMN_NAME, c.DATA_TYPE, c.IS_NULLABLE 
FROM INFORMATION_SCHEMA.TABLES t 
JOIN INFORMATION_SCHEMA.COLUMNS c 
  ON t.TABLE_CATALOG = c.TABLE_CATALOG 
  AND t.TABLE_SCHEMA = c.TABLE_SCHEMA 
  AND t.TABLE_NAME = c.TABLE_NAME 
WHERE t.TABLE_TYPE = 'BASE TABLE';
This join operation links table-level with column specifics, facilitating structured exploration. Filtering refines results using WHERE clauses on view columns, while sorting organizes output with ORDER BY. For instance, to retrieve only tables from a specific schema, sorted alphabetically:
sql
SELECT TABLE_NAME, TABLE_TYPE 
FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_SCHEMA = 'public' 
  AND TABLE_TYPE = 'BASE TABLE' 
ORDER BY TABLE_NAME;
Conditions can target elements like COLUMN_NAME for precise column filtering, such as WHERE COLUMN_NAME LIKE 'id%'. Aggregate functions enable summaries, like counting constraints per schema:
sql
SELECT TABLE_SCHEMA, COUNT(*) AS constraint_count 
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS 
WHERE TABLE_TYPE = 'BASE TABLE' 
GROUP BY TABLE_SCHEMA;
These techniques allow efficient metadata aggregation without scanning entire databases. Error handling in Information Schema queries accounts for scenarios where results may be empty due to non-existent schemas or insufficient user privileges, in which case no error is raised—instead, zero rows are returned, enabling applications to detect and respond to missing data programmatically. For example, querying a schema without access privileges yields an from TABLES, rather than failing the query. Implementations may also return multiple rows for certain , such as constraints with non-unique names, necessitating additional filtering to avoid duplicates. Privileges typically require at least SELECT access on the underlying objects, though the itself is often readable by default in compliant systems.

Practical Applications and Code Samples

One practical application of the information schema is generating (DDL) scripts to recreate structures, which facilitates database cloning or backup processes. By querying the INFORMATION_SCHEMA.COLUMNS view, developers can construct CREATE TABLE statements dynamically. For instance, the following SQL query generates a basic CREATE TABLE script for each in the current database, concatenating column definitions based on such as data types and nullability (tested in SQL Server environments):
sql
SELECT 
    'CREATE TABLE ' + TABLE_SCHEMA + '.' + TABLE_NAME + ' (' AS ddl_start,
    STRING_AGG(
        COLUMN_NAME + ' ' + 
        DATA_TYPE + 
        CASE 
            WHEN CHARACTER_MAXIMUM_LENGTH IS NOT NULL THEN '(' + CAST(CHARACTER_MAXIMUM_LENGTH AS VARCHAR) + ')'
            WHEN NUMERIC_PRECISION IS NOT NULL THEN '(' + CAST(NUMERIC_PRECISION AS VARCHAR) + 
                CASE WHEN NUMERIC_SCALE IS NOT NULL THEN ',' + CAST(NUMERIC_SCALE AS VARCHAR) ELSE '' END + ')'
            ELSE ''
        END + 
        CASE WHEN IS_NULLABLE = 'NO' THEN ' NOT NULL' ELSE ' NULL' END,
        ', '
    ) WITHIN GROUP (ORDER BY ORDINAL_POSITION) AS columns_def,
    ');' AS ddl_end
FROM [INFORMATION_SCHEMA.COLUMNS](/page/INFORMATION_SCHEMA.COLUMNS)
GROUP BY TABLE_SCHEMA, TABLE_NAME;
In scenarios, the information schema enables analysis of constraints to identify dependencies and potential issues, such as cycles in relationships, prior to structural alterations. The INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS view provides details on constraints, including unique constraint references, which can be joined with other views to map dependency graphs. To detect cycles, one approach involves constructing a recursive common table expression () over foreign key paths derived from these views; for example, the query below lists all foreign key dependencies as a starting point for algorithms (applicable in and compliant RDBMS):
sql
WITH RECURSIVE fk_graph AS (
    SELECT 
        kcu.table_name AS child_table,
        ccu.table_name AS parent_table,
        kcu.column_name AS child_column,
        ccu.column_name AS parent_column,
        1 AS depth
    FROM information_schema.key_column_usage kcu
    JOIN information_schema.constraint_column_usage ccu 
        ON kcu.constraint_name = ccu.constraint_name
    WHERE kcu.table_schema = '[public](/page/Public)'  -- Adjust schema as needed
    UNION ALL
    SELECT 
        fg.child_table,
        kcu.table_name AS parent_table,
        fg.child_column,
        ccu.column_name AS parent_column,
        fg.depth + 1
    FROM fk_graph fg
    JOIN information_schema.key_column_usage kcu 
        ON fg.parent_table = kcu.table_name
    JOIN information_schema.constraint_column_usage ccu 
        ON kcu.constraint_name = ccu.constraint_name
    WHERE fg.depth < 10  -- Limit [recursion](/page/Recursion) to prevent infinite loops if cycles exist
)
SELECT * FROM fk_graph
ORDER BY child_table, depth;
This output can be analyzed for self-referential paths exceeding expected depths, indicating cycles that might block migrations like drops or renames. Code samples leveraging the information schema often focus on extracting constraint details for application logic. A common example is listing all foreign key columns for a specific , which aids in or reporting tools. The following multi-line query retrieves foreign key columns referencing a given table (e.g., 'orders') in or compatible systems:
sql
SELECT 
    kcu.COLUMN_NAME,
    kcu.TABLE_NAME AS FK_TABLE_NAME,
    kcu.REFERENCED_TABLE_NAME,
    kcu.REFERENCED_COLUMN_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu
JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc 
    ON kcu.CONSTRAINT_NAME = rc.CONSTRAINT_NAME
WHERE kcu.REFERENCED_TABLE_NAME = 'orders'
    AND kcu.TABLE_SCHEMA = DATABASE();
Integration with object-relational mapping (ORM) tools like SQLAlchemy allows dynamic schema mapping without hardcoding table structures, using the information schema for runtime introspection. SQLAlchemy's Inspector class reflects database metadata, including tables and columns from the information_schema equivalent, to generate mapped classes automatically via extensions like Automap. For example, in a Python application:
python
from sqlalchemy import create_engine, inspect
from sqlalchemy.ext.automap import automap_base

engine = create_engine('postgresql://user:pass@localhost/dbname')
inspector = inspect(engine)
AutomapBase = automap_base()
AutomapBase.prepare(engine, reflect=True)
# Now AutomapBase.classes contains dynamically mapped classes from [schema](/page/Schema)
Order = AutomapBase.classes.orders  # Example mapped class
This approach supports multi-tenant applications where details vary. For auditing purposes, the information supports checks by quantifying characteristics, such as the number of nullable columns per table, which highlights potential incompleteness risks. The IS_NULLABLE column in INFORMATION_SCHEMA.COLUMNS indicates null permissibility, enabling aggregation queries like the following to count nullable columns across tables (in SQL Server and other compliant systems):
sql
SELECT 
    TABLE_NAME,
    COUNT(*) AS nullable_count,
    (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS c2 
     WHERE c2.TABLE_NAME = c.TABLE_NAME) AS total_columns
FROM INFORMATION_SCHEMA.COLUMNS c
WHERE IS_NULLABLE = 'YES'
GROUP BY TABLE_NAME
ORDER BY nullable_count DESC;
Such audits inform by identifying tables with high null tolerance.

Limitations and Alternatives

Compliance Gaps

The SQL:2016 standard introduced formal support for JSON functions and operators for handling data, typically stored as text. Earlier versions such as SQL:2011 and prior provided no such support, limiting portability for applications relying on these features. A native data type was added in SQL:2023, allowing standardized exposure in views like COLUMNS for columns in compliant systems. Similarly, while window functions were added in SQL:1999, the information schema in pre-2016 standards lacks comprehensive exposure for advanced analytic features like these, as the schema's core views focused primarily on basic relational objects such as tables and constraints. The SQL:2023 standard (ISO/IEC 9075:2023) updates Part 11 to include for newer features such as native types (T801) and temporal tables, improving , though vendor adoption may vary as of November 2025. In legacy database systems, partial implementation of information schema views creates significant gaps; for instance, versions prior to 5.5.3 lacked the view entirely, preventing standardized access to stored routine details that was later added to align with ISO requirements. Additionally, as views generated dynamically from underlying system catalogs, information schema queries often incur performance overhead, such as in where accessing tables like TABLES requires scanning all database files, leading to slowdowns in environments with many objects. Portability challenges arise from varying handling of identifier case sensitivity across systems; in PostgreSQL, unquoted schema and table names are folded to lowercase, while SQL Server typically preserves case based on collation settings, causing queries against views like SCHEMATA or TABLES to fail or return inconsistent results when migrating code between databases. Vendor-specific extensions can sometimes mitigate these issues by providing additional metadata access, though they do not resolve core standard compliance shortfalls.

Complementary Tools and Approaches

While the INFORMATION_SCHEMA provides standardized access to database metadata, system catalogs offer direct, vendor-specific tables that enable deeper introspection into database structures and internals. In PostgreSQL, the pg_class catalog table describes tables, indexes, sequences, views, and other objects similar to tables, including attributes like relation size and access methods not fully exposed in INFORMATION_SCHEMA views. Similarly, in SQL Server, the sys.tables catalog view contains a row for each user-defined table in the database, capturing details such as schema ID, type, and temporal properties that complement the more limited INFORMATION_SCHEMA.TABLES. These catalogs serve as the underlying storage for all schema metadata, allowing advanced users to query raw information for performance tuning, debugging, or custom reporting where standard views fall short. External tools extend management beyond native SQL queries by providing programmatic access and visualization capabilities. The JDBC DatabaseMetaData , part of the SQL standard, enables applications to retrieve comprehensive database properties, such as supported , table catalogs, and column details, through methods like getTables() and getColumns(), facilitating cross-database introspection without direct SQL reliance. In ecosystems, SQLAlchemy's class supports metadata reflection by querying the database to fetch details on tables, columns, indexes, and foreign keys, often caching results for efficiency in ORM-based applications. For schema visualization, tools leveraging Database Markup Language (DBML) allow users to define or import schemas in a readable DSL format, automatically generating Entity-Relationship Diagrams (ERDs) to illustrate relationships and structures, as implemented in platforms like dbdiagram.io. Hybrid approaches integrate INFORMATION_SCHEMA with system catalogs or to achieve comprehensive coverage, particularly addressing compliance gaps in standard access. Developers often join INFORMATION_SCHEMA views with vendor-specific catalogs, such as querying pg_class alongside INFORMATION_SCHEMA.COLUMNS in , to obtain both standardized and proprietary details like internal object IDs or extended statistics. In frameworks, combines these sources; for instance, SQLAlchemy's reflect() populates a MetaData object from database introspection, blending INFORMATION_SCHEMA-like portability with dialect-specific depth from system catalogs. This supports dynamic in applications, enabling automatic model generation without manual .

References

  1. [1]
    Database languages — SQL - ISO/IEC 9075-11:2016
    ISO/IEC 9075-11:2016 specifies an Information Schema and a Definition Schema that describes the structure and integrity constraints of SQL-data.
  2. [2]
    Documentation: 18: Chapter 35. The Information Schema - PostgreSQL
    The information schema consists of a set of views that contain information about the objects defined in the current database.35.1. The Schema · 35.17. columns · 35.54. tables · 35.3...
  3. [3]
    International Standard ISO/IEC 9075:1992
    21)Clause 21, "Information Schema and Definition Schema", defines viewed tables that contain schema information. ... <SQL schema statement>s. <schema name>s ...
  4. [4]
    System Information Schema Views (Transact-SQL) - Microsoft Learn
    Jul 17, 2025 · The information schema views included in SQL Server comply with the ISO standard definition for the INFORMATION_SCHEMA .
  5. [5]
    ISO Information Schema | MonetDB Docs
    ISO Information Schema. The Information Schema consists of a standardized set of views that contain information about the objects defined in the database.
  6. [6]
    MySQL Information Schema :: 2 Introduction
    The implementation for the INFORMATION_SCHEMA table structures in MySQL follows the ANSI/ISO SQL:2003 standard Part 11 Schemata. Our intent is approximate ...
  7. [7]
    What is INFORMATION_SCHEMA? What databases support it?
    Sep 30, 2018 · INFORMATION_SCHEMA is schema with a set of standard views/tables (depending on specific database engine) providing access to the database metadata and data ...
  8. [8]
    The SQL Standard - ISO/IEC 9075:2023 (ANSI X3.135)
    Oct 5, 2018 · SQL (Structured Query Language) standard for relational database management systems is ISO/IEC 9075:2023, with origins in ANSI X3.135.
  9. [9]
    INFORMATION_SCHEMA Views - Mimer Developer
    The Information Schema views are read-only views from which users can retrieve information about any database objects they own or to which they have some access ...
  10. [10]
  11. [11]
    [PDF] ANSI X3.135-1992, Database Language SQL—January 4, 1993
    Jan 4, 1993 · ... Information Schema,. Introduction xvii. Page 19. ANSI X3.135-1992. 12) Support for dynamic execution of SQL language,. 13) Support for certain ...
  12. [12]
    [PDF] Structured Query Language (SQL) Version 2 - The Open Group
    May 5, 2011 · Information Schema ... ANSI standard X3.135-1992). MIA. Multivendor Integration Architecture ...
  13. [13]
    SQL Standards - JCC Consulting
    The original SQL standard was completed as a USA ANSI (American National Standards Institute) standard in 1986, and adopted as an ISO (International Standards ...
  14. [14]
    [PDF] SQL:1999, formerly known as SQL3
    Intended as a major enhancement of the current second generation SQL standard, commonly called SQL-92 because of the year it was published, SQL3 was originally ...
  15. [15]
    Temporal features in SQL:2011 | ACM SIGMOD Record
    This paper covers the most important new functionality that is part of SQL:2011: the ability to create and manipulate temporal tables.
  16. [16]
    [PDF] ANSI/ISO/IEC International Standard (IS) Database Language SQL
    11) Clause 11, ''Schema definition and manipulation'', defines facilities for creating and managing a schema. 12) Clause 12, ''Access control'', defines ...
  17. [17]
    Documentation: 18: 35.17. columns - PostgreSQL
    The view columns contains information about all table columns (or view columns) in the database. System columns ( ctid , etc.) are not included.
  18. [18]
    MySQL 8.0: Improvements to Information_schema
    Sep 13, 2016 · INFORMATION_SCHEMA was first introduced into MySQL 5.0, as a standards compliant way of retrieving meta data from a running MySQL server.
  19. [19]
    MySQL 8.4 Reference Manual :: 28 INFORMATION_SCHEMA Tables
    INFORMATION_SCHEMA provides access to database metadata, information about the MySQL server such as the name of a database or table, the data type of a column, ...28.1 Introduction · 28.2... · 28.3... · Extensions to SHOW StatementsMissing: compliance | Show results with:compliance
  20. [20]
    The information schema - PostgreSQL - sql-info.de
    Oct 29, 2004 · Added in PostgreSQL 7.4, the information schema is a facility to provide a standardized description of PostgreSQL metadata: definitions of ...
  21. [21]
    INFORMATION_SCHEMA Support in MySQL, PostgreSQL
    Feb 18, 2008 · The INFORMATION_SCHEMA views provide meta data information about the tables, columns, and other parts of your database.<|separator|>
  22. [22]
    Documentation: 18: D.1. Supported Features - PostgreSQL
    SQL comments using leading double minus. E171, Core, SQLSTATE support. E182, Core, Host language binding. F021, Core, Basic information schema ... SQL Conformance ...
  23. [23]
    The case against INFORMATION_SCHEMA views - SQLBlog.org
    Nov 3, 2011 · In SQL Server 2000, INFORMATION_SCHEMA was the way I derived all of my metadata information – table names, procedure names, column names and data types, ...
  24. [24]
    SQL Server: should I use information_schema tables over sys tables?
    Sep 6, 2010 · I would always try to use the Information_schema views over querying the sys schema directly. The Views are ISO compliant so in theory you should be able to ...
  25. [25]
    Oracle equivalent of information_schema.tables - sql - Stack Overflow
    Mar 7, 2019 · Oracle indeed doesn't provide the information_schema views, but has its own data dictionary. You can use all_tables to create a similar ...
  26. [26]
    Oracle Information Schema download | SourceForge.net
    Oct 1, 2015 · Oracle does not support the SQL standard INFORMATION_SCHEMA data dictionary. This project creates an information_schema schema and adds ...
  27. [27]
    INFORMATION_SCHEMA and Oracle - SQL Tutorial
    Among the lead manufacturers, perhaps, only Oracle does not support INFORMATION_SCHEMA. To be fair, it should be said that Oracle provides the ability to use ...
  28. [28]
  29. [29]
    MySQL :: MySQL 8.0 Reference Manual :: 28.3.22 The INFORMATION_SCHEMA PLUGINS Table
    ### Summary of the PLUGINS Table in MySQL INFORMATION_SCHEMA
  30. [30]
    35.10. collations
    ### Summary of the `collations` View in PostgreSQL INFORMATION_SCHEMA
  31. [31]
    35.23. domains - PostgreSQL: Documentation: 18
    The view domains contains all domains defined in the current database. Only those domains are shown that the current user has access to.Missing: INFORMATION_SCHEMA | Show results with:INFORMATION_SCHEMA
  32. [32]
    35.46. schemata
    ### Summary of `schemata` View in PostgreSQL
  33. [33]
  34. [34]
  35. [35]
  36. [36]
  37. [37]
  38. [38]
    [PDF] Native JSON Datatype Support: Maturing SQL and NoSQL ...
    2.1 SQL/JSON 2016. The SQL/JSON 2016 [21] standard defines a set of SQL/JSON operators and table functions to query JSON text and generate. JSON text using ...
  39. [39]
    Solving INFORMATION_SCHEMA slowness - Percona
    Dec 23, 2011 · The solution is simple, just set innodb_stats_on_metadata=0 which will prevent statistic update when you query information_schema.
  40. [40]
    Case sensitivity differences for ANSI SQL - AWS Documentation
    This topic provides reference information on handling object name case sensitivity when migrating from Microsoft SQL Server 2019 to Amazon Aurora PostgreSQL.Missing: portability | Show results with:portability<|separator|>
  41. [41]
    Documentation: 18: 52.11. pg_class - PostgreSQL
    The catalog pg_class describes tables and other objects that have columns or are otherwise similar to a table. This includes indexes (but see also pg_index ) ...
  42. [42]
    sys.tables (Transact-SQL) - SQL Server - Microsoft Learn
    Sep 4, 2024 · Memory optimized tables can be accessed from natively compiled stored procedures. Applies to: SQL Server 2014 (12. x) and later versions, and ...
  43. [43]
    Documentation: 18: Chapter 52. System Catalogs - PostgreSQL
    The system catalogs are the place where a relational database management system stores schema metadata, such as information about tables and columns.52.1. Overview · 52.15. pg_database · 52.11. pg_classMissing: INFORMATION_SCHEMA | Show results with:INFORMATION_SCHEMA
  44. [44]
    DatabaseMetaData (Java Platform SE 8 ) - Oracle Help Center
    For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions ...
  45. [45]
    DBML | dbdiagram Docs
    dbdiagram.io uses DBML as our syntax for defining database. DBML is open-sourced markup language used to define database schema structure.