pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
"DELETE FROM" protection
6+ messages / 5 participants
[nested] [flat]

* "DELETE FROM" protection
@ 2004-02-20 06:05 Jeremy Smith <jer@highboard.com>
  2004-02-20 10:12 ` Re: "DELETE FROM" protection Matt Clark <matt@ymogen.net>
  0 siblings, 1 reply; 6+ messages in thread

From: Jeremy Smith @ 2004-02-20 06:05 UTC (permalink / raw)
  To: pgsql-admin


This may be an all-time idiotic question, but when I used phpmysql, when I
would type in a "DELETE FROM" query in the SQL window, it would make me
confirm it before I allowed it to go through.  I don't think in all of the
presumably thousands of times that I used it that I ever canceled out of the
statement, but I always liked that it is there.

So now with pgsql, when I am typing "DELETE FROM...." until I get to the
"WHERE" part of the statement, I get a little nervous because I know hitting
Enter by mistake will wipe out that table.  Of course, I have backups, but
it is a live site with alot of traffic and I would hate to have to shut
things down while I restored the DB.

Anyway, this may all seem silly, but is there a setting in pgsql to do this?

Thanks,
Jeremy




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: "DELETE FROM" protection
  2004-02-20 06:05 "DELETE FROM" protection Jeremy Smith <jer@highboard.com>
@ 2004-02-20 10:12 ` Matt Clark <matt@ymogen.net>
  2004-02-20 10:56   ` Re: "DELETE FROM" protection Dave Ewart <Dave.Ewart@cancer.org.uk>
  0 siblings, 1 reply; 6+ messages in thread

From: Matt Clark @ 2004-02-20 10:12 UTC (permalink / raw)
  To: jer@highboard.com; pgsql-admin

BEGIN;
DELETE FROM mytable;
!!! OOOPS !!!!
ROLLBACK;


> -----Original Message-----
> From: pgsql-admin-owner@postgresql.org
> [mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Jeremy Smith
> Sent: 20 February 2004 06:06
> To: pgsql-admin@postgresql.org
> Subject: [ADMIN] "DELETE FROM" protection
> 
> 
> 
> This may be an all-time idiotic question, but when I used phpmysql, when I
> would type in a "DELETE FROM" query in the SQL window, it would make me
> confirm it before I allowed it to go through.  I don't think in all of the
> presumably thousands of times that I used it that I ever canceled out of the
> statement, but I always liked that it is there.
> 
> So now with pgsql, when I am typing "DELETE FROM...." until I get to the
> "WHERE" part of the statement, I get a little nervous because I know hitting
> Enter by mistake will wipe out that table.  Of course, I have backups, but
> it is a live site with alot of traffic and I would hate to have to shut
> things down while I restored the DB.
> 
> Anyway, this may all seem silly, but is there a setting in pgsql to do this?
> 
> Thanks,
> Jeremy
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: "DELETE FROM" protection
  2004-02-20 06:05 "DELETE FROM" protection Jeremy Smith <jer@highboard.com>
  2004-02-20 10:12 ` Re: "DELETE FROM" protection Matt Clark <matt@ymogen.net>
@ 2004-02-20 10:56   ` Dave Ewart <Dave.Ewart@cancer.org.uk>
  2004-02-20 13:27     ` Re: "DELETE FROM" protection Yuji Shinozaki <ys2n@virginia.edu>
  0 siblings, 1 reply; 6+ messages in thread

From: Dave Ewart @ 2004-02-20 10:56 UTC (permalink / raw)
  To: pgsql-admin

On Friday, 20.02.2004 at 10:12 +0000, Matt Clark wrote:

> > So now with pgsql, when I am typing "DELETE FROM...." until I get to
> > the "WHERE" part of the statement, I get a little nervous because I
> > know hitting Enter by mistake will wipe out that table.  [...]

How about typing the "WHERE" part of the statement first, then
'left-arrowing' back to the start of the statement and do "DELETE FROM
..." *last*?

Dave.
-- 
Dave Ewart
Dave.Ewart@cancer.org.uk
Computing Manager, Epidemiology Unit, Oxford
Cancer Research UK
PGP: CC70 1883 BD92 E665 B840 118B 6E94 2CFD 694D E370




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: "DELETE FROM" protection
  2004-02-20 06:05 "DELETE FROM" protection Jeremy Smith <jer@highboard.com>
  2004-02-20 10:12 ` Re: "DELETE FROM" protection Matt Clark <matt@ymogen.net>
  2004-02-20 10:56   ` Re: "DELETE FROM" protection Dave Ewart <Dave.Ewart@cancer.org.uk>
@ 2004-02-20 13:27     ` Yuji Shinozaki <ys2n@virginia.edu>
  2004-02-20 18:26       ` Re: "DELETE FROM" protection Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 1 reply; 6+ messages in thread

From: Yuji Shinozaki @ 2004-02-20 13:27 UTC (permalink / raw)
  To: Dave Ewart <Dave.Ewart@cancer.org.uk>; +Cc: pgsql-admin


I've gotten myself into the habit of always writing out a

	SELECT ... FROM ... WHERE ...;

first, and then command-line editing it to

	DELETE FROM ... WHERE ...;

Putting it in a transaction (BEGIN, COMMIT or ROLLBACK) is probably the
best practice.

yuji
----


On Fri, 20 Feb 2004, Dave Ewart wrote:

