# Redshift Show Tables | How to List Redshift Tables

**Published:** Dec 03, 2021
**Author:** Donal Tobin
**Category:** Cloud Integration

## Summary

In order to list or show all of the tables in a Redshift database, you'll need to query the PG_TABLE_DEF systems table. An interesting thing to note is the PG_ prefix. This is because Redshift is based off Postgres, so that little prefix is a throwback to Redshift’s Postgres origins.


![Redshift Show Tables | How to List Redshift Tables](https://cdn.buttercms.com/XOG54s2ZSNefAjLGKSMZ)


## Content

In order to list or show all of the tables in a Redshift database, you'll need to query the `PG_TABLE_DEF` systems table. An interesting thing to note is the `PG_` prefix. This is because Redshift is based off Postgres, so that little prefix is a throwback to Redshift’s Postgres origins.

internal-cta-form

Running `SELECT * FROM PG_TABLE_DEF` will return every column from every table in every schema. This means that systems tables will be included and each table will be listed multiple times, one for each column. For this reason, if you just want to get a list of tables, you’ll want to use the following query:

```text
SELECT DISTINCT tablename FROM pg_table_def WHERE schemaname = 'public';

```

This will return a single column of table names for the public schema, which is probably where most of your data resides.

When we `SELECT * FROM PG_TABLE_DEF;`, we get the following columns:

1. schemaname

You most likely want to limit this to “public” otherwise it will also include all of the systems tables.
2. You most likely want to limit this to “public” otherwise it will also include all of the systems tables.
3. tablename

The name of the table, yay!
4. The name of the table, yay!
5. columnname

The name of each column
6. The name of each column
7. type

The datatype of each column
8. The datatype of each column
9. encoding
10. distkey and sortkey

Learn more about Redshift distkey and sortkey.
11. Learn more about Redshift distkey and sortkey.
12. notnull

Boolean to determine if the column has a NOT NULL constraint.
13. Boolean to determine if the column has a NOT NULL constraint.

internal-signup-cta-form

And there you go! Should be pretty simple. Let us know in the comments if you have any questions!


## Tags

aws, en, redshift, Redshift Tables

## Categories

Cloud Integration