PostgreSQL: clear all tables

Possible duplicate:
How to delete a SQL database?

What is the fastest way to delete all records from all tables in db if they have too much data (maybe there are several records in some tables, but no more)?

I find that re-creating a database from a dump structure is much longer.

+3
source share
1 answer

TRUNCATE TABLE name1, name2, ... CASCADE

TRUNCATE quickly removes all rows from a set of tables. It has the same effect as an unqualified DELETE for each table, but since it does not actually scan tables, it works faster. This is most useful for large tables.

, , .

. . grantall, .

+5

Source: https://habr.com/ru/post/1729766/


All Articles