N
N
nano_e_t_42016-01-06 12:35:00
PostgreSQL
nano_e_t_4, 2016-01-06 12:35:00

How to delete data in postgres?

Hello everyone
Guys, plz tell me how to delete a large amount of data from a table.
Escape, after reading on the Internet, I realized that if you just do delete, then everything will fall into place. It is advised to delete data in batches and then vacuum full. I'm not very familiar with the syntax of postgres, can someone tell me the command (I apologize for impudence and partly laziness) how to delete data in batches, by id for example
Thank you
z.s.
Googled this option
DELETE FROM [your table]
WHERE [ID] IN
(SELECT TOP 10000 * FROM [your table])
but have very little idea how to use it

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2016-01-06
@mblp

If you need to completely clear the table, then

TRUNCATE ИМЯ_ТАБЛИЦЫ;
VACUUM FULL;

If not the entire table, but some specific data, then you yourself brought the query. It already depends on what exactly you need to remove.

P
Puma Thailand, 2016-01-06
@opium

Delete one by one in a loop

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question