

# Working with system tables

AWS services create and maintain system tables as Apache Iceberg tables in AWS managed table buckets in your account. They include operational data, such as logs, metrics, and query and job history, and resource data, such as the inventory and configuration of your resources. You can query system tables with SQL from AWS analytics services and any engine that is compatible with Apache Iceberg. Use them to analyze queries, troubleshoot failed jobs, track storage usage, and review configuration across AWS services. For more information about AWS managed table buckets, see [Working with AWS managed table buckets](s3-tables-aws-managed-buckets.md).

## How system tables work
<a name="system-tables-how-they-work"></a>

The following points apply to every system table:
+ After you turn on system tables, AWS creates the table bucket, namespaces, and tables for you. Some tables appear only after the service has data to write to them.
+ AWS defines the schemas and writes the data. Amazon S3 Tables handles compaction and snapshots.
+ The tables are read-only. You can't insert, update, or delete rows.
+ You control who can read the tables.

## AWS services that offer system tables
<a name="system-tables-services"></a>

The following AWS services offer system tables. Each link goes to the documentation for that service or feature, including how to turn its system tables on:
+ [Amazon Athena](https://docs.aws.amazon.com/athena/latest/ug/athena-system-tables.html)
+ [Amazon CloudWatch Logs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/s3-tables-integration.html)
+ [Amazon Data Firehose](https://docs.aws.amazon.com/firehose/latest/dev/firehose-system-tables.html)
+ [Amazon EMR](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-system-tables.html)
+ [AWS Glue Data Catalog](https://docs.aws.amazon.com/glue/latest/dg/catalog-system-tables.html) (catalog metadata, lineage, and data quality)
+ [AWS Glue ETL](https://docs.aws.amazon.com/glue/latest/dg/glue-system-tables.html) (jobs and interactive sessions)
+ [AWS Glue Schema Registry](https://docs.aws.amazon.com/glue/latest/dg/schema-registry-system-tables.html)
+ [Amazon Kinesis Data Streams](https://docs.aws.amazon.com/streams/latest/dev/system-tables.html)
+ [Amazon Managed Streaming for Apache Kafka (Amazon MSK)](https://docs.aws.amazon.com/msk/latest/developerguide/msk-system-tables.html)
+ [Amazon OpenSearch Service](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/opensearch-system-tables.html)
+ [Amazon Redshift](https://docs.aws.amazon.com/redshift/latest/mgmt/system-table-s3-tables.html)
+ [Amazon Simple Storage Service (Amazon S3)](use-amazon-s3-system-tables.md)
+ [Amazon SageMaker AI](https://docs.aws.amazon.com/sagemaker/latest/dg/catalog-assets-system-tables.html)
+ [Amazon SageMaker Unified Studio](https://docs.aws.amazon.com/sagemaker-unified-studio/latest/adminguide/usage-system-tables.html)

The following database services also offer resource system tables:
+ Amazon Aurora
+ Amazon DocumentDB (with MongoDB compatibility)
+ Amazon DynamoDB
+ Amazon ElastiCache
+ Amazon Keyspaces (for Apache Cassandra)
+ Amazon Neptune
+ Amazon Relational Database Service (Amazon RDS)
+ Amazon Timestream for InfluxDB

AWS Glue Data Catalog writes these tables to the `aws-catalog` table bucket. To turn them on, see [Turning on resource system tables](#system-tables-turning-on-resource-tables).

## Turning on resource system tables
<a name="system-tables-turning-on-resource-tables"></a>

AWS Glue Data Catalog writes resource system tables, such as inventories of your database clusters, streams, and Athena workgroups, to the `aws-catalog` table bucket. To get these tables, turn on auto-discovery and metadata export in AWS Glue Data Catalog. There's no separate setting for each service or table. For instructions, see [Use AWS Glue Data Catalog system tables](https://docs.aws.amazon.com/glue/latest/dg/catalog-system-tables.html) in the *AWS Glue User Guide*.

## Permissions for querying system tables
<a name="system-tables-query-permissions"></a>

To query system tables with AWS analytics services, such as Amazon Athena, first integrate your table buckets with AWS analytics services. For instructions, see [Integrating Amazon S3 Tables with AWS analytics services](s3-tables-integrating-aws.md). For the permissions that you need, see [Permissions to work with AWS managed table buckets and to query tables](s3-tables-aws-managed-buckets.md#aws-managed-buckets-permissions). For example queries, see [Querying tables in AWS managed table buckets](s3-tables-aws-managed-buckets.md#querying-tables-in-aws-managed-table-buckets).

## Queries across services
<a name="system-tables-queries-across-services"></a>

You can join system tables from more than one service. For example, you can join tables to answer the following questions:
+ Which Data Catalog tables were not named in any Athena query in the last 90 days? Join `glue.tables` with the `tables_accessed` column of the Athena `query_executions` table, and use UNNEST to flatten `tables_accessed`.
+ How many queries ran in each workgroup, and how much data did they scan? Join `athena.work_groups` with the Athena `query_executions` table on the workgroup name.
+ Which buckets store data in S3 Standard but had no read requests in the last 90 days? Combine the S3 Storage Lens storage metrics with the server access logs table (`amazon_s3__server_access`).