# PGSQL 列出所有的表

**URL:** <https://www.isharkfly.com/t/pgsql/18482>\
**Category:** 数据库\
**Tags:** postgresql\
**Created:** [November 25, 2025, 7:18pm UTC](https://www.isharkfly.com/t/pgsql/18482 "2025-11-25T19:18:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hex](https://www.isharkfly.com/user_avatar/www.isharkfly.com/hex/32/21953_2.png) [@hex](https://www.isharkfly.com/u/hex)\
**Post date:** [November 25, 2025, 7:18pm UTC](https://www.isharkfly.com/t/pgsql/18482/1 "2025-11-25T19:18:27Z")

</div>

可以直接使用 SQL 列出所有的表：

```auto
SELECT tablename 
FROM pg_tables 
WHERE schemaname = 'public';

```

 ![2025-11-26_08-51-18](https://cdn.isharkfly.com/com-isharkfly-www/discourse-uploads/original/3X/b/e/bee0b87201c91e9d7460a2228cfad9bb8f4d8d1f.jpeg)

或者输入 `\dt` 也可以。

```auto
isharkfly_www=# \dt
                            List of tables
 Schema | Name | Type | Owner
--------+------------------------------------------+-------+----------
 public | admin_notices | table | postgres
 public | ai_api_audit_logs | table | postgres
 public | ai_artifact_key_values | table | postgres
 public | ai_artifact_versions | table | postgres
 public | ai_artifacts | table | postgres
 public | ai_moderation_settings | table | postgres
 public | ai_personas | table | postgres
 public | ai_spam_logs | table | postgres
 public | ai_summaries | table | postgres
 public | ai_tools | table | postgres
 public | allowed_pm_users | table | postgres
 public | anonymous_users | table | postgres
 public | api_key_scopes | table | postgres
 public | api_keys | table | postgres
 public | application_requests | table | postgres
 public | ar_internal_metadata | table | postgres
 public | assignments | table | postgres
 public | associated_groups | table | postgres
 public | backup_draft_posts | table | postgres
 public | backup_draft_topics | table | postgres
 public | backup_metadata | table | postgres
 public | badge_groupings | table | postgres
 public | badge_types | table | postgres
 public | badges | table | postgres
 public | bookmarks | table | postgres
 public | calendar_events | table | postgres
 public | categories | table | postgres
 public | categories_web_hooks | table | postgres

```

 ![2025-11-26_08-55-09](https://cdn.isharkfly.com/com-isharkfly-www/discourse-uploads/original/3X/f/6/f613e84e33e65cc73b981819d82d99d9e36f1ad1.jpeg)
