Search code examples
databasepostgresqldata-retrieval

Retrieving Deleted Data on postgres


I am going to retrieve data on the original table. How am I going to retrieve the deleted data to the original table ?


Solution

  • Is this what you are looking for?:

    create table ex (a int);
    insert into ex (a) values (1),(2),(3);
    delete from ex where a > 2 returning *;
    

    You can check more about returning keyword as well as output_expression in the Postgres Docs.