[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

RE: [sqr-users] sql delete from table where 1 = 1



The programmer may have left a where clause there in anticipation of someday
restricting the deletion to certain rows (for testing purposes perhaps).

When the goal is to delete all rows in a large table, it is much, much
faster to say "truncate table NAMES_TABLE".  However some DBAs don't like
that because you cannot rollback a truncate.  You should check on your
shop's policy.

-----Original Message-----
From: Larry Roux [mailto:LRoux@syr.edu] 
Sent: Monday, January 23, 2006 8:46 AM
To: sqr-users@sqrug.org
Subject: Re: [sqr-users] sql delete from table where 1 = 1

It means "always" or "all rows"  ie - if I said

select
NAME
from NAMES_TABLE
where 1 = 1

it is exactly the same as

select
NAME
from NAMES_TABLE

or "return every row in NAMES_TABLE"

where 1 = 1 is totally unnecessary.




Larry Roux
Syracuse University
lroux@syr.edu


>>> bpreddy78@yahoo.com 01/23/06 11:39 AM >>>

Thanks for the reply,

When do you use the condition where 1 = 1. What does
it actually mean.

--- Larry Roux <LRoux@syr.edu> wrote:

> Are you sure it is 1 = 1 and not I = 1?  If it is as
> listed then 1 = 1 would always be true and all rows
> would be deleted (and so the where claude is
> unnecessary).
> 
> 
> 
> 
> Larry Roux
> Syracuse University
> lroux@syr.edu 
> 
> 
> >>> bpreddy78@yahoo.com 01/23/06 11:31 AM >>>
> Hi,
> 
> I'm testing a sqr, I found a procedure
> delete-old-data.
> I'm not sure how the Where statement is identifying
> the old data, Where 1 = 1.
> 
> BEGIN-PROCEDURE DELETE-OLD-DATA
>
!**************************************************************************
> BEGIN-SQL
> DELETE FROM TABLE_NAME WHERE 1 = 1
> END-SQL
> 
> END-PROCEDURE
> 
> Please can someone enlight me...
> 
> Thanks 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com 
> 
> _______________________________________________
> sqr-users mailing list
> sqr-users@sqrug.org 
> http://www.sqrug.org/mailman/listinfo/sqr-users 
> 
> 
> _______________________________________________
> sqr-users mailing list
> sqr-users@sqrug.org 
> http://www.sqrug.org/mailman/listinfo/sqr-users 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org 
http://www.sqrug.org/mailman/listinfo/sqr-users


_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users

_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users