How to “TRUNCATE” database table without TRUNCATE command

So I am currently developing something with Supabase. Then I need to do a data cleaning. TRUNCATE command is my favorite.

But strangely, the command does not seem to work. Using dbeaver, it shows that the command is running endlessly. Even using Supabase built-in dashboard, I got hit with timeout.

Honestly, I am not sure what is the problem. Table locking? Exclusive access? OMG, I just want a clean table. The table I want to clean is not even 500KB.

But without further ado:

DELETE FROM your_table;
ALTER SEQUENCE your_table_id_seq RESTART;

Anyway, I am not testing the VACUUM. Command above will also restart the sequence.

If you come here for the TRUNCATE trouble, here is the short/temporary solution.

Hope this helps.

Comments

comments