0

I have not done anything. I just run this command DELETE FROM feed_republic. But I want to get my data again. What should I do?

When I run rollback I am getting the following message. Please help!

WARNING:  there is no transaction in progress

I have not used any commit or any other command unlike this question Can I rollback a transaction I've already committed? (data loss).

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
Mr.Robot
  • 133
  • 2
  • 3
  • 10
  • 1
    Possible duplicate of [Restore deleted records in PostgreSQL](https://stackoverflow.com/questions/20113586/restore-deleted-records-in-postgresql) – Robby Cornelissen Mar 14 '19 at 06:28
  • You can't rollback a transaction that is already committed. – Robby Cornelissen Mar 14 '19 at 06:29
  • I have not used commit command. So, my database is commited ot not? – Mr.Robot Mar 14 '19 at 06:32
  • 1
    I'm afraid, there's no straightforward way to bring data back. I hope you have not done that in production. I believe you're new to Postgres. It's not like Oracle that by default dmls can be rolled back when run as a single statement. In Postgres, a statement is automatically committed unless you're running those inside a transaction, starting with `BEGIN;` – Kaushik Nayak Mar 14 '19 at 06:32
  • It's committed. You performed your operation outside the scope of a transaction, so it's committed automatically. – Robby Cornelissen Mar 14 '19 at 06:33
  • Not in production but this is my college project. We are fecthing news from long time and storing in AWS RDS. This is important because we need to train model by our data. – Mr.Robot Mar 14 '19 at 06:34
  • Any other step I can do. If you gusy know. Because I don't work on sql so much and this data is important for my college presentation. – Mr.Robot Mar 14 '19 at 06:38
  • Looks like you where running in auto-commit mode so your `DELETE` command has been committed immediately. If you don't have a backup, the only thing you can try is follow the answer in https://stackoverflow.com/questions/20113586/restore-deleted-records-in-postgresql and give `pg_dirtyread` a try. Even easier, just have a look at your RDS backups and restore one (if you can afford losing other data changes): https://aws.amazon.com/rds/details/backup/ – Ancoron Mar 14 '19 at 07:01

1 Answers1

1

PostgreSQL is running in autocommit mode, so every statement is running in its own transaction unless you explicitly start a transaction with BEGIN or START TRANSACTION.

The only way you can get your data back is by restoring from a backup.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263