Home » SQL & PL/SQL » SQL & PL/SQL » doubts in delete statement
doubts in delete statement [message #207825] Thu, 07 December 2006 02:55 Go to next message
hari.choprala
Messages: 65
Registered: November 2006
Location: Mumbai
Member

How to delete rows starting from 5 to 10 in emp
Re: doubts in delete statement [message #207829 is a reply to message #207825] Thu, 07 December 2006 02:59 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
What do you mean by starting?
Is there any order by?
What is your criteria to find the required rows?

By
Vamsi
Re: doubts in delete statement [message #207834 is a reply to message #207825] Thu, 07 December 2006 03:04 Go to previous messageGo to next message
Mohammad Taj
Messages: 2412
Registered: September 2006
Location: Dubai, UAE
Senior Member

hi,

you can use between clause.
suppose ur emp table having 1 to 10 rows.
and you want to delete 5 to 9 then used.
delete tablename
where columnname between 5 and 9;


or explain more if this not help.
Re: doubts in delete statement [message #207836 is a reply to message #207834] Thu, 07 December 2006 03:13 Go to previous messageGo to next message
hari.choprala
Messages: 65
Registered: November 2006
Location: Mumbai
Member

Hi


emp table contains some 20 records

and actually i want to delete the rows starting from 5th row to 10th row
Re: doubts in delete statement [message #207838 is a reply to message #207834] Thu, 07 December 2006 03:14 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
@Taj
I don't think he is talking about data of a particular column.

@Hari
You can check this for data retrieval.
can_one_retrieve_only_rows_x_to_y_from_a_table

By
Vamsi

[Updated on: Thu, 07 December 2006 03:15]

Report message to a moderator

Re: doubts in delete statement [message #207847 is a reply to message #207838] Thu, 07 December 2006 03:30 Go to previous messageGo to next message
hari.choprala
Messages: 65
Registered: November 2006
Location: Mumbai
Member

Hi


I got the solution

delete from emp where empno in
(
SELECT empno FROM (
SELECT empno, rownum rn
FROM emp WHERE rownum < 10
) WHERE RN between 4 and 6)
Re: doubts in delete statement [message #207850 is a reply to message #207847] Thu, 07 December 2006 03:34 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
No, that isn't the solution to your problem.
That is the solution to the question: How do I delete 5 random rows from my table.

The thing you are overlooking is that unless you use an ORDER BY statement, the rows returned by a query do not come back in a guaranteed order.
Re: doubts in delete statement [message #207860 is a reply to message #207850] Thu, 07 December 2006 03:55 Go to previous messageGo to next message
hari.choprala
Messages: 65
Registered: November 2006
Location: Mumbai
Member

Hi
Thanks for u r suggestion

can i go for this

delete from emp where empno in
(
SELECT empno FROM (
SELECT empno, rownum rn
FROM emp WHERE rownum < 10 order by rownum
) WHERE RN between 4 and 6)


Re: doubts in delete statement [message #207866 is a reply to message #207860] Thu, 07 December 2006 04:02 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
No. Try any column depending on your requirement. empno or so.
If you really want to depend on creation_date of the row, try to add one column and populate it.

By
Vamsi
Re: doubts in delete statement [message #207894 is a reply to message #207866] Thu, 07 December 2006 04:42 Go to previous message
hari.choprala
Messages: 65
Registered: November 2006
Location: Mumbai
Member

hi vamsi

thanks for u r suggestion
Previous Topic: Distinguish between global variables and private variable
Next Topic: Format a number to double type
Goto Forum:
  


Current Time: Sat Dec 03 18:34:41 CST 2016

Total time taken to generate the page: 0.08924 seconds