Create INSERT INTO from SELECT in PostgreSQL How to create INSERT INTO statements, using SELECT statement? I need it because I want to delete 10k of records from a table, but if someday some of that record need to be restored I want to do that easily. I don't want to backup the whole table, because I just need to restore some of deleted rows.
You can use pg_dump with the --inserts option. You should also check the manual of your SQL client. Some can export data as INSERT statements. 

Another option is to just copy the rows that you delete into a new table:

create table _backup
as
with deleted as (
  delete from the_table 
  where .... --&lt;&lt; put your condition here
  returning *
)
select  *
from deleted;


The above will delete rows from the_table and all rows that are deleted are copied into the table _backup