> On Friday, 20.02.2004 at 10:12 +0000, Matt Clark wrote:
>
> > > So now with pgsql, when I am typing "DELETE FROM...." until I get to
> > > the "WHERE" part of the statement, I get a little nervous because I
> > > know hitting Enter by mistake will wipe out that table.  [...]
>
> How about typing the "WHERE" part of the statement first, then
> 'left-arrowing' back to the start of the statement and do "DELETE FROM
> ..." *last*?
>
> Dave.
> --
> Dave Ewart
> Dave.Ewart@cancer.org.uk
> Computing Manager, Epidemiology Unit, Oxford
> Cancer Research UK
> PGP: CC70 1883 BD92 E665 B840 118B 6E94 2CFD 694D E370
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@postgresql.org so that your
>       message can get through to the mailing list cleanly
>
>

Yuji Shinozaki	                        Computer Systems Senior Engineer
ys2n@virginia.edu			Advanced Technologies Group
(434)924-7171				Information Technology & Communication
http://www.people.virginia.edu/~ys2n    University of Virginia




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: "DELETE FROM" protection
  2004-02-20 06:05 "DELETE FROM" protection Jeremy Smith <jer@highboard.com>
  2004-02-20 10:12 ` Re: "DELETE FROM" protection Matt Clark <matt@ymogen.net>
  2004-02-20 10:56   ` Re: "DELETE FROM" protection Dave Ewart <Dave.Ewart@cancer.org.uk>
  2004-02-20 13:27     ` Re: "DELETE FROM" protection Yuji Shinozaki <ys2n@virginia.edu>
@ 2004-02-20 18:26       ` Bruce Momjian <pgman@candle.pha.pa.us>
  2004-02-20 20:05         ` Re: "DELETE FROM" protection Jeremy Smith <jer@highboard.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Bruce Momjian @ 2004-02-20 18:26 UTC (permalink / raw)
  To: Yuji Shinozaki <ys2n@virginia.edu>; +Cc: Dave Ewart <Dave.Ewart@cancer.org.uk>; pgsql-admin

Yuji Shinozaki wrote:
> 
> I've gotten myself into the habit of always writing out a
> 
> 	SELECT ... FROM ... WHERE ...;
> 
> first, and then command-line editing it to
> 
> 	DELETE FROM ... WHERE ...;
> 
> Putting it in a transaction (BEGIN, COMMIT or ROLLBACK) is probably the
> best practice.

I used to do this with Informix before a DELETE:

> 	SELECT COUNT(*) FROM ... WHERE ...;

               ^^^^^^^^
and Informix had that "Are your sure" check in dbaccess too, but after I
did the COUNT(*), the prompt was just annoying.

Also, what interfaces allow you to just press ENTER to send a command? 
With psql, you have to terminate it with a semicolon or nothing happens.

I think there is justification for an "Are you sure" only if a single
keystroke sends the command.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: "DELETE FROM" protection
  2004-02-20 06:05 "DELETE FROM" protection Jeremy Smith <jer@highboard.com>
  2004-02-20 10:12 ` Re: "DELETE FROM" protection Matt Clark <matt@ymogen.net>
  2004-02-20 10:56   ` Re: "DELETE FROM" protection Dave Ewart <Dave.Ewart@cancer.org.uk>
  2004-02-20 13:27     ` Re: "DELETE FROM" protection Yuji Shinozaki <ys2n@virginia.edu>
  2004-02-20 18:26       ` Re: "DELETE FROM" protection Bruce Momjian <pgman@candle.pha.pa.us>
@ 2004-02-20 20:05         ` Jeremy Smith <jer@highboard.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Jeremy Smith @ 2004-02-20 20:05 UTC (permalink / raw)
  To: pgsql-admin

Great point Bruce,

I hadn't really thought of the semi-colon as a safety mechanism, but I guess
it is.

Jeremy

-----Original Message-----
From: pgsql-admin-owner@postgresql.org
[mailto:pgsql-admin-owner@postgresql.org]On Behalf Of Bruce Momjian
Sent: Friday, February 20, 2004 1:27 PM
To: Yuji Shinozaki
Cc: Dave Ewart; pgsql-admin@postgresql.org
Subject: Re: [ADMIN] "DELETE FROM" protection


Yuji Shinozaki wrote:
>
> I've gotten myself into the habit of always writing out a
>
> 	SELECT ... FROM ... WHERE ...;
>
> first, and then command-line editing it to
>
> 	DELETE FROM ... WHERE ...;
>
> Putting it in a transaction (BEGIN, COMMIT or ROLLBACK) is probably the
> best practice.

I used to do this with Informix before a DELETE:

> 	SELECT COUNT(*) FROM ... WHERE ...;

               ^^^^^^^^
and Informix had that "Are your sure" check in dbaccess too, but after I
did the COUNT(*), the prompt was just annoying.

Also, what interfaces allow you to just press ENTER to send a command?
With psql, you have to terminate it with a semicolon or nothing happens.

I think there is justification for an "Are you sure" only if a single
keystroke sends the command.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)





^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2004-02-20 20:05 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-02-20 06:05 "DELETE FROM" protection Jeremy Smith <jer@highboard.com>
2004-02-20 10:12 ` Matt Clark <matt@ymogen.net>
2004-02-20 10:56   ` Dave Ewart <Dave.Ewart@cancer.org.uk>
2004-02-20 13:27     ` Yuji Shinozaki <ys2n@virginia.edu>
2004-02-20 18:26       ` Bruce Momjian <pgman@candle.pha.pa.us>
2004-02-20 20:05         ` Jeremy Smith <jer@highboard.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox