Unix Technical Forum

Rollback in Postgres

This is a discussion on Rollback in Postgres within the pgsql Sql forums, part of the PostgreSQL category; --> Hi all.... This is a very basic question.....can we roll back data after we run a query. I know ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-14-2008, 06:51 PM
samantha mahindrakar
 
Posts: n/a
Default Rollback in Postgres

Hi all....
This is a very basic question.....can we roll back data after we run a
query.
I know that a delete within a transaction can be rolled back. But how about
independent delete queries???
If i ran a delete statement and lost data...how do i recover. I know that
oracle has this provision of rollingback queries.
Iam surprised iam not able to find the same in postgres.

Sam

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-14-2008, 06:51 PM
Mark Roberts
 
Posts: n/a
Default Re: Rollback in Postgres


On Fri, 2008-07-11 at 11:43 -0400, samantha mahindrakar wrote:
> Hi all....
> This is a very basic question.....can we roll back data after we run a
> query.
> I know that a delete within a transaction can be rolled back. But how
> about independent delete queries???
> If i ran a delete statement and lost data...how do i recover. I know
> that oracle has this provision of rollingback queries.
> Iam surprised iam not able to find the same in postgres.
>
> Sam


Postgres certainly can roll back queries, table creations, and many
other actions. You can find more information about rollback here:
http://www.postgresql.org/docs/8.3/i...-rollback.html

Best of luck in your endeavor

-Mark



--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-14-2008, 06:51 PM
Scott Marlowe
 
Posts: n/a
Default Re: Rollback in Postgres

On Fri, Jul 11, 2008 at 9:43 AM, samantha mahindrakar
<sam.mahindrakar@gmail.com> wrote:
> Hi all....
> This is a very basic question.....can we roll back data after we run a
> query.
> I know that a delete within a transaction can be rolled back. But how about
> independent delete queries???
> If i ran a delete statement and lost data...how do i recover. I know that
> oracle has this provision of rollingback queries.
> Iam surprised iam not able to find the same in postgres.


If you were not in a query, then you cannot just roll back. This is
because each statement is an individual transaction and a delete query
"outside" a transaction is actually a begin;delete...;commit; in
nature.

Oracle only supports the rollback after commit if you have the right
module installed and activated. And it uses up a fair bit of disk
space to do it. TANSTAAFL.

IF you have PITR setup in postgresql then you can recover to a
previous point in time. Otherwise, you need to restore from backups.

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-14-2008, 06:51 PM
Simon Riggs
 
Posts: n/a
Default Re: Rollback in Postgres


On Fri, 2008-07-11 at 11:21 -0600, Scott Marlowe wrote:
> rollback after commit


Are you sure?

Personally I don't think its viable. If it really does that it will
would also need to rollback all transactions whose changes depend upon
the earlier transaction. It would also need to track transactions that
read data changed by an earlier transaction and then makes changes to
the database. It's got no way to track that without extensive and costly
additional infrastructure, since after transaction commit row locking
information can be cleaned up by read-only transactions accessing those
changed data blocks.

Flashback query allows reading data as it was at a certain point in the
past. We might one day provide that, but undoing individual transactions
isn't ever going to be feasible, without unknowable risk.

Not jumping on you, just think their marketing is ahead of the reality.

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support


--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-14-2008, 06:52 PM
Lewis Cunningham
 
Posts: n/a
Default Re: Rollback in Postgres

In addition to allowing you to read old data, Flashback will allow you to rollback to a point in time, including returning a single table to a specific state. Flashback database is like PITR without the log files.

It started in 9i and improved dramatically in 10g. 11g has made additional improvements.

http://download.oracle.com/docs/cd/B...2/intro007.htm

http://download.oracle.com/docs/cd/B...0/rcmflash.htm


Lewis R Cunningham

An Expert's Guide to Oracle Technology
http://blogs.ittoolbox.com/oracle/guide/

Postgres Forums
http://postgres.enterprisedb.com/forum.do




--- On Fri, 7/11/08, Simon Riggs <simon@2ndquadrant.com> wrote:

