---
title: "Discussion on \"Howto: drop Postgres tables matching a pattern\" | Hashnode"
description: "Discussion on \"Howto: drop Postgres tables matching a pattern\". Suppose that your database has lots of tables, with similar names (maybe partitions of a bigger table?), here's a quick way to drop them in bulk\nSELECT 'drop table '||n.nspname ||'.'|| c.relname||';' as \"Name\" \nFROM pg_catalog.pg_class c\n     LEFT JO..."
url: "https://hashnode.com/posts/howto-drop-postgres-tables-matching-a-pattern/64c23dba2fd958189c7f3b67"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Howto: drop Postgres tables matching a pattern](https://fragland.dev/howto-drop-postgres-tables-matching-a-pattern?utm_source=hashnode&utm_medium=feed)

Suppose that your database has lots of tables, with similar names (maybe partitions of a bigger table?), here's a quick way to drop them in bulk SELECT 'drop table '||n.nspname ||'.'|| c.relname||';' as "Name" FROM pg\_catalog.pg\_class c LEFT JO...

Jul 27, 2020 · 1 min read · fragland.dev  
Read the article

-   [#howtos](https://hashnode.com/tag/howtos)
-   [#sql](https://hashnode.com/tag/sql)
-   [#postgresql](https://hashnode.com/tag/postgresql)

## Written by

[Matteo Crosta](https://hashnode.com/@Frag)

@Frag · Italy, IT

  
[View profile](https://hashnode.com/@Frag)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