> From: Simon Riggs <simon@2ndquadrant.com>
> Subject: Re: [SQL] Rollback in Postgres
> To: "Scott Marlowe" <scott.marlowe@gmail.com>
> Cc: "samantha mahindrakar" <sam.mahindrakar@gmail.com>, pgsql-sql@postgresql.org
> Date: Friday, July 11, 2008, 2:58 PM
> On Fri, 2008-07-11 at 11:21 -0600, Scott Marlowe wrote:
> > rollback after commit

>
> Are you sure?
>
> Personally I don't think its viable. If it really does
> that it will
> would also need to rollback all transactions whose changes
> depend upon
> the earlier transaction. It would also need to track
> transactions that
> read data changed by an earlier transaction and then makes
> changes to
> the database. It's got no way to track that without
> extensive and costly
> additional infrastructure, since after transaction commit
> row locking
> information can be cleaned up by read-only transactions
> accessing those
> changed data blocks.
>
> Flashback query allows reading data as it was at a certain
> point in the
> past. We might one day provide that, but undoing individual
> transactions
> isn't ever going to be feasible, without unknowable
> risk.
>
> Not jumping on you, just think their marketing is ahead of
> the reality.
>
> --
> Simon Riggs www.2ndQuadrant.com
> PostgreSQL Training, Services and Support
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql


--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 07-14-2008, 06:52 PM
Simon Riggs
 
Posts: n/a
Default Re: Rollback in Postgres


On Fri, 2008-07-11 at 18:56 -0700, Lewis Cunningham wrote:

> In addition to allowing you to read old data, Flashback will allow you
> to rollback to a point in time, including returning a single table to
> a specific state. Flashback database is like PITR without the log
> files.


Like I said: you cannot rollback a single transaction after commit.

Please don't put links to copyrighted material on our lists.

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support


--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 07-14-2008, 06:52 PM
Dave Page
 
Posts: n/a
Default Re: Rollback in Postgres

On Sat, Jul 12, 2008 at 8:56 AM, Simon Riggs <simon@2ndquadrant.com> wrote:
>
> Please don't put links to copyrighted material on our lists.


That's an odd thing to say, given that virtually every link on our
lists probably points to material copyrighted in some way.

--
Dave Page
EnterpriseDB UK: http://www.enterprisedb.com

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 07-14-2008, 06:52 PM
Simon Riggs
 
Posts: n/a
Default Re: Rollback in Postgres


On Sat, 2008-07-12 at 09:40 +0100, Dave Page wrote:
> On Sat, Jul 12, 2008 at 8:56 AM, Simon Riggs <simon@2ndquadrant.com> wrote:
> >
> > Please don't put links to copyrighted material on our lists.

>
> That's an odd thing to say, given that virtually every link on our
> lists probably points to material copyrighted in some way.


Prudence is all I ask for. We don't need to provide additional
advertising for others, nor do we wish to embroil ourselves in
accusations over copyright violations.

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support


--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 07-14-2008, 06:52 PM
Lewis Cunningham
 
Posts: n/a
Default Re: Rollback in Postgres


>
> Please don't put links to copyrighted material on our
> lists.
>


Postgres docs are copyrighted. The oracle docs are free to access just like the postgres docs. What is the issue?

LewisC


--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 07-14-2008, 06:52 PM
Lewis Cunningham
 
Posts: n/a
Default Re: Rollback in Postgres

--- On Sat, 7/12/08, Scott Marlowe <scott.marlowe@gmail.com> wrote:

> What I would appreciate as regards Oracle's flashback
> technology would
> have been a link to a well written review showing the warts
> as well as
> the beauty. I've found that Oracle stuff sounds good
> on paper, and
> turns into a giant maintenance nightmare upon deployment.
> But that's
> just what I've seen looking over Oracle DBA shoulders
> in the past.


Oracle-base is a site I trust and use. Tim writes very good articles and this is one he did recently covering flashback in 11g. The example on flashback transaction is the best I've seen.

http://www.oracle-base.com/articles/...ents_11gR1.php


Lewis R Cunningham

An Expert's Guide to Oracle Technology
http://blogs.ittoolbox.com/oracle/guide/

Postgres Forums
http://postgres.enterprisedb.com/forum.do






--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:20 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